v.0.9.0 DigitalClock
This commit is contained in:
26
app/utils/digital_clock.py
Normal file
26
app/utils/digital_clock.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from app.display.neopixel_64x64 import NeoPixel_64x64
|
||||
from app.utils import get_datetime_string
|
||||
from app.utils import colors
|
||||
|
||||
|
||||
class DigitalClock:
|
||||
CLOCK_WIDTH = 38
|
||||
|
||||
def __init__(self, display: NeoPixel_64x64, xpos: int, ypos: int):
|
||||
self.display = display
|
||||
self.xpos = xpos
|
||||
self.ypos = ypos
|
||||
|
||||
async def tick(self):
|
||||
time_str: str = get_datetime_string("time")
|
||||
self.display.clear_box(
|
||||
self.ypos,
|
||||
self.xpos,
|
||||
self.ypos + self.display.font_height,
|
||||
self.xpos + self.CLOCK_WIDTH,
|
||||
color=colors.MAGENTA,
|
||||
)
|
||||
|
||||
self.display.write_text(
|
||||
time_str[:8], self.xpos, self.ypos, color=colors.NEON_YELLOW
|
||||
)
|
||||
Reference in New Issue
Block a user