Update themes

This commit is contained in:
fvanroie 2020-11-29 02:57:02 +01:00
parent 689c193f82
commit 6eaa62458a
3 changed files with 53 additions and 51 deletions

View File

@ -403,8 +403,8 @@ typedef void* lv_font_user_data_t;
#define LV_THEME_DEFAULT_FONT_TITLE LV_FONT_DEFAULT // &lv_font_montserrat_28_compressed #define LV_THEME_DEFAULT_FONT_TITLE LV_FONT_DEFAULT // &lv_font_montserrat_28_compressed
#endif #endif
#define LV_USE_THEME_EMPTY 1 #define LV_USE_THEME_EMPTY 0
#define LV_USE_THEME_TEMPLATE 1 #define LV_USE_THEME_TEMPLATE 0
#define LV_USE_THEME_HASP 1 #define LV_USE_THEME_HASP 1
/*================= /*=================

View File

@ -51,7 +51,7 @@
**********************/ **********************/
uint8_t haspStartDim = 100; uint8_t haspStartDim = 100;
uint8_t haspStartPage = 0; uint8_t haspStartPage = 0;
uint8_t haspThemeId = 0; uint8_t haspThemeId = 2;
uint16_t haspThemeHue = 200; uint16_t haspThemeHue = 200;
char haspPagesPath[32] = "/pages.jsonl"; char haspPagesPath[32] = "/pages.jsonl";
char haspZiFontPath[32]; char haspZiFontPath[32];
@ -256,31 +256,31 @@ void haspSetup()
guiSetDim(haspStartDim); guiSetDim(haspStartDim);
/******* File System Test ********************************************************************/ /******* File System Test ********************************************************************/
lv_fs_file_t f; // lv_fs_file_t f;
lv_fs_res_t res; // lv_fs_res_t res;
res = lv_fs_open(&f, "E:/config.json", LV_FS_MODE_RD); // res = lv_fs_open(&f, "E:/config.json", LV_FS_MODE_RD);
if(res == LV_FS_RES_OK) // if(res == LV_FS_RES_OK)
Log.verbose(TAG_HASP, F("Opening config.json OK")); // Log.verbose(TAG_HASP, F("Opening config.json OK"));
else // else
Log.error(TAG_HASP, F("Opening config.json from FS failed %d"), res); // Log.error(TAG_HASP, F("Opening config.json from FS failed %d"), res);
uint32_t btoread = 128; // uint32_t btoread = 128;
uint32_t bread = 0; // uint32_t bread = 0;
char buffer[129]; // char buffer[129];
// res = lv_fs_read(&f, buffer, btoread, &bread); // res = lv_fs_read(&f, buffer, btoread, &bread);
if(res == LV_FS_RES_OK) { // if(res == LV_FS_RES_OK) {
Log.verbose(TAG_HASP, F("Reading config.json OK %u"), bread); // Log.verbose(TAG_HASP, F("Reading config.json OK %u"), bread);
buffer[127] = '\0'; // buffer[127] = '\0';
Log.trace(TAG_HASP, buffer); // Log.trace(TAG_HASP, buffer);
} else // } else
Log.error(TAG_HASP, F("Reading config.json from FS failed %d"), res); // Log.error(TAG_HASP, F("Reading config.json from FS failed %d"), res);
res = lv_fs_close(&f); // res = lv_fs_close(&f);
if(res == LV_FS_RES_OK) // if(res == LV_FS_RES_OK)
Log.verbose(TAG_HASP, F("Closing config.json OK")); // Log.verbose(TAG_HASP, F("Closing config.json OK"));
else // else
Log.error(TAG_HASP, F("Closing config.json on FS failed %d"), res); // Log.error(TAG_HASP, F("Closing config.json on FS failed %d"), res);
/******* File System Test ********************************************************************/ /******* File System Test ********************************************************************/
/* ********** Font Initializations ********** */ /* ********** Font Initializations ********** */
@ -298,12 +298,16 @@ void haspSetup()
#endif #endif
#endif #endif
haspFonts[0] = lv_font_load("E:/font_1.fnt"); // haspFonts[0] = lv_font_load("E:/font_1.fnt");
// haspFonts[2] = lv_font_load("E:/font_2.fnt"); // haspFonts[2] = lv_font_load("E:/font_2.fnt");
// haspFonts[3] = lv_font_load("E:/font_3.fnt"); // haspFonts[3] = lv_font_load("E:/font_3.fnt");
/* ********** Theme Initializations ********** */ /* ********** Theme Initializations ********** */
lv_theme_t * th; if(haspThemeId == 8) haspThemeId = 1; // update old HASP id
if(haspThemeId == 9) haspThemeId = 5; // update old material id
if(haspThemeId <= 0 || haspThemeId > 5) haspThemeId = 1; // check bounds
lv_theme_t * th = NULL;
switch(haspThemeId) { switch(haspThemeId) {
#if(LV_USE_THEME_EMPTY == 1) #if(LV_USE_THEME_EMPTY == 1)
case 0: case 0:
@ -312,6 +316,17 @@ void haspSetup()
break; break;
#endif #endif
#if(LV_USE_THEME_HASP == 1)
case 2: // Dark
case 1: // Light
case 8: // Light (old id)
th = lv_theme_hasp_init(lv_color_hsv_to_rgb(haspThemeHue, 100, 100),
lv_color_hsv_to_rgb(haspThemeHue, 100, 100),
LV_THEME_HASP_FLAG_DARK + LV_THEME_HASP_FLAG_NO_FOCUS, haspFonts[0], haspFonts[1],
haspFonts[2], haspFonts[3]);
break;
#endif
#if LV_USE_THEME_ALIEN == 1 #if LV_USE_THEME_ALIEN == 1
case 1: case 1:
th = lv_theme_alien_init(haspThemeHue, defaultFont); th = lv_theme_alien_init(haspThemeHue, defaultFont);
@ -345,7 +360,8 @@ void haspSetup()
LV_THEME_MATERIAL_FLAG_NO_TRANSITION, LV_THEME_MATERIAL_FLAG_NO_TRANSITION,
haspFonts[0], haspFonts[1], haspFonts[2], haspFonts[3]); haspFonts[0], haspFonts[1], haspFonts[2], haspFonts[3]);
break; break;
case 9: case 5:
case 9: // Light (old id)
th = lv_theme_material_init(LV_COLOR_PURPLE, LV_COLOR_ORANGE, th = lv_theme_material_init(LV_COLOR_PURPLE, LV_COLOR_ORANGE,
LV_THEME_MATERIAL_FLAG_DARK + LV_THEME_MATERIAL_FLAG_NO_FOCUS + LV_THEME_MATERIAL_FLAG_DARK + LV_THEME_MATERIAL_FLAG_NO_FOCUS +
LV_THEME_MATERIAL_FLAG_NO_TRANSITION, LV_THEME_MATERIAL_FLAG_NO_TRANSITION,
@ -372,25 +388,8 @@ void haspSetup()
break; break;
#endif #endif
#if(LV_USE_THEME_HASP == 1)
case 8:
th = lv_theme_hasp_init(lv_color_hsv_to_rgb(haspThemeHue, 100, 100),
lv_color_hsv_to_rgb(haspThemeHue, 100, 100), LV_THEME_DEFAULT_FLAGS, haspFonts[0],
haspFonts[1], haspFonts[2], haspFonts[3]);
break;
#endif
/* case 0:
#if LV_USE_THEME_DEFAULT == 1
th = lv_theme_default_init(haspThemeHue, defaultFont);
#else
th = lv_theme_hasp_init(512, defaultFont);
#endif
break;
*/
default: default:
th = lv_theme_template_init(LV_COLOR_PURPLE, LV_COLOR_ORANGE, LV_THEME_DEFAULT_FLAGS, haspFonts[0],
haspFonts[1], haspFonts[2], haspFonts[3]);
Log.error(TAG_HASP, F("Unknown theme selected")); Log.error(TAG_HASP, F("Unknown theme selected"));
} }
@ -398,7 +397,7 @@ void haspSetup()
lv_theme_set_act(th); lv_theme_set_act(th);
Log.trace(TAG_HASP, F("Custom theme loaded")); Log.trace(TAG_HASP, F("Custom theme loaded"));
} else { } else {
Log.error(TAG_HASP, F("No theme could be loaded")); Log.error(TAG_HASP, F("Theme could not be loaded"));
} }
// lv_theme_set_current(th); // lv_theme_set_current(th);
/* ********** Theme Initializations ********** */ /* ********** Theme Initializations ********** */

