Skip to content

Commit 188ce42

Browse files
committed
feat(ports): flash scripts into vfs
1 parent b6f8df9 commit 188ce42

File tree

6 files changed

+48
-39
lines changed

6 files changed

+48
-39
lines changed

ports/esp32/boards/ESP32_S3_BOX_3/mpconfigboard.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@
1010
#define MICROPY_HW_I2C0_SCL (9)
1111
#define MICROPY_HW_I2C0_SDA (8)
1212

13-
#define MICROPY_LV_USE_LOG (1)
13+
#define MICROPY_LV_USE_LOG (0)
14+
#define MICROPY_TASK_STACK_SIZE (50 * 1024)

ports/esp32/boards/ESP32_S3_BOX_3/sdkconfig.board

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y
99
CONFIG_SPIRAM_RODATA=y
1010
CONFIG_SPIRAM_SPEED_80M=y
1111
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
12-
CONFIG_ESP_CONSOLE_UART_CUSTOM=y
13-
CONFIG_ESP_CONSOLE_UART_BAUDRATE=2000000
1412
CONFIG_FREERTOS_HZ=1000
1513
CONFIG_ESP_BROOKESIA_MEMORY_USE_CUSTOM=y
1614
CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y
15+
CONFIG_FATFS_LFN_HEAP=y

ports/esp32/main_esp32s3_box3/esp32_common.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ idf_component_register(
170170
${IDF_COMPONENTS}
171171
)
172172

173+
fatfs_create_rawflash_image(vfs ./scripts FLASH_IN_PROJECT)
174+
173175
# Set the MicroPython target as the current (main) IDF component target.
174176
set(MICROPY_TARGET ${COMPONENT_TARGET})
175177

ports/esp32/main_esp32s3_box3/lvgl_port.c

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
#include "lvgl/lvgl.h"
1212
#include "lvgl_port.h"
1313

14-
#define LVGL_DRAW_BUF_LINES 20 // number of display lines in each draw buffer
14+
#define LVGL_DRAW_BUF_LINES 50 // number of display lines in each draw buffer
1515
#define LVGL_TICK_PERIOD_MS 2
1616
#define LVGL_TASK_MAX_DELAY_MS 500
1717
#define LVGL_TASK_MIN_DELAY_MS 1
1818
#define LVGL_TASK_STACK_SIZE (6 * 1024)
19-
#define LVGL_TASK_PRIORITY 2
19+
#define LVGL_TASK_PRIORITY (4)
2020

2121
static _lock_t lvgl_api_lock;
2222
static const char *TAG = "lvgl_port";
@@ -29,38 +29,38 @@ bool lvgl_port_notify_lvgl_flush_ready(esp_lcd_panel_io_handle_t panel_io, esp_l
2929
}
3030

3131
/* Rotate display and touch, when rotated screen in LVGL. Called when driver parameters are updated. */
32-
static void lvgl_port_update_callback(lv_display_t *disp)
33-
{
34-
esp_lcd_panel_handle_t panel_handle = lv_display_get_user_data(disp);
35-
lv_display_rotation_t rotation = lv_display_get_rotation(disp);
36-
37-
switch (rotation) {
38-
case LV_DISPLAY_ROTATION_0:
39-
// Rotate LCD display
40-
esp_lcd_panel_swap_xy(panel_handle, false);
41-
esp_lcd_panel_mirror(panel_handle, true, false);
42-
break;
43-
case LV_DISPLAY_ROTATION_90:
44-
// Rotate LCD display
45-
esp_lcd_panel_swap_xy(panel_handle, true);
46-
esp_lcd_panel_mirror(panel_handle, true, true);
47-
break;
48-
case LV_DISPLAY_ROTATION_180:
49-
// Rotate LCD display
50-
esp_lcd_panel_swap_xy(panel_handle, false);
51-
esp_lcd_panel_mirror(panel_handle, false, true);
52-
break;
53-
case LV_DISPLAY_ROTATION_270:
54-
// Rotate LCD display
55-
esp_lcd_panel_swap_xy(panel_handle, true);
56-
esp_lcd_panel_mirror(panel_handle, false, false);
57-
break;
58-
}
59-
}
32+
// static void lvgl_port_update_callback(lv_display_t *disp)
33+
// {
34+
// esp_lcd_panel_handle_t panel_handle = lv_display_get_user_data(disp);
35+
// lv_display_rotation_t rotation = lv_display_get_rotation(disp);
36+
37+
// switch (rotation) {
38+
// case LV_DISPLAY_ROTATION_0:
39+
// // Rotate LCD display
40+
// esp_lcd_panel_swap_xy(panel_handle, false);
41+
// esp_lcd_panel_mirror(panel_handle, true, false);
42+
// break;
43+
// case LV_DISPLAY_ROTATION_90:
44+
// // Rotate LCD display
45+
// esp_lcd_panel_swap_xy(panel_handle, true);
46+
// esp_lcd_panel_mirror(panel_handle, true, true);
47+
// break;
48+
// case LV_DISPLAY_ROTATION_180:
49+
// // Rotate LCD display
50+
// esp_lcd_panel_swap_xy(panel_handle, false);
51+
// esp_lcd_panel_mirror(panel_handle, false, true);
52+
// break;
53+
// case LV_DISPLAY_ROTATION_270:
54+
// // Rotate LCD display
55+
// esp_lcd_panel_swap_xy(panel_handle, true);
56+
// esp_lcd_panel_mirror(panel_handle, false, false);
57+
// break;
58+
// }
59+
// }
6060

6161
static void lvgl_flush_cb(lv_display_t *disp, const lv_area_t *area, uint8_t *px_map)
6262
{
63-
lvgl_port_update_callback(disp);
63+
// lvgl_port_update_callback(disp);
6464
esp_lcd_panel_handle_t panel_handle = lv_display_get_user_data(disp);
6565
int offsetx1 = area->x1;
6666
int offsetx2 = area->x2;
@@ -72,6 +72,12 @@ static void lvgl_flush_cb(lv_display_t *disp, const lv_area_t *area, uint8_t *px
7272
esp_lcd_panel_draw_bitmap(panel_handle, offsetx1, offsety1, offsetx2 + 1, offsety2 + 1, px_map);
7373
}
7474

75+
static void lvgl_flush_wait_cb(lv_display_t * disp)
76+
{
77+
// wait for the flush to be ready
78+
vTaskDelay(pdMS_TO_TICKS(LVGL_TASK_MIN_DELAY_MS));
79+
}
80+
7581
static void lvgl_touch_cb(lv_indev_t * indev, lv_indev_data_t * data)
7682
{
7783
uint16_t touchpad_x[1] = {0};
@@ -108,13 +114,13 @@ static MP_DEFINE_CONST_FUN_OBJ_1(mp_lv_task_handler_obj, mp_lv_task_handler);
108114
static void lvgl_port_task(void *arg)
109115
{
110116
printf("Starting LVGL task\n");
111-
uint32_t time_till_next_ms = 5;
117+
uint32_t time_till_next_ms = 10;
112118
// uint32_t time_threshold_ms = 1000 / CONFIG_FREERTOS_HZ;
113119
while (1) {
114120
mp_sched_schedule((mp_obj_t)&mp_lv_task_handler_obj, mp_const_none);
115121
// in case of triggering a task watch dog time out
116122
// time_till_next_ms = MAX(time_till_next_ms, time_threshold_ms);
117-
usleep(1000 * time_till_next_ms);
123+
vTaskDelay(pdMS_TO_TICKS(time_till_next_ms));
118124
}
119125
}
120126

@@ -142,6 +148,7 @@ lv_display_t *lvgl_port_init(int h_res, int v_res, esp_lcd_panel_handle_t panel_
142148
lv_display_set_color_format(display, LV_COLOR_FORMAT_RGB565);
143149
// set the callback which can copy the rendered image to an area of the display
144150
lv_display_set_flush_cb(display, lvgl_flush_cb);
151+
lv_display_set_flush_wait_cb(display, lvgl_flush_wait_cb);
145152

146153
printf("Install LVGL tick timer\n");
147154
// Tick interface for LVGL (using esp_timer to generate 2ms periodic event)

ports/esp32/main_esp32s3_box3/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
#include "lvgl_port.h"
7575

7676
// MicroPython runs as a task under FreeRTOS
77-
#define MP_TASK_PRIORITY (ESP_TASK_PRIO_MIN + 1)
77+
#define MP_TASK_PRIORITY (ESP_TASK_PRIO_MIN + 5)
7878

7979
// Set the margin for detecting stack overflow, depending on the CPU architecture.
8080
#if CONFIG_IDF_TARGET_ESP32C3
@@ -145,8 +145,6 @@ void mp_task(void *pvParameter) {
145145
machine_i2s_init0();
146146
#endif
147147

148-
init_lvgl_port();
149-
150148
// run boot-up scripts
151149
pyexec_frozen_module("_boot.py", false);
152150
int ret = pyexec_file_if_exists("boot.py");
@@ -160,6 +158,8 @@ void mp_task(void *pvParameter) {
160158
}
161159
}
162160

161+
init_lvgl_port();
162+
163163
for (;;) {
164164
if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) {
165165
vprintf_like_t vprintf_log = esp_log_set_vprintf(vprintf_null);
Binary file not shown.

0 commit comments

Comments
 (0)