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
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:
- double buffer
- next frame checking --- lcd/cpu trigger to redraw
Thanks
Guy -
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 :
-
create your sprite object
TFT_eSprite tftSprite = TFT_eSprite(&M5.Lcd); -
create a sprite and give it the size
tftSprite.createSprite(160, 80); -
clear the sprite
tftSprite.fillSprite(WHITE); -
draw into the sprite
tftSprite.drawBitmap(x, y, w, h,(uint16_t *)img, 0xffff); -
copy the sprite to the screen, and let it know where to draw it
tftSprite.pushSprite(0, 0);
-