feat: integrate MCP and ES3C28P audio support with upstream compatibility updates
This commit is contained in:
@@ -39,6 +39,8 @@ struct StatusbarData {
|
||||
uint8_t time_minutes = 0;
|
||||
bool time_set = false;
|
||||
kernel::SystemEventSubscription systemEventSubscription = 0;
|
||||
std::string battery_text;
|
||||
bool battery_text_visible = false;
|
||||
};
|
||||
|
||||
static StatusbarData statusbar_data;
|
||||
@@ -47,7 +49,7 @@ typedef struct {
|
||||
lv_obj_t obj;
|
||||
lv_obj_t* time;
|
||||
lv_obj_t* icons[STATUSBAR_ICON_LIMIT];
|
||||
lv_obj_t* battery_icon;
|
||||
lv_obj_t* battery_label;
|
||||
PubSub<void*>::SubscriptionHandle pubsub_subscription;
|
||||
} Statusbar;
|
||||
|
||||
@@ -199,6 +201,13 @@ lv_obj_t* statusbar_create(lv_obj_t* parent) {
|
||||
update_icon(image, &(statusbar_data.icons[i]));
|
||||
}
|
||||
statusbar_data.mutex.unlock();
|
||||
|
||||
statusbar->battery_label = lv_label_create(obj);
|
||||
lv_obj_set_style_text_color(statusbar->battery_label, lv_color_white(), LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_pad_all(statusbar->battery_label, 0, LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_margin_right(statusbar->battery_label, 4, LV_STATE_DEFAULT);
|
||||
lv_obj_add_flag(statusbar->battery_label, LV_OBJ_FLAG_HIDDEN);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -219,6 +228,12 @@ static void update_main(Statusbar* statusbar) {
|
||||
for (int i = 0; i < STATUSBAR_ICON_LIMIT; ++i) {
|
||||
update_icon(statusbar->icons[i], &(statusbar_data.icons[i]));
|
||||
}
|
||||
if (statusbar_data.battery_text_visible && !statusbar_data.battery_text.empty()) {
|
||||
lv_label_set_text(statusbar->battery_label, statusbar_data.battery_text.c_str());
|
||||
lv_obj_remove_flag(statusbar->battery_label, LV_OBJ_FLAG_HIDDEN);
|
||||
} else {
|
||||
lv_obj_add_flag(statusbar->battery_label, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
statusbar_data.mutex.unlock();
|
||||
}
|
||||
}
|
||||
@@ -306,6 +321,20 @@ void statusbar_icon_set_visibility(int8_t id, bool visible) {
|
||||
statusbar_data.pubsub->publish(nullptr);
|
||||
}
|
||||
|
||||
void statusbar_set_battery_text(const std::string& text) {
|
||||
statusbar_data.mutex.lock();
|
||||
statusbar_data.battery_text = text;
|
||||
statusbar_data.mutex.unlock();
|
||||
statusbar_data.pubsub->publish(nullptr);
|
||||
}
|
||||
|
||||
void statusbar_set_battery_visibility(bool visible) {
|
||||
statusbar_data.mutex.lock();
|
||||
statusbar_data.battery_text_visible = visible;
|
||||
statusbar_data.mutex.unlock();
|
||||
statusbar_data.pubsub->publish(nullptr);
|
||||
}
|
||||
|
||||
int statusbar_get_height() {
|
||||
const auto icon_size = lvgl_get_statusbar_icon_font_height();
|
||||
const auto vertical_padding = static_cast<uint32_t>((static_cast<float>(icon_size) * 0.1f));
|
||||
|
||||
Reference in New Issue
Block a user