update status bar immediately after network started

This commit is contained in:
Terrence
2025-05-24 07:25:34 +08:00
parent 6d5331dddd
commit 0204b8800b
4 changed files with 47 additions and 44 deletions

View File

@@ -395,6 +395,9 @@ void Application::Start() {
/* Wait for the network to be ready */ /* Wait for the network to be ready */
board.StartNetwork(); board.StartNetwork();
// Update the status bar immediately to show the network state
display->UpdateStatusBar(true);
// Check for new firmware version or get the MQTT broker address // Check for new firmware version or get the MQTT broker address
CheckNewVersion(); CheckNewVersion();

View File

@@ -92,7 +92,7 @@ void Display::ShowNotification(const char* notification, int duration_ms) {
ESP_ERROR_CHECK(esp_timer_start_once(notification_timer_, duration_ms * 1000)); ESP_ERROR_CHECK(esp_timer_start_once(notification_timer_, duration_ms * 1000));
} }
void Display::UpdateStatusBar() { void Display::UpdateStatusBar(bool update_all) {
auto& board = Board::GetInstance(); auto& board = Board::GetInstance();
auto codec = board.GetAudioCodec(); auto codec = board.GetAudioCodec();
@@ -112,9 +112,6 @@ void Display::UpdateStatusBar() {
} }
} }
// 每 10 秒更新一次电池图标
static int seconds_counter = 0;
if (seconds_counter++ % 10 == 0) {
esp_pm_lock_acquire(pm_lock_); esp_pm_lock_acquire(pm_lock_);
// 更新电池图标 // 更新电池图标
int battery_level; int battery_level;
@@ -156,6 +153,9 @@ void Display::UpdateStatusBar() {
} }
} }
// 每 10 秒更新一次网络图标
static int seconds_counter = 0;
if (update_all || seconds_counter++ % 10 == 0) {
// 升级固件时,不读取 4G 网络状态,避免占用 UART 资源 // 升级固件时,不读取 4G 网络状态,避免占用 UART 资源
auto device_state = Application::GetInstance().GetDeviceState(); auto device_state = Application::GetInstance().GetDeviceState();
static const std::vector<DeviceState> allowed_states = { static const std::vector<DeviceState> allowed_states = {
@@ -173,9 +173,9 @@ void Display::UpdateStatusBar() {
lv_label_set_text(network_label_, network_icon_); lv_label_set_text(network_label_, network_icon_);
} }
} }
}
esp_pm_lock_release(pm_lock_); esp_pm_lock_release(pm_lock_);
}
} }

View File

@@ -27,7 +27,7 @@ public:
virtual void SetIcon(const char* icon); virtual void SetIcon(const char* icon);
virtual void SetTheme(const std::string& theme_name); virtual void SetTheme(const std::string& theme_name);
virtual std::string GetTheme() { return current_theme_name_; } virtual std::string GetTheme() { return current_theme_name_; }
virtual void UpdateStatusBar(); virtual void UpdateStatusBar(bool update_all = false);
inline int width() const { return width_; } inline int width() const { return width_; }
inline int height() const { return height_; } inline int height() const { return height_; }

View File

@@ -20,7 +20,7 @@ dependencies:
espressif/knob: ^1.0.0 espressif/knob: ^1.0.0
espressif/esp_lcd_touch_ft5x06: ~1.0.7 espressif/esp_lcd_touch_ft5x06: ~1.0.7
espressif/esp_lcd_touch_gt911: ^1 espressif/esp_lcd_touch_gt911: ^1
waveshare/esp_lcd_touch_cst9217: ^1.0.2 waveshare/esp_lcd_touch_cst9217: ^1.0.3
lvgl/lvgl: ~9.2.2 lvgl/lvgl: ~9.2.2
esp_lvgl_port: ~2.6.0 esp_lvgl_port: ~2.6.0
espressif/esp_io_expander_tca95xx_16bit: ^2.0.0 espressif/esp_io_expander_tca95xx_16bit: ^2.0.0