Refactor callMode (#702)
This commit is contained in:
parent
c1a8fde9a0
commit
1a4061fdb5
@ -39,7 +39,7 @@ void userLoop() {
|
|||||||
|
|
||||||
//call for notifier -> 0: init 1: direct change 2: button 3: notification 4: nightlight 5: other (No notification)
|
//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
|
// 6: fx changed 7: hue 8: preset cycle 9: blynk 10: alexa
|
||||||
colorUpdated(6);
|
colorUpdated(NOTIFIER_CALL_MODE_FX_CHANGED);
|
||||||
lastTime = millis();
|
lastTime = millis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ void userLoop()
|
|||||||
if (millis() + strip.timebase > (cycleTime - 25)) { //wipe complete
|
if (millis() + strip.timebase > (cycleTime - 25)) { //wipe complete
|
||||||
effectCurrent = FX_MODE_STATIC;
|
effectCurrent = FX_MODE_STATIC;
|
||||||
timeStaticStart = millis();
|
timeStaticStart = millis();
|
||||||
colorUpdated(3);
|
colorUpdated(NOTIFIER_CALL_MODE_NOTIFICATION);
|
||||||
wipeState = 2;
|
wipeState = 2;
|
||||||
}
|
}
|
||||||
} else if (wipeState == 2) { //static
|
} else if (wipeState == 2) { //static
|
||||||
@ -59,7 +59,7 @@ void userLoop()
|
|||||||
#ifdef STAIRCASE_WIPE_OFF
|
#ifdef STAIRCASE_WIPE_OFF
|
||||||
effectCurrent = FX_MODE_COLOR_WIPE;
|
effectCurrent = FX_MODE_COLOR_WIPE;
|
||||||
strip.timebase = 360 + (255 - effectSpeed)*75 - millis(); //make sure wipe starts fully lit
|
strip.timebase = 360 + (255 - effectSpeed)*75 - millis(); //make sure wipe starts fully lit
|
||||||
colorUpdated(3);
|
colorUpdated(NOTIFIER_CALL_MODE_NOTIFICATION);
|
||||||
wipeState = 4;
|
wipeState = 4;
|
||||||
#else
|
#else
|
||||||
turnOff();
|
turnOff();
|
||||||
@ -93,7 +93,7 @@ void startWipe()
|
|||||||
bool doReverse = (userVar0 == 2);
|
bool doReverse = (userVar0 == 2);
|
||||||
seg.setOption(1, doReverse);
|
seg.setOption(1, doReverse);
|
||||||
|
|
||||||
colorUpdated(3);
|
colorUpdated(NOTIFIER_CALL_MODE_NOTIFICATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
void turnOff()
|
void turnOff()
|
||||||
@ -104,7 +104,7 @@ void turnOff()
|
|||||||
transitionDelayTemp = 4000; //fade out slowly
|
transitionDelayTemp = 4000; //fade out slowly
|
||||||
#endif
|
#endif
|
||||||
bri = 0;
|
bri = 0;
|
||||||
colorUpdated(3);
|
colorUpdated(NOTIFIER_CALL_MODE_NOTIFICATION);
|
||||||
wipeState = 0;
|
wipeState = 0;
|
||||||
userVar0 = 0;
|
userVar0 = 0;
|
||||||
previousUserVar0 = 0;
|
previousUserVar0 = 0;
|
||||||
|
@ -7,6 +7,19 @@
|
|||||||
#define AP_BEHAVIOR_ALWAYS 2 //Always open
|
#define AP_BEHAVIOR_ALWAYS 2 //Always open
|
||||||
#define AP_BEHAVIOR_BUTTON_ONLY 3 //Only when button pressed for 6 sec
|
#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
|
||||||
|
#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
|
||||||
|
|
||||||
//RGB to RGBW conversion mode
|
//RGB to RGBW conversion mode
|
||||||
#define RGBW_MODE_MANUAL_ONLY 0 //No automatic white channel calculation. Manual white channel slider
|
#define RGBW_MODE_MANUAL_ONLY 0 //No automatic white channel calculation. Manual white channel slider
|
||||||
#define RGBW_MODE_AUTO_BRIGHTER 1 //New algorithm. Adds as much white as the darkest RGBW channel
|
#define RGBW_MODE_AUTO_BRIGHTER 1 //New algorithm. Adds as much white as the darkest RGBW channel
|
||||||
|
@ -301,7 +301,7 @@ unsigned long buttonWaitTime = 0;
|
|||||||
bool notifyDirectDefault = notifyDirect;
|
bool notifyDirectDefault = notifyDirect;
|
||||||
bool receiveNotifications = true;
|
bool receiveNotifications = true;
|
||||||
unsigned long notificationSentTime = 0;
|
unsigned long notificationSentTime = 0;
|
||||||
byte notificationSentCallMode = 0;
|
byte notificationSentCallMode = NOTIFIER_CALL_MODE_INIT;
|
||||||
bool notificationTwoRequired = false;
|
bool notificationTwoRequired = false;
|
||||||
|
|
||||||
//effects
|
//effects
|
||||||
@ -369,7 +369,7 @@ unsigned long realtimeTimeout = 0;
|
|||||||
//mqtt
|
//mqtt
|
||||||
long lastMqttReconnectAttempt = 0;
|
long lastMqttReconnectAttempt = 0;
|
||||||
long lastInterfaceUpdate = 0;
|
long lastInterfaceUpdate = 0;
|
||||||
byte interfaceUpdateCallMode = 0;
|
byte interfaceUpdateCallMode = NOTIFIER_CALL_MODE_INIT;
|
||||||
char mqttStatusTopic[40] = ""; //this must be global because of async handlers
|
char mqttStatusTopic[40] = ""; //this must be global because of async handlers
|
||||||
|
|
||||||
#if AUXPIN >= 0
|
#if AUXPIN >= 0
|
||||||
|
@ -651,7 +651,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req)
|
|||||||
if (pos < 1) XML_response(request);
|
if (pos < 1) XML_response(request);
|
||||||
|
|
||||||
pos = req.indexOf("&NN"); //do not send UDP notifications this time
|
pos = req.indexOf("&NN"); //do not send UDP notifications this time
|
||||||
colorUpdated((pos > 0) ? 5:1);
|
colorUpdated((pos > 0) ? NOTIFIER_CALL_MODE_NO_NOTIFY : NOTIFIER_CALL_MODE_DIRECT_CHANGE);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ void beginStrip()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (bootPreset>0) applyPreset(bootPreset, turnOnAtBoot, true, true);
|
if (bootPreset>0) applyPreset(bootPreset, turnOnAtBoot, true, true);
|
||||||
colorUpdated(0);
|
colorUpdated(NOTIFIER_CALL_MODE_INIT);
|
||||||
|
|
||||||
//init relay pin
|
//init relay pin
|
||||||
#if RLYPIN >= 0
|
#if RLYPIN >= 0
|
||||||
|
@ -11,15 +11,15 @@ void notify(byte callMode, bool followUp=false)
|
|||||||
if (!udpConnected) return;
|
if (!udpConnected) return;
|
||||||
switch (callMode)
|
switch (callMode)
|
||||||
{
|
{
|
||||||
case 0: return;
|
case NOTIFIER_CALL_MODE_INIT: return;
|
||||||
case 1: if (!notifyDirect) return; break;
|
case NOTIFIER_CALL_MODE_DIRECT_CHANGE: if (!notifyDirect) return; break;
|
||||||
case 2: if (!notifyButton) return; break;
|
case NOTIFIER_CALL_MODE_BUTTON: if (!notifyButton) return; break;
|
||||||
case 4: if (!notifyDirect) return; break;
|
case NOTIFIER_CALL_MODE_NIGHTLIGHT: if (!notifyDirect) return; break;
|
||||||
case 6: if (!notifyDirect) return; break; //fx change
|
case NOTIFIER_CALL_MODE_FX_CHANGED: if (!notifyDirect) return; break; //fx change
|
||||||
case 7: if (!notifyHue) return; break;
|
case NOTIFIER_CALL_MODE_HUE: if (!notifyHue) return; break;
|
||||||
case 8: if (!notifyDirect) return; break;
|
case NOTIFIER_CALL_MODE_PRESET_CYCLE: if (!notifyDirect) return; break;
|
||||||
case 9: if (!notifyDirect) return; break;
|
case NOTIFIER_CALL_MODE_BLYNK: if (!notifyDirect) return; break;
|
||||||
case 10: if (!notifyAlexa) return; break;
|
case NOTIFIER_CALL_MODE_ALEXA: if (!notifyAlexa) return; break;
|
||||||
default: return;
|
default: return;
|
||||||
}
|
}
|
||||||
byte udpOut[WLEDPACKETSIZE];
|
byte udpOut[WLEDPACKETSIZE];
|
||||||
@ -157,9 +157,9 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP){
|
|||||||
col[3] = p->property_values[DMXAddress+11]; //white
|
col[3] = p->property_values[DMXAddress+11]; //white
|
||||||
colSec[3] = p->property_values[DMXAddress+12];
|
colSec[3] = p->property_values[DMXAddress+12];
|
||||||
}
|
}
|
||||||
transitionDelayTemp = 0; // act fast
|
transitionDelayTemp = 0; // act fast
|
||||||
colorUpdated(3); // don't send UDP
|
colorUpdated(NOTIFIER_CALL_MODE_NOTIFICATION); // don't send UDP
|
||||||
return; // don't activate realtime live mode
|
return; // don't activate realtime live mode
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DMX_MODE_MULTIPLE_RGB:
|
case DMX_MODE_MULTIPLE_RGB:
|
||||||
@ -329,7 +329,7 @@ void handleNotifications()
|
|||||||
if (nightlightActive) nightlightDelayMins = udpIn[7];
|
if (nightlightActive) nightlightDelayMins = udpIn[7];
|
||||||
|
|
||||||
if (receiveNotificationBrightness || !someSel) bri = udpIn[2];
|
if (receiveNotificationBrightness || !someSel) bri = udpIn[2];
|
||||||
colorUpdated(3);
|
colorUpdated(NOTIFIER_CALL_MODE_NOTIFICATION);
|
||||||
|
|
||||||
} else if (udpIn[0] > 0 && udpIn[0] < 5 && receiveDirect) //1 warls //2 drgb //3 drgbw
|
} else if (udpIn[0] > 0 && udpIn[0] < 5 && receiveDirect) //1 warls //2 drgb //3 drgbw
|
||||||
{
|
{
|
||||||
|
@ -79,6 +79,7 @@ bool colorChanged()
|
|||||||
{
|
{
|
||||||
if (col[i] != colIT[i]) return true;
|
if (col[i] != colIT[i]) return true;
|
||||||
if (colSec[i] != colSecIT[i]) return true;
|
if (colSec[i] != colSecIT[i]) return true;
|
||||||
|
if (col[i] != colNlT[i]) return true;
|
||||||
}
|
}
|
||||||
if (bri != briIT) return true;
|
if (bri != briIT) return true;
|
||||||
return false;
|
return false;
|
||||||
@ -89,18 +90,24 @@ void colorUpdated(int callMode)
|
|||||||
{
|
{
|
||||||
//call for notifier -> 0: init 1: direct change 2: button 3: notification 4: nightlight 5: other (No notification)
|
//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
|
// 6: fx changed 7: hue 8: preset cycle 9: blynk 10: alexa
|
||||||
if (callMode != 0 && callMode != 1 && callMode != 5) strip.applyToAllSelected = true; //if not from JSON api, which directly sets segments
|
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
|
||||||
|
|
||||||
bool fxChanged = strip.setEffectConfig(effectCurrent, effectSpeed, effectIntensity, effectPalette);
|
bool fxChanged = strip.setEffectConfig(effectCurrent, effectSpeed, effectIntensity, effectPalette);
|
||||||
if (!colorChanged())
|
if (!colorChanged())
|
||||||
{
|
{
|
||||||
if (nightlightActive && !nightlightActiveOld && callMode != 3 && callMode != 5)
|
if (nightlightActive && !nightlightActiveOld &&
|
||||||
|
callMode != NOTIFIER_CALL_MODE_NOTIFICATION &&
|
||||||
|
callMode != NOTIFIER_CALL_MODE_NO_NOTIFY)
|
||||||
{
|
{
|
||||||
notify(4); interfaceUpdateCallMode = 4; return;
|
notify(NOTIFIER_CALL_MODE_NIGHTLIGHT);
|
||||||
|
interfaceUpdateCallMode = NOTIFIER_CALL_MODE_NIGHTLIGHT;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if (fxChanged) {
|
else if (fxChanged) {
|
||||||
notify(6);
|
notify(NOTIFIER_CALL_MODE_FX_CHANGED);
|
||||||
if (callMode != 8) interfaceUpdateCallMode = 6;
|
if (callMode != NOTIFIER_CALL_MODE_PRESET_CYCLE) interfaceUpdateCallMode = NOTIFIER_CALL_MODE_FX_CHANGED;
|
||||||
if (realtimeTimeout == UINT32_MAX) realtimeTimeout = 0;
|
if (realtimeTimeout == UINT32_MAX) realtimeTimeout = 0;
|
||||||
if (isPreset) {isPreset = false;}
|
if (isPreset) {isPreset = false;}
|
||||||
else {currentPreset = -1;}
|
else {currentPreset = -1;}
|
||||||
@ -110,7 +117,7 @@ void colorUpdated(int callMode)
|
|||||||
if (realtimeTimeout == UINT32_MAX) realtimeTimeout = 0;
|
if (realtimeTimeout == UINT32_MAX) realtimeTimeout = 0;
|
||||||
if (isPreset) {isPreset = false;}
|
if (isPreset) {isPreset = false;}
|
||||||
else {currentPreset = -1;}
|
else {currentPreset = -1;}
|
||||||
if (callMode != 5 && nightlightActive && nightlightFade)
|
if (callMode != NOTIFIER_CALL_MODE_NO_NOTIFY && nightlightActive && nightlightFade)
|
||||||
{
|
{
|
||||||
briNlT = bri;
|
briNlT = bri;
|
||||||
nightlightDelayMs -= (millis() - nightlightStartTime);
|
nightlightDelayMs -= (millis() - nightlightStartTime);
|
||||||
@ -123,8 +130,8 @@ void colorUpdated(int callMode)
|
|||||||
}
|
}
|
||||||
if (briT == 0)
|
if (briT == 0)
|
||||||
{
|
{
|
||||||
setLedsStandard(true); //do not color transition if starting from off
|
setLedsStandard(true); //do not color transition if starting from off
|
||||||
if (callMode != 3) resetTimebase(); //effect start from beginning
|
if (callMode != NOTIFIER_CALL_MODE_NOTIFICATION) resetTimebase(); //effect start from beginning
|
||||||
}
|
}
|
||||||
|
|
||||||
briIT = bri;
|
briIT = bri;
|
||||||
@ -135,7 +142,7 @@ void colorUpdated(int callMode)
|
|||||||
if (fadeTransition)
|
if (fadeTransition)
|
||||||
{
|
{
|
||||||
//set correct delay if not using notification delay
|
//set correct delay if not using notification delay
|
||||||
if (callMode != 3 && !jsonTransitionOnce) transitionDelayTemp = transitionDelay;
|
if (callMode != NOTIFIER_CALL_MODE_NOTIFICATION && !jsonTransitionOnce) transitionDelayTemp = transitionDelay;
|
||||||
jsonTransitionOnce = false;
|
jsonTransitionOnce = false;
|
||||||
if (transitionDelayTemp == 0) {setLedsStandard(); strip.trigger(); return;}
|
if (transitionDelayTemp == 0) {setLedsStandard(); strip.trigger(); return;}
|
||||||
|
|
||||||
@ -158,7 +165,7 @@ void colorUpdated(int callMode)
|
|||||||
strip.trigger();
|
strip.trigger();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (callMode == 8) return;
|
if (callMode == NOTIFIER_CALL_MODE_PRESET_CYCLE) return;
|
||||||
//set flag to update blynk and mqtt
|
//set flag to update blynk and mqtt
|
||||||
interfaceUpdateCallMode = callMode;
|
interfaceUpdateCallMode = callMode;
|
||||||
}
|
}
|
||||||
@ -167,12 +174,13 @@ void colorUpdated(int callMode)
|
|||||||
void updateInterfaces(uint8_t callMode)
|
void updateInterfaces(uint8_t callMode)
|
||||||
{
|
{
|
||||||
#ifndef WLED_DISABLE_ALEXA
|
#ifndef WLED_DISABLE_ALEXA
|
||||||
if (espalexaDevice != nullptr && callMode != 10) {
|
if (espalexaDevice != nullptr && callMode != NOTIFIER_CALL_MODE_ALEXA) {
|
||||||
espalexaDevice->setValue(bri);
|
espalexaDevice->setValue(bri);
|
||||||
espalexaDevice->setColor(col[0], col[1], col[2]);
|
espalexaDevice->setColor(col[0], col[1], col[2]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (callMode != 9 && callMode != 5) updateBlynk();
|
if (callMode != NOTIFIER_CALL_MODE_BLYNK &&
|
||||||
|
callMode != NOTIFIER_CALL_MODE_NO_NOTIFY) updateBlynk();
|
||||||
doPublishMqtt = true;
|
doPublishMqtt = true;
|
||||||
lastInterfaceUpdate = millis();
|
lastInterfaceUpdate = millis();
|
||||||
}
|
}
|
||||||
@ -233,7 +241,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
|
for (byte i=0; i<4; i++) col[i] = colNlT[i]+ ((colSec[i] - colNlT[i])*nper); // fading from actual color to secondary color
|
||||||
}
|
}
|
||||||
colorUpdated(5);
|
colorUpdated(NOTIFIER_CALL_MODE_NO_NOTIFY);
|
||||||
}
|
}
|
||||||
if (nper >= 1)
|
if (nper >= 1)
|
||||||
{
|
{
|
||||||
@ -241,7 +249,7 @@ void handleNightlight()
|
|||||||
if (!nightlightFade)
|
if (!nightlightFade)
|
||||||
{
|
{
|
||||||
bri = nightlightTargetBri;
|
bri = nightlightTargetBri;
|
||||||
colorUpdated(5);
|
colorUpdated(NOTIFIER_CALL_MODE_NO_NOTIFY);
|
||||||
}
|
}
|
||||||
updateBlynk();
|
updateBlynk();
|
||||||
if (bri == 0) briLast = briNlT;
|
if (bri == 0) briLast = briNlT;
|
||||||
@ -257,7 +265,7 @@ void handleNightlight()
|
|||||||
applyPreset(presetCycCurr,presetApplyBri,presetApplyCol,presetApplyFx);
|
applyPreset(presetCycCurr,presetApplyBri,presetApplyCol,presetApplyFx);
|
||||||
presetCycCurr++; if (presetCycCurr > presetCycleMax) presetCycCurr = presetCycleMin;
|
presetCycCurr++; if (presetCycCurr > presetCycleMax) presetCycCurr = presetCycleMin;
|
||||||
if (presetCycCurr > 25) presetCycCurr = 1;
|
if (presetCycCurr > 25) presetCycCurr = 1;
|
||||||
colorUpdated(8);
|
colorUpdated(NOTIFIER_CALL_MODE_PRESET_CYCLE);
|
||||||
presetCycledTime = millis();
|
presetCycledTime = millis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ void shortPressAction()
|
|||||||
if (!macroButton)
|
if (!macroButton)
|
||||||
{
|
{
|
||||||
toggleOnOff();
|
toggleOnOff();
|
||||||
colorUpdated(2);
|
colorUpdated(NOTIFIER_CALL_MODE_BUTTON);
|
||||||
} else {
|
} else {
|
||||||
applyMacro(macroButton);
|
applyMacro(macroButton);
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ void onAlexaChange(EspalexaDevice* dev)
|
|||||||
if (bri == 0)
|
if (bri == 0)
|
||||||
{
|
{
|
||||||
bri = briLast;
|
bri = briLast;
|
||||||
colorUpdated(10);
|
colorUpdated(NOTIFIER_CALL_MODE_ALEXA);
|
||||||
}
|
}
|
||||||
} else applyMacro(macroAlexaOn);
|
} else applyMacro(macroAlexaOn);
|
||||||
} else if (m == EspalexaDeviceProperty::off)
|
} else if (m == EspalexaDeviceProperty::off)
|
||||||
@ -52,13 +52,13 @@ void onAlexaChange(EspalexaDevice* dev)
|
|||||||
{
|
{
|
||||||
briLast = bri;
|
briLast = bri;
|
||||||
bri = 0;
|
bri = 0;
|
||||||
colorUpdated(10);
|
colorUpdated(NOTIFIER_CALL_MODE_ALEXA);
|
||||||
}
|
}
|
||||||
} else applyMacro(macroAlexaOff);
|
} else applyMacro(macroAlexaOff);
|
||||||
} else if (m == EspalexaDeviceProperty::bri)
|
} else if (m == EspalexaDeviceProperty::bri)
|
||||||
{
|
{
|
||||||
bri = espalexaDevice->getValue();
|
bri = espalexaDevice->getValue();
|
||||||
colorUpdated(10);
|
colorUpdated(NOTIFIER_CALL_MODE_ALEXA);
|
||||||
} else //color
|
} else //color
|
||||||
{
|
{
|
||||||
uint32_t color = espalexaDevice->getRGB();
|
uint32_t color = espalexaDevice->getRGB();
|
||||||
@ -67,7 +67,7 @@ void onAlexaChange(EspalexaDevice* dev)
|
|||||||
col[1] = ((color >> 8) & 0xFF);
|
col[1] = ((color >> 8) & 0xFF);
|
||||||
col[2] = (color & 0xFF);
|
col[2] = (color & 0xFF);
|
||||||
if (useRGBW && col[3] == 0) colorRGBtoRGBW(col); // do not touch white value if EspalexaDevice.cpp did set the white channel
|
if (useRGBW && col[3] == 0) colorRGBtoRGBW(col); // do not touch white value if EspalexaDevice.cpp did set the white channel
|
||||||
colorUpdated(10);
|
colorUpdated(NOTIFIER_CALL_MODE_ALEXA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ void handleHue()
|
|||||||
{
|
{
|
||||||
if (hueReceived)
|
if (hueReceived)
|
||||||
{
|
{
|
||||||
colorUpdated(7); hueReceived = false;
|
colorUpdated(NOTIFIER_CALL_MODE_HUE); hueReceived = false;
|
||||||
if (hueStoreAllowed && hueNewKey)
|
if (hueStoreAllowed && hueNewKey)
|
||||||
{
|
{
|
||||||
saveSettingsToEEPROM(); //save api key
|
saveSettingsToEEPROM(); //save api key
|
||||||
|
@ -41,45 +41,45 @@ void updateBlynk()
|
|||||||
BLYNK_WRITE(V0)
|
BLYNK_WRITE(V0)
|
||||||
{
|
{
|
||||||
bri = param.asInt();//bri
|
bri = param.asInt();//bri
|
||||||
colorUpdated(9);
|
colorUpdated(NOTIFIER_CALL_MODE_BLYNK);
|
||||||
}
|
}
|
||||||
|
|
||||||
BLYNK_WRITE(V1)
|
BLYNK_WRITE(V1)
|
||||||
{
|
{
|
||||||
blHue = param.asInt();//hue
|
blHue = param.asInt();//hue
|
||||||
colorHStoRGB(blHue*10,blSat,(false)? colSec:col);
|
colorHStoRGB(blHue*10,blSat,(false)? colSec:col);
|
||||||
colorUpdated(9);
|
colorUpdated(NOTIFIER_CALL_MODE_BLYNK);
|
||||||
}
|
}
|
||||||
|
|
||||||
BLYNK_WRITE(V2)
|
BLYNK_WRITE(V2)
|
||||||
{
|
{
|
||||||
blSat = param.asInt();//sat
|
blSat = param.asInt();//sat
|
||||||
colorHStoRGB(blHue*10,blSat,(false)? colSec:col);
|
colorHStoRGB(blHue*10,blSat,(false)? colSec:col);
|
||||||
colorUpdated(9);
|
colorUpdated(NOTIFIER_CALL_MODE_BLYNK);
|
||||||
}
|
}
|
||||||
|
|
||||||
BLYNK_WRITE(V3)
|
BLYNK_WRITE(V3)
|
||||||
{
|
{
|
||||||
bool on = (param.asInt()>0);
|
bool on = (param.asInt()>0);
|
||||||
if (!on != !bri) {toggleOnOff(); colorUpdated(9);}
|
if (!on != !bri) {toggleOnOff(); colorUpdated(NOTIFIER_CALL_MODE_BLYNK);}
|
||||||
}
|
}
|
||||||
|
|
||||||
BLYNK_WRITE(V4)
|
BLYNK_WRITE(V4)
|
||||||
{
|
{
|
||||||
effectCurrent = param.asInt()-1;//fx
|
effectCurrent = param.asInt()-1;//fx
|
||||||
colorUpdated(9);
|
colorUpdated(NOTIFIER_CALL_MODE_BLYNK);
|
||||||
}
|
}
|
||||||
|
|
||||||
BLYNK_WRITE(V5)
|
BLYNK_WRITE(V5)
|
||||||
{
|
{
|
||||||
effectSpeed = param.asInt();//sx
|
effectSpeed = param.asInt();//sx
|
||||||
colorUpdated(9);
|
colorUpdated(NOTIFIER_CALL_MODE_BLYNK);
|
||||||
}
|
}
|
||||||
|
|
||||||
BLYNK_WRITE(V6)
|
BLYNK_WRITE(V6)
|
||||||
{
|
{
|
||||||
effectIntensity = param.asInt();//ix
|
effectIntensity = param.asInt();//ix
|
||||||
colorUpdated(9);
|
colorUpdated(NOTIFIER_CALL_MODE_BLYNK);
|
||||||
}
|
}
|
||||||
|
|
||||||
BLYNK_WRITE(V7)
|
BLYNK_WRITE(V7)
|
||||||
|
@ -12,7 +12,7 @@ void parseMQTTBriPayload(char* payload)
|
|||||||
uint8_t in = strtoul(payload, NULL, 10);
|
uint8_t in = strtoul(payload, NULL, 10);
|
||||||
if (in == 0 && bri > 0) briLast = bri;
|
if (in == 0 && bri > 0) briLast = bri;
|
||||||
bri = in;
|
bri = in;
|
||||||
colorUpdated(1);
|
colorUpdated(NOTIFIER_CALL_MODE_DIRECT_CHANGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties
|
|||||||
if (strstr(topic, "/col"))
|
if (strstr(topic, "/col"))
|
||||||
{
|
{
|
||||||
colorFromDecOrHexString(col, (char*)payload);
|
colorFromDecOrHexString(col, (char*)payload);
|
||||||
colorUpdated(1);
|
colorUpdated(NOTIFIER_CALL_MODE_DIRECT_CHANGE);
|
||||||
} else if (strstr(topic, "/api"))
|
} else if (strstr(topic, "/api"))
|
||||||
{
|
{
|
||||||
String apireq = "win&";
|
String apireq = "win&";
|
||||||
|
@ -154,7 +154,7 @@ bool deserializeState(JsonObject root)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
colorUpdated(noNotification ? 5:1);
|
colorUpdated(noNotification ? NOTIFIER_CALL_MODE_NO_NOTIFY : NOTIFIER_CALL_MODE_DIRECT_CHANGE);
|
||||||
|
|
||||||
ps = root["psave"] | -1;
|
ps = root["psave"] | -1;
|
||||||
if (ps >= 0) savePreset(ps);
|
if (ps >= 0) savePreset(ps);
|
||||||
|
@ -29,7 +29,7 @@ bool decodeIRCustom(uint32_t code)
|
|||||||
|
|
||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
if (code != IRCUSTOM_MACRO1) colorUpdated(2); //don't update color again if we apply macro, it already does it
|
if (code != IRCUSTOM_MACRO1) colorUpdated(NOTIFIER_CALL_MODE_BUTTON); //don't update color again if we apply macro, it already does it
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,25 +51,25 @@ void decodeIR(uint32_t code)
|
|||||||
irTimesRepeated++;
|
irTimesRepeated++;
|
||||||
if (lastValidCode == IR24_BRIGHTER || lastValidCode == IR40_BPLUS )
|
if (lastValidCode == IR24_BRIGHTER || lastValidCode == IR40_BPLUS )
|
||||||
{
|
{
|
||||||
relativeChange(&bri, 10); colorUpdated(2);
|
relativeChange(&bri, 10); colorUpdated(NOTIFIER_CALL_MODE_BUTTON);
|
||||||
}
|
}
|
||||||
else if (lastValidCode == IR24_DARKER || lastValidCode == IR40_BMINUS )
|
else if (lastValidCode == IR24_DARKER || lastValidCode == IR40_BMINUS )
|
||||||
{
|
{
|
||||||
relativeChange(&bri, -10, 5); colorUpdated(2);
|
relativeChange(&bri, -10, 5); colorUpdated(NOTIFIER_CALL_MODE_BUTTON);
|
||||||
}
|
}
|
||||||
if (lastValidCode == IR40_WPLUS)
|
if (lastValidCode == IR40_WPLUS)
|
||||||
{
|
{
|
||||||
relativeChangeWhite(10); colorUpdated(2);
|
relativeChangeWhite(10); colorUpdated(NOTIFIER_CALL_MODE_BUTTON);
|
||||||
}
|
}
|
||||||
else if (lastValidCode == IR40_WMINUS)
|
else if (lastValidCode == IR40_WMINUS)
|
||||||
{
|
{
|
||||||
relativeChangeWhite(-10, 5); colorUpdated(2);
|
relativeChangeWhite(-10, 5); colorUpdated(NOTIFIER_CALL_MODE_BUTTON);
|
||||||
}
|
}
|
||||||
else if ((lastValidCode == IR24_ON || lastValidCode == IR40_ON) && irTimesRepeated > 7 )
|
else if ((lastValidCode == IR24_ON || lastValidCode == IR40_ON) && irTimesRepeated > 7 )
|
||||||
{
|
{
|
||||||
nightlightActive = true;
|
nightlightActive = true;
|
||||||
nightlightStartTime = millis();
|
nightlightStartTime = millis();
|
||||||
colorUpdated(2);
|
colorUpdated(NOTIFIER_CALL_MODE_BUTTON);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -85,11 +85,12 @@ void decodeIR(uint32_t code)
|
|||||||
case 3: decodeIR40(code); break; // blue 40-key remote with 25%, 50%, 75% and 100% keys
|
case 3: decodeIR40(code); break; // blue 40-key remote with 25%, 50%, 75% and 100% keys
|
||||||
case 4: decodeIR44(code); break; // white 44-key remote with color-up/down keys and DIY1 to 6 keys
|
case 4: decodeIR44(code); break; // white 44-key remote with color-up/down keys and DIY1 to 6 keys
|
||||||
case 5: decodeIR21(code); break; // white 21-key remote
|
case 5: decodeIR21(code); break; // white 21-key remote
|
||||||
case 6: decodeIR6(code); break; // black 6-key learning remote defaults: "CH" controls brightness,
|
case 6: decodeIR6(code); break; // black 6-key learning remote defaults: "CH" controls brightness,
|
||||||
// "VOL +" controls effect, "VOL -" controls colour/palette, "MUTE"
|
// "VOL +" controls effect, "VOL -" controls colour/palette, "MUTE"
|
||||||
// sets bright plain white
|
// sets bright plain white
|
||||||
default: return;
|
default: return;
|
||||||
}
|
}
|
||||||
|
colorUpdated(NOTIFIER_CALL_MODE_BUTTON); //for notifier, IR is considered a button input
|
||||||
}
|
}
|
||||||
//code <= 0xF70000 also invalid
|
//code <= 0xF70000 also invalid
|
||||||
}
|
}
|
||||||
@ -125,7 +126,6 @@ void decodeIR24(uint32_t code)
|
|||||||
default: return;
|
default: return;
|
||||||
}
|
}
|
||||||
lastValidCode = code;
|
lastValidCode = code;
|
||||||
colorUpdated(2); //for notifier, IR is considered a button input
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void decodeIR24OLD(uint32_t code)
|
void decodeIR24OLD(uint32_t code)
|
||||||
@ -158,7 +158,6 @@ void decodeIR24OLD(uint32_t code)
|
|||||||
default: return;
|
default: return;
|
||||||
}
|
}
|
||||||
lastValidCode = code;
|
lastValidCode = code;
|
||||||
colorUpdated(2); //for notifier, IR is considered a button input
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -194,7 +193,6 @@ void decodeIR24CT(uint32_t code)
|
|||||||
default: return;
|
default: return;
|
||||||
}
|
}
|
||||||
lastValidCode = code;
|
lastValidCode = code;
|
||||||
colorUpdated(2); //for notifier, IR is considered a button input
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -253,7 +251,6 @@ void decodeIR40(uint32_t code)
|
|||||||
case IR40_FLASH : if (!applyPreset(4)) { effectCurrent = FX_MODE_RAINBOW; effectPalette = 0; } break;
|
case IR40_FLASH : if (!applyPreset(4)) { effectCurrent = FX_MODE_RAINBOW; effectPalette = 0; } break;
|
||||||
}
|
}
|
||||||
lastValidCode = code;
|
lastValidCode = code;
|
||||||
colorUpdated(2); //for notifier, IR is considered a button input
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void decodeIR44(uint32_t code)
|
void decodeIR44(uint32_t code)
|
||||||
@ -317,12 +314,11 @@ void decodeIR44(uint32_t code)
|
|||||||
case IR44_FADE7 : bri = 255; break;
|
case IR44_FADE7 : bri = 255; break;
|
||||||
}
|
}
|
||||||
lastValidCode = code;
|
lastValidCode = code;
|
||||||
colorUpdated(2); //for notifier, IR is considered a button input
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void decodeIR21(uint32_t code)
|
void decodeIR21(uint32_t code)
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case IR21_BRIGHTER: relativeChange(&bri, 10); break;
|
case IR21_BRIGHTER: relativeChange(&bri, 10); break;
|
||||||
case IR21_DARKER: relativeChange(&bri, -10, 5); break;
|
case IR21_DARKER: relativeChange(&bri, -10, 5); break;
|
||||||
case IR21_OFF: briLast = bri; bri = 0; break;
|
case IR21_OFF: briLast = bri; bri = 0; break;
|
||||||
@ -345,51 +341,42 @@ void decodeIR21(uint32_t code)
|
|||||||
case IR21_FADE: if (!applyPreset(3)) { effectCurrent = FX_MODE_BREATH; effectPalette = 0; } break;
|
case IR21_FADE: if (!applyPreset(3)) { effectCurrent = FX_MODE_BREATH; effectPalette = 0; } break;
|
||||||
case IR21_SMOOTH: if (!applyPreset(4)) { effectCurrent = FX_MODE_RAINBOW; effectPalette = 0; } break;
|
case IR21_SMOOTH: if (!applyPreset(4)) { effectCurrent = FX_MODE_RAINBOW; effectPalette = 0; } break;
|
||||||
default: return;
|
default: return;
|
||||||
}
|
}
|
||||||
lastValidCode = code;
|
lastValidCode = code;
|
||||||
colorUpdated(2); //for notifier, IR is considered a button input
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void decodeIR6(uint32_t code)
|
void decodeIR6(uint32_t code)
|
||||||
{
|
{
|
||||||
|
switch (code) {
|
||||||
switch (code) {
|
case IR6_POWER: toggleOnOff(); break;
|
||||||
case IR6_POWER: toggleOnOff(); break;
|
case IR6_CHANNEL_UP: relativeChange(&bri, 10); break;
|
||||||
case IR6_CHANNEL_UP: relativeChange(&bri, 10); break;
|
case IR6_CHANNEL_DOWN: relativeChange(&bri, -10, 5); break;
|
||||||
case IR6_CHANNEL_DOWN: relativeChange(&bri, -10, 5); break;
|
case IR6_VOLUME_UP: /* next effect */ relativeChange(&effectCurrent, 1); break;
|
||||||
case IR6_VOLUME_UP: /* next effect */ relativeChange(&effectCurrent, 1); break;
|
case IR6_VOLUME_DOWN:
|
||||||
case IR6_VOLUME_DOWN:
|
/* next palette */
|
||||||
/* next palette */
|
relativeChange(&effectPalette, 1);
|
||||||
|
switch(lastIR6ColourIdx) {
|
||||||
relativeChange(&effectPalette, 1);
|
case 0: colorFromUint32(COLOR_RED); break;
|
||||||
|
case 1: colorFromUint32(COLOR_REDDISH); break;
|
||||||
switch(lastIR6ColourIdx)
|
case 2:colorFromUint32(COLOR_ORANGE); break;
|
||||||
{
|
case 3:colorFromUint32(COLOR_YELLOWISH); break;
|
||||||
case 0: colorFromUint32(COLOR_RED); break;
|
case 4:colorFromUint32(COLOR_GREEN); break;
|
||||||
case 1: colorFromUint32(COLOR_REDDISH); break;
|
case 5:colorFromUint32(COLOR_GREENISH); break;
|
||||||
case 2:colorFromUint32(COLOR_ORANGE); break;
|
case 6:colorFromUint32(COLOR_TURQUOISE); break;
|
||||||
case 3:colorFromUint32(COLOR_YELLOWISH); break;
|
case 7: colorFromUint32(COLOR_CYAN); break;
|
||||||
case 4:colorFromUint32(COLOR_GREEN); break;
|
case 8:colorFromUint32(COLOR_BLUE); break;
|
||||||
case 5:colorFromUint32(COLOR_GREENISH); break;
|
case 9:colorFromUint32(COLOR_DEEPBLUE); break;
|
||||||
case 6:colorFromUint32(COLOR_TURQUOISE); break;
|
case 10:colorFromUint32(COLOR_PURPLE); break;
|
||||||
case 7: colorFromUint32(COLOR_CYAN); break;
|
case 11:colorFromUint32(COLOR_PINK); break;
|
||||||
case 8:colorFromUint32(COLOR_BLUE); break;
|
case 12:colorFromUint32(COLOR_WHITE); break;
|
||||||
case 9:colorFromUint32(COLOR_DEEPBLUE); break;
|
default:break;
|
||||||
case 10:colorFromUint32(COLOR_PURPLE); break;
|
}
|
||||||
case 11:colorFromUint32(COLOR_PINK); break;
|
lastIR6ColourIdx++;
|
||||||
case 12:colorFromUint32(COLOR_WHITE); break;
|
if(lastIR6ColourIdx > 12) lastIR6ColourIdx = 0;
|
||||||
default:break;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
lastIR6ColourIdx++;
|
|
||||||
if(lastIR6ColourIdx > 12) lastIR6ColourIdx = 0;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case IR6_MUTE: effectCurrent = 0; effectPalette = 0; colorFromUint32(COLOR_WHITE); bri=255; break;
|
case IR6_MUTE: effectCurrent = 0; effectPalette = 0; colorFromUint32(COLOR_WHITE); bri=255; break;
|
||||||
}
|
}
|
||||||
lastValidCode = code;
|
lastValidCode = code;
|
||||||
colorUpdated(2); //for notifier, IR is considered a button input
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user