@@ -108,68 +108,11 @@ static inline void lv_flush_oled(lv_display_t *display, const lv_area_t *area, u
108108 // More information about the monochrome, please refer to https://docs.lvgl.io/9.2/porting/display.html#monochrome-displays
109109 px_map += 8 ;
110110
111- // log_v("Converting to tiled format for OLED");
112- // #define LVGL_OLED_BIT_ORDER_LSB true
113- // // lv_draw_sw_i1_convert_to_vtiled(px_map, area_buf_size, w, h, oled_buffer, area_buf_size, LVGL_OLED_BIT_ORDER_LSB);
114- // // - The output buffer (oled_buffer) must be at least as large as the input buffer, and is statically allocated for the full display size.
115- // // - The function assumes that both width and height are multiples of 8, as required by LVGL for monochrome tiled rendering.
116- // // - If the area is not aligned to 8x8, or the buffer sizes are insufficient, the function may assert or produce incorrect output.
117- // log_v("Convert to vtiled: w=%d, h=%d, buf_size=%d", w, h, px_buf_size);
118- // lv_draw_sw_i1_convert_to_vtiled(px_map, px_buf_size, w, h, &oled_buffer, px_buf_size, LVGL_OLED_BIT_ORDER_LSB);
119- uint32_t hor_res = lv_display_get_physical_horizontal_resolution (display );
120- int32_t x1 = area -> x1 ;
121- int32_t x2 = area -> x2 ;
122- int32_t y1 = area -> y1 ;
123- int32_t y2 = area -> y2 ;
124-
125- for (int y = y1 ; y <= y2 ; y ++ )
126- {
127- for (int32_t x = x1 ; x <= x2 ; x ++ )
128- {
129- /* The order of bits is MSB first
130- MSB LSB
131- bits 7 6 5 4 3 2 1 0
132- pixels 0 1 2 3 4 5 6 7
133- Left Right
134- */
135- bool chroma_color = (px_map [(hor_res >> 3 ) * y + (x >> 3 )] & 1 << (7 - x % 8 ));
136- /* Write to the buffer as required for the display.
137- * It writes only 1-bit for monochrome displays mapped vertically.*/
138- uint8_t * buf = oled_buffer + hor_res * (y >> 3 ) + (x );
139- if (chroma_color )
140- * buf &= ~(1 << (y % 8 ));
141- else
142- * buf |= (1 << (y % 8 ));
143- }
144- }
111+ const size_t px_buf_size = lv_display_get_draw_buf_size (display );
112+ lv_draw_sw_i1_convert_to_vtiled (px_map , px_buf_size , LVGL_HOR_RES , LVGL_VER_RES , oled_buffer , sizeof (oled_buffer ), false);
145113
146114 // pass the draw buffer to the driver
147- esp_lcd_panel_draw_bitmap (panel_handle , area -> x1 , area -> y1 , area -> x2 + 1 , area -> y2 + 1 , oled_buffer );
148-
149-
150-
151- // // To use LV_COLOR_FORMAT_I1, we need an extra buffer to hold the converted data
152- // int32_t w = area->x2 - area->x1 + 1;
153- // int32_t h = area->y2 - area->y1 + 1;
154- // size_t area_buf_size = (w * h) / 8;
155- // uint8_t *oled_buffer = (uint8_t *)heap_caps_malloc(area_buf_size, LVGL_BUFFER_MALLOC_FLAGS);
156- // assert(oled_buffer != NULL);
157-
158- // // This is necessary because LVGL reserves 2 x 4 bytes in the buffer, as these are assumed to be used as a palette. Skip the palette here
159- // // More information about the monochrome, please refer to https://docs.lvgl.io/9.2/porting/display.html#monochrome-displays
160- // px_map += 8;
161-
162- // #define LVGL_OLED_BIT_ORDER_LSB true
163- // // lv_draw_sw_i1_convert_to_vtiled(px_map, area_buf_size, w, h, oled_buffer, area_buf_size, LVGL_OLED_BIT_ORDER_LSB);
164- // // - The output buffer (oled_buffer) must be at least as large as the input buffer, and is statically allocated for the full display size.
165- // // - The function assumes that both width and height are multiples of 8, as required by LVGL for monochrome tiled rendering.
166- // // - If the area is not aligned to 8x8, or the buffer sizes are insufficient, the function may assert or produce incorrect output.
167- // lv_draw_sw_i1_convert_to_vtiled(px_map, area_buf_size, w, h, oled_buffer, area_buf_size, true);
168-
169- // // pass the draw buffer to the driver
170- // esp_lcd_panel_draw_bitmap(panel_handle, area->x1, area->y1, area->x2, area->y2 , oled_buffer);
171-
172- // free(oled_buffer);
115+ esp_lcd_panel_draw_bitmap (panel_handle , 0 ,0 , LVGL_HOR_RES , LVGL_VER_RES , oled_buffer );
173116}
174117
175118static inline void lvgl_setup_panel (esp_lcd_panel_handle_t panel_handle )
0 commit comments