🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    M5Paper, using canvas in procedure

    Scheduled Pinned Locked Moved Modules
    m5paper
    2 Posts 2 Posters 5.2k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P Offline
      Powersoft
      last edited by

      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

      world101W 1 Reply Last reply Reply Quote 0
      • world101W Offline
        world101 @Powersoft
        last edited by world101

        @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
        
        1 Reply Last reply Reply Quote 0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post