Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion i75/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self,
color_order: hub75.ColorOrder
= hub75.COLOR_ORDER_RGB) -> None:
self._driver = picographics.PicoGraphics(display_type)
self.rotate = rotate
self.rotate = rotate # for now only accept 90,180, 270

self.width, self.height = self._driver.get_bounds()
self.hub75 = hub75.Hub75(self.width,
Expand Down Expand Up @@ -113,13 +113,27 @@ def fill(self, tl_x: int, tl_y: int, br_x: int, br_y: int) -> None:
self.pixel(x, y)

def pixel(self, x: int, y: int) -> None:
if self.rotate != 0:
x, y = self._rotate_pixels(x, y)

if x >= 0 and x < self.width and y >= 0 and y < self.height:
self._driver.pixel(x, y)

def __pixel_reverse(self, x: int, y: int) -> None:
if self.rotate != 0:
x, y = self._rotate_pixels(x, y)

if x >= 0 and x < self.width and y >= 0 and y < self.height:
self._driver.pixel(y, x)

def _rotate_pixels(self, x: int, y: int) -> Tuple[int, int]:
x_h = x
y_h = y
if self.rotate == 270:
x_h = y
y_h = self.height - 1 - x
return x_h, y_h

def update(self) -> None:
self.hub75.update(self._driver)

Expand Down