View File

@ -1472,8 +1472,11 @@ void webHandleHaspConfig()
httpMessage += F("<p><b>UI Theme</b> <i><small>(required)</small></i><select id='theme' name='theme'>"); httpMessage += F("<p><b>UI Theme</b> <i><small>(required)</small></i><select id='theme' name='theme'>");
uint8_t themeid = settings[FPSTR(F_CONFIG_THEME)].as<uint8_t>(); uint8_t themeid = settings[FPSTR(F_CONFIG_THEME)].as<uint8_t>();
httpMessage += getOption(0, F("Built-in"), themeid == 0); // httpMessage += getOption(0, F("Built-in"), themeid == 0);
httpMessage += getOption(8, F("Hasp"), themeid == 8); #if LV_USE_THEME_HASP == 1
httpMessage += getOption(2, F("Hasp Dark"), themeid == 2);
httpMessage += getOption(1, F("Hasp Light"), themeid == 1);
#endif
#if LV_USE_THEME_EMPTY == 1 #if LV_USE_THEME_EMPTY == 1
httpMessage += getOption(0, F("Empty"), themeid == 0); httpMessage += getOption(0, F("Empty"), themeid == 0);
#endif #endif
@ -1487,8 +1490,8 @@ void webHandleHaspConfig()
httpMessage += getOption(3, F("Mono"), themeid == 3); httpMessage += getOption(3, F("Mono"), themeid == 3);
#endif #endif
#if LV_USE_THEME_MATERIAL == 1 #if LV_USE_THEME_MATERIAL == 1
httpMessage += getOption(5, F("Material Dark"), themeid == 5);
httpMessage += getOption(4, F("Material Light"), themeid == 4); httpMessage += getOption(4, F("Material Light"), themeid == 4);
httpMessage += getOption(9, F("Material Dark"), themeid == 9);
#endif #endif
#if LV_USE_THEME_ZEN == 1 #if LV_USE_THEME_ZEN == 1
// httpMessage += getOption(5, F("Zen"), themeid == 5); // httpMessage += getOption(5, F("Zen"), themeid == 5);