|
28 | 28 | * Author(s): Radomir Dopieralski, Michael McWethy
|
29 | 29 | """
|
30 | 30 |
|
| 31 | +import time |
| 32 | + |
31 | 33 | try:
|
32 | 34 | import struct
|
33 | 35 | except ImportError:
|
|
84 | 86 | _GMCTRP1 = const(0xE0)
|
85 | 87 | _GMCTRN1 = const(0xE1)
|
86 | 88 |
|
| 89 | +_TSTCMD1 = const(0xF0) |
| 90 | +_DISRPSM1 = const(0xF6) |
| 91 | + |
87 | 92 |
|
88 | 93 | class ST7735(DisplaySPI):
|
89 | 94 | """
|
@@ -193,3 +198,81 @@ def init(self):
|
193 | 198 | self.write(command, data)
|
194 | 199 | if self._bgr:
|
195 | 200 | self.write(_MADCTL, b'\xc0')
|
| 201 | + |
| 202 | +class ST7735S(ST7735): |
| 203 | + """A simple driver for the ST7735S-based displays.""" |
| 204 | + _INIT = ( |
| 205 | + # Frame Rate |
| 206 | + (_FRMCTR1, b'\x01\x2c\x2d'), # B1 |
| 207 | + (_FRMCTR2, b'\x01\x2c\x2d'), # B2 |
| 208 | + (_FRMCTR3, b'\x01\x2c\x2d\x01\x2c\x2d'), # B3 |
| 209 | + |
| 210 | + # Column inversion |
| 211 | + (_INVCTR, b'\x07'), # B4 |
| 212 | + |
| 213 | + # Power Sequence |
| 214 | + (_PWCTR1, b'\xa2\x02\x84'), # C0 |
| 215 | + (_PWCTR2, b'\xc5'), # C1 |
| 216 | + (_PWCTR3, b'\x0a\x00'), # C2 |
| 217 | + (_PWCTR4, b'\x8a\x2a'), # C3 |
| 218 | + (_PWCTR5, b'\x8a\xee'), # C4 |
| 219 | + |
| 220 | + # VCOM |
| 221 | + (_VMCTR1, b'\x0e'), # C5 |
| 222 | + |
| 223 | + # Gamma |
| 224 | + (_GMCTRP1, b'\x0f\x1a\x0f\x18\x2f\x28\x20\x22' # E0 |
| 225 | + b'\x1f\x1b\x23\x37\x00\x07\x02\x10'), |
| 226 | + |
| 227 | + (_GMCTRN1, b'\x0f\x1b\x0f\x17\x33\x2c\x29\x2e' # E1 |
| 228 | + b'\x30\x30\x39\x3f\x00\x07\x03\x10'), |
| 229 | + # Enable test command |
| 230 | + (_TSTCMD1, b'\x01'), # F0 |
| 231 | + # Disable ram power save mode |
| 232 | + (_DISRPSM1, b'\x00'), # F6 |
| 233 | + # 65k mode |
| 234 | + (_COLMOD, b'\x05'), # 3A |
| 235 | + # set scan direction: up to down, right to left |
| 236 | + (_MADCTL, b'\x60'), # 36 |
| 237 | + ) |
| 238 | + |
| 239 | + #pylint: disable-msg=useless-super-delegation, too-many-arguments |
| 240 | + def __init__(self, spi, dc, cs, bl, rst=None, width=128, height=160, |
| 241 | + baudrate=16000000, polarity=0, phase=0, *, |
| 242 | + x_offset=2, y_offset=1, rotation=0, bgr=False): |
| 243 | + self._bl = bl |
| 244 | + # Turn on backlight |
| 245 | + print('turn on backlight') |
| 246 | + self._bl.switch_to_output(value=1) |
| 247 | + super().__init__(spi, dc, cs, rst, width, height, |
| 248 | + baudrate=baudrate, polarity=polarity, phase=phase, |
| 249 | + x_offset=x_offset, y_offset=y_offset, rotation=rotation) |
| 250 | + |
| 251 | + # def reset(self): |
| 252 | + # print('reset') |
| 253 | + # self.rst.value = 1 |
| 254 | + # time.sleep(0.100) |
| 255 | + # self.rst.value = 0 |
| 256 | + # time.sleep(0.100) |
| 257 | + # self.rst.value = 1 |
| 258 | + # time.sleep(0.100) |
| 259 | + |
| 260 | + def init(self): |
| 261 | + |
| 262 | + super().init() |
| 263 | + print('last commands of init') |
| 264 | + |
| 265 | + # cols = struct.pack('>HH', 0, self.width - 1) |
| 266 | + # rows = struct.pack('>HH', 0, self.height - 1) |
| 267 | + |
| 268 | + # for command, data in ( |
| 269 | + # (_CASET, cols), |
| 270 | + # (_RASET, rows), |
| 271 | + # (_NORON, None), |
| 272 | + # (_DISPON, None), |
| 273 | + # ): |
| 274 | + # self.write(command, data) |
| 275 | + time.sleep(0.200) |
| 276 | + self.write(_SLPOUT) |
| 277 | + time.sleep(0.120) |
| 278 | + self.write(_DISPON) |
0 commit comments