M5Paper, using canvas in procedure



  • Have wrote a simple program, with a procedure that use canvas.
    When compile the program get error message
    "canvas1' was not declared in this scope" .

    This is my program:

    #include <M5EPD.h>

    void setup() {
    M5.begin();
    M5.TP.SetRotation(180);
    M5.EPD.SetRotation(180);
    M5.EPD.Clear(true);
    canvas1.createCanvas(960, 540);
    canvas1.loadFont("/fonts/GenSenRounded-R.ttf", SD);
    DisplayDisplayWindSection(480, 270, 300, 3.5, 40)
    canvas1.pushCanvas(0, 0, UPDATE_MODE_GL16);

    }

    void loop() {
    // put your main code here, to run repeatedly:

    }

    void drawWindroos()
    {
    canvas1.loadFont("/fonts/GenSenRounded-R.ttf", SD);
    canvas1.createRender(30);
    canvas1.setTextSize(30);
    }

    The error is shown in the first line of the procedure drawWindroos.
    How to avoid this error?

    Cheers,
    Jan



  • @powersoft
    Do you only have 1 canvas? Try canvas instead of canvas1.

    BTW, you can enclose your code in three back ticks (```) to make it easier for us to read, like this...

    this text has three back ticks before and after it