Day 1:
Spent my whole day working on a display framework for my trail project!
I’m developing a new display framework for the SSD1306 in MicroPython that aims to simplify building advanced interactive user interfaces.
• Implemented the ability to nest child components within parent components for proper relative positioning.
• Updated rendering logic so child components are positioned based on their parent’s size and position.
Using it is very simple. Just create a new component and update the properties!
async def main():
_display = Display()
_vcanvas = vcanvas.vCanvas(128, 64, lambda data: _display.render(data))
render_task = uasyncio.create_task(_vcanvas.render())
frame = vcanvas.Frame(_vcanvas, width=64, height=32, background_color=1,
ax=0.5, ay=0.5, position_type="scale", x=0.5, y=0.5)
label = vcanvas.TextLabel(frame, text="Welcome!", text_size=1,
ax=0.5, ay=0.5, position_type="scale", x=0.5, y=0.5)
amogus = 1
try:
while True:
await uasyncio.sleep(1)
print("Looping", utime.ticks_ms())
Pin("LED", Pin.OUT).toggle()
if amogus == 0:
frame.x = 0.25
frame.y = 0.25
label.text = "Welcome!"
amogus = 1
elif amogus == 1:
frame.x = 0.75
frame.y = 0.75
label.text = "Welcome"
amogus = 0
finally:
render_task.cancel()
try:
await render_task
except uasyncio.CancelledError:
print("Cancelled render task")
uasyncio.run(main())