Hello, everyone, I was drawing some pixels and according to the docs, the methods I see are not necesarly clearing the canvas, I was wondering if there is a best practice to clear the canvas content, right now I am creating the canvas like this:
canvas = lv_canvas_create(lv_scr_act(), NULL);
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_IMG_CF_INDEXED_1BIT);
lv_canvas_set_palette(canvas, 0, LV_COLOR_TRANSP);
lv_canvas_set_palette(canvas, 1, LV_COLOR_MAKE(155, 205, 0x00));
And I draw some rectangles in pixel format with this little method
void mydrawRec(uint32_t x,uint32_t y,uint32_t w,uint32_t h){
lv_color_t c0;
c0.full = 1;
uint32_t mx;
uint32_t my;
for( my = y; my < y+h; my++) {
for( mx = x; mx < x+w; mx++) {
lv_canvas_set_px(canvas, mx, my, c0);
}
}
}
and when I need to erase the content, I do this:
void clearCanvas(){
lv_color_t c1;
c1.full = 0;
uint32_t x;
uint32_t y;
for( y = 0; y < CANVAS_HEIGHT; y++) {
for( x = 0; x < CANVAS_WIDTH; x++) {
lv_canvas_set_px(canvas, x, y, c1);
}
}
}
Fortunately it is erasing the canvas, but my guess is that, going pixel by pixel is not the best approach