Renamed NOTIFIER_CALL_MODE_ to CALL_MODE_

This commit is contained in:
cschwinne 2021-07-09 18:54:28 +02:00
parent 2c6850f6e4
commit a17f83cedd
26 changed files with 129 additions and 128 deletions

View File

@ -6,6 +6,7 @@
- Fixed presets using wrong call mode (e.g. causing buttons to send UDP under direct change type)
- Increased hue buffer
- Renamed `NOTIFIER_CALL_MODE_` to `CALL_MODE_`
#### Build 2107090

View File

@ -123,7 +123,7 @@ class Animated_Staircase : public Usermod {
// Always mark segments as "transitional", we are animating the staircase
segments->setOption(SEG_OPTION_TRANSITIONAL, 1, 1);
}
colorUpdated(NOTIFIER_CALL_MODE_DIRECT_CHANGE);
colorUpdated(CALL_MODE_DIRECT_CHANGE);
}
/*
@ -298,7 +298,7 @@ class Animated_Staircase : public Usermod {
}
segments->setOption(SEG_OPTION_ON, 1, 1);
}
colorUpdated(NOTIFIER_CALL_MODE_DIRECT_CHANGE);
colorUpdated(CALL_MODE_DIRECT_CHANGE);
DEBUG_PRINTLN(F("Animated Staircase disabled."));
}
enabled = enable;

View File

@ -62,7 +62,7 @@ class PIRsensorSwitch : public Usermod {
// PIR sensor pin
const uint8_t PIRsensorPin = 13; // D7 on D1 mini
// notification mode for colorUpdated()
const byte NotifyUpdateMode = NOTIFIER_CALL_MODE_NO_NOTIFY; // NOTIFIER_CALL_MODE_DIRECT_CHANGE
const byte NotifyUpdateMode = CALL_MODE_NO_NOTIFY; // CALL_MODE_DIRECT_CHANGE
// 1 min delay before switch off after the sensor state goes LOW
uint32_t m_switchOffDelay = 60000;
// off timer start time

View File

@ -58,7 +58,7 @@ private:
// PIR sensor pin
int8_t PIRsensorPin = PIR_SENSOR_PIN;
// notification mode for colorUpdated()
const byte NotifyUpdateMode = NOTIFIER_CALL_MODE_NO_NOTIFY; // NOTIFIER_CALL_MODE_DIRECT_CHANGE
const byte NotifyUpdateMode = CALL_MODE_NO_NOTIFY; // CALL_MODE_DIRECT_CHANGE
// delay before switch off after the sensor state goes LOW
uint32_t m_switchOffDelay = 600000; // 10min
// off timer start time

View File

@ -54,46 +54,46 @@ void userLoop()
switch (myKey) {
case '1':
applyPreset(1);
colorUpdated(NOTIFIER_CALL_MODE_FX_CHANGED);
colorUpdated(CALL_MODE_FX_CHANGED);
break;
case '2':
applyPreset(2);
colorUpdated(NOTIFIER_CALL_MODE_FX_CHANGED);
colorUpdated(CALL_MODE_FX_CHANGED);
break;
case '3':
applyPreset(3);
colorUpdated(NOTIFIER_CALL_MODE_FX_CHANGED);
colorUpdated(CALL_MODE_FX_CHANGED);
break;
case '4':
applyPreset(4);
colorUpdated(NOTIFIER_CALL_MODE_FX_CHANGED);
colorUpdated(CALL_MODE_FX_CHANGED);
break;
case '5':
applyPreset(5);
colorUpdated(NOTIFIER_CALL_MODE_FX_CHANGED);
colorUpdated(CALL_MODE_FX_CHANGED);
break;
case '6':
applyPreset(6);
colorUpdated(NOTIFIER_CALL_MODE_FX_CHANGED);
colorUpdated(CALL_MODE_FX_CHANGED);
break;
case 'A':
applyPreset(7);
colorUpdated(NOTIFIER_CALL_MODE_FX_CHANGED);
colorUpdated(CALL_MODE_FX_CHANGED);
break;
case 'B':
applyPreset(8);
colorUpdated(NOTIFIER_CALL_MODE_FX_CHANGED);
colorUpdated(CALL_MODE_FX_CHANGED);
break;
case '7':
effectCurrent += 1;
if (effectCurrent >= MODE_COUNT) effectCurrent = 0;
colorUpdated(NOTIFIER_CALL_MODE_FX_CHANGED);
colorUpdated(CALL_MODE_FX_CHANGED);
break;
case '*':
effectCurrent -= 1;
if (effectCurrent < 0) effectCurrent = (MODE_COUNT-1);
colorUpdated(NOTIFIER_CALL_MODE_FX_CHANGED);
colorUpdated(CALL_MODE_FX_CHANGED);
break;
case '8':
@ -102,7 +102,7 @@ void userLoop()
} else if (effectSpeed < 255) {
effectSpeed += 1;
}
colorUpdated(NOTIFIER_CALL_MODE_FX_CHANGED);
colorUpdated(CALL_MODE_FX_CHANGED);
break;
case '0':
if (effectSpeed > 15) {
@ -110,7 +110,7 @@ void userLoop()
} else if (effectSpeed > 0) {
effectSpeed -= 1;
}
colorUpdated(NOTIFIER_CALL_MODE_FX_CHANGED);
colorUpdated(CALL_MODE_FX_CHANGED);
break;
case '9':
@ -119,7 +119,7 @@ void userLoop()
} else if (effectIntensity < 255) {
effectIntensity += 1;
}
colorUpdated(NOTIFIER_CALL_MODE_FX_CHANGED);
colorUpdated(CALL_MODE_FX_CHANGED);
break;
case '#':
if (effectIntensity > 15) {
@ -127,18 +127,18 @@ void userLoop()
} else if (effectIntensity > 0) {
effectIntensity -= 1;
}
colorUpdated(NOTIFIER_CALL_MODE_FX_CHANGED);
colorUpdated(CALL_MODE_FX_CHANGED);
break;
case 'C':
effectPalette += 1;
if (effectPalette >= 50) effectPalette = 0;
colorUpdated(NOTIFIER_CALL_MODE_FX_CHANGED);
colorUpdated(CALL_MODE_FX_CHANGED);
break;
case 'D':
effectPalette -= 1;
if (effectPalette <= 0) effectPalette = 50;
colorUpdated(NOTIFIER_CALL_MODE_FX_CHANGED);
colorUpdated(CALL_MODE_FX_CHANGED);
break;
}

View File

@ -39,7 +39,7 @@ void userLoop() {
//call for notifier -> 0: init 1: direct change 2: button 3: notification 4: nightlight 5: other (No notification)
// 6: fx changed 7: hue 8: preset cycle 9: blynk 10: alexa
colorUpdated(NOTIFIER_CALL_MODE_FX_CHANGED);
colorUpdated(CALL_MODE_FX_CHANGED);
lastTime = millis();
}
}

View File

@ -42,7 +42,7 @@ class StairwayWipeUsermod : public Usermod {
if (millis() + strip.timebase > (cycleTime - 25)) { //wipe complete
effectCurrent = FX_MODE_STATIC;
timeStaticStart = millis();
colorUpdated(NOTIFIER_CALL_MODE_NOTIFICATION);
colorUpdated(CALL_MODE_NOTIFICATION);
wipeState = 2;
}
} else if (wipeState == 2) { //static
@ -54,7 +54,7 @@ class StairwayWipeUsermod : public Usermod {
#ifdef STAIRCASE_WIPE_OFF
effectCurrent = FX_MODE_COLOR_WIPE;
strip.timebase = 360 + (255 - effectSpeed)*75 - millis(); //make sure wipe starts fully lit
colorUpdated(NOTIFIER_CALL_MODE_NOTIFICATION);
colorUpdated(CALL_MODE_NOTIFICATION);
wipeState = 4;
#else
turnOff();
@ -100,7 +100,7 @@ class StairwayWipeUsermod : public Usermod {
bool doReverse = (userVar0 == 2);
seg.setOption(1, doReverse);
colorUpdated(NOTIFIER_CALL_MODE_NOTIFICATION);
colorUpdated(CALL_MODE_NOTIFICATION);
}
void turnOff()
@ -111,7 +111,7 @@ class StairwayWipeUsermod : public Usermod {
transitionDelayTemp = 4000; //fade out slowly
#endif
bri = 0;
colorUpdated(NOTIFIER_CALL_MODE_NOTIFICATION);
colorUpdated(CALL_MODE_NOTIFICATION);
wipeState = 0;
userVar0 = 0;
previousUserVar0 = 0;

View File

@ -47,7 +47,7 @@ void userLoop()
if (millis() + strip.timebase > (cycleTime - 25)) { //wipe complete
effectCurrent = FX_MODE_STATIC;
timeStaticStart = millis();
colorUpdated(NOTIFIER_CALL_MODE_NOTIFICATION);
colorUpdated(CALL_MODE_NOTIFICATION);
wipeState = 2;
}
} else if (wipeState == 2) { //static
@ -59,7 +59,7 @@ void userLoop()
#ifdef STAIRCASE_WIPE_OFF
effectCurrent = FX_MODE_COLOR_WIPE;
strip.timebase = 360 + (255 - effectSpeed)*75 - millis(); //make sure wipe starts fully lit
colorUpdated(NOTIFIER_CALL_MODE_NOTIFICATION);
colorUpdated(CALL_MODE_NOTIFICATION);
wipeState = 4;
#else
turnOff();
@ -93,7 +93,7 @@ void startWipe()
bool doReverse = (userVar0 == 2);
seg.setOption(1, doReverse);
colorUpdated(NOTIFIER_CALL_MODE_NOTIFICATION);
colorUpdated(CALL_MODE_NOTIFICATION);
}
void turnOff()
@ -104,7 +104,7 @@ void turnOff()
transitionDelayTemp = 4000; //fade out slowly
#endif
bri = 0;
colorUpdated(NOTIFIER_CALL_MODE_NOTIFICATION);
colorUpdated(CALL_MODE_NOTIFICATION);
wipeState = 0;
userVar0 = 0;
previousUserVar0 = 0;

View File

@ -138,8 +138,8 @@ public:
}
//call for notifier -> 0: init 1: direct change 2: button 3: notification 4: nightlight 5: other (No notification)
// 6: fx changed 7: hue 8: preset cycle 9: blynk 10: alexa
colorUpdated(NOTIFIER_CALL_MODE_BUTTON);
updateInterfaces(NOTIFIER_CALL_MODE_BUTTON);
colorUpdated(CALL_MODE_BUTTON);
updateInterfaces(CALL_MODE_BUTTON);
}
Enc_A_prev = Enc_A; // Store value of A for next time
loopTime = currentTime; // Updates loopTime

View File

@ -267,8 +267,8 @@ public:
//call for notifier -> 0: init 1: direct change 2: button 3: notification 4: nightlight 5: other (No notification)
// 6: fx changed 7: hue 8: preset cycle 9: blynk 10: alexa
colorUpdated(NOTIFIER_CALL_MODE_DIRECT_CHANGE);
updateInterfaces(NOTIFIER_CALL_MODE_DIRECT_CHANGE);
colorUpdated(CALL_MODE_DIRECT_CHANGE);
updateInterfaces(CALL_MODE_DIRECT_CHANGE);
}
void changeBrightness(bool increase) {

View File

@ -64,13 +64,13 @@ void hourChime()
{
//strip.resetSegments();
selectWordSegments(true);
colorUpdated(NOTIFIER_CALL_MODE_FX_CHANGED);
colorUpdated(CALL_MODE_FX_CHANGED);
savePreset(13, false);
selectWordSegments(false);
//strip.getSegment(0).setOption(0, true);
strip.getSegment(0).setOption(2, true);
applyPreset(12);
colorUpdated(NOTIFIER_CALL_MODE_FX_CHANGED);
colorUpdated(CALL_MODE_FX_CHANGED);
}
void displayTime(byte hour, byte minute)

View File

@ -44,10 +44,10 @@ void onAlexaChange(EspalexaDevice* dev)
if (bri == 0)
{
bri = briLast;
colorUpdated(NOTIFIER_CALL_MODE_ALEXA);
colorUpdated(CALL_MODE_ALEXA);
}
} else {
applyPreset(macroAlexaOn, NOTIFIER_CALL_MODE_ALEXA);
applyPreset(macroAlexaOn, CALL_MODE_ALEXA);
if (bri == 0) espalexaDevice->setValue(briLast); //stop Alexa from complaining if macroAlexaOn does not actually turn on
}
} else if (m == EspalexaDeviceProperty::off)
@ -58,16 +58,16 @@ void onAlexaChange(EspalexaDevice* dev)
{
briLast = bri;
bri = 0;
colorUpdated(NOTIFIER_CALL_MODE_ALEXA);
colorUpdated(CALL_MODE_ALEXA);
}
} else {
applyPreset(macroAlexaOff, NOTIFIER_CALL_MODE_ALEXA);
applyPreset(macroAlexaOff, CALL_MODE_ALEXA);
if (bri != 0) espalexaDevice->setValue(0); //stop Alexa from complaining if macroAlexaOff does not actually turn off
}
} else if (m == EspalexaDeviceProperty::bri)
{
bri = espalexaDevice->getValue();
colorUpdated(NOTIFIER_CALL_MODE_ALEXA);
colorUpdated(CALL_MODE_ALEXA);
} else //color
{
if (espalexaDevice->getColorMode() == EspalexaColorMode::ct) //shade of white
@ -93,7 +93,7 @@ void onAlexaChange(EspalexaDevice* dev)
col[2] = ( color & 0xFF);
col[3] = 0;
}
colorUpdated(NOTIFIER_CALL_MODE_ALEXA);
colorUpdated(CALL_MODE_ALEXA);
}
}

View File

@ -44,45 +44,45 @@ void updateBlynk()
BLYNK_WRITE(V0)
{
bri = param.asInt();//bri
colorUpdated(NOTIFIER_CALL_MODE_BLYNK);
colorUpdated(CALL_MODE_BLYNK);
}
BLYNK_WRITE(V1)
{
blHue = param.asInt();//hue
colorHStoRGB(blHue*10,blSat,(false)? colSec:col);
colorUpdated(NOTIFIER_CALL_MODE_BLYNK);
colorUpdated(CALL_MODE_BLYNK);
}
BLYNK_WRITE(V2)
{
blSat = param.asInt();//sat
colorHStoRGB(blHue*10,blSat,(false)? colSec:col);
colorUpdated(NOTIFIER_CALL_MODE_BLYNK);
colorUpdated(CALL_MODE_BLYNK);
}
BLYNK_WRITE(V3)
{
bool on = (param.asInt()>0);
if (!on != !bri) {toggleOnOff(); colorUpdated(NOTIFIER_CALL_MODE_BLYNK);}
if (!on != !bri) {toggleOnOff(); colorUpdated(CALL_MODE_BLYNK);}
}
BLYNK_WRITE(V4)
{
effectCurrent = param.asInt()-1;//fx
colorUpdated(NOTIFIER_CALL_MODE_BLYNK);
colorUpdated(CALL_MODE_BLYNK);
}
BLYNK_WRITE(V5)
{
effectSpeed = param.asInt();//sx
colorUpdated(NOTIFIER_CALL_MODE_BLYNK);
colorUpdated(CALL_MODE_BLYNK);
}
BLYNK_WRITE(V6)
{
effectIntensity = param.asInt();//ix
colorUpdated(NOTIFIER_CALL_MODE_BLYNK);
colorUpdated(CALL_MODE_BLYNK);
}
BLYNK_WRITE(V7)

View File

@ -13,9 +13,9 @@ void shortPressAction(uint8_t b)
if (!macroButton[b])
{
toggleOnOff();
colorUpdated(NOTIFIER_CALL_MODE_BUTTON);
colorUpdated(CALL_MODE_BUTTON);
} else {
applyPreset(macroButton[b], NOTIFIER_CALL_MODE_BUTTON);
applyPreset(macroButton[b], CALL_MODE_BUTTON);
}
// publish MQTT message
@ -62,14 +62,14 @@ void handleSwitch(uint8_t b)
if (millis() - buttonPressedTime[b] > WLED_DEBOUNCE_THRESHOLD) { //fire edge event only after 50ms without change (debounce)
if (!buttonPressedBefore[b]) { // on -> off
if (macroButton[b]) applyPreset(macroButton[b], NOTIFIER_CALL_MODE_BUTTON);
if (macroButton[b]) applyPreset(macroButton[b], CALL_MODE_BUTTON);
else { //turn on
if (!bri) {toggleOnOff(); colorUpdated(NOTIFIER_CALL_MODE_BUTTON);}
if (!bri) {toggleOnOff(); colorUpdated(CALL_MODE_BUTTON);}
}
} else { // off -> on
if (macroLongPress[b]) applyPreset(macroLongPress[b], NOTIFIER_CALL_MODE_BUTTON);
if (macroLongPress[b]) applyPreset(macroLongPress[b], CALL_MODE_BUTTON);
else { //turn off
if (bri) {toggleOnOff(); colorUpdated(NOTIFIER_CALL_MODE_BUTTON);}
if (bri) {toggleOnOff(); colorUpdated(CALL_MODE_BUTTON);}
}
}
@ -154,14 +154,14 @@ void handleAnalog(uint8_t b)
seg.setOption(SEG_OPTION_ON, 1);
}
// this will notify clients of update (websockets,mqtt,etc)
updateInterfaces(NOTIFIER_CALL_MODE_BUTTON);
updateInterfaces(CALL_MODE_BUTTON);
}
} else {
//TODO:
// we can either trigger a preset depending on the level (between short and long entries)
// or use it for RGBW direct control
}
colorUpdated(NOTIFIER_CALL_MODE_BUTTON);
colorUpdated(CALL_MODE_BUTTON);
}
void handleButton()
@ -195,7 +195,7 @@ void handleButton()
{
if (!buttonLongPressed[b])
{
if (macroLongPress[b]) {applyPreset(macroLongPress[b], NOTIFIER_CALL_MODE_BUTTON);}
if (macroLongPress[b]) {applyPreset(macroLongPress[b], CALL_MODE_BUTTON);}
else _setRandomColor(false,true);
// publish MQTT message
@ -224,7 +224,7 @@ void handleButton()
if (macroDoublePress[b])
{
if (doublePress) {
applyPreset(macroDoublePress[b], NOTIFIER_CALL_MODE_BUTTON);
applyPreset(macroDoublePress[b], CALL_MODE_BUTTON);
// publish MQTT message
if (buttonPublishMqtt && WLED_MQTT_CONNECTED) {

View File

@ -66,18 +66,18 @@
#define AP_BEHAVIOR_BUTTON_ONLY 3 //Only when button pressed for 6 sec
//Notifier callMode
#define NOTIFIER_CALL_MODE_INIT 0 //no updates on init, can be used to disable updates
#define NOTIFIER_CALL_MODE_DIRECT_CHANGE 1
#define NOTIFIER_CALL_MODE_BUTTON 2
#define NOTIFIER_CALL_MODE_NOTIFICATION 3
#define NOTIFIER_CALL_MODE_NIGHTLIGHT 4
#define NOTIFIER_CALL_MODE_NO_NOTIFY 5
#define NOTIFIER_CALL_MODE_FX_CHANGED 6 //no longer used
#define NOTIFIER_CALL_MODE_HUE 7
#define NOTIFIER_CALL_MODE_PRESET_CYCLE 8
#define NOTIFIER_CALL_MODE_BLYNK 9
#define NOTIFIER_CALL_MODE_ALEXA 10
#define NOTIFIER_CALL_MODE_WS_SEND 11 //special call mode, not for notifier, updates websocket only
#define CALL_MODE_INIT 0 //no updates on init, can be used to disable updates
#define CALL_MODE_DIRECT_CHANGE 1
#define CALL_MODE_BUTTON 2
#define CALL_MODE_NOTIFICATION 3
#define CALL_MODE_NIGHTLIGHT 4
#define CALL_MODE_NO_NOTIFY 5
#define CALL_MODE_FX_CHANGED 6 //no longer used
#define CALL_MODE_HUE 7
#define CALL_MODE_PRESET_CYCLE 8
#define CALL_MODE_BLYNK 9
#define CALL_MODE_ALEXA 10
#define CALL_MODE_WS_SEND 11 //special call mode, not for notifier, updates websocket only
//RGB to RGBW conversion mode
#define RGBW_MODE_MANUAL_ONLY 0 //No automatic white channel calculation. Manual white channel slider

View File

@ -156,9 +156,9 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){
col[3] = e131_data[DMXAddress+11]; //white
colSec[3] = e131_data[DMXAddress+12];
}
transitionDelayTemp = 0; // act fast
colorUpdated(NOTIFIER_CALL_MODE_NOTIFICATION); // don't send UDP
return; // don't activate realtime live mode
transitionDelayTemp = 0; // act fast
colorUpdated(CALL_MODE_NOTIFICATION); // don't send UDP
return; // don't activate realtime live mode
break;
case DMX_MODE_MULTIPLE_DRGB:

View File

@ -120,7 +120,7 @@ void handleIR();
#include "FX.h"
void deserializeSegment(JsonObject elem, byte it, byte presetId = 0);
bool deserializeState(JsonObject root, byte callMode = NOTIFIER_CALL_MODE_DIRECT_CHANGE, byte presetId = 0);
bool deserializeState(JsonObject root, byte callMode = CALL_MODE_DIRECT_CHANGE, byte presetId = 0);
void serializeSegment(JsonObject& root, WS2812FX::Segment& seg, byte id, bool forPreset = false, bool segmentBounds = true);
void serializeState(JsonObject root, bool forPreset = false, bool includeBri = true, bool segmentBounds = true);
void serializeInfo(JsonObject root);
@ -181,7 +181,7 @@ void loadPlaylist(JsonObject playlistObject, byte presetId = 0);
void handlePlaylist();
//presets.cpp
bool applyPreset(byte index, byte callMode = NOTIFIER_CALL_MODE_DIRECT_CHANGE);
bool applyPreset(byte index, byte callMode = CALL_MODE_DIRECT_CHANGE);
void savePreset(byte index, bool persist = true, const char* pname = nullptr, JsonObject saveobj = JsonObject());
void deletePreset(byte index);

View File

@ -10,7 +10,7 @@ void handleHue()
{
if (hueReceived)
{
colorUpdated(NOTIFIER_CALL_MODE_HUE); hueReceived = false;
colorUpdated(CALL_MODE_HUE); hueReceived = false;
if (hueStoreAllowed && hueNewKey)
{
serializeConfigSec(); //save api key

View File

@ -71,7 +71,7 @@ void decBrightness()
// apply preset or fallback to a effect and palette if it doesn't exist
void presetFallback(uint8_t presetID, uint8_t effectID, uint8_t paletteID)
{
if (!applyPreset(presetID, NOTIFIER_CALL_MODE_BUTTON)) {
if (!applyPreset(presetID, CALL_MODE_BUTTON)) {
effectCurrent = effectID;
effectPalette = paletteID;
}
@ -85,11 +85,11 @@ bool decodeIRCustom(uint32_t code)
{
//just examples, feel free to modify or remove
case IRCUSTOM_ONOFF : toggleOnOff(); break;
case IRCUSTOM_MACRO1 : applyPreset(1, NOTIFIER_CALL_MODE_BUTTON); break;
case IRCUSTOM_MACRO1 : applyPreset(1, CALL_MODE_BUTTON); break;
default: return false;
}
if (code != IRCUSTOM_MACRO1) colorUpdated(NOTIFIER_CALL_MODE_BUTTON); //don't update color again if we apply macro, it already does it
if (code != IRCUSTOM_MACRO1) colorUpdated(CALL_MODE_BUTTON); //don't update color again if we apply macro, it already does it
return true;
}
@ -183,51 +183,51 @@ void decodeIR(uint32_t code)
}
if (nightlightActive && bri == 0) nightlightActive = false;
colorUpdated(NOTIFIER_CALL_MODE_BUTTON); //for notifier, IR is considered a button input
colorUpdated(CALL_MODE_BUTTON); //for notifier, IR is considered a button input
}
void applyRepeatActions(){
if (lastRepeatableAction == ACTION_BRIGHT_UP)
{
incBrightness(); colorUpdated(NOTIFIER_CALL_MODE_BUTTON);
incBrightness(); colorUpdated(CALL_MODE_BUTTON);
}
else if (lastRepeatableAction == ACTION_BRIGHT_DOWN )
{
decBrightness(); colorUpdated(NOTIFIER_CALL_MODE_BUTTON);
decBrightness(); colorUpdated(CALL_MODE_BUTTON);
}
if (lastRepeatableAction == ACTION_SPEED_UP)
{
changeEffectSpeed(lastRepeatableValue); colorUpdated(NOTIFIER_CALL_MODE_BUTTON);
changeEffectSpeed(lastRepeatableValue); colorUpdated(CALL_MODE_BUTTON);
}
else if (lastRepeatableAction == ACTION_SPEED_DOWN )
{
changeEffectSpeed(lastRepeatableValue); colorUpdated(NOTIFIER_CALL_MODE_BUTTON);
changeEffectSpeed(lastRepeatableValue); colorUpdated(CALL_MODE_BUTTON);
}
if (lastRepeatableAction == ACTION_INTENSITY_UP)
{
changeEffectIntensity(lastRepeatableValue); colorUpdated(NOTIFIER_CALL_MODE_BUTTON);
changeEffectIntensity(lastRepeatableValue); colorUpdated(CALL_MODE_BUTTON);
}
else if (lastRepeatableAction == ACTION_INTENSITY_DOWN )
{
changeEffectIntensity(lastRepeatableValue); colorUpdated(NOTIFIER_CALL_MODE_BUTTON);
changeEffectIntensity(lastRepeatableValue); colorUpdated(CALL_MODE_BUTTON);
}
if (lastValidCode == IR40_WPLUS)
{
relativeChangeWhite(10); colorUpdated(NOTIFIER_CALL_MODE_BUTTON);
relativeChangeWhite(10); colorUpdated(CALL_MODE_BUTTON);
}
else if (lastValidCode == IR40_WMINUS)
{
relativeChangeWhite(-10, 5); colorUpdated(NOTIFIER_CALL_MODE_BUTTON);
relativeChangeWhite(-10, 5); colorUpdated(CALL_MODE_BUTTON);
}
else if ((lastValidCode == IR24_ON || lastValidCode == IR40_ON) && irTimesRepeated > 7 )
{
nightlightActive = true;
nightlightStartTime = millis();
colorUpdated(NOTIFIER_CALL_MODE_BUTTON);
colorUpdated(CALL_MODE_BUTTON);
}
else if (irEnabled == 8)
{
@ -612,7 +612,7 @@ void decodeIRJson(uint32_t code)
// command is JSON object
//allow applyPreset() to reuse JSON buffer, or it would alloc. a second buffer and run out of mem.
fileDoc = &irDoc;
deserializeState(jsonCmdObj, NOTIFIER_CALL_MODE_BUTTON);
deserializeState(jsonCmdObj, CALL_MODE_BUTTON);
fileDoc = nullptr;
}
}

View File

@ -312,10 +312,10 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
loadPlaylist(playlist, presetId);
noNotification = true; //do not notify both for this request and the first playlist entry
} else {
interfaceUpdateCallMode = NOTIFIER_CALL_MODE_WS_SEND;
interfaceUpdateCallMode = CALL_MODE_WS_SEND;
}
colorUpdated(noNotification ? NOTIFIER_CALL_MODE_NO_NOTIFY : callMode);
colorUpdated(noNotification ? CALL_MODE_NO_NOTIFY : callMode);
return stateResponse;
}

View File

@ -88,13 +88,13 @@ void colorUpdated(int callMode)
{
//call for notifier -> 0: init 1: direct change 2: button 3: notification 4: nightlight 5: other (No notification)
// 6: fx changed 7: hue 8: preset cycle 9: blynk 10: alexa
if (callMode != NOTIFIER_CALL_MODE_INIT &&
callMode != NOTIFIER_CALL_MODE_DIRECT_CHANGE &&
callMode != NOTIFIER_CALL_MODE_NO_NOTIFY) strip.applyToAllSelected = true; //if not from JSON api, which directly sets segments
if (callMode != CALL_MODE_INIT &&
callMode != CALL_MODE_DIRECT_CHANGE &&
callMode != CALL_MODE_NO_NOTIFY) strip.applyToAllSelected = true; //if not from JSON api, which directly sets segments
bool someSel = false;
if (callMode == NOTIFIER_CALL_MODE_NOTIFICATION) {
if (callMode == CALL_MODE_NOTIFICATION) {
someSel = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects);
}
@ -119,17 +119,17 @@ void colorUpdated(int callMode)
interfaceUpdateCallMode = callMode;
} else {
if (nightlightActive && !nightlightActiveOld &&
callMode != NOTIFIER_CALL_MODE_NOTIFICATION &&
callMode != NOTIFIER_CALL_MODE_NO_NOTIFY)
callMode != CALL_MODE_NOTIFICATION &&
callMode != CALL_MODE_NO_NOTIFY)
{
notify(NOTIFIER_CALL_MODE_NIGHTLIGHT);
interfaceUpdateCallMode = NOTIFIER_CALL_MODE_NIGHTLIGHT;
notify(CALL_MODE_NIGHTLIGHT);
interfaceUpdateCallMode = CALL_MODE_NIGHTLIGHT;
}
}
if (!colChanged) return; //following code is for e.g. initiating transitions
if (callMode != NOTIFIER_CALL_MODE_NO_NOTIFY && nightlightActive && (nightlightMode == NL_MODE_FADE || nightlightMode == NL_MODE_COLORFADE))
if (callMode != CALL_MODE_NO_NOTIFY && nightlightActive && (nightlightMode == NL_MODE_FADE || nightlightMode == NL_MODE_COLORFADE))
{
briNlT = bri;
nightlightDelayMs -= (millis() - nightlightStartTime);
@ -143,19 +143,19 @@ void colorUpdated(int callMode)
if (briT == 0)
{
//setLedsStandard(true); //do not color transition if starting from off!
if (callMode != NOTIFIER_CALL_MODE_NOTIFICATION) resetTimebase(); //effect start from beginning
if (callMode != CALL_MODE_NOTIFICATION) resetTimebase(); //effect start from beginning
}
briIT = bri;
if (bri > 0) briLast = bri;
//deactivate nightlight if target brightness is reached
if (bri == nightlightTargetBri && callMode != NOTIFIER_CALL_MODE_NO_NOTIFY && nightlightMode != NL_MODE_SUN) nightlightActive = false;
if (bri == nightlightTargetBri && callMode != CALL_MODE_NO_NOTIFY && nightlightMode != NL_MODE_SUN) nightlightActive = false;
if (fadeTransition)
{
//set correct delay if not using notification delay
if (callMode != NOTIFIER_CALL_MODE_NOTIFICATION && !jsonTransitionOnce) transitionDelayTemp = transitionDelay;
if (callMode != CALL_MODE_NOTIFICATION && !jsonTransitionOnce) transitionDelayTemp = transitionDelay;
jsonTransitionOnce = false;
strip.setTransition(transitionDelayTemp);
if (transitionDelayTemp == 0) {setLedsStandard(); strip.trigger(); return;}
@ -180,19 +180,19 @@ void colorUpdated(int callMode)
void updateInterfaces(uint8_t callMode)
{
sendDataWs();
if (callMode == NOTIFIER_CALL_MODE_WS_SEND) {
if (callMode == CALL_MODE_WS_SEND) {
lastInterfaceUpdate = millis();
return;
}
#ifndef WLED_DISABLE_ALEXA
if (espalexaDevice != nullptr && callMode != NOTIFIER_CALL_MODE_ALEXA) {
if (espalexaDevice != nullptr && callMode != CALL_MODE_ALEXA) {
espalexaDevice->setValue(bri);
espalexaDevice->setColor(col[0], col[1], col[2]);
}
#endif
if (callMode != NOTIFIER_CALL_MODE_BLYNK &&
callMode != NOTIFIER_CALL_MODE_NO_NOTIFY) updateBlynk();
if (callMode != CALL_MODE_BLYNK &&
callMode != CALL_MODE_NO_NOTIFY) updateBlynk();
doPublishMqtt = true;
lastInterfaceUpdate = millis();
}
@ -254,7 +254,7 @@ void handleNightlight()
if (bri) effectSpeed += 60; //sunset if currently on
briNlT = !bri; //true == sunrise, false == sunset
if (!bri) bri = briLast;
colorUpdated(NOTIFIER_CALL_MODE_NO_NOTIFY);
colorUpdated(CALL_MODE_NO_NOTIFY);
}
}
float nper = (millis() - nightlightStartTime)/((float)nightlightDelayMs);
@ -265,7 +265,7 @@ void handleNightlight()
{
for (byte i=0; i<4; i++) col[i] = colNlT[i]+ ((colSec[i] - colNlT[i])*nper); // fading from actual color to secondary color
}
colorUpdated(NOTIFIER_CALL_MODE_NO_NOTIFY);
colorUpdated(CALL_MODE_NO_NOTIFY);
}
if (nper >= 1) //nightlight duration over
{
@ -273,7 +273,7 @@ void handleNightlight()
if (nightlightMode == NL_MODE_SET)
{
bri = nightlightTargetBri;
colorUpdated(NOTIFIER_CALL_MODE_NO_NOTIFY);
colorUpdated(CALL_MODE_NO_NOTIFY);
}
if (bri == 0) briLast = briNlT;
if (nightlightMode == NL_MODE_SUN)
@ -297,7 +297,7 @@ void handleNightlight()
effectCurrent = colNlT[0];
effectSpeed = colNlT[1];
effectPalette = colNlT[2];
colorUpdated(NOTIFIER_CALL_MODE_NO_NOTIFY);
colorUpdated(CALL_MODE_NO_NOTIFY);
}
nightlightActiveOld = false;
}

View File

@ -15,7 +15,7 @@ void parseMQTTBriPayload(char* payload)
uint8_t in = strtoul(payload, NULL, 10);
if (in == 0 && bri > 0) briLast = bri;
bri = in;
colorUpdated(NOTIFIER_CALL_MODE_DIRECT_CHANGE);
colorUpdated(CALL_MODE_DIRECT_CHANGE);
}
}
@ -88,7 +88,7 @@ void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties
if (strcmp_P(topic, PSTR("/col")) == 0) {
colorFromDecOrHexString(col, (char*)payloadStr);
colorUpdated(NOTIFIER_CALL_MODE_DIRECT_CHANGE);
colorUpdated(CALL_MODE_DIRECT_CHANGE);
} else if (strcmp_P(topic, PSTR("/api")) == 0) {
if (payload[0] == '{') { //JSON API
DynamicJsonDocument doc(JSON_BUFFER_SIZE);

View File

@ -919,7 +919,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
strip.applyToAllSelected = false;
pos = req.indexOf(F("&NN")); //do not send UDP notifications this time
colorUpdated((pos > 0) ? NOTIFIER_CALL_MODE_NO_NOTIFY : NOTIFIER_CALL_MODE_DIRECT_CHANGE);
colorUpdated((pos > 0) ? CALL_MODE_NO_NOTIFY : CALL_MODE_DIRECT_CHANGE);
return true;
}

View File

@ -13,14 +13,14 @@ void notify(byte callMode, bool followUp)
if (!udpConnected) return;
switch (callMode)
{
case NOTIFIER_CALL_MODE_INIT: return;
case NOTIFIER_CALL_MODE_DIRECT_CHANGE: if (!notifyDirect) return; break;
case NOTIFIER_CALL_MODE_BUTTON: if (!notifyButton) return; break;
case NOTIFIER_CALL_MODE_NIGHTLIGHT: if (!notifyDirect) return; break;
case NOTIFIER_CALL_MODE_HUE: if (!notifyHue) return; break;
case NOTIFIER_CALL_MODE_PRESET_CYCLE: if (!notifyDirect) return; break;
case NOTIFIER_CALL_MODE_BLYNK: if (!notifyDirect) return; break;
case NOTIFIER_CALL_MODE_ALEXA: if (!notifyAlexa) return; break;
case CALL_MODE_INIT: return;
case CALL_MODE_DIRECT_CHANGE: if (!notifyDirect) return; break;
case CALL_MODE_BUTTON: if (!notifyButton) return; break;
case CALL_MODE_NIGHTLIGHT: if (!notifyDirect) return; break;
case CALL_MODE_HUE: if (!notifyHue) return; break;
case CALL_MODE_PRESET_CYCLE: if (!notifyDirect) return; break;
case CALL_MODE_BLYNK: if (!notifyDirect) return; break;
case CALL_MODE_ALEXA: if (!notifyAlexa) return; break;
default: return;
}
byte udpOut[WLEDPACKETSIZE];
@ -296,7 +296,7 @@ void handleNotifications()
if (nightlightActive) nightlightDelayMins = udpIn[7];
if (receiveNotificationBrightness || !someSel) bri = udpIn[2];
colorUpdated(NOTIFIER_CALL_MODE_NOTIFICATION);
colorUpdated(CALL_MODE_NOTIFICATION);
return;
}

View File

@ -387,14 +387,14 @@ void WLED::beginStrip()
strip.setShowCallback(handleOverlayDraw);
if (bootPreset > 0) {
applyPreset(bootPreset, NOTIFIER_CALL_MODE_INIT);
applyPreset(bootPreset, CALL_MODE_INIT);
} else if (turnOnAtBoot) {
if (briS > 0) bri = briS;
else if (bri == 0) bri = 128;
} else {
briLast = briS; bri = 0;
}
colorUpdated(NOTIFIER_CALL_MODE_INIT);
colorUpdated(CALL_MODE_INIT);
// init relay pin
if (rlyPin>=0)

View File

@ -453,7 +453,7 @@ WLED_GLOBAL byte touchThreshold _INIT(TOUCH_THRESH
WLED_GLOBAL bool notifyDirectDefault _INIT(notifyDirect);
WLED_GLOBAL bool receiveNotifications _INIT(true);
WLED_GLOBAL unsigned long notificationSentTime _INIT(0);
WLED_GLOBAL byte notificationSentCallMode _INIT(NOTIFIER_CALL_MODE_INIT);
WLED_GLOBAL byte notificationSentCallMode _INIT(CALL_MODE_INIT);
WLED_GLOBAL bool notificationTwoRequired _INIT(false);
// effects
@ -519,7 +519,7 @@ WLED_GLOBAL uint16_t tpmPayloadFrameSize _INIT(0);
// mqtt
WLED_GLOBAL unsigned long lastMqttReconnectAttempt _INIT(0);
WLED_GLOBAL unsigned long lastInterfaceUpdate _INIT(0);
WLED_GLOBAL byte interfaceUpdateCallMode _INIT(NOTIFIER_CALL_MODE_INIT);
WLED_GLOBAL byte interfaceUpdateCallMode _INIT(CALL_MODE_INIT);
WLED_GLOBAL char mqttStatusTopic[40] _INIT(""); // this must be global because of async handlers
// alexa udp