cs
This commit is contained in:
parent
dbeae3385a
commit
d255ebe15b
@ -1,11 +1,11 @@
|
|||||||
import RPi.GPIO
|
import RPi.GPIO
|
||||||
import sys
|
import sys
|
||||||
|
from PIL import Image
|
||||||
sys.path.append("../../")
|
sys.path.append("../../")
|
||||||
from gfxlcd.driver.ili9325.gpio import GPIO as ILIGPIO
|
from gfxlcd.driver.ili9325.gpio import GPIO as ILIGPIO
|
||||||
from gfxlcd.driver.ili9325.ili9325 import ILI9325
|
from gfxlcd.driver.ili9325.ili9325 import ILI9325
|
||||||
RPi.GPIO.setmode(RPi.GPIO.BCM)
|
RPi.GPIO.setmode(RPi.GPIO.BCM)
|
||||||
|
|
||||||
from PIL import Image
|
|
||||||
|
|
||||||
lcd_tft = ILI9325(240, 320, ILIGPIO())
|
lcd_tft = ILI9325(240, 320, ILIGPIO())
|
||||||
lcd_tft.init()
|
lcd_tft.init()
|
||||||
@ -20,4 +20,4 @@ lcd_tft.draw_image(0, 0, image_file)
|
|||||||
|
|
||||||
numbers_image = Image.open("assets/dsp2017_101_64.png")
|
numbers_image = Image.open("assets/dsp2017_101_64.png")
|
||||||
lcd_tft.transparency_color = (0, 0, 0)
|
lcd_tft.transparency_color = (0, 0, 0)
|
||||||
lcd_tft.draw_image(10, 10, numbers_image)
|
lcd_tft.draw_image(10, 10, numbers_image)
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import RPi.GPIO
|
import RPi.GPIO
|
||||||
import sys
|
import sys
|
||||||
import random
|
import random
|
||||||
|
from PIL import Image
|
||||||
sys.path.append("../../")
|
sys.path.append("../../")
|
||||||
from gfxlcd.driver.nju6450.gpio import GPIO
|
from gfxlcd.driver.nju6450.gpio import GPIO
|
||||||
from gfxlcd.driver.nju6450.nju6450 import NJU6450
|
from gfxlcd.driver.nju6450.nju6450 import NJU6450
|
||||||
RPi.GPIO.setmode(RPi.GPIO.BCM)
|
RPi.GPIO.setmode(RPi.GPIO.BCM)
|
||||||
|
|
||||||
from PIL import Image
|
|
||||||
|
|
||||||
lcd_nju = NJU6450(122, 32, GPIO())
|
lcd_nju = NJU6450(122, 32, GPIO())
|
||||||
lcd_nju.init()
|
lcd_nju.init()
|
||||||
@ -17,4 +17,4 @@ image_file = Image.open("assets/dsp2017_122_29.png")
|
|||||||
# lcd_nju.transparency_color = [110, 57]
|
# lcd_nju.transparency_color = [110, 57]
|
||||||
lcd_nju.draw_image(0, 0, image_file)
|
lcd_nju.draw_image(0, 0, image_file)
|
||||||
|
|
||||||
lcd_nju.flush(True)
|
lcd_nju.flush(True)
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import RPi.GPIO
|
import RPi.GPIO
|
||||||
import sys
|
import sys
|
||||||
|
from PIL import Image
|
||||||
sys.path.append("../../")
|
sys.path.append("../../")
|
||||||
from gfxlcd.driver.ssd1306.spi import SPI
|
from gfxlcd.driver.ssd1306.spi import SPI
|
||||||
from gfxlcd.driver.ssd1306.ssd1306 import SSD1306
|
from gfxlcd.driver.ssd1306.ssd1306 import SSD1306
|
||||||
RPi.GPIO.setmode(RPi.GPIO.BCM)
|
RPi.GPIO.setmode(RPi.GPIO.BCM)
|
||||||
from PIL import Image
|
|
||||||
|
|
||||||
lcd_oled = SSD1306(128, 64, SPI())
|
lcd_oled = SSD1306(128, 64, SPI())
|
||||||
lcd_oled.init()
|
lcd_oled.init()
|
||||||
@ -20,4 +20,4 @@ lcd_oled.threshold = 0
|
|||||||
|
|
||||||
lcd_oled.draw_image(10, 0, image_file)
|
lcd_oled.draw_image(10, 0, image_file)
|
||||||
|
|
||||||
lcd_oled.flush(True)
|
lcd_oled.flush(True)
|
||||||
|
@ -138,8 +138,18 @@ class Area(Pixel):
|
|||||||
temporary_area = None
|
temporary_area = None
|
||||||
for red, green, blue in list(image_file.getdata()):
|
for red, green, blue in list(image_file.getdata()):
|
||||||
if self._is_transparent((red, green, blue)):
|
if self._is_transparent((red, green, blue)):
|
||||||
area = (pos_x, pos_y + row + 1, pos_x + width - 1, pos_y + height - 1)
|
area = (
|
||||||
temporary_area = (pos_x + col + 1, pos_y + row, pos_x + width - 1, pos_y + row)
|
pos_x,
|
||||||
|
pos_y + row + 1,
|
||||||
|
pos_x + width - 1,
|
||||||
|
pos_y + height - 1
|
||||||
|
)
|
||||||
|
temporary_area = (
|
||||||
|
pos_x + col + 1,
|
||||||
|
pos_y + row,
|
||||||
|
pos_x + width - 1,
|
||||||
|
pos_y + row
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
if temporary_area is not None:
|
if temporary_area is not None:
|
||||||
self._set_area(*temporary_area)
|
self._set_area(*temporary_area)
|
||||||
@ -159,9 +169,11 @@ class Area(Pixel):
|
|||||||
"""check if color is a transparency color"""
|
"""check if color is a transparency color"""
|
||||||
if self.options['transparency_color'] is None:
|
if self.options['transparency_color'] is None:
|
||||||
return False
|
return False
|
||||||
elif type(self.options['transparency_color'][0]) == int and color == self.options['transparency_color']:
|
elif type(self.options['transparency_color'][0]) == int \
|
||||||
return True
|
and color == self.options['transparency_color']:
|
||||||
elif type(self.options['transparency_color'][0]) == list and color in self.options['transparency_color']:
|
return True
|
||||||
return True
|
elif type(self.options['transparency_color'][0]) == list \
|
||||||
|
and color in self.options['transparency_color']:
|
||||||
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
@ -121,7 +121,8 @@ class Page(Pixel, metaclass=abc.ABCMeta):
|
|||||||
offset_x = 0
|
offset_x = 0
|
||||||
offset_y = 0
|
offset_y = 0
|
||||||
for stream in list(image_file.getdata()):
|
for stream in list(image_file.getdata()):
|
||||||
if stream > self.options['threshold'] and not self._is_transparent(stream):
|
if stream > self.options['threshold'] \
|
||||||
|
and not self._is_transparent(stream):
|
||||||
self.draw_pixel(pos_x + offset_x, pos_y + offset_y)
|
self.draw_pixel(pos_x + offset_x, pos_y + offset_y)
|
||||||
offset_x += 1
|
offset_x += 1
|
||||||
if offset_x > width - 1:
|
if offset_x > width - 1:
|
||||||
@ -130,9 +131,11 @@ class Page(Pixel, metaclass=abc.ABCMeta):
|
|||||||
|
|
||||||
def _is_transparent(self, color):
|
def _is_transparent(self, color):
|
||||||
"""check if color is a transparency color"""
|
"""check if color is a transparency color"""
|
||||||
if type(self.options['transparency_color']) == int and color == self.options['transparency_color']:
|
if type(self.options['transparency_color']) == int \
|
||||||
|
and color == self.options['transparency_color']:
|
||||||
return True
|
return True
|
||||||
elif type(self.options['transparency_color']) == list and color in self.options['transparency_color']:
|
elif type(self.options['transparency_color']) == list \
|
||||||
|
and color in self.options['transparency_color']:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
"""driver/ssd1306 module"""
|
"""driver/ssd1306 module"""
|
||||||
__author__ = 'Bartosz Kosciow'
|
__author__ = 'Bartosz Kosciow'
|
||||||
|
2
tox.ini
2
tox.ini
@ -16,5 +16,5 @@ commands= nosetests --with-xunit --xunit-file=junit-{envname}.xml gfxlcd/tests
|
|||||||
/bin/bash -c "pylint gfxlcd > pylint-{envname}.log || :"
|
/bin/bash -c "pylint gfxlcd > pylint-{envname}.log || :"
|
||||||
[flake8]
|
[flake8]
|
||||||
show-source = True
|
show-source = True
|
||||||
exclude = .git,.venv,.tox,dist,doc,build,*egg,*/tests/*
|
exclude = .git,.venv,.tox,dist,doc,build,*egg,*/tests/*,*/demos/*
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user