Skip to content

Commit 9c4b2ec

Browse files
committed
working version of bootloader for M5Stack
1 parent 068b769 commit 9c4b2ec

File tree

5 files changed

+83
-115
lines changed

5 files changed

+83
-115
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,9 @@ modules.order
5050
Module.symvers
5151
Mkfile.old
5252
dkms.conf
53+
54+
# ESP-IDF
55+
build/
56+
managed_components/
57+
dependencies.lock
58+

main/bootloader_ui.c

Lines changed: 9 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ typedef struct {
88
int count_val;
99
} my_timer_context_t;
1010

11-
static lv_obj_t *img_text;
12-
static lv_obj_t *label_value; // Label to display the value
1311

1412
static void ota_button_event_handler(lv_event_t *e) {
1513
lv_obj_t *btn = lv_event_get_target(e);
@@ -37,14 +35,20 @@ static void ota_button_event_handler(lv_event_t *e) {
3735
}
3836
}
3937

40-
4138
static void add_number_buttons(lv_obj_t *scr, lv_obj_t *ref_obj) {
4239
int button_width = 50;
4340
int button_height = 60;
4441

4542
lv_obj_t *flex_cont = lv_obj_create(scr);
4643
lv_obj_set_size(flex_cont, 5 * button_width + 4 * 10, button_height);
47-
lv_obj_align_to(flex_cont, ref_obj, LV_ALIGN_OUT_TOP_MID, 0, -10);
44+
45+
// Check if ref_obj is provided, if not, align to the screen
46+
if (ref_obj) {
47+
lv_obj_align_to(flex_cont, ref_obj, LV_ALIGN_OUT_TOP_MID, 0, -10);
48+
} else {
49+
lv_obj_align(flex_cont, LV_ALIGN_CENTER, 0, 0); // Center the container on the screen
50+
}
51+
4852
lv_obj_set_flex_flow(flex_cont, LV_FLEX_FLOW_ROW);
4953
lv_obj_set_flex_align(flex_cont, LV_FLEX_ALIGN_SPACE_BETWEEN, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
5054
lv_obj_set_scrollbar_mode(flex_cont, LV_SCROLLBAR_MODE_OFF);
@@ -71,60 +75,8 @@ static void add_number_buttons(lv_obj_t *scr, lv_obj_t *ref_obj) {
7175
}
7276
}
7377

74-
static void add_icon_buttons(lv_obj_t *scr, lv_obj_t *ref_obj) {
75-
int button_width = 60; // Button width
76-
int button_height = 60; // Button height
77-
78-
// Create a flex container for the icon buttons
79-
lv_obj_t *icon_flex_cont = lv_obj_create(scr);
80-
lv_obj_set_size(icon_flex_cont, 4 * button_width + 3 * 10, button_height);
81-
lv_obj_align_to(icon_flex_cont, ref_obj, LV_ALIGN_OUT_TOP_MID, 0, -button_height - 20);
82-
lv_obj_set_flex_flow(icon_flex_cont, LV_FLEX_FLOW_ROW);
83-
lv_obj_set_flex_align(icon_flex_cont, LV_FLEX_ALIGN_SPACE_BETWEEN, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
84-
lv_obj_set_scrollbar_mode(icon_flex_cont, LV_SCROLLBAR_MODE_OFF);
85-
86-
// Array of raw images for icons
87-
const lv_img_dsc_t *icons[] = {&cloud_raw, &sun_raw, &snowflake_raw, &wind_raw};
88-
89-
// Create and position the buttons within the icon flex container
90-
for (int i = 0; i < 4; i++) {
91-
lv_obj_t *btn = lv_btn_create(icon_flex_cont);
92-
lv_obj_set_size(btn, button_width, button_height);
93-
94-
// Create an image for the button with the icon
95-
lv_obj_t *img = lv_img_create(btn);
96-
lv_img_set_src(img, icons[i]);
97-
lv_obj_center(img); // Center the image within the button
98-
}
99-
}
100-
10178

10279
void bootloader_ui(lv_obj_t *scr) {
103-
// Create new image and make it transparent
104-
img_text = lv_img_create(scr);
105-
lv_img_set_src(img_text, &esp_text);
106-
lv_obj_set_style_img_opa(img_text, 0, 0);
107-
108-
// Create a label for displaying the slider value
109-
label_value = lv_label_create(scr);
110-
lv_label_set_text(label_value, "0°C"); // Initialize with a default value
111-
112-
// Create a slider
113-
slider = lv_slider_create(scr);
114-
lv_obj_set_width(slider, 200); // Set the slider's width
115-
116-
// Position the slider at the bottom of the screen
117-
lv_obj_align(slider, LV_ALIGN_BOTTOM_MID, 0, -10); // -10 pixels from the bottom for some padding
118-
119-
// Position the label above the slider
120-
lv_obj_align_to(label_value, slider, LV_ALIGN_OUT_TOP_MID, 0, -10); // Align above slider with some padding
121-
122-
// Set the slider's range
123-
lv_slider_set_range(slider, -20, 40);
124-
125-
// Add event callback to the slider
126-
lv_obj_add_event_cb(slider, slider_event_handler, LV_EVENT_VALUE_CHANGED, NULL);
12780

128-
add_number_buttons(scr, label_value);
129-
add_icon_buttons(scr, label_value);
81+
add_number_buttons(scr, NULL);
13082
}

main/idf_component.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
description: BSP Display example
1+
description: ESP32 Graphical Bootloader
22

33
dependencies:
44
m5stack_core_s3:
55
version: "^1.0.0"
6-
override_path: "../../../bsp/m5stack_core_s3"

partitions.csv

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Name, Type, Subtype, Offset, Size, Flags
2+
nvs, data, nvs, 0x9000, 24K,
3+
otadata, data, ota, , 8K,
4+
phy_init, data, phy, , 4K,
5+
factory, app, factory, , 2M,
6+
ota_0, app, ota_0, , 2816K,
7+
ota_1, app, ota_1, , 2816K,
8+
ota_2, app, ota_2, , 2816K,
9+
ota_3, app, ota_3, , 2816K,
10+
ota_4, app, ota_4, , 2816K,
11+

sdkconfig

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,30 +1425,42 @@ CONFIG_WL_SECTOR_SIZE=4096
14251425
# end of Wear Levelling
14261426

14271427
#
1428-
# Audio Codec Device Configuration
1428+
# Board Support Package
14291429
#
1430-
CONFIG_CODEC_ES8311_SUPPORT=y
1431-
CONFIG_CODEC_ES7210_SUPPORT=y
1432-
CONFIG_CODEC_ES7243_SUPPORT=y
1433-
CONFIG_CODEC_ES7243E_SUPPORT=y
1434-
CONFIG_CODEC_ES8156_SUPPORT=y
1435-
CONFIG_CODEC_AW88298_SUPPORT=y
1436-
CONFIG_CODEC_ES8374_SUPPORT=y
1437-
CONFIG_CODEC_ES8388_SUPPORT=y
1438-
CONFIG_CODEC_TAS5805M_SUPPORT=y
1439-
# CONFIG_CODEC_ZL38063_SUPPORT is not set
1440-
# end of Audio Codec Device Configuration
1430+
CONFIG_BSP_ERROR_CHECK=y
14411431

14421432
#
1443-
# CMake Utilities
1433+
# I2C
14441434
#
1445-
# CONFIG_CU_RELINKER_ENABLE is not set
1446-
# CONFIG_CU_DIAGNOSTICS_COLOR_NEVER is not set
1447-
CONFIG_CU_DIAGNOSTICS_COLOR_ALWAYS=y
1448-
# CONFIG_CU_DIAGNOSTICS_COLOR_AUTO is not set
1449-
# CONFIG_CU_GCC_LTO_ENABLE is not set
1450-
# CONFIG_CU_GCC_STRING_1BYTE_ALIGN is not set
1451-
# end of CMake Utilities
1435+
CONFIG_BSP_I2C_NUM=1
1436+
CONFIG_BSP_I2C_FAST_MODE=y
1437+
CONFIG_BSP_I2C_CLK_SPEED_HZ=400000
1438+
# end of I2C
1439+
1440+
#
1441+
# SPIFFS - Virtual File System
1442+
#
1443+
# CONFIG_BSP_SPIFFS_FORMAT_ON_MOUNT_FAIL is not set
1444+
CONFIG_BSP_SPIFFS_MOUNT_POINT="/spiffs"
1445+
CONFIG_BSP_SPIFFS_PARTITION_LABEL="storage"
1446+
CONFIG_BSP_SPIFFS_MAX_FILES=5
1447+
# end of SPIFFS - Virtual File System
1448+
1449+
#
1450+
# SD card - Virtual File System
1451+
#
1452+
# CONFIG_BSP_SD_FORMAT_ON_MOUNT_FAIL is not set
1453+
CONFIG_BSP_SD_MOUNT_POINT="/sdcard"
1454+
# end of SD card - Virtual File System
1455+
1456+
#
1457+
# Display
1458+
#
1459+
CONFIG_BSP_DISPLAY_BRIGHTNESS_LEDC_CH=1
1460+
# end of Display
1461+
1462+
CONFIG_BSP_I2S_NUM=1
1463+
# end of Board Support Package
14521464

14531465
#
14541466
# LVGL configuration
@@ -1754,11 +1766,19 @@ CONFIG_LV_USE_SNAPSHOT=y
17541766
# end of LVGL configuration
17551767

17561768
#
1757-
# ESP LCD TOUCH
1769+
# Audio Codec Device Configuration
17581770
#
1759-
CONFIG_ESP_LCD_TOUCH_MAX_POINTS=5
1760-
CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS=1
1761-
# end of ESP LCD TOUCH
1771+
CONFIG_CODEC_ES8311_SUPPORT=y
1772+
CONFIG_CODEC_ES7210_SUPPORT=y
1773+
CONFIG_CODEC_ES7243_SUPPORT=y
1774+
CONFIG_CODEC_ES7243E_SUPPORT=y
1775+
CONFIG_CODEC_ES8156_SUPPORT=y
1776+
CONFIG_CODEC_AW88298_SUPPORT=y
1777+
CONFIG_CODEC_ES8374_SUPPORT=y
1778+
CONFIG_CODEC_ES8388_SUPPORT=y
1779+
CONFIG_CODEC_TAS5805M_SUPPORT=y
1780+
# CONFIG_CODEC_ZL38063_SUPPORT is not set
1781+
# end of Audio Codec Device Configuration
17621782

17631783
#
17641784
# Camera configuration
@@ -1792,42 +1812,22 @@ CONFIG_CAMERA_DMA_BUFFER_SIZE_MAX=32768
17921812
# end of Camera configuration
17931813

17941814
#
1795-
# Board Support Package
1796-
#
1797-
CONFIG_BSP_ERROR_CHECK=y
1798-
1799-
#
1800-
# I2C
1801-
#
1802-
CONFIG_BSP_I2C_NUM=1
1803-
CONFIG_BSP_I2C_FAST_MODE=y
1804-
CONFIG_BSP_I2C_CLK_SPEED_HZ=400000
1805-
# end of I2C
1806-
1807-
#
1808-
# SPIFFS - Virtual File System
1809-
#
1810-
# CONFIG_BSP_SPIFFS_FORMAT_ON_MOUNT_FAIL is not set
1811-
CONFIG_BSP_SPIFFS_MOUNT_POINT="/spiffs"
1812-
CONFIG_BSP_SPIFFS_PARTITION_LABEL="storage"
1813-
CONFIG_BSP_SPIFFS_MAX_FILES=5
1814-
# end of SPIFFS - Virtual File System
1815-
1816-
#
1817-
# SD card - Virtual File System
1815+
# ESP LCD TOUCH
18181816
#
1819-
# CONFIG_BSP_SD_FORMAT_ON_MOUNT_FAIL is not set
1820-
CONFIG_BSP_SD_MOUNT_POINT="/sdcard"
1821-
# end of SD card - Virtual File System
1817+
CONFIG_ESP_LCD_TOUCH_MAX_POINTS=5
1818+
CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS=1
1819+
# end of ESP LCD TOUCH
18221820

18231821
#
1824-
# Display
1822+
# CMake Utilities
18251823
#
1826-
CONFIG_BSP_DISPLAY_BRIGHTNESS_LEDC_CH=1
1827-
# end of Display
1828-
1829-
CONFIG_BSP_I2S_NUM=1
1830-
# end of Board Support Package
1824+
# CONFIG_CU_RELINKER_ENABLE is not set
1825+
# CONFIG_CU_DIAGNOSTICS_COLOR_NEVER is not set
1826+
CONFIG_CU_DIAGNOSTICS_COLOR_ALWAYS=y
1827+
# CONFIG_CU_DIAGNOSTICS_COLOR_AUTO is not set
1828+
# CONFIG_CU_GCC_LTO_ENABLE is not set
1829+
# CONFIG_CU_GCC_STRING_1BYTE_ALIGN is not set
1830+
# end of CMake Utilities
18311831
# end of Component config
18321832

18331833
# CONFIG_IDF_EXPERIMENTAL_FEATURES is not set

0 commit comments

Comments
 (0)