Skip to content

Commit

Permalink
add more command options
Browse files Browse the repository at this point in the history
  • Loading branch information
michaellee1019 committed Apr 12, 2024
1 parent 101126b commit d79cd68
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion models.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,35 @@ async def do_command(
match drawing["type"]:
case "border":
self.border(draw)

case "text":
message = drawing["message"]
start_pixel = drawing["start_pixel"]
font = drawing.get("font", "CP437_FONT")
self.text(draw, start_pixel, message, font)
case "point":
pixel = drawing["pixel"]
self.point(draw, pixel)
case "line":
pixels = drawing["pixels"]
self.point(draw, pixels)
result["drawings"] = True
return result

def border(self, draw):
draw.rectangle(self.device.bounding_box, outline="white")

def text(self, draw, start_pixel: list[int], message: str, font):
font_cls = CP437_FONT
if font is "LCD_FONT":
font_cls = LCD_FONT
text(draw, start_pixel, message, fill="white", font=proportional(font_cls))

def point(self, draw, pixel: list[int]):
draw.point(pixel, fill="white")

def line(self, draw, pixels: list[int]):
draw.line(pixels, fill="white")

def reconfigure(self,
config: ComponentConfig,
dependencies: Mapping[ResourceName, ResourceBase]):
Expand Down

0 comments on commit d79cd68

Please sign in to comment.