mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 15:12:06 +00:00 
			
		
		
		
	[lvgl] memset canvas buffer to prevent display of random garbage (#11582)
Co-authored-by: clydebarrow <2366188+clydebarrow@users.noreply.github.com>
This commit is contained in:
		| @@ -33,7 +33,7 @@ from ..lv_validation import ( | ||||
|     pixels, | ||||
|     size, | ||||
| ) | ||||
| from ..lvcode import LocalVariable, lv, lv_assign | ||||
| from ..lvcode import LocalVariable, lv, lv_assign, lv_expr | ||||
| from ..schemas import STYLE_PROPS, STYLE_REMAP, TEXT_SCHEMA, point_schema | ||||
| from ..types import LvType, ObjUpdateAction, WidgetType | ||||
| from . import Widget, get_widgets | ||||
| @@ -70,11 +70,14 @@ class CanvasType(WidgetType): | ||||
|         width = config[CONF_WIDTH] | ||||
|         height = config[CONF_HEIGHT] | ||||
|         use_alpha = "_ALPHA" if config[CONF_TRANSPARENT] else "" | ||||
|         buf_size = literal( | ||||
|             f"LV_CANVAS_BUF_SIZE_TRUE_COLOR{use_alpha}({width}, {height})" | ||||
|         ) | ||||
|         with LocalVariable("buf", cg.void, lv_expr.custom_mem_alloc(buf_size)) as buf: | ||||
|             cg.add(cg.RawExpression(f"memset({buf}, 0, {buf_size});")) | ||||
|             lv.canvas_set_buffer( | ||||
|                 w.obj, | ||||
|             lv.custom_mem_alloc( | ||||
|                 literal(f"LV_CANVAS_BUF_SIZE_TRUE_COLOR{use_alpha}({width}, {height})") | ||||
|             ), | ||||
|                 buf, | ||||
|                 width, | ||||
|                 height, | ||||
|                 literal(f"LV_IMG_CF_TRUE_COLOR{use_alpha}"), | ||||
|   | ||||
		Reference in New Issue
	
	Block a user