Enable light/dark theme switch

This commit is contained in:
fvanroie 2020-12-20 22:14:59 +01:00
parent 840adaa2c1
commit 98e2bb1591
3 changed files with 13 additions and 48 deletions

View File

@ -291,8 +291,9 @@ void haspSetup()
if(haspThemeId == 9) haspThemeId = 5; // update old material id
if(haspThemeId <= 0 || haspThemeId > 5) haspThemeId = 1; // check bounds
lv_theme_t * th = NULL;
lv_theme_hasp_flag_t flags = LV_THEME_HASP_FLAG_LIGHT;
lv_theme_t * th = NULL;
lv_theme_hasp_flag_t hasp_flags = LV_THEME_HASP_FLAG_LIGHT;
lv_theme_material_flag_t material_flags = LV_THEME_MATERIAL_FLAG_LIGHT;
switch(haspThemeId) {
#if(LV_USE_THEME_EMPTY == 1)
@ -304,12 +305,12 @@ void haspSetup()
#if(LV_USE_THEME_HASP == 1)
case 2: // Dark
flags = LV_THEME_HASP_FLAG_DARK;
hasp_flags = LV_THEME_HASP_FLAG_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), flags + LV_THEME_HASP_FLAG_NO_FOCUS,
haspFonts[0], haspFonts[1], haspFonts[2], haspFonts[3]);
th = lv_theme_hasp_init(
lv_color_hsv_to_rgb(haspThemeHue, 100, 100), lv_color_hsv_to_rgb(haspThemeHue, 100, 100),
hasp_flags + LV_THEME_HASP_FLAG_NO_FOCUS, haspFonts[0], haspFonts[1], haspFonts[2], haspFonts[3]);
break;
#endif
@ -332,41 +333,20 @@ void haspSetup()
break;
#endif
/*
* LV_THEME_MATERIAL_FLAG_LIGHT: light theme
* LV_THEME_MATERIAL_FLAG_DARK: dark theme
* LV_THEME_MATERIAL_FLAG_NO_TRANSITION: disable transitions (state change animations)
* LV_THEME_MATERIAL_FLAG_NO_FOCUS: disable indication of focused state)
* */
// LV_THEME_MATERIAL_FLAG_NO_TRANSITION : disable transitions(state change animations)
// LV_THEME_MATERIAL_FLAG_NO_FOCUS: disable indication of focused state)
#if LV_USE_THEME_MATERIAL == 1
case 4:
th = lv_theme_material_init(LV_COLOR_PURPLE, LV_COLOR_ORANGE,
LV_THEME_MATERIAL_FLAG_LIGHT + LV_THEME_MATERIAL_FLAG_NO_FOCUS +
LV_THEME_MATERIAL_FLAG_NO_TRANSITION,
haspFonts[0], haspFonts[1], haspFonts[2], haspFonts[3]);
break;
case 5:
case 5: // Dark
material_flags = LV_THEME_MATERIAL_FLAG_DARK;
case 4: // Light
case 9: // Light (old id)
th = lv_theme_material_init(LV_COLOR_PURPLE, LV_COLOR_ORANGE,
LV_THEME_MATERIAL_FLAG_DARK + LV_THEME_MATERIAL_FLAG_NO_FOCUS +
material_flags + LV_THEME_MATERIAL_FLAG_NO_FOCUS +
LV_THEME_MATERIAL_FLAG_NO_TRANSITION,
haspFonts[0], haspFonts[1], haspFonts[2], haspFonts[3]);
break;
#endif
#if LV_USE_THEME_ZEN == 1
case 5:
th = lv_theme_zen_init(haspThemeHue, defaultFont); // lightweight break;
#endif
#if LV_USE_THEME_NEMO == 1
case 6:
th =
// lv_theme_nemo_init(haspThemeHue, defaultFont); // heavy
break;
#endif
#if LV_USE_THEME_TEMPLATE == 1
case 7:
th = lv_theme_template_init(LV_COLOR_PURPLE, LV_COLOR_ORANGE, LV_THEME_DEFAULT_FLAGS, haspFonts[0],

View File

@ -163,12 +163,7 @@ void dispatch_topic_payload(const char * topic, const char * payload)
if(topic == strstr_P(topic, PSTR("command/"))) { // startsWith command/
topic += 8u;
// Log.verbose(TAG_MSGR,F("MQTT IN: command subtopic: %s"), topic);
// '[...]/device/command/p[1].b[4].txt' -m '"Lights On"' ==
// nextionSetAttr("p[1].b[4].txt", "\"Lights On\"")
dispatch_command(topic, (char *)payload);
return;
}

View File

@ -33,7 +33,6 @@ EthernetClient mqttNetworkClient;
#endif
#include "hasp_hal.h"
//#include "hasp_tft.h"
#include "hasp_debug.h"
#include "hasp_config.h"
#include "hasp_dispatch.h"
@ -101,11 +100,6 @@ char mqttGroupName[16] = "";
#define MQTT_PREFIX "hasp"
#endif
/*
const String mqttLightSubscription = "hasp/" + String(haspGetNodename()) + "/light/#";
const String mqttLightBrightSubscription = "hasp/" + String(haspGetNodename()) + "/brightness/#";
*/
PubSubClient mqttClient(mqttNetworkClient);
static void mqttResult(bool result, const char * topic, const char * payload)
@ -196,10 +190,6 @@ static void mqtt_message_cb(char * topic, byte * payload, unsigned int length)
payload[length] = '\0';
}
// Incoming Namespace (replace /device/ with /group/ for group commands)
// '[...]/device/command' -m '' = No command requested, respond with mqttStatusUpdate()
// '[...]/device/command' -m 'dim=50' = nextionSendCmd("dim=50")
Log.notice(TAG_MQTT_RCV, F("%s = %s"), topic, (char *)payload);
if(topic == strstr(topic, mqttNodeTopic)) { // startsWith mqttNodeTopic