26
26
__version__ = "0.0.0+auto.0"
27
27
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display.git"
28
28
29
- # Command constants
30
- _NOP = const (0x00 )
31
- _SWRESET = const (0x01 )
32
- _SLPIN = const (0x10 )
33
- _SLPOUT = const (0x11 )
29
+ # Constants for MADCTL
30
+ _MADCTL_MY = const (0x80 ) # Bottom to top
31
+ _MADCTL_MX = const (0x40 ) # Right to left
32
+ _MADCTL_MV = const (0x20 ) # Reverse Mode
33
+ _MADCTL_ML = const (0x10 ) # LCD refresh Bottom to top
34
+ _MADCTL_RGB = const (0x00 ) # Red-Green-Blue pixel order
35
+ _MADCTL_BGR = const (0x08 ) # Blue-Green-Red pixel order
36
+ _MADCTL_MH = const (0x04 ) # LCD refresh right to left
34
37
_PTLON = const (0x12 )
35
38
_NORON = const (0x13 )
36
39
_INVOFF = const (0x20 )
@@ -136,9 +139,19 @@ def init(self) -> None:
136
139
cols = struct .pack (">HH" , self ._X_START , self .width + self ._X_START - 1 )
137
140
rows = struct .pack (">HH" , self ._Y_START , self .height + self ._Y_START - 1 )
138
141
139
- for command , data in (
140
- (_MADCTL , b"\xc0 " ), # Set rotation to 0 and use RGB
141
- (_CASET , b"\x00 \x00 \x00 \xef " ), # Column Address Set [Start col = 0, end col = 239]
142
- (_RASET , b"\x00 \x00 \x00 \xef " ), # Row Address Set [Start row = 0, end row = 239]
143
- ):
144
- self .write (command , data )
142
+ def init (self ) -> None :
143
+ """Initialize the display"""
144
+ super ().init ()
145
+
146
+ # Initialize display
147
+ self .write (_SWRESET )
148
+ time .sleep (0.150 ) # 150ms delay after reset
149
+
150
+ # Set addressing mode and color format
151
+ self .write (_MADCTL , bytes ([_MADCTL_MX | _MADCTL_BGR ]))
152
+
153
+ # Set addressing windows
154
+ self .write (_CASET , b"\x00 \x00 \x00 \xef " ) # Column Address Set [0-239]
155
+ self .write (_RASET , b"\x00 \x00 \x00 \xef " ) # Row Address Set [0-239]
156
+
157
+ time .sleep (0.150 ) # 150ms delay before turning on display
0 commit comments