mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-23 19:26:38 +00:00
Enable light/dark theme switch
This commit is contained in:
parent
840adaa2c1
commit
98e2bb1591
46
src/hasp.cpp
46
src/hasp.cpp
@ -291,8 +291,9 @@ void haspSetup()
|
|||||||
if(haspThemeId == 9) haspThemeId = 5; // update old material id
|
if(haspThemeId == 9) haspThemeId = 5; // update old material id
|
||||||
if(haspThemeId <= 0 || haspThemeId > 5) haspThemeId = 1; // check bounds
|
if(haspThemeId <= 0 || haspThemeId > 5) haspThemeId = 1; // check bounds
|
||||||
|
|
||||||
lv_theme_t * th = NULL;
|
lv_theme_t * th = NULL;
|
||||||
lv_theme_hasp_flag_t flags = LV_THEME_HASP_FLAG_LIGHT;
|
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) {
|
switch(haspThemeId) {
|
||||||
#if(LV_USE_THEME_EMPTY == 1)
|
#if(LV_USE_THEME_EMPTY == 1)
|
||||||
@ -304,12 +305,12 @@ void haspSetup()
|
|||||||
|
|
||||||
#if(LV_USE_THEME_HASP == 1)
|
#if(LV_USE_THEME_HASP == 1)
|
||||||
case 2: // Dark
|
case 2: // Dark
|
||||||
flags = LV_THEME_HASP_FLAG_DARK;
|
hasp_flags = LV_THEME_HASP_FLAG_DARK;
|
||||||
case 1: // Light
|
case 1: // Light
|
||||||
case 8: // Light (old id)
|
case 8: // Light (old id)
|
||||||
th = lv_theme_hasp_init(lv_color_hsv_to_rgb(haspThemeHue, 100, 100),
|
th = lv_theme_hasp_init(
|
||||||
lv_color_hsv_to_rgb(haspThemeHue, 100, 100), flags + LV_THEME_HASP_FLAG_NO_FOCUS,
|
lv_color_hsv_to_rgb(haspThemeHue, 100, 100), lv_color_hsv_to_rgb(haspThemeHue, 100, 100),
|
||||||
haspFonts[0], haspFonts[1], haspFonts[2], haspFonts[3]);
|
hasp_flags + LV_THEME_HASP_FLAG_NO_FOCUS, haspFonts[0], haspFonts[1], haspFonts[2], haspFonts[3]);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -332,41 +333,20 @@ void haspSetup()
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
// LV_THEME_MATERIAL_FLAG_NO_TRANSITION : disable transitions(state change animations)
|
||||||
* LV_THEME_MATERIAL_FLAG_LIGHT: light theme
|
// LV_THEME_MATERIAL_FLAG_NO_FOCUS: disable indication of focused state)
|
||||||
* 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)
|
|
||||||
* */
|
|
||||||
|
|
||||||
#if LV_USE_THEME_MATERIAL == 1
|
#if LV_USE_THEME_MATERIAL == 1
|
||||||
case 4:
|
case 5: // Dark
|
||||||
th = lv_theme_material_init(LV_COLOR_PURPLE, LV_COLOR_ORANGE,
|
material_flags = LV_THEME_MATERIAL_FLAG_DARK;
|
||||||
LV_THEME_MATERIAL_FLAG_LIGHT + LV_THEME_MATERIAL_FLAG_NO_FOCUS +
|
case 4: // Light
|
||||||
LV_THEME_MATERIAL_FLAG_NO_TRANSITION,
|
|
||||||
haspFonts[0], haspFonts[1], haspFonts[2], haspFonts[3]);
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
case 9: // Light (old id)
|
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 +
|
material_flags + LV_THEME_MATERIAL_FLAG_NO_FOCUS +
|
||||||
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;
|
||||||
#endif
|
#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
|
#if LV_USE_THEME_TEMPLATE == 1
|
||||||
case 7:
|
case 7:
|
||||||
th = lv_theme_template_init(LV_COLOR_PURPLE, LV_COLOR_ORANGE, LV_THEME_DEFAULT_FLAGS, haspFonts[0],
|
th = lv_theme_template_init(LV_COLOR_PURPLE, LV_COLOR_ORANGE, LV_THEME_DEFAULT_FLAGS, haspFonts[0],
|
||||||
|
@ -163,12 +163,7 @@ void dispatch_topic_payload(const char * topic, const char * payload)
|
|||||||
|
|
||||||
if(topic == strstr_P(topic, PSTR("command/"))) { // startsWith command/
|
if(topic == strstr_P(topic, PSTR("command/"))) { // startsWith command/
|
||||||
topic += 8u;
|
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);
|
dispatch_command(topic, (char *)payload);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@ EthernetClient mqttNetworkClient;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "hasp_hal.h"
|
#include "hasp_hal.h"
|
||||||
//#include "hasp_tft.h"
|
|
||||||
#include "hasp_debug.h"
|
#include "hasp_debug.h"
|
||||||
#include "hasp_config.h"
|
#include "hasp_config.h"
|
||||||
#include "hasp_dispatch.h"
|
#include "hasp_dispatch.h"
|
||||||
@ -101,11 +100,6 @@ char mqttGroupName[16] = "";
|
|||||||
#define MQTT_PREFIX "hasp"
|
#define MQTT_PREFIX "hasp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
const String mqttLightSubscription = "hasp/" + String(haspGetNodename()) + "/light/#";
|
|
||||||
const String mqttLightBrightSubscription = "hasp/" + String(haspGetNodename()) + "/brightness/#";
|
|
||||||
*/
|
|
||||||
|
|
||||||
PubSubClient mqttClient(mqttNetworkClient);
|
PubSubClient mqttClient(mqttNetworkClient);
|
||||||
|
|
||||||
static void mqttResult(bool result, const char * topic, const char * payload)
|
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';
|
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);
|
Log.notice(TAG_MQTT_RCV, F("%s = %s"), topic, (char *)payload);
|
||||||
|
|
||||||
if(topic == strstr(topic, mqttNodeTopic)) { // startsWith mqttNodeTopic
|
if(topic == strstr(topic, mqttNodeTopic)) { // startsWith mqttNodeTopic
|
||||||
|
Loading…
x
Reference in New Issue
Block a user