feat: add manual upgrade firmware

This commit is contained in:
Terrence
2025-09-12 08:45:29 +08:00
parent 469ee2d92a
commit f79506d58b
9 changed files with 169 additions and 66 deletions

View File

@@ -161,8 +161,12 @@ bool Assets::Apply() {
ESP_LOGE(TAG, "Failed to load fonts.bin");
return false;
}
light_theme->set_text_font(text_font);
dark_theme->set_text_font(text_font);
if (light_theme != nullptr) {
light_theme->set_text_font(text_font);
}
if (dark_theme != nullptr) {
dark_theme->set_text_font(text_font);
}
} else {
ESP_LOGE(TAG, "The font file %s is not found", fonts_text_file.c_str());
}
@@ -186,14 +190,18 @@ bool Assets::Apply() {
}
}
}
light_theme->set_emoji_collection(custom_emoji_collection);
dark_theme->set_emoji_collection(custom_emoji_collection);
if (light_theme != nullptr) {
light_theme->set_emoji_collection(custom_emoji_collection);
}
if (dark_theme != nullptr) {
dark_theme->set_emoji_collection(custom_emoji_collection);
}
}
cJSON* skin = cJSON_GetObjectItem(root, "skin");
if (cJSON_IsObject(skin)) {
cJSON* light_skin = cJSON_GetObjectItem(skin, "light");
if (cJSON_IsObject(light_skin)) {
if (cJSON_IsObject(light_skin) && light_theme != nullptr) {
cJSON* text_color = cJSON_GetObjectItem(light_skin, "text_color");
cJSON* background_color = cJSON_GetObjectItem(light_skin, "background_color");
cJSON* background_image = cJSON_GetObjectItem(light_skin, "background_image");
@@ -214,7 +222,7 @@ bool Assets::Apply() {
}
}
cJSON* dark_skin = cJSON_GetObjectItem(skin, "dark");
if (cJSON_IsObject(dark_skin)) {
if (cJSON_IsObject(dark_skin) && dark_theme != nullptr) {
cJSON* text_color = cJSON_GetObjectItem(dark_skin, "text_color");
cJSON* background_color = cJSON_GetObjectItem(dark_skin, "background_color");
cJSON* background_image = cJSON_GetObjectItem(dark_skin, "background_image");
@@ -239,7 +247,11 @@ bool Assets::Apply() {
auto display = Board::GetInstance().GetDisplay();
ESP_LOGI(TAG, "Refreshing display theme...");
display->SetTheme(display->GetTheme());
auto current_theme = display->GetTheme();
if (current_theme != nullptr) {
display->SetTheme(current_theme);
}
cJSON_Delete(root);
return true;
}
@@ -253,7 +265,6 @@ bool Assets::Download(std::string url, std::function<void(int progress, size_t s
mmap_handle_ = 0;
mmap_root_ = nullptr;
}
partition_valid_ = false;
checksum_valid_ = false;
assets_.clear();