commit
ec4d6335a4
@ -1,3 +1,5 @@
|
||||
0.2.1
|
||||
- CS & LED pin do ILI drv
|
||||
0.2.0
|
||||
- add AD7843 touch panel driver
|
||||
0.1.0
|
||||
|
@ -31,6 +31,8 @@ def draw_net(o):
|
||||
|
||||
|
||||
drv = GPIO()
|
||||
drv.pins['LED'] = 6
|
||||
drv.pins['CS'] = 18
|
||||
o = ILI9325(240, 320, drv)
|
||||
|
||||
o.init()
|
||||
|
@ -37,14 +37,12 @@ def draw_net(o):
|
||||
o.draw_line(0, s, o.width-1, s)
|
||||
s += 10
|
||||
|
||||
|
||||
lcd_tft = ILI9325(240, 320, ILIGPIO())
|
||||
drv = ILIGPIO()
|
||||
drv.pins['LED'] = 6
|
||||
drv.pins['CS'] = 18
|
||||
lcd_tft = ILI9325(240, 320, drv)
|
||||
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)
|
||||
lcd_tft.background_color = (255, 255, 255)
|
||||
lcd_tft.fill_rect(0, 0, 240, 320)
|
||||
lcd_tft.color = (0, 255, 1)
|
||||
|
@ -7,13 +7,12 @@ from gfxlcd.driver.ili9325.ili9325 import ILI9325
|
||||
RPi.GPIO.setmode(RPi.GPIO.BCM)
|
||||
|
||||
|
||||
lcd_tft = ILI9325(240, 320, ILIGPIO())
|
||||
drv = ILIGPIO()
|
||||
drv.pins['LED'] = 6
|
||||
drv.pins['CS'] = 18
|
||||
lcd_tft = ILI9325(240, 320, drv)
|
||||
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("assets/japan_temple_240x320.jpg")
|
||||
lcd_tft.draw_image(0, 0, image_file)
|
||||
|
@ -4,7 +4,7 @@ import time
|
||||
sys.path.append("../../")
|
||||
from gfxlcd.driver.ili9325.gpio import GPIO as ILIGPIO
|
||||
from gfxlcd.driver.ili9325.ili9325 import ILI9325
|
||||
from gfxlcd.driver.ad7843.ad7853 import AD7843
|
||||
from gfxlcd.driver.ad7843.ad7843 import AD7843
|
||||
RPi.GPIO.setmode(RPi.GPIO.BCM)
|
||||
|
||||
|
||||
@ -21,10 +21,7 @@ touch.init()
|
||||
|
||||
while True:
|
||||
try:
|
||||
time.sleep(0.05)
|
||||
# ret = touch.get_position()
|
||||
# if ret:
|
||||
# print(ret[0], ret[1])
|
||||
time.sleep(1)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
touch.close()
|
||||
|
32
gfxlcd/demos/touch_loop.py
Normal file
32
gfxlcd/demos/touch_loop.py
Normal file
@ -0,0 +1,32 @@
|
||||
import RPi.GPIO
|
||||
import sys
|
||||
import time
|
||||
sys.path.append("../../")
|
||||
from gfxlcd.driver.ili9325.gpio import GPIO as ILIGPIO
|
||||
from gfxlcd.driver.ili9325.ili9325 import ILI9325
|
||||
from gfxlcd.driver.ad7843.ad7843 import AD7843
|
||||
RPi.GPIO.setmode(RPi.GPIO.BCM)
|
||||
|
||||
|
||||
lcd_tft = ILI9325(240, 320, ILIGPIO())
|
||||
lcd_tft.init()
|
||||
|
||||
|
||||
def callback(position):
|
||||
print('(x,y)', position)
|
||||
|
||||
touch = AD7843(240, 320)
|
||||
|
||||
touch.init()
|
||||
|
||||
while True:
|
||||
try:
|
||||
time.sleep(0.05)
|
||||
ret = touch.get_position()
|
||||
if ret:
|
||||
print(ret[0], ret[1])
|
||||
|
||||
except KeyboardInterrupt:
|
||||
touch.close()
|
||||
RPi.GPIO.cleanup()
|
||||
|
@ -20,6 +20,8 @@ class GPIO(Driver):
|
||||
'DB14': 20,
|
||||
'DB15': 21,
|
||||
'RST': 25,
|
||||
'LED': None,
|
||||
'CS': None
|
||||
}
|
||||
self.data_pins = [
|
||||
'DB8', 'DB9', 'DB10', 'DB11', 'DB12', 'DB13', 'DB14', 'DB15',
|
||||
@ -28,11 +30,16 @@ class GPIO(Driver):
|
||||
def init(self):
|
||||
"""initialize pins"""
|
||||
for pin in self.pins:
|
||||
if self.pins[pin] is not None:
|
||||
RPi.GPIO.setup(self.pins[pin], RPi.GPIO.OUT)
|
||||
RPi.GPIO.output(self.pins[pin], 0)
|
||||
|
||||
def reset(self):
|
||||
"""reset a display"""
|
||||
if self.pins['LED']:
|
||||
RPi.GPIO.output(self.pins['LED'], 1)
|
||||
if self.pins['CS']:
|
||||
RPi.GPIO.output(self.pins['CS'], 1)
|
||||
RPi.GPIO.output(self.pins['RST'], 1)
|
||||
time.sleep(0.005)
|
||||
RPi.GPIO.output(self.pins['RST'], 0)
|
||||
@ -54,12 +61,16 @@ class GPIO(Driver):
|
||||
|
||||
def send(self, char, enable):
|
||||
"""send 16bit as 2*8bit"""
|
||||
if self.pins['CS']:
|
||||
RPi.GPIO.output(self.pins['CS'], 0)
|
||||
self._set_pins(char >> 8)
|
||||
RPi.GPIO.output(self.pins['W'], 0)
|
||||
RPi.GPIO.output(self.pins['W'], 1)
|
||||
self._set_pins(char)
|
||||
RPi.GPIO.output(self.pins['W'], 0)
|
||||
RPi.GPIO.output(self.pins['W'], 1)
|
||||
if self.pins['CS']:
|
||||
RPi.GPIO.output(self.pins['CS'], 1)
|
||||
|
||||
def data(self, data, enable):
|
||||
"""send data to display"""
|
||||
|
@ -98,6 +98,8 @@ Custom pins:
|
||||
'DB14': 20,
|
||||
'DB15': 21,
|
||||
'RST': 25,
|
||||
'LED': None,
|
||||
'CS': None
|
||||
}
|
||||
o = ILI9325(240, 320, drv)
|
||||
o.init()
|
||||
@ -231,6 +233,6 @@ Default:
|
||||
DB13 ------------------------ G16
|
||||
DB14 ------------------------ G20
|
||||
DB15 ------------------------ G21
|
||||
CS ------------------------ GND (always selected)
|
||||
CS ------------------------ GND (always selected) (or connect to GPIO pin)
|
||||
REST ------------------------ G25
|
||||
LED_A ------------------------ 3.3
|
||||
LED_A ------------------------ 3.3 (can be connected to GPIO pin)
|
||||
|
2
setup.py
2
setup.py
@ -13,7 +13,7 @@ def read(*paths):
|
||||
|
||||
setup(
|
||||
name='gfxlcd',
|
||||
version='0.2.0',
|
||||
version='0.2.1',
|
||||
description='gfxlcd is a handler for graphical lcds: ILI9328, SSD1306, NJU6450, touch panel: AD7843 @ Raspberry Pi.',
|
||||
keywords=['gfxlcd', 'raspberry pi' ,'ili9328' ,'ssd1306', 'nju6450', 'lcd', 'graphical lcd', 'touch panel', 'ad7843'],
|
||||
long_description=(read('readme.md')),
|
||||
|
Loading…
Reference in New Issue
Block a user