Theme update

This commit is contained in:
fvanroie 2020-10-28 18:00:49 +01:00
parent 7c966e7a2d
commit ae6cad97c4
5 changed files with 712 additions and 359 deletions

View File

@ -402,6 +402,7 @@ typedef void* lv_font_user_data_t;
#define LV_USE_THEME_EMPTY 1 #define LV_USE_THEME_EMPTY 1
#define LV_USE_THEME_TEMPLATE 1 #define LV_USE_THEME_TEMPLATE 1
#define LV_USE_THEME_HASP 1
/*================= /*=================
* Text settings * Text settings

View File

@ -24,6 +24,7 @@
//#include "hasp_attr_get.h" //#include "hasp_attr_get.h"
#include "hasp_attribute.h" #include "hasp_attribute.h"
#include "hasp.h" #include "hasp.h"
#include "lv_theme_hasp.h"
#include "EEPROM.h" #include "EEPROM.h"
@ -358,7 +359,7 @@ void haspSetup()
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266) #if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
lv_zifont_init(); lv_zifont_init();
if(lv_zifont_font_init(&haspFonts[0], haspZiFontPath, 24) != 0) { if(lv_zifont_font_init(&haspFonts[0], haspZiFontPath, 32) != 0) {
Log.error(F("HASP: Failed to set font to %s"), haspZiFontPath); Log.error(F("HASP: Failed to set font to %s"), haspZiFontPath);
haspFonts[0] = LV_FONT_DEFAULT; haspFonts[0] = LV_FONT_DEFAULT;
} else { } else {
@ -416,10 +417,11 @@ void haspSetup()
th = lv_theme_templ_init(haspThemeHue, defaultFont); // lightweight, not for production... th = lv_theme_templ_init(haspThemeHue, defaultFont); // lightweight, not for production...
break; break;
#endif #endif
#if(LV_USE_THEME_HASP == 1) || (LV_USE_THEME_TEMPLATE == 1) #if(LV_USE_THEME_HASP == 1)
case 8: case 8:
th = lv_theme_template_init(LV_COLOR_PURPLE, LV_COLOR_ORANGE, LV_THEME_DEFAULT_FLAGS, haspFonts[0], th = lv_theme_hasp_init(lv_color_hsv_to_rgb(haspThemeHue, 100, 100),
haspFonts[1], haspFonts[2], haspFonts[3]); lv_color_hsv_to_rgb(haspThemeHue, 100, 100), LV_THEME_DEFAULT_FLAGS, haspFonts[0],
haspFonts[1], haspFonts[2], haspFonts[3]);
break; break;
#endif #endif
/* case 0: /* case 0:

View File

@ -5,7 +5,7 @@
#include "hasp_conf.h" #include "hasp_conf.h"
#include "hasp_spiffs.h" #include "hasp_spiffs.h"
#if HASP_USE_SPIFFS>0 #if HASP_USE_SPIFFS > 0
#if defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP32)
#include "SPIFFS.h" #include "SPIFFS.h"
#endif #endif
@ -69,20 +69,31 @@ void spiffsInfo()
void spiffsList() void spiffsList()
{ {
Log.verbose(F("FILE: Listing files on the internal flash:")); #if HASP_USE_SPIFFS > 0
#if defined(ARDUINO_ARCH_ESP8266)
if(!SPIFFS.begin()) {
#else
if(!SPIFFS.begin(true)) {
#endif
Log.error(F("FILE: Flash file system not mouted."));
} else {
Log.verbose(F("FILE: Listing files on the internal flash:"));
#if defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP32)
File root = SPIFFS.open("/"); File root = SPIFFS.open("/");
File file = root.openNextFile(); File file = root.openNextFile();
while(file) { while(file) {
Log.verbose(F("FILE: * %s (%u bytes)"), file.name(), (uint32_t)file.size()); Log.verbose(F("FILE: * %s (%u bytes)"), file.name(), (uint32_t)file.size());
file = root.openNextFile(); file = root.openNextFile();
} }
#endif #endif
#if defined(ARDUINO_ARCH_ESP8266) #if defined(ARDUINO_ARCH_ESP8266)
Dir dir = SPIFFS.openDir("/"); Dir dir = SPIFFS.openDir("/");
while(dir.next()) { while(dir.next()) {
Log.notice(F("FILE: * %s (%u bytes)"), dir.fileName().c_str(), (uint32_t)dir.fileSize()); Log.notice(F("FILE: * %s (%u bytes)"), dir.fileName().c_str(), (uint32_t)dir.fileSize());
}
#endif
} }
#endif #endif
} }
@ -91,7 +102,7 @@ void spiffsSetup()
{ {
// no SPIFFS settings, as settings depend on SPIFFS // no SPIFFS settings, as settings depend on SPIFFS
#if HASP_USE_SPIFFS>0 #if HASP_USE_SPIFFS > 0
#if defined(ARDUINO_ARCH_ESP8266) #if defined(ARDUINO_ARCH_ESP8266)
if(!SPIFFS.begin()) { if(!SPIFFS.begin()) {
#else #else

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/** /**
* @file lv_theme_default.h * @file lv_theme_hasp.h
* *
*/ */
@ -13,8 +13,7 @@ extern "C" {
/********************* /*********************
* INCLUDES * INCLUDES
*********************/ *********************/
#include "lvgl.h" #include "lv_conf.h"
//#include "../lib/lvgl/src/lv_conf_internal.h"
#if LV_USE_THEME_HASP #if LV_USE_THEME_HASP
@ -31,19 +30,19 @@ extern "C" {
**********************/ **********************/
/** /**
* Initialize the default theme * Initialize the default
* @param hue [0..360] hue value from HSV color space to define the theme's base color * @param color_primary the primary color of the theme
* @param font pointer to a font (NULL to use the default) * @param color_secondary the secondary color for the theme
* @return pointer to the initialized theme * @param flags ORed flags starting with `LV_THEME_DEF_FLAG_...`
* @param font_small pointer to a small font
* @param font_normal pointer to a normal font
* @param font_subtitle pointer to a large font
* @param font_title pointer to a extra large font
* @return a pointer to reference this theme later
*/ */
lv_theme_t * lv_theme_hasp_init(uint16_t hue, lv_font_t * font); lv_theme_t * lv_theme_hasp_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags,
const lv_font_t * font_small, const lv_font_t * font_normal,
/** const lv_font_t * font_subtitle, const lv_font_t * font_title);
* Get a pointer to the theme
* @return pointer to the theme
*/
lv_theme_t * lv_theme_get_hasp(void);
/********************** /**********************
* MACROS * MACROS
**********************/ **********************/
@ -54,4 +53,4 @@ lv_theme_t * lv_theme_get_hasp(void);
} /* extern "C" */ } /* extern "C" */
#endif #endif
#endif /*LV_THEME_TEMPL_H*/ #endif /*LV_THEME_HASP_H*/