From 70a450ba741fe42c6dfe251af6336d1c65f0890d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Ko=C5=9Bci=C3=B3w?= Date: Mon, 8 May 2017 20:45:50 +0200 Subject: [PATCH] ili CS pin --- gfxlcd/demos/ili.py | 1 + gfxlcd/demos/ili_2.py | 1 + gfxlcd/demos/ili_image.py | 1 + gfxlcd/driver/ili9325/gpio.py | 6 ++++++ readme.md | 2 +- 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gfxlcd/demos/ili.py b/gfxlcd/demos/ili.py index 15833f5..23ee492 100644 --- a/gfxlcd/demos/ili.py +++ b/gfxlcd/demos/ili.py @@ -32,6 +32,7 @@ def draw_net(o): drv = GPIO() drv.pins['LED'] = 6 +drv.pins['CS'] = 18 o = ILI9325(240, 320, drv) o.init() diff --git a/gfxlcd/demos/ili_2.py b/gfxlcd/demos/ili_2.py index a253b60..49957d6 100644 --- a/gfxlcd/demos/ili_2.py +++ b/gfxlcd/demos/ili_2.py @@ -39,6 +39,7 @@ def draw_net(o): drv = ILIGPIO() drv.pins['LED'] = 6 +drv.pins['CS'] = 18 lcd_tft = ILI9325(240, 320, drv) lcd_tft.init() diff --git a/gfxlcd/demos/ili_image.py b/gfxlcd/demos/ili_image.py index a3f4e6a..7c58fc6 100644 --- a/gfxlcd/demos/ili_image.py +++ b/gfxlcd/demos/ili_image.py @@ -9,6 +9,7 @@ RPi.GPIO.setmode(RPi.GPIO.BCM) drv = ILIGPIO() drv.pins['LED'] = 6 +drv.pins['CS'] = 18 lcd_tft = ILI9325(240, 320, drv) lcd_tft.init() diff --git a/gfxlcd/driver/ili9325/gpio.py b/gfxlcd/driver/ili9325/gpio.py index dff3fd2..9d06f5d 100644 --- a/gfxlcd/driver/ili9325/gpio.py +++ b/gfxlcd/driver/ili9325/gpio.py @@ -38,6 +38,8 @@ class GPIO(Driver): """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) @@ -59,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""" diff --git a/readme.md b/readme.md index e1c963f..18c87b4 100644 --- a/readme.md +++ b/readme.md @@ -233,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 (can be connected to GPIO pin)