|
30 | 30 | from serial.tools.list_ports import comports
|
31 | 31 |
|
32 | 32 | from library.lcd.lcd_comm import Orientation, LcdComm
|
33 |
| -from library.lcd.serialize import image_to_BGRA, image_to_BGR, chunked |
| 33 | +from library.lcd.serialize import image_to_BGRA, image_to_compressed_BGRA, chunked |
34 | 34 | from library.log import logger
|
35 | 35 |
|
36 | 36 |
|
@@ -200,7 +200,8 @@ def _hello(self):
|
200 | 200 | # This command reads LCD answer on serial link, so it bypasses the queue
|
201 | 201 | self.sub_revision = SubRevision.UNKNOWN
|
202 | 202 | self._send_command(Command.HELLO, bypass_queue=True)
|
203 |
| - response = ''.join(filter(lambda x: x in set(string.printable), str(self.serial_read(23).decode(errors="ignore")))) |
| 203 | + response = ''.join( |
| 204 | + filter(lambda x: x in set(string.printable), str(self.serial_read(23).decode(errors="ignore")))) |
204 | 205 | self.serial_flush_input()
|
205 | 206 | logger.debug("Display ID returned: %s" % response)
|
206 | 207 |
|
@@ -252,13 +253,13 @@ def Clear(self):
|
252 | 253 | self.SetOrientation(orientation=backup_orientation)
|
253 | 254 |
|
254 | 255 | def ScreenOff(self):
|
255 |
| - logger.info("Calling ScreenOff") |
| 256 | + # logger.info("Calling ScreenOff") |
256 | 257 | self._send_command(Command.STOP_VIDEO)
|
257 | 258 | self._send_command(Command.STOP_MEDIA, readsize=1024)
|
258 | 259 | self._send_command(Command.TURNOFF)
|
259 | 260 |
|
260 | 261 | def ScreenOn(self):
|
261 |
| - logger.info("Calling ScreenOn") |
| 262 | + # logger.info("Calling ScreenOn") |
262 | 263 | self._send_command(Command.STOP_VIDEO)
|
263 | 264 | self._send_command(Command.STOP_MEDIA, readsize=1024)
|
264 | 265 | # self._send_command(Command.SET_BRIGHTNESS, payload=bytearray([255]))
|
@@ -357,7 +358,7 @@ def _generate_full_image(self, image: Image.Image) -> bytes:
|
357 | 358 | elif self.orientation == Orientation.REVERSE_LANDSCAPE:
|
358 | 359 | image = image.rotate(180)
|
359 | 360 |
|
360 |
| - bgra_data = image_to_BGRA(image) |
| 361 | + bgra_data, pixel_size = image_to_BGRA(image) |
361 | 362 |
|
362 | 363 | return b'\x00'.join(chunked(bgra_data, 249))
|
363 | 364 |
|
@@ -397,15 +398,13 @@ def _generate_update_image(
|
397 | 398 |
|
398 | 399 | img_raw_data = bytearray()
|
399 | 400 |
|
400 |
| - # Some screens require BGR for update image, some require BGRA |
| 401 | + # Some screens require different RGBA encoding |
401 | 402 | if self.rom_version > 88:
|
402 |
| - # BGRA mode |
403 |
| - img_data = image_to_BGRA(image) |
404 |
| - pixel_size = 4 |
| 403 | + # BGRA mode on 4 bytes : [B, G, R, A] |
| 404 | + img_data, pixel_size = image_to_BGRA(image) |
405 | 405 | else:
|
406 |
| - # BGR mode |
407 |
| - img_data = image_to_BGR(image) |
408 |
| - pixel_size = 3 |
| 406 | + # BGRA mode on 3 bytes: [6-bit B + 2-bit A, 6-bit G + 2-bit A, R] |
| 407 | + img_data, pixel_size = image_to_compressed_BGRA(image) |
409 | 408 |
|
410 | 409 | for h, line in enumerate(chunked(img_data, image.width * pixel_size)):
|
411 | 410 | if self.sub_revision == SubRevision.REV_8INCH:
|
|
0 commit comments