Add Pico display rendering abstraction

This commit is contained in:
2026-06-03 02:49:22 -06:00
parent b5e8bf43fc
commit d2583baf5a
3 changed files with 138 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
class Display:
def __init__(self, driver=None):
self.driver = driver
self.commands = []
def clear(self):
self.commands.append(("clear",))
def text(self, x, y, value, size=1):
self.commands.append(("text", x, y, str(value), size))
def rect(self, x, y, w, h, filled=False):
self.commands.append(("rect", x, y, w, h, filled))
def flush(self):
if not self.driver:
return
for command in self.commands:
name = command[0]
if name == "clear":
self.driver.clear()
elif name == "text":
_, x, y, value, size = command
self.driver.text(x, y, value, size)
elif name == "rect":
_, x, y, w, h, filled = command
self.driver.rect(x, y, w, h, filled)
self.commands = []