rotaion for ili9325
This commit is contained in:
parent
fbb69d2db9
commit
221ee59f79
@ -6,9 +6,33 @@ from gfxlcd.abstract.chip import Chip
|
|||||||
|
|
||||||
class ILI9325(Area, Chip):
|
class ILI9325(Area, Chip):
|
||||||
"""Class for ILI9325 based LCD"""
|
"""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):
|
def __init__(self, width, height, driver):
|
||||||
Chip.__init__(self, width, height, driver, True)
|
Chip.__init__(self, width, height, driver, True)
|
||||||
Area.__init__(self, driver)
|
Area.__init__(self, driver)
|
||||||
|
self.rotation = 270
|
||||||
|
|
||||||
def _converted_background_color(self):
|
def _converted_background_color(self):
|
||||||
"""color from 8-8-8 to 5-6-5"""
|
"""color from 8-8-8 to 5-6-5"""
|
||||||
@ -36,13 +60,16 @@ class ILI9325(Area, Chip):
|
|||||||
# ************* ILI9325C/D **********
|
# ************* ILI9325C/D **********
|
||||||
# set SS and SM bit
|
# set SS and SM bit
|
||||||
self.driver.cmd(0x0001, None)
|
self.driver.cmd(0x0001, None)
|
||||||
self.driver.data(0x0100, None)
|
self.driver.data(self.rotations[self.rotation]['output'], None)
|
||||||
|
|
||||||
# set 1 line inversion
|
# set 1 line inversion
|
||||||
self.driver.cmd(0x0002, None)
|
self.driver.cmd(0x0002, None)
|
||||||
self.driver.data(0x0200, None)
|
self.driver.data(0x0200, None)
|
||||||
|
|
||||||
# set GRAM write direction and BGR=1
|
# set GRAM write direction and BGR=1
|
||||||
self.driver.cmd(0x0003, None)
|
self.driver.cmd(0x0003, None)
|
||||||
self.driver.data(0x1030, None)
|
self.driver.data(self.rotations[self.rotation]['mode'], None)
|
||||||
|
|
||||||
# Resize register
|
# Resize register
|
||||||
self.driver.cmd(0x0004, None)
|
self.driver.cmd(0x0004, None)
|
||||||
self.driver.data(0x0000, None)
|
self.driver.data(0x0000, None)
|
||||||
@ -145,7 +172,8 @@ class ILI9325(Area, Chip):
|
|||||||
self.driver.data(0x013F, None)
|
self.driver.data(0x013F, None)
|
||||||
# Gate Scan Line
|
# Gate Scan Line
|
||||||
self.driver.cmd(0x0060, None)
|
self.driver.cmd(0x0060, None)
|
||||||
self.driver.data(0xA700, None)
|
self.driver.data(self.rotations[self.rotation]['output2'], None)
|
||||||
|
|
||||||
# NDL, VLE, REV
|
# NDL, VLE, REV
|
||||||
self.driver.cmd(0x0061, None)
|
self.driver.cmd(0x0061, None)
|
||||||
self.driver.data(0x0001, 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):
|
def _set_area(self, pos_x1, pos_y1, pos_x2, pos_y2):
|
||||||
"""select area to work with"""
|
"""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.cmd(0x0020, None)
|
||||||
self.driver.data(pos_x1, None)
|
self.driver.data(pos_x1, None)
|
||||||
self.driver.cmd(0x0021, None)
|
self.driver.cmd(0x0021, None)
|
||||||
|
Loading…
Reference in New Issue
Block a user