Skip to content

Commit a8d636d

Browse files
committed
fixes RGBBus compilation errors
1 parent 5861bbd commit a8d636d

File tree

4 files changed

+43
-53
lines changed

4 files changed

+43
-53
lines changed

ext_mod/lcd_bus/esp32_include/rgb_bus.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
bool rgb_bus_event_isset_from_isr(rgb_bus_event_t *event);
8989
void rgb_bus_event_set_from_isr(rgb_bus_event_t *event);
9090

91-
int rgb_bus_lock_acquire(thread_lock_t *lock, int32_t wait_ms);
91+
int rgb_bus_lock_acquire(rgb_bus_lock_t *lock, int32_t wait_ms);
9292
void rgb_bus_lock_release(rgb_bus_lock_t *lock);
9393
void rgb_bus_lock_init(rgb_bus_lock_t *lock);
9494
void rgb_bus_lock_delete(rgb_bus_lock_t *lock);

ext_mod/lcd_bus/esp32_src/rgb_bus.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
// stdlib includes
3030
#include <string.h>
3131

32+
#define DEFAULT_STACK_SIZE (5 * 1024)
33+
3234

3335
typedef struct {
3436
esp_lcd_panel_t base; // Base class of generic lcd panel
@@ -53,8 +55,8 @@
5355
static bool rgb_bus_trans_done_cb(esp_lcd_panel_handle_t panel, const esp_lcd_rgb_panel_event_data_t *edata, void *user_ctx)
5456
{
5557
LCD_UNUSED(edata);
56-
57-
rgb_panel_t *rgb_panel = __containerof(panel, rgb_panel_t, base);
58+
LCD_UNUSED(panel);
59+
// rgb_panel_t *rgb_panel = __containerof(panel, rgb_panel_t, base);
5860
mp_lcd_rgb_bus_obj_t *self = (mp_lcd_rgb_bus_obj_t *)user_ctx;
5961

6062
if (rgb_bus_event_isset_from_isr(&self->swap_bufs)) {
@@ -420,10 +422,9 @@
420422
self->panel_io_config.timings.v_res = (uint32_t)height;
421423
self->panel_io_config.bits_per_pixel = (size_t)bpp;
422424

423-
self->buf_to_flush.width = width;
424-
self->buf_to_flush.height = height;
425-
self->buf_to_flush.bytes_per_pixel = bpp / 8;
426-
self->buf_to_flush.buf = NULL;
425+
self->width = width;
426+
self->height = height;
427+
self->bytes_per_pixel = bpp / 8;
427428

428429
self->panel_io_config.flags.fb_in_psram = 1;
429430
self->panel_io_config.flags.double_fb = 1;
@@ -474,7 +475,7 @@
474475
rgb_bus_lock_init(&self->swap_lock);
475476

476477
xTaskCreatePinnedToCore(
477-
rgb_bus_copy_task, "rgb_task", const uint32_t ulStackDepth,
478+
rgb_bus_copy_task, "rgb_task", DEFAULT_STACK_SIZE / sizeof(StackType_t),
478479
self, ESP_TASK_PRIO_MAX - 1, &self->copy_task_handle, 0);
479480

480481
return LCD_OK;
@@ -493,7 +494,7 @@
493494
}
494495

495496

496-
mp_lcd_err_t rgb_tx_color(mp_obj_t obj, int lcd_cmd, void *color, size_t color_size, int x_start, int y_start, int x_end, int y_end, int rotation, bool last_update)
497+
mp_lcd_err_t rgb_tx_color(mp_obj_t obj, int lcd_cmd, void *color, size_t color_size, int x_start, int y_start, int x_end, int y_end, uint8_t rotation, bool last_update)
497498
{
498499
#if CONFIG_LCD_ENABLE_DEBUG_LOG
499500
printf("rgb_tx_color(self, lcd_cmd=%d, color, color_size=%d, x_start=%d, y_start=%d, x_end=%d, y_end=%d)\n", lcd_cmd, color_size, x_start, y_start, x_end, y_end);

ext_mod/lcd_bus/esp32_src/rgb_bus_rotation.c

Lines changed: 32 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@
1212
#include "freertos/event_groups.h"
1313
#include "freertos/idf_additions.h"
1414

15+
#include "esp_lcd_panel_ops.h"
16+
1517
#include "rgb_bus.h"
1618

19+
#include <string.h>
1720

18-
#define RGB_BIT_0 ( 1 << 0 )
21+
#define RGB_BIT_0 (1 << 0)
1922

2023

2124
void rgb_bus_event_init(rgb_bus_event_t *event)
@@ -61,11 +64,11 @@
6164

6265
void rgb_bus_event_set_from_isr(rgb_bus_event_t *event)
6366
{
64-
xEventGroupSetBitsFromISR(event->handle, RGB_BIT_0, pdFALSE)
67+
xEventGroupSetBitsFromISR(event->handle, RGB_BIT_0, pdFALSE);
6568
}
6669

6770

68-
int rgb_bus_lock_acquire(thread_lock_t *lock, int32_t wait_ms)
71+
int rgb_bus_lock_acquire(rgb_bus_lock_t *lock, int32_t wait_ms)
6972
{
7073
return pdTRUE == xSemaphoreTake(lock->handle, wait_ms < 0 ? portMAX_DELAY : pdMS_TO_TICKS((uint16_t)wait_ms));
7174
}
@@ -79,7 +82,7 @@
7982

8083
void rgb_bus_lock_release_from_isr(rgb_bus_lock_t *lock)
8184
{
82-
xSemaphoreGiveFromISR(lock->handle, pdFALSE)
85+
xSemaphoreGiveFromISR(lock->handle, pdFALSE);
8386
}
8487

8588

@@ -103,10 +106,9 @@
103106
typedef void (* copy_func_cb_t)(uint8_t *to, const uint8_t *from);
104107

105108
static void copy_pixels(
106-
uint8_t *to, uint8_t *from, uint16_t x_start, uint16_t y_start,
107-
uint16_t x_end, uint16_t y_end, uint16_t h_res, uint16_t v_res,
108-
uint8_t bytes_per_pixel, copy_func_cb_t func, uint8_t rotate,
109-
uint8_t bytes_per_pixel);
109+
uint8_t *to, uint8_t *from, uint32_t x_start, uint32_t y_start,
110+
uint32_t x_end, uint32_t y_end, uint32_t h_res, uint32_t v_res,
111+
uint32_t bytes_per_pixel, copy_func_cb_t func, uint8_t rotate);
110112

111113

112114
__attribute__((always_inline))
@@ -134,31 +136,24 @@
134136
mp_lcd_rgb_bus_obj_t *self = (mp_lcd_rgb_bus_obj_t *)self_in;
135137

136138
copy_func_cb_t func;
137-
uint8_t bytes_per_pixel;
138-
uint32_t copy_bytes_per_line;
139-
uint8_t *from;
140-
size_t offset;
141-
uint8_t *to;
142-
143-
switch (self->bpp) {
144-
case 8:
139+
uint8_t bytes_per_pixel = self->bytes_per_pixel;
140+
141+
switch (bytes_per_pixel) {
142+
case 1:
145143
func = copy_8bpp;
146-
bytes_per_pixel = 1;
147-
case 16:
144+
break;
145+
case 2:
148146
func = copy_16bpp;
149-
bytes_per_pixel = 2;
150-
case 24:
147+
break;
148+
case 3:
151149
func = copy_24bpp;
152-
bytes_per_pixel = 3;
150+
break;
153151
default:
154152
// raise error
155153
return;
156154
}
157155

158-
uint8_t *partial_buf;
159-
160156
rgb_bus_lock_acquire(&self->copy_lock, -1);
161-
rgb_bus_event_clear(&self->full_copy);
162157

163158
while (!rgb_bus_event_isset(&self->copy_task_exit)) {
164159
rgb_bus_lock_acquire(&self->copy_lock, -1);
@@ -167,9 +162,9 @@
167162
rgb_bus_event_clear(&self->partial_copy);
168163

169164
copy_pixels(
170-
self->idle_buf, self->partial_buf,
171-
self->start_x, self->start_y,
172-
self->end_x, self->end_y,
165+
self->idle_fb, self->partial_buf,
166+
self->x_start, self->y_start,
167+
self->x_end, self->y_end,
173168
self->width, self->height,
174169
bytes_per_pixel, func, self->rotation);
175170

@@ -178,7 +173,7 @@
178173

179174
if (rgb_bus_event_isset(&self->last_update)) {
180175
rgb_bus_event_clear(&self->last_update);
181-
uint8_t *idle_buf = self->idle_buf;
176+
uint8_t *idle_fb = self->idle_fb;
182177
rgb_bus_event_set(&self->swap_bufs);
183178

184179
esp_lcd_panel_draw_bitmap(
@@ -187,11 +182,11 @@
187182
0,
188183
self->width,
189184
self->height,
190-
idle_buf;
185+
idle_fb
191186
);
192187

193188
rgb_bus_lock_acquire(&self->swap_lock, -1);
194-
memcpy(self->idle_buf, self.->active_buf, self->width * self->height * bytes_per_pixel);
189+
memcpy(self->idle_fb, self->active_fb, self->width * self->height * bytes_per_pixel);
195190
}
196191
}
197192
}
@@ -208,7 +203,7 @@
208203
uint32_t v_res,
209204
uint32_t bytes_per_pixel,
210205
copy_func_cb_t func,
211-
uint8_t rotate,
206+
uint8_t rotate
212207
) {
213208

214209
if (rotate == RGB_BUS_ROTATION_90 || rotate == RGB_BUS_ROTATION_270) {
@@ -223,7 +218,9 @@
223218
y_end = MIN(y_end, v_res);
224219
}
225220

226-
uint16_t copy_bytes_per_line = (self->x_end - self->x_start) * (uint16_t)bytes_per_pixel;
221+
uint16_t copy_bytes_per_line = (x_end - x_start) * (uint16_t)bytes_per_pixel;
222+
int pixels_per_line = h_res;
223+
uint32_t bytes_per_line = bytes_per_pixel * pixels_per_line;
227224
size_t offset = y_start * copy_bytes_per_line + x_start * bytes_per_pixel;
228225

229226
switch (rotate) {
@@ -234,8 +231,6 @@
234231
fb += bytes_per_line;
235232
from += copy_bytes_per_line;
236233
}
237-
bytes_to_flush = (y_end - y_start) * bytes_per_line;
238-
flush_ptr = to + y_start * bytes_per_line;
239234
break;
240235

241236
case RGB_BUS_ROTATION_180:
@@ -249,8 +244,6 @@
249244
from += bytes_per_pixel;
250245
}
251246
}
252-
bytes_to_flush = (y_end - y_start) * bytes_per_line;
253-
flush_ptr = to + (v_res - y_end) * bytes_per_line;
254247
break;
255248

256249
case RGB_BUS_ROTATION_90:
@@ -264,13 +257,11 @@
264257
func(to + i, from + j);
265258
}
266259
}
267-
bytes_to_flush = (x_end - x_start) * bytes_per_line;
268-
flush_ptr = to + x_start * bytes_per_line;
269260
break;
270261

271-
case ROTATE_MASK_SWAP_XY | ROTATE_MASK_MIRROR_X | ROTATE_MASK_MIRROR_Y:
272-
uint32_t jj
273-
uint32_t ii
262+
case RGB_BUS_ROTATION_270:
263+
uint32_t jj;
264+
uint32_t ii;
274265

275266
for (int y = y_start; y < y_end; y++) {
276267
for (int x = x_start; x < x_end; x++) {
@@ -279,8 +270,6 @@
279270
func(to + ii, from + jj);
280271
}
281272
}
282-
bytes_to_flush = (x_end - x_start) * bytes_per_line;
283-
flush_ptr = to + (v_res - x_end) * bytes_per_line;
284273
break;
285274

286275
default:

ext_mod/lcd_bus/modlcd_bus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ mp_obj_t mp_lcd_bus_tx_color(size_t n_args, const mp_obj_t *pos_args, mp_map_t *
179179
(int)args[ARG_y_start].u_int,
180180
(int)args[ARG_x_end].u_int,
181181
(int)args[ARG_y_end].u_int,
182-
(uint8_t)args[ARG_rotation].u_int
182+
(uint8_t)args[ARG_rotation].u_int,
183183
(bool)args[ARG_last_update].u_bool
184184
);
185185

0 commit comments

Comments
 (0)