Skip to content

Commit

Permalink
support clearing display
Browse files Browse the repository at this point in the history
  • Loading branch information
michaellee1019 committed Apr 12, 2024
1 parent 7635427 commit 825365e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ Draw a line of pixels on the display. Options:
]
}

### Clear
Erases all pixels on the display to show a blank screen.
{
"drawings": [
{
"type": "clear"
}
]
}

### Multiple drawings.
Provide a list of drawings to place multiple elements on to the screen. The next DoCommand will erase the screen
{
Expand Down
5 changes: 5 additions & 0 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ async def do_command(
pixels = drawing["pixels"]
width = drawing.get("width")
self.line(draw, pixels, width)
case "clear":
self.clear(draw)
result["drawings"] = True
return result

Expand All @@ -87,6 +89,9 @@ def line(self, draw, pixels: list[int], width):
width=1
draw.line(pixels, fill="white", width=width)

def clear(self, draw):
draw.clear()

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

0 comments on commit 825365e

Please sign in to comment.