Skip to content

Commit 0890dc0

Browse files
committed
add custom color565 method (fix error)
I removed color565 from the Draw class in v1.6.8
1 parent 9e88d77 commit 0890dc0

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed
45 Bytes
Binary file not shown.

builds/CircuitPython/apps_unfrozen/screensavers/Starfield.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ def __rng() -> int:
3030
return zc
3131

3232

33+
def color565(r: int, g: int, b: int) -> int:
34+
"""Convert RGB888 to RGB565 color format"""
35+
return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3)
36+
37+
3338
def start(view_manager) -> bool:
3439
"""Start the app"""
3540
import random
@@ -121,7 +126,7 @@ def run(view_manager) -> None:
121126

122127
if 0 <= screen_x < screen_size.x and 0 <= screen_y < screen_size.y:
123128
r = g = b = 255 - sz[i]
124-
color = tft.color565(r, g, b)
129+
color = color565(r, g, b)
125130
pixel_vector.x = screen_x
126131
pixel_vector.y = screen_y
127132
tft.pixel(pixel_vector, color)
45 Bytes
Binary file not shown.

builds/MicroPython/apps_unfrozen/screensavers/Starfield.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ def __rng() -> int:
3030
return zc
3131

3232

33+
def color565(r: int, g: int, b: int) -> int:
34+
"""Convert RGB888 to RGB565 color format"""
35+
return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3)
36+
37+
3338
def start(view_manager) -> bool:
3439
"""Start the app"""
3540
import random
@@ -121,7 +126,7 @@ def run(view_manager) -> None:
121126

122127
if 0 <= screen_x < screen_size.x and 0 <= screen_y < screen_size.y:
123128
r = g = b = 255 - sz[i]
124-
color = tft.color565(r, g, b)
129+
color = color565(r, g, b)
125130
pixel_vector.x = screen_x
126131
pixel_vector.y = screen_y
127132
tft.pixel(pixel_vector, color)

0 commit comments

Comments
 (0)