From 221ee59f794e556881ef52b215e87596b8835eb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Ko=C5=9Bci=C3=B3w?= Date: Thu, 18 May 2017 18:28:14 +0200 Subject: [PATCH] rotaion for ili9325 --- gfxlcd/driver/ili9325/ili9325.py | 36 +++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/gfxlcd/driver/ili9325/ili9325.py b/gfxlcd/driver/ili9325/ili9325.py index 7e4330a..7182881 100644 --- a/gfxlcd/driver/ili9325/ili9325.py +++ b/gfxlcd/driver/ili9325/ili9325.py @@ -6,9 +6,33 @@ from gfxlcd.abstract.chip import Chip class ILI9325(Area, Chip): """Class for ILI9325 based LCD""" + rotations = { + 0: { + 'output': 0x0100, + 'mode': 0x1038, + 'output2': 0xa700 + }, + 90: { + 'output': 0x0000, + 'mode': 0x1038, + 'output2': 0xa700 + }, + 180: { + 'output': 0x0000, + 'mode': 0x1038, + 'output2': 0x2700 + }, + 270: { + 'output': 0x0100, + 'mode': 0x1038, + 'output2': 0x2700 + } + } + def __init__(self, width, height, driver): Chip.__init__(self, width, height, driver, True) Area.__init__(self, driver) + self.rotation = 270 def _converted_background_color(self): """color from 8-8-8 to 5-6-5""" @@ -36,13 +60,16 @@ class ILI9325(Area, Chip): # ************* ILI9325C/D ********** # set SS and SM bit self.driver.cmd(0x0001, None) - self.driver.data(0x0100, None) + self.driver.data(self.rotations[self.rotation]['output'], None) + # set 1 line inversion self.driver.cmd(0x0002, None) self.driver.data(0x0200, None) + # set GRAM write direction and BGR=1 self.driver.cmd(0x0003, None) - self.driver.data(0x1030, None) + self.driver.data(self.rotations[self.rotation]['mode'], None) + # Resize register self.driver.cmd(0x0004, None) self.driver.data(0x0000, None) @@ -145,7 +172,8 @@ class ILI9325(Area, Chip): self.driver.data(0x013F, None) # Gate Scan Line self.driver.cmd(0x0060, None) - self.driver.data(0xA700, None) + self.driver.data(self.rotations[self.rotation]['output2'], None) + # NDL, VLE, REV self.driver.cmd(0x0061, None) self.driver.data(0x0001, None) @@ -178,6 +206,8 @@ class ILI9325(Area, Chip): def _set_area(self, pos_x1, pos_y1, pos_x2, pos_y2): """select area to work with""" + if self.rotation == 90 or self.rotation == 270: + pos_x1, pos_y1, pos_x2, pos_y2 = pos_y1, pos_x1, pos_y2, pos_x2 self.driver.cmd(0x0020, None) self.driver.data(pos_x1, None) self.driver.cmd(0x0021, None)