|
9 | 9 |
|
10 | 10 | // esp-idf includes |
11 | 11 | #include "hal/lcd_hal.h" |
12 | | - #include "esp_lcd_common.h" |
13 | 12 | #include "esp_pm.h" |
| 13 | + #include "esp_intr_alloc.h" |
| 14 | + #include "esp_heap_caps.h" |
14 | 15 |
|
15 | 16 | #include "esp_lcd_panel_io.h" |
16 | 17 | #include "esp_lcd_panel_ops.h" |
|
28 | 29 | #include <string.h> |
29 | 30 |
|
30 | 31 |
|
31 | | - struct rgb_panel_t { |
| 32 | + typedef struct { |
32 | 33 | esp_lcd_panel_t base; // Base class of generic lcd panel |
33 | 34 | int panel_id; // LCD panel ID |
34 | 35 | lcd_hal_context_t hal; // Hal layer object |
|
43 | 44 | esp_pm_lock_handle_t pm_lock; // Power management lock |
44 | 45 | size_t num_dma_nodes; // Number of DMA descriptors that used to carry the frame buffer |
45 | 46 | uint8_t *fbs[3]; // Frame buffers |
46 | | - }; |
| 47 | + } rgb_panel_t; |
47 | 48 |
|
48 | 49 | bool rgb_bus_trans_done_cb(esp_lcd_panel_handle_t panel_io, const esp_lcd_rgb_panel_event_data_t *edata, void *user_ctx) |
49 | 50 | { |
|
252 | 253 | mp_lcd_rgb_bus_obj_t *self = (mp_lcd_rgb_bus_obj_t *)obj; |
253 | 254 |
|
254 | 255 | if (self->panel_handle != NULL) { |
255 | | - mp_raise_msg( |
256 | | - &mp_type_ValueError, |
257 | | - MP_ERROR_TEXT("Frame buffers can not be freed once the display has been initilized"), |
258 | | - ); |
| 256 | + mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("Unable to free buffer")); |
259 | 257 | return mp_const_none; |
260 | 258 | } |
261 | 259 |
|
262 | 260 | mp_obj_array_t *array_buf = (mp_obj_array_t *)MP_OBJ_TO_PTR(buf); |
263 | | - void *buf = array_buf->items; |
| 261 | + void *item_buf = array_buf->items; |
264 | 262 |
|
265 | 263 | if (array_buf == self->view1) { |
266 | | - heap_caps_free(buf); |
| 264 | + heap_caps_free(item_buf); |
267 | 265 | self->view1 = NULL; |
268 | 266 | } else if (array_buf == self->view2) { |
269 | | - heap_caps_free(buf); |
| 267 | + heap_caps_free(item_buf); |
270 | 268 | self->view2 = NULL; |
271 | 269 | } else { |
272 | 270 | mp_raise_msg(&mp_type_MemoryError, MP_ERROR_TEXT("No matching buffer found")); |
273 | 271 | } |
274 | 272 | return mp_const_none; |
275 | 273 | } |
276 | | - |
| 274 | + |
277 | 275 | mp_obj_t rgb_allocate_framebuffer(mp_obj_t obj, uint32_t size, uint32_t caps) |
278 | 276 | { |
279 | 277 | mp_lcd_rgb_bus_obj_t *self = (mp_lcd_rgb_bus_obj_t *)obj; |
|
305 | 303 | self->view2 = view; |
306 | 304 | return MP_OBJ_FROM_PTR(view); |
307 | 305 | } else { |
308 | | - mp_raise_msg( |
309 | | - &mp_type_ValueError, |
310 | | - MP_ERROR_TEXT("There is a maximum of 2 frame buffers allowed"), |
311 | | - ); |
| 306 | + mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("There is a maximum of 2 frame buffers allowed")); |
312 | 307 | return mp_const_none; |
313 | 308 | } |
314 | 309 | } |
|
353 | 348 | return ret; |
354 | 349 | } |
355 | 350 |
|
356 | | - rgb_panel_t *rgb_panel = __containerof(self->panel_handle, rgb_panel_t, base); |
| 351 | + rgb_panel_t *rgb_panel = __containerof((esp_lcd_panel_t *)self->panel_handle, rgb_panel_t, base); |
357 | 352 |
|
358 | 353 | void *buf1 = self->view1->items; |
359 | 354 | self->view1->items = (void *)rgb_panel->fbs[0]; |
|
0 commit comments