diff --git a/gfxlcd/abstract/chip.py b/gfxlcd/abstract/chip.py index 36eb407..03bf3c0 100644 --- a/gfxlcd/abstract/chip.py +++ b/gfxlcd/abstract/chip.py @@ -99,3 +99,8 @@ class Chip(metaclass=abc.ABCMeta): def fill_rect(self, pos_x1, pos_y1, pos_x2, pos_y2): """draw a filled rectangle""" pass + + @abc.abstractmethod + def draw_image(self, pos_x, pos_y, image): + """draw a PIL image""" + pass diff --git a/gfxlcd/demos/dsp2017_101_64.png b/gfxlcd/demos/dsp2017_101_64.png new file mode 100644 index 0000000..1f9beb1 Binary files /dev/null and b/gfxlcd/demos/dsp2017_101_64.png differ diff --git a/gfxlcd/demos/dsp2017_122_29.png b/gfxlcd/demos/dsp2017_122_29.png new file mode 100644 index 0000000..298425f Binary files /dev/null and b/gfxlcd/demos/dsp2017_122_29.png differ diff --git a/gfxlcd/demos/ili_image.py b/gfxlcd/demos/ili_image.py new file mode 100644 index 0000000..a96ab44 --- /dev/null +++ b/gfxlcd/demos/ili_image.py @@ -0,0 +1,20 @@ +import RPi.GPIO +import sys +sys.path.append("../../") +from gfxlcd.driver.ili9325.gpio import GPIO as ILIGPIO +from gfxlcd.driver.ili9325.ili9325 import ILI9325 +RPi.GPIO.setmode(RPi.GPIO.BCM) + +from PIL import Image + +lcd_tft = ILI9325(240, 320, ILIGPIO()) +lcd_tft.init() + +# bypass of missing +3v line to power backlight +LED = 6 +RPi.GPIO.setup(LED, RPi.GPIO.OUT) +RPi.GPIO.output(LED, 1) + +image_file = Image.open("japan_temple_240x320.jpg") +image_file = image_file.convert('RGB') +lcd_tft.draw_image(0, 0, image_file) diff --git a/gfxlcd/demos/japan_temple_240x320.jpg b/gfxlcd/demos/japan_temple_240x320.jpg new file mode 100644 index 0000000..0946e24 Binary files /dev/null and b/gfxlcd/demos/japan_temple_240x320.jpg differ diff --git a/gfxlcd/drawing/area.py b/gfxlcd/drawing/area.py index 8fc1d19..9712b39 100644 --- a/gfxlcd/drawing/area.py +++ b/gfxlcd/drawing/area.py @@ -121,3 +121,17 @@ class Area(Pixel): color = self._converted_background_color() for _ in range(0, size): self.driver.data(color, None) + + def draw_image(self, pos_x, pos_y, image): + """draw a PIL image""" + image_file = image.convert('RGB') + width, height = image_file.size + self._set_area( + pos_x, + pos_y, + pos_x + width - 1, + pos_y + height - 1 + ) + for r, g, b in list(image_file.getdata()): + self.color = (r, g, b) + self.driver.data(self._converted_color(), None) \ No newline at end of file diff --git a/setup.py b/setup.py index d2016fa..d2bb2cb 100644 --- a/setup.py +++ b/setup.py @@ -13,11 +13,11 @@ def read(*paths): setup( name='gfxlcd', - version='0.1.0', + version='0.1.2', description='gfxlcd is a handler for grpahical lcds: ILI9328, SSD1306, NJU6450 @ Raspberry Pi.', keywords=['gfxlcd', 'raspberry pi' ,'ili9328' ,'ssd1306', 'nju6450', 'lcd', 'graphical lcd'], long_description=(read('readme.md')), - url='https://bitbucket.org/kosci/charlcd.git', + url='https://github.com/bkosciow/gfxlcd', license='MIT', author='Bartosz Kościów', author_email='kosci1@gmail.com',