Skip to content

Canvas drawing not working - it needs hard reset #39

@mroglic

Description

@mroglic

I am using the M5 Dial and testing Canvas drawing. Each time I change the position or color of a circle and save it to the M5 Dial (whether using UIFlow, VS Code, or Thonny), I need to restart the device with a hard reset for the changes to be visible, otherwise the Lcd stops drawing anything and just shows the black background. The changes don't take effect after a soft reset or when pasting the same code through REPL, which is something that is expected I guess.

The Widgets.Image works fine (it doesn't require a hard reset and behaves as expected), but I specifically want to use the Canvas for smooth drawing of graphics/images. The issue I encounter with Widgets.Image is that when I try to animate the image's movement, the screen flickers.

This is what I got in main.py, just changing the canvas.drawCircle parameters, would result in completely black screen.

import M5
import time

canvas = None
 
def setup():
    global canvas
    M5.begin()
    canvas = M5.Lcd.newCanvas(240, 240, 16, True)  
    
def loop():
    global canvas
    M5.update()         
    canvas.drawCircle(120, 120, 33, 0x00ff00)
    canvas.push(0, 0)
    canvas.clear()
 
if __name__ == '__main__':
    try:
        setup()
        while True:
            loop()
    except (Exception, KeyboardInterrupt) as e:
        print("Program terminated.")
        if isinstance(e, Exception):
            print(f"Error: {e}")
    finally:
        print("Performing final cleanup...")
        if canvas:
            canvas.delete()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions