Skip to content

Commit 05ed86a

Browse files
committed
Gets unix/macos port to compile and fixes compilation for ESP32
1 parent 98f65e4 commit 05ed86a

File tree

19 files changed

+113
-81
lines changed

19 files changed

+113
-81
lines changed

ext_mod/lcd_bus/common_include/lcd_bus_task.h

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,25 @@
33
#ifndef __LCD_BUS_TASK_H__
44
#define __LCD_BUS_TASK_H__
55

6-
typedef struct _lcd_bus_lock_t {
6+
struct _lcd_bus_lock_t {
77
void *handle;
88
void *buffer;
9-
} lcd_bus_lock_t;
9+
};
1010

11-
typedef struct _lcd_bus_event_t {
11+
struct _lcd_bus_event_t {
1212
void *handle;
1313
void *buffer;
14-
} lcd_bus_event_t;
15-
16-
void lcd_bus_event_init(lcd_bus_event_t *event);
17-
14+
};
1815

1916
#define lcd_bus_event_wait(event)
2017
#define lcd_bus_event_set(event)
2118
#define lcd_bus_event_clear(event)
2219
#define lcd_bus_event_clear_from_isr(event)
2320
#define lcd_bus_event_set_from_isr(event)
2421

25-
void lcd_bus_event_delete(lcd_bus_event_t *event);
26-
bool lcd_bus_event_isset(lcd_bus_event_t *event);
27-
bool lcd_bus_event_isset_from_isr(lcd_bus_event_t *event);
28-
29-
3022
#define lcd_bus_lock_acquire(lock)
3123
#define lcd_bus_lock_release(lock)
3224
#define lcd_bus_lock_release_from_isr(lock)
3325
#define lcd_bus_lock_delete(lock)
3426

35-
void lcd_bus_lock_init(lcd_bus_lock_t *lock);
36-
37-
void lcd_bus_task(void *self_in);
38-
3927
#endif

ext_mod/lcd_bus/common_src/allocate_buffers.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1+
#include <stdint.h>
2+
#include <inttypes.h>
3+
14
#include "allocate_buffers.h"
5+
#include "py/obj.h"
6+
#include "py/runtime.h"
7+
#include "py/misc.h"
8+
29

310
int allocate_buffers(uint8_t num_buffs, size_t buf_size, uint8_t *buf1, uint8_t *buf2)
411
{
@@ -8,7 +15,7 @@ int allocate_buffers(uint8_t num_buffs, size_t buf_size, uint8_t *buf1, uint8_t
815
} else if (num_buffs == 2) {
916
buf2 = m_malloc(buf_size);
1017
if (buf2 == NULL) {
11-
m_free(buf1)
18+
m_free(buf1);
1219
buf1 = NULL;
1320
return -1;
1421
} else {

ext_mod/lcd_bus/common_src/bus_trans_done.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
#include <stdbool.h>
2+
#include "bus_trans_done.h"
3+
#include "lcd_types.h"
14

5+
#include "py/obj.h"
6+
#include "py/runtime.h"
27

38

49
bool bus_trans_done_cb(void *user_ctx)

ext_mod/lcd_bus/common_src/lcd_bus_task.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include "lcd_bus_task.h"
44
#include "lcd_types.h"
55

6-
76
void lcd_bus_event_init(lcd_bus_event_t *event) { }
87

98
void lcd_bus_event_delete(lcd_bus_event_t *event) { }
@@ -18,6 +17,10 @@ bool lcd_bus_event_isset_from_isr(lcd_bus_event_t *event) { return false; }
1817
void lcd_bus_lock_init(lcd_bus_lock_t *lock) { }
1918

2019

20+
void lcd_bus_task(void *self_in) { }
21+
22+
23+
2124
static void rgb565_byte_swap(void *buf, size_t buf_size_px)
2225
{
2326
uint16_t *buf16 = (uint16_t *)buf;
@@ -27,6 +30,3 @@ static void rgb565_byte_swap(void *buf, size_t buf_size_px)
2730
}
2831
}
2932

30-
31-
void lcd_bus_task(void *self_in) { }
32-

ext_mod/lcd_bus/common_src/led_bus.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright (c) 2024 - 2025 Kevin G. Schlosser
2+
3+
// local includes
4+
#include "lcd_types.h"
5+
#include "modlcd_bus.h"
6+
#include "led_bus.h"
7+
8+
// micropython includes
9+
#include "py/obj.h"
10+
#include "py/runtime.h"
11+
12+
// stdlib includes
13+
#include <string.h>
14+
15+
16+
mp_obj_t mp_lcd_led_bus_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args)
17+
{
18+
LCD_UNUSED(type);
19+
LCD_UNUSED(n_args);
20+
LCD_UNUSED(n_kw);
21+
LCD_UNUSED(all_args);
22+
23+
mp_raise_msg(&mp_type_NotImplementedError, MP_ERROR_TEXT("LED display bus is not supported"));
24+
return mp_const_none;
25+
}
26+
27+
28+
MP_DEFINE_CONST_OBJ_TYPE(
29+
mp_lcd_led_bus_type,
30+
MP_QSTR_LEDBus,
31+
MP_TYPE_FLAG_NONE,
32+
make_new, mp_lcd_led_bus_make_new,
33+
locals_dict, (mp_obj_dict_t *)&mp_lcd_bus_locals_dict
34+
);

ext_mod/lcd_bus/common_src/spi_bus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ static MP_DEFINE_CONST_DICT(mp_lcd_spi_bus_locals_dict, mp_lcd_spi_bus_locals_di
360360
*/
361361
MP_DEFINE_CONST_OBJ_TYPE(
362362
mp_lcd_spi_bus_type,
363-
MP_QSTR_SPI_Bus,
363+
MP_QSTR_SPIBus,
364364
MP_TYPE_FLAG_NONE,
365365
make_new, mp_lcd_spi_bus_make_new,
366366
locals_dict, (mp_obj_dict_t *)&mp_lcd_bus_locals_dict

ext_mod/lcd_bus/esp32_include/lcd_bus_task.h

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,25 @@
88
#ifndef __LCD_BUS_TASK_H__
99
#define __LCD_BUS_TASK_H__
1010

11-
typedef struct _lcd_bus_lock_t {
11+
struct _lcd_bus_lock_t {
1212
SemaphoreHandle_t handle;
1313
StaticSemaphore_t buffer;
14-
} lcd_bus_lock_t;
14+
};
1515

16-
typedef struct _lcd_bus_event_t {
16+
struct _lcd_bus_event_t {
1717
EventGroupHandle_t handle;
1818
StaticEventGroup_t buffer;
19-
} lcd_bus_event_t;
20-
21-
void lcd_bus_event_init(lcd_bus_event_t *event);
22-
19+
};
2320

2421
#define lcd_bus_event_wait(event) xEventGroupWaitBits(event.handle, (1 << 0), pdFALSE, pdTRUE, portMAX_DELAY)
2522
#define lcd_bus_event_set(event) xEventGroupSetBits(event.handle, (1 << 0))
2623
#define lcd_bus_event_clear(event) xEventGroupClearBits(event.handle, (1 << 0))
2724
#define lcd_bus_event_clear_from_isr(event) xEventGroupClearBitsFromISR(event.handle, (1 << 0))
2825
#define lcd_bus_event_set_from_isr(event) xEventGroupSetBitsFromISR(event.handle, (1 << 0), pdFALSE)
2926

30-
void lcd_bus_event_delete(lcd_bus_event_t *event);
31-
bool lcd_bus_event_isset(lcd_bus_event_t *event);
32-
bool lcd_bus_event_isset_from_isr(lcd_bus_event_t *event);
33-
34-
3527
#define lcd_bus_lock_acquire(lock) xSemaphoreTake(lock.handle, portMAX_DELAY)
3628
#define lcd_bus_lock_release(lock) xSemaphoreGive(lock.handle)
3729
#define lcd_bus_lock_release_from_isr(lock) xSemaphoreGiveFromISR(lock.handle, pdFALSE)
3830
#define lcd_bus_lock_delete(lock) vSemaphoreDelete(lock.handle)
3931

40-
void lcd_bus_lock_init(lcd_bus_lock_t *lock);
41-
42-
void lcd_bus_task(void *self_in);
43-
4432
#endif

ext_mod/lcd_bus/esp32_src/dsi_bus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@
289289

290290
xTaskCreatePinnedToCore(
291291
lcd_bus_task, "dsi_task", LCD_DEFAULT_STACK_SIZE / sizeof(StackType_t),
292-
self, ESP_TASK_PRIO_MAX - 1, &self->task.handle, 0);
292+
self, ESP_TASK_PRIO_MAX - 1, (TaskHandle_t *)&self->task.handle, 0);
293293

294294
lcd_bus_lock_acquire(self->init.lock);
295295
lcd_bus_lock_release(self->init.lock);

ext_mod/lcd_bus/esp32_src/i2c_bus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ mp_lcd_err_t i2c_init(mp_lcd_bus_obj_t *self_in, uint16_t width, uint16_t height
189189

190190
xTaskCreatePinnedToCore(
191191
lcd_bus_task, "i2c_task", LCD_DEFAULT_STACK_SIZE / sizeof(StackType_t),
192-
self, ESP_TASK_PRIO_MAX - 1, &self->task.handle, 0);
192+
self, ESP_TASK_PRIO_MAX - 1, (TaskHandle_t *)&self->task.handle, 0);
193193

194194
lcd_bus_lock_acquire(self->init.lock);
195195
lcd_bus_lock_release(self->init.lock);

ext_mod/lcd_bus/esp32_src/i80_bus.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
}
132132

133133
for (; i < tuple->len; i++) {
134-
self->bus_config.data_gpio_nums[i] = (int)mp_obj_get_int(tuple->items[i])
134+
self->bus_config.data_gpio_nums[i] = (int)mp_obj_get_int(tuple->items[i]);
135135
}
136136

137137
for (i++; i < SOC_LCD_I80_BUS_WIDTH; i++) {
@@ -228,7 +228,7 @@
228228

229229
xTaskCreatePinnedToCore(
230230
lcd_bus_task, "i80_task", LCD_DEFAULT_STACK_SIZE / sizeof(StackType_t),
231-
self, ESP_TASK_PRIO_MAX - 1, &self->task.handle, 0);
231+
self, ESP_TASK_PRIO_MAX - 1, (TaskHandle_t *)&self->task.handle, 0);
232232

233233
lcd_bus_lock_acquire(self->init.lock);
234234
lcd_bus_lock_release(self->init.lock);

ext_mod/lcd_bus/esp32_src/led_bus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ mp_lcd_err_t led_init(mp_lcd_bus_obj_t *self_in, uint16_t width, uint16_t height
424424

425425
xTaskCreatePinnedToCore(
426426
lcd_bus_task, "led_task", LCD_DEFAULT_STACK_SIZE / sizeof(StackType_t),
427-
self, ESP_TASK_PRIO_MAX - 1, &self->task.handle, 0);
427+
self, ESP_TASK_PRIO_MAX - 1, (TaskHandle_t *)&self->task.handle, 0);
428428

429429
lcd_bus_lock_acquire(self->init.lock);
430430
lcd_bus_lock_release(self->init.lock);

ext_mod/lcd_bus/esp32_src/rgb_bus.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,10 @@
210210
}
211211

212212
for (; i < tuple->len; i++) {
213-
self->panel_io_config.data_gpio_nums[i] = (int)mp_obj_get_int(tuple->items[i])
213+
self->panel_io_config.data_gpio_nums[i] = (int)mp_obj_get_int(tuple->items[i]);
214214
}
215215

216-
for (i++; i < SOC_LCD_I80_BUS_WIDTH; i++) {
216+
for (i++; i < 16; i++) {
217217
self->panel_io_config.data_gpio_nums[i] = -1;
218218
}
219219

@@ -352,7 +352,7 @@
352352

353353
xTaskCreatePinnedToCore(
354354
lcd_bus_task, "rgb_task", LCD_DEFAULT_STACK_SIZE / sizeof(StackType_t),
355-
self, ESP_TASK_PRIO_MAX - 1, &self->task.handle, 0);
355+
self, ESP_TASK_PRIO_MAX - 1, (TaskHandle_t *)&self->task.handle, 0);
356356

357357
lcd_bus_lock_acquire(self->init.lock);
358358
lcd_bus_lock_release(self->init.lock);

ext_mod/lcd_bus/esp32_src/spi_bus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ mp_lcd_err_t spi_init(mp_lcd_bus_obj_t *self_in, uint16_t width, uint16_t height
258258

259259
xTaskCreatePinnedToCore(
260260
lcd_bus_task, "spi_task", LCD_DEFAULT_STACK_SIZE / sizeof(StackType_t),
261-
self, ESP_TASK_PRIO_MAX - 1, &self->task.handle, 0);
261+
self, ESP_TASK_PRIO_MAX - 1, (TaskHandle_t *)&self->task.handle, 0);
262262

263263
lcd_bus_lock_acquire(self->init.lock);
264264
lcd_bus_lock_release(self->init.lock);

ext_mod/lcd_bus/lcd_types.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@
5454
} mp_lcd_err_t;
5555
#endif
5656

57+
typedef struct _lcd_bus_lock_t lcd_bus_lock_t;
58+
typedef struct _lcd_bus_event_t lcd_bus_event_t;
59+
typedef void * lcd_bus_task_handle_t;
60+
5761
typedef struct _mp_lcd_bus_obj_t mp_lcd_bus_obj_t;
5862

5963
typedef void (*flush_func_t)(mp_lcd_bus_obj_t *self_in, rotation_data_t *r_data, rotation_data_t *original_r_data, uint8_t *idle_fb, uint8_t last_update);
@@ -76,7 +80,7 @@
7680

7781

7882
typedef struct _lcd_task_t {
79-
TaskHandle_t handle;
83+
lcd_bus_task_handle_t handle;
8084
lcd_bus_event_t exit;
8185
lcd_bus_lock_t lock;
8286
} lcd_task_t;
@@ -141,4 +145,11 @@
141145
internal_cb_funcs_t internal_cb_funcs;
142146
};
143147

148+
void lcd_bus_event_init(lcd_bus_event_t *event);
149+
void lcd_bus_event_delete(lcd_bus_event_t *event);
150+
bool lcd_bus_event_isset(lcd_bus_event_t *event);
151+
bool lcd_bus_event_isset_from_isr(lcd_bus_event_t *event);
152+
void lcd_bus_lock_init(lcd_bus_lock_t *lock);
153+
void lcd_bus_task(void *self_in);
154+
144155
#endif /* _LCD_TYPES_H_ */

ext_mod/lcd_bus/micropython.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ LVGL_BINDING_DIR = $(subst /ext_mod/lcd_bus,,$(MOD_DIR))
99
CFLAGS_USERMOD += -I$(MOD_DIR)
1010
CFLAGS_USERMOD += -I$(MOD_DIR)/common_include
1111
CFLAGS_USERMOD += -I$(MOD_DIR)/sdl_bus
12+
CFLAGS_USERMOD += -I$(MOD_DIR)/rotation/include
1213

1314
ifneq (,$(findstring -Wno-missing-field-initializers, $(CFLAGS_USERMOD)))
1415
CFLAGS_USERMOD += -Wno-missing-field-initializers
@@ -24,6 +25,8 @@ SRC_USERMOD_C += $(MOD_DIR)/common_src/led_bus.c
2425
SRC_USERMOD_C += $(MOD_DIR)/common_src/lcd_bus_task.c
2526
SRC_USERMOD_C += $(MOD_DIR)/common_src/allocate_buffers.c
2627
SRC_USERMOD_C += $(MOD_DIR)/common_src/bus_trans_done.c
28+
SRC_USERMOD_C += $(MOD_DIR)/rotation/src/rotation.c
29+
SRC_USERMOD_C += $(MOD_DIR)/rotation/src/dither.c
2730
SRC_USERMOD_C += $(MOD_DIR)/sdl_bus/sdl_bus.c
2831

2932
ifneq (,$(findstring unix, $(LV_PORT)))

ext_mod/lcd_bus/modlcd_bus.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,6 @@ static mp_obj_t mp_lcd_bus_deinit(mp_obj_t self_in)
350350

351351
if (self->view1 != NULL) {
352352
free_framebuffer(self->view1->items);
353-
heap_caps_free(self->view1->items);
354353
self->view1->items = NULL;
355354
self->view1->len = 0;
356355
self->view1 = NULL;

ext_mod/lcd_bus/rotation/src/dither.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
#include "dither.h"
88

9+
#include "py/obj.h"
10+
#include "py/runtime.h"
11+
#include "py/misc.h"
12+
913

1014
uint8_t* red_thresh = NULL;
1115
uint8_t* green_thresh = NULL;
@@ -14,9 +18,9 @@ uint8_t* blue_thresh = NULL;
1418

1519
void dither_deinit(void)
1620
{
17-
if (red_thresh != NULL) free(red_thresh);
18-
if (green_thresh != NULL) free(green_thresh);
19-
if (blue_thresh != NULL) free(blue_thresh);
21+
if (red_thresh != NULL) m_free(red_thresh);
22+
if (green_thresh != NULL) m_free(green_thresh);
23+
if (blue_thresh != NULL) m_free(blue_thresh);
2024

2125
red_thresh = NULL;
2226
green_thresh = NULL;
@@ -28,7 +32,7 @@ void dither_deinit(void)
2832
bool dither_init(void)
2933
{
3034
if (red_thresh == NULL) {
31-
red_thresh = (uint8_t *)malloc(64);
35+
red_thresh = (uint8_t *)m_malloc(64);
3236
if (red_thresh != NULL) {
3337
memcpy(red_thresh,
3438
(uint8_t []){
@@ -45,7 +49,7 @@ bool dither_init(void)
4549
}
4650

4751
if (green_thresh == NULL) {
48-
green_thresh = (uint8_t *)malloc(64);
52+
green_thresh = (uint8_t *)m_malloc(64);
4953
if (green_thresh != NULL) {
5054
memcpy(green_thresh,
5155
(uint8_t []){
@@ -61,7 +65,7 @@ bool dither_init(void)
6165
}
6266
}
6367
if (blue_thresh == NULL) {
64-
blue_thresh = (uint8_t *)malloc(64);
68+
blue_thresh = (uint8_t *)m_malloc(64);
6569
if (blue_thresh != NULL) {
6670
memcpy(blue_thresh,
6771
(uint8_t []){

0 commit comments

Comments
 (0)