draw_image o ili
demo file
This commit is contained in:
parent
17d540bf15
commit
465e14c972
@ -99,3 +99,8 @@ class Chip(metaclass=abc.ABCMeta):
|
|||||||
def fill_rect(self, pos_x1, pos_y1, pos_x2, pos_y2):
|
def fill_rect(self, pos_x1, pos_y1, pos_x2, pos_y2):
|
||||||
"""draw a filled rectangle"""
|
"""draw a filled rectangle"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@abc.abstractmethod
|
||||||
|
def draw_image(self, pos_x, pos_y, image):
|
||||||
|
"""draw a PIL image"""
|
||||||
|
pass
|
||||||
|
BIN
gfxlcd/demos/dsp2017_101_64.png
Normal file
BIN
gfxlcd/demos/dsp2017_101_64.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
BIN
gfxlcd/demos/dsp2017_122_29.png
Normal file
BIN
gfxlcd/demos/dsp2017_122_29.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
20
gfxlcd/demos/ili_image.py
Normal file
20
gfxlcd/demos/ili_image.py
Normal file
@ -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)
|
BIN
gfxlcd/demos/japan_temple_240x320.jpg
Normal file
BIN
gfxlcd/demos/japan_temple_240x320.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 44 KiB |
@ -121,3 +121,17 @@ class Area(Pixel):
|
|||||||
color = self._converted_background_color()
|
color = self._converted_background_color()
|
||||||
for _ in range(0, size):
|
for _ in range(0, size):
|
||||||
self.driver.data(color, None)
|
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)
|
4
setup.py
4
setup.py
@ -13,11 +13,11 @@ def read(*paths):
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='gfxlcd',
|
name='gfxlcd',
|
||||||
version='0.1.0',
|
version='0.1.2',
|
||||||
description='gfxlcd is a handler for grpahical lcds: ILI9328, SSD1306, NJU6450 @ Raspberry Pi.',
|
description='gfxlcd is a handler for grpahical lcds: ILI9328, SSD1306, NJU6450 @ Raspberry Pi.',
|
||||||
keywords=['gfxlcd', 'raspberry pi' ,'ili9328' ,'ssd1306', 'nju6450', 'lcd', 'graphical lcd'],
|
keywords=['gfxlcd', 'raspberry pi' ,'ili9328' ,'ssd1306', 'nju6450', 'lcd', 'graphical lcd'],
|
||||||
long_description=(read('readme.md')),
|
long_description=(read('readme.md')),
|
||||||
url='https://bitbucket.org/kosci/charlcd.git',
|
url='https://github.com/bkosciow/gfxlcd',
|
||||||
license='MIT',
|
license='MIT',
|
||||||
author='Bartosz Kościów',
|
author='Bartosz Kościów',
|
||||||
author_email='kosci1@gmail.com',
|
author_email='kosci1@gmail.com',
|
||||||
|
Loading…
Reference in New Issue
Block a user