split touch samples

add LED pin to driver
This commit is contained in:
Bartosz Kościów 2017-05-08 19:57:33 +02:00
parent 3f91cc0c7a
commit 2f0a32e71f
8 changed files with 51 additions and 19 deletions

View File

@ -31,6 +31,7 @@ def draw_net(o):
drv = GPIO()
drv.pins['LED'] = 6
o = ILI9325(240, 320, drv)
o.init()

View File

@ -37,14 +37,11 @@ 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
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)

View File

@ -7,13 +7,11 @@ 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
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)

View 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()

View 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()

View File

@ -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,14 @@ 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)
RPi.GPIO.output(self.pins['RST'], 1)
time.sleep(0.005)
RPi.GPIO.output(self.pins['RST'], 0)

View File

@ -98,6 +98,8 @@ Custom pins:
'DB14': 20,
'DB15': 21,
'RST': 25,
'LED': None,
'CS': None
}
o = ILI9325(240, 320, drv)
o.init()
@ -233,4 +235,4 @@ Default:
DB15 ------------------------ G21
CS ------------------------ GND (always selected)
REST ------------------------ G25
LED_A ------------------------ 3.3
LED_A ------------------------ 3.3 (can be connected to GPIO pin)