Double buffer in m5stickC

  • 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

    // 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


  • 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

    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);