edit signal display

This commit is contained in:
Terrence
2025-02-01 23:08:41 +08:00
parent c34cf27ccb
commit d840699bbf
3 changed files with 26 additions and 18 deletions

View File

@@ -112,16 +112,14 @@ const char* Ml307Board::GetNetworkStateIcon() {
int csq = modem_.GetCsq();
if (csq == -1) {
return FONT_AWESOME_SIGNAL_OFF;
} else if (csq >= 0 && csq <= 9) {
} else if (csq >= 0 && csq <= 14) {
return FONT_AWESOME_SIGNAL_1;
} else if (csq >= 10 && csq <= 14) {
return FONT_AWESOME_SIGNAL_2;
} else if (csq >= 15 && csq <= 19) {
return FONT_AWESOME_SIGNAL_3;
return FONT_AWESOME_SIGNAL_2;
} else if (csq >= 20 && csq <= 24) {
return FONT_AWESOME_SIGNAL_4;
return FONT_AWESOME_SIGNAL_3;
} else if (csq >= 25 && csq <= 31) {
return FONT_AWESOME_SIGNAL_FULL;
return FONT_AWESOME_SIGNAL_4;
}
ESP_LOGW(TAG, "Invalid CSQ: %d", csq);

View File

@@ -165,9 +165,9 @@ const char* WifiBoard::GetNetworkStateIcon() {
return FONT_AWESOME_WIFI_OFF;
}
int8_t rssi = wifi_station.GetRssi();
if (rssi >= -55) {
if (rssi >= -60) {
return FONT_AWESOME_WIFI;
} else if (rssi >= -65) {
} else if (rssi >= -70) {
return FONT_AWESOME_WIFI_FAIR;
} else {
return FONT_AWESOME_WIFI_WEAK;

View File

@@ -88,14 +88,16 @@ void Display::Update() {
auto& board = Board::GetInstance();
auto codec = board.GetAudioCodec();
DisplayLockGuard lock(this);
// 如果静音状态改变,则更新图标
if (codec->output_volume() == 0 && !muted_) {
muted_ = true;
lv_label_set_text(mute_label_, FONT_AWESOME_VOLUME_MUTE);
} else if (codec->output_volume() > 0 && muted_) {
muted_ = false;
lv_label_set_text(mute_label_, "");
{
DisplayLockGuard lock(this);
// 如果静音状态改变,则更新图标
if (codec->output_volume() == 0 && !muted_) {
muted_ = true;
lv_label_set_text(mute_label_, FONT_AWESOME_VOLUME_MUTE);
} else if (codec->output_volume() > 0 && muted_) {
muted_ = false;
lv_label_set_text(mute_label_, "");
}
}
// 更新电池图标
@@ -117,16 +119,24 @@ void Display::Update() {
icon = levels[battery_level / 20];
}
if (battery_icon_ != icon) {
DisplayLockGuard lock(this);
battery_icon_ = icon;
lv_label_set_text(battery_label_, battery_icon_);
}
}
// 仅在聊天状态为空闲时,读取网络状态避免升级时占用 UART 资源
// 升级固件时,读取 4G 网络状态避免占用 UART 资源
auto device_state = Application::GetInstance().GetDeviceState();
if (device_state == kDeviceStateIdle || device_state == kDeviceStateStarting) {
static const std::vector<DeviceState> allowed_states = {
kDeviceStateIdle,
kDeviceStateStarting,
kDeviceStateWifiConfiguring,
kDeviceStateListening,
};
if (std::find(allowed_states.begin(), allowed_states.end(), device_state) != allowed_states.end()) {
icon = board.GetNetworkStateIcon();
if (network_icon_ != icon) {
DisplayLockGuard lock(this);
network_icon_ = icon;
lv_label_set_text(network_label_, network_icon_);
}