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

    Double buffer in m5stickC

    M5 Stick/StickC
    2
    2
    5.5k
    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.
    • G
      Guy
      last edited by

      Hello,

      I want to draw an image in m5stickC using Arduino IDE, but the image non-stop flash in screen.

      void loop() {
      // Change the sprite position
      x = ...
      y = ...

      // Clear screen
      M5.Lcd.fillScreen(WHITE);

      // Redraw image to new location
      M5.Lcd.drawBitmap(x, y, w, h,(uint16_t *)img, 0xffff);
      }

      Does m5stickC provide similiar functions / demo code:

      1. double buffer
      2. next frame checking --- lcd/cpu trigger to redraw

      Thanks
      Guy

      1 Reply Last reply Reply Quote 0
      • M
        Maxrom
        last edited by Maxrom

        You need to look at using sprites to avoid the flickering / flashing when you blank the screen. Take a look at the example sprite projects to see how it's done. The M5.Lcd functions can be called on a sprite object, so bitmap drawing, text drawing etc can be done the same way. Clearing, and drawing the sprite happens off screen, and then is copied quickly to the screen with pushSprite() which avoids visible flashing. The examples provided show you how to do it all, but here's the basic process :

        1. create your sprite object
          TFT_eSprite tftSprite = TFT_eSprite(&M5.Lcd);

        2. create a sprite and give it the size
          tftSprite.createSprite(160, 80);

        3. clear the sprite
          tftSprite.fillSprite(WHITE);

        4. draw into the sprite
          tftSprite.drawBitmap(x, y, w, h,(uint16_t *)img, 0xffff);

        5. copy the sprite to the screen, and let it know where to draw it
          tftSprite.pushSprite(0, 0);

        1 Reply Last reply Reply Quote 1
        • First post
          Last post