Skip to content

Commit eb580f0

Browse files
committed
feat(ui): add battery status indication
* Update espp submodule to fix bug when unsubscribing from an event * Update menu to properly unsubscribe the menu component instead of the gui component (copy paste error from long ago) * Add battery header to box-emu-hal which includes the serialization component, adds a battery topic, and adds a BatteryInfo structure (the message data) * Updated menu and gui to have battery status icons (battery level symbol, charge symbol) and battery status labels * Updated menu and gui to subscribe to the battery topic and update their battery status displays when the event fires * Updated main to send new battery info every second to test charge and discharge display in main gui and menu (until hardware V1 arrives with support for actual SoC / charge measurement Closes #24
1 parent a558a2a commit eb580f0

File tree

32 files changed

+3497
-994
lines changed

32 files changed

+3497
-994
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ set(EMULATOR_COMPONENTS
7171

7272
set(
7373
COMPONENTS
74-
"main esptool_py esp_lcd esp_psram task format display display_drivers monitor esp-idf-cxx ${EMULATOR_COMPONENTS} box-emu-hal gui menu"
74+
"main esptool_py esp_lcd esp_psram task format display display_drivers monitor timer ${EMULATOR_COMPONENTS} box-emu-hal gui menu"
7575
CACHE STRING
7676
"List of components to include"
7777
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
idf_component_register(
22
INCLUDE_DIRS "include"
33
SRC_DIRS "src"
4-
REQUIRES "driver" "heap" "fatfs" "esp_lcd" "esp_psram" "hal" "usb" "esp_tinyusb" "spi_flash" "nvs_flash" "codec" "aw9523" "display" "display_drivers" "mcp23x17" "input_drivers" "tt21100" "gt911" "drv2605" "event_manager" "i2c" "task" "timer"
4+
REQUIRES "driver" "heap" "fatfs" "esp_lcd" "esp_psram" "hal" "usb" "esp_tinyusb" "spi_flash" "nvs_flash" "codec" "aw9523" "display" "display_drivers" "mcp23x17" "input_drivers" "tt21100" "gt911" "drv2605" "event_manager" "i2c" "task" "timer" "serialization"
55
)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#pragma once
2+
3+
#include "serialization.hpp"
4+
5+
static const std::string battery_topic = "battery";
6+
7+
struct BatteryInfo {
8+
uint8_t level;
9+
bool charging;
10+
};

components/espp

Submodule espp updated 110 files

components/gui/generated/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ SET(SOURCES screens/ui_romscreen.c
22
screens/ui_settingsscreen.c
33
ui.c
44
components/ui_comp_hook.c
5-
ui_helpers.c)
5+
ui_helpers.c
6+
ui_events.c)
67

78
add_library(ui ${SOURCES})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// This file was generated by SquareLine Studio
2-
// SquareLine Studio version: SquareLine Studio 1.3.3
2+
// SquareLine Studio version: SquareLine Studio 1.3.4
33
// LVGL version: 8.3.3
44
// Project name: emu
55

components/gui/generated/filelist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ screens/ui_settingsscreen.c
33
ui.c
44
components/ui_comp_hook.c
55
ui_helpers.c
6+
ui_events.c

components/gui/generated/screens/ui_romscreen.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// This file was generated by SquareLine Studio
2-
// SquareLine Studio version: SquareLine Studio 1.3.3
2+
// SquareLine Studio version: SquareLine Studio 1.3.4
33
// LVGL version: 8.3.3
44
// Project name: emu
55

@@ -29,6 +29,28 @@ lv_obj_set_height( ui_Screen1_Label2, LV_SIZE_CONTENT); /// 1
2929
lv_obj_set_align( ui_Screen1_Label2, LV_ALIGN_CENTER );
3030
lv_label_set_text(ui_Screen1_Label2,LV_SYMBOL_SETTINGS);
3131

32+
ui_battery_soc_symbol_1 = lv_label_create(ui_header);
33+
lv_obj_set_width( ui_battery_soc_symbol_1, LV_SIZE_CONTENT); /// 1
34+
lv_obj_set_height( ui_battery_soc_symbol_1, LV_SIZE_CONTENT); /// 1
35+
lv_obj_set_x( ui_battery_soc_symbol_1, 52 );
36+
lv_obj_set_y( ui_battery_soc_symbol_1, 5 );
37+
lv_label_set_text(ui_battery_soc_symbol_1,LV_SYMBOL_BATTERY_EMPTY);
38+
39+
ui_battery_charging_symbol_1 = lv_label_create(ui_header);
40+
lv_obj_set_width( ui_battery_charging_symbol_1, LV_SIZE_CONTENT); /// 1
41+
lv_obj_set_height( ui_battery_charging_symbol_1, LV_SIZE_CONTENT); /// 1
42+
lv_obj_set_x( ui_battery_charging_symbol_1, 70 );
43+
lv_obj_set_y( ui_battery_charging_symbol_1, 5 );
44+
lv_label_set_text(ui_battery_charging_symbol_1,"");
45+
46+
ui_battery_soc_text_1 = lv_label_create(ui_header);
47+
lv_obj_set_width( ui_battery_soc_text_1, LV_SIZE_CONTENT); /// 1
48+
lv_obj_set_height( ui_battery_soc_text_1, LV_SIZE_CONTENT); /// 1
49+
lv_obj_set_x( ui_battery_soc_text_1, 52 );
50+
lv_obj_set_y( ui_battery_soc_text_1, -5 );
51+
lv_obj_set_align( ui_battery_soc_text_1, LV_ALIGN_BOTTOM_LEFT );
52+
lv_label_set_text(ui_battery_soc_text_1,"100%");
53+
3254
ui_Screen1_Label1 = lv_label_create(ui_header);
3355
lv_obj_set_width( ui_Screen1_Label1, LV_SIZE_CONTENT); /// 1
3456
lv_obj_set_height( ui_Screen1_Label1, LV_SIZE_CONTENT); /// 1

components/gui/generated/screens/ui_settingsscreen.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// This file was generated by SquareLine Studio
2-
// SquareLine Studio version: SquareLine Studio 1.3.3
2+
// SquareLine Studio version: SquareLine Studio 1.3.4
33
// LVGL version: 8.3.3
44
// Project name: emu
55

@@ -16,6 +16,28 @@ lv_obj_set_width( ui_header1, lv_pct(100));
1616
lv_obj_set_align( ui_header1, LV_ALIGN_TOP_MID );
1717
lv_obj_clear_flag( ui_header1, LV_OBJ_FLAG_SCROLLABLE ); /// Flags
1818

19+
ui_battery_charging_symbol = lv_label_create(ui_header1);
20+
lv_obj_set_width( ui_battery_charging_symbol, LV_SIZE_CONTENT); /// 1
21+
lv_obj_set_height( ui_battery_charging_symbol, LV_SIZE_CONTENT); /// 1
22+
lv_obj_set_x( ui_battery_charging_symbol, 70 );
23+
lv_obj_set_y( ui_battery_charging_symbol, 5 );
24+
lv_label_set_text(ui_battery_charging_symbol,"");
25+
26+
ui_battery_soc_symbol = lv_label_create(ui_header1);
27+
lv_obj_set_width( ui_battery_soc_symbol, LV_SIZE_CONTENT); /// 1
28+
lv_obj_set_height( ui_battery_soc_symbol, LV_SIZE_CONTENT); /// 1
29+
lv_obj_set_x( ui_battery_soc_symbol, 52 );
30+
lv_obj_set_y( ui_battery_soc_symbol, 5 );
31+
lv_label_set_text(ui_battery_soc_symbol,LV_SYMBOL_BATTERY_EMPTY);
32+
33+
ui_battery_soc_text = lv_label_create(ui_header1);
34+
lv_obj_set_width( ui_battery_soc_text, LV_SIZE_CONTENT); /// 1
35+
lv_obj_set_height( ui_battery_soc_text, LV_SIZE_CONTENT); /// 1
36+
lv_obj_set_x( ui_battery_soc_text, 52 );
37+
lv_obj_set_y( ui_battery_soc_text, -5 );
38+
lv_obj_set_align( ui_battery_soc_text, LV_ALIGN_BOTTOM_LEFT );
39+
lv_label_set_text(ui_battery_soc_text,"100%");
40+
1941
ui_closebutton = lv_btn_create(ui_header1);
2042
lv_obj_set_width( ui_closebutton, 48);
2143
lv_obj_set_height( ui_closebutton, 48);
@@ -54,6 +76,7 @@ lv_obj_clear_flag( ui_volumepanel, LV_OBJ_FLAG_SCROLLABLE ); /// Flags
5476

5577
ui_volumebar = lv_bar_create(ui_volumepanel);
5678
lv_bar_set_value(ui_volumebar,25,LV_ANIM_OFF);
79+
lv_bar_set_start_value(ui_volumebar, 0, LV_ANIM_OFF);
5780
lv_obj_set_width( ui_volumebar, 130);
5881
lv_obj_set_height( ui_volumebar, 10);
5982
lv_obj_set_x( ui_volumebar, 25 );
@@ -111,6 +134,7 @@ lv_obj_clear_flag( ui_brightnesspanel, LV_OBJ_FLAG_SCROLLABLE ); /// Flags
111134

112135
ui_brightnessbar = lv_bar_create(ui_brightnesspanel);
113136
lv_bar_set_value(ui_brightnessbar,100,LV_ANIM_OFF);
137+
lv_bar_set_start_value(ui_brightnessbar, 0, LV_ANIM_OFF);
114138
lv_obj_set_width( ui_brightnessbar, 180);
115139
lv_obj_set_height( ui_brightnessbar, 10);
116140
lv_obj_set_align( ui_brightnessbar, LV_ALIGN_CENTER );

components/gui/generated/ui.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// This file was generated by SquareLine Studio
2-
// SquareLine Studio version: SquareLine Studio 1.3.3
2+
// SquareLine Studio version: SquareLine Studio 1.3.4
33
// LVGL version: 8.3.3
44
// Project name: emu
55

@@ -16,6 +16,9 @@ lv_obj_t *ui_header;
1616
void ui_event_settingsbutton( lv_event_t * e);
1717
lv_obj_t *ui_settingsbutton;
1818
lv_obj_t *ui_Screen1_Label2;
19+
lv_obj_t *ui_battery_soc_symbol_1;
20+
lv_obj_t *ui_battery_charging_symbol_1;
21+
lv_obj_t *ui_battery_soc_text_1;
1922
lv_obj_t *ui_Screen1_Label1;
2023
lv_obj_t *ui_playbutton;
2124
lv_obj_t *ui_Screen1_Label3;
@@ -28,6 +31,9 @@ lv_obj_t *ui_boxart;
2831
void ui_settingsscreen_screen_init(void);
2932
lv_obj_t *ui_settingsscreen;
3033
lv_obj_t *ui_header1;
34+
lv_obj_t *ui_battery_charging_symbol;
35+
lv_obj_t *ui_battery_soc_symbol;
36+
lv_obj_t *ui_battery_soc_text;
3137
void ui_event_closebutton( lv_event_t * e);
3238
lv_obj_t *ui_closebutton;
3339
lv_obj_t *ui_Screen1_Label4;

0 commit comments

Comments
 (0)