repeat actions cleanup & fix

This commit is contained in:
Blaz Kristan 2022-02-07 11:13:12 +01:00
parent 8c5b3fe23e
commit 4eb0dbb5a4

View File

@ -162,6 +162,7 @@ void decodeIR(uint32_t code)
return; return;
} }
lastValidCode = 0; irTimesRepeated = 0; lastValidCode = 0; irTimesRepeated = 0;
lastRepeatableAction = ACTION_NONE;
if (decodeIRCustom(code)) return; if (decodeIRCustom(code)) return;
if (irEnabled == 8) { // any remote configurable with ir.json file if (irEnabled == 8) { // any remote configurable with ir.json file
decodeIRJson(code); decodeIRJson(code);
@ -193,57 +194,32 @@ void decodeIR(uint32_t code)
colorUpdated(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(){ void applyRepeatActions()
if (irEnabled == 8)
{ {
if (irEnabled == 8) {
decodeIRJson(lastValidCode); decodeIRJson(lastValidCode);
return;
} else switch (lastRepeatableAction) {
case ACTION_BRIGHT_UP : incBrightness(); colorUpdated(CALL_MODE_BUTTON); return;
case ACTION_BRIGHT_DOWN : decBrightness(); colorUpdated(CALL_MODE_BUTTON); return;
case ACTION_SPEED_UP : changeEffectSpeed(lastRepeatableValue); colorUpdated(CALL_MODE_BUTTON); return;
case ACTION_SPEED_DOWN : changeEffectSpeed(lastRepeatableValue); colorUpdated(CALL_MODE_BUTTON); return;
case ACTION_INTENSITY_UP : changeEffectIntensity(lastRepeatableValue); colorUpdated(CALL_MODE_BUTTON); return;
case ACTION_INTENSITY_DOWN : changeEffectIntensity(lastRepeatableValue); colorUpdated(CALL_MODE_BUTTON); return;
default: break;
} }
else if (lastValidCode == IR40_WPLUS) {
{ relativeChangeWhite(10);
if (lastRepeatableAction == ACTION_BRIGHT_UP) colorUpdated(CALL_MODE_BUTTON);
{ } else if (lastValidCode == IR40_WMINUS) {
incBrightness(); colorUpdated(CALL_MODE_BUTTON); relativeChangeWhite(-10, 5);
} colorUpdated(CALL_MODE_BUTTON);
else if (lastRepeatableAction == ACTION_BRIGHT_DOWN ) } else if ((lastValidCode == IR24_ON || lastValidCode == IR40_ON) && irTimesRepeated > 7 ) {
{
decBrightness(); colorUpdated(CALL_MODE_BUTTON);
}
if (lastRepeatableAction == ACTION_SPEED_UP)
{
changeEffectSpeed(lastRepeatableValue); colorUpdated(CALL_MODE_BUTTON);
}
else if (lastRepeatableAction == ACTION_SPEED_DOWN )
{
changeEffectSpeed(lastRepeatableValue); colorUpdated(CALL_MODE_BUTTON);
}
if (lastRepeatableAction == ACTION_INTENSITY_UP)
{
changeEffectIntensity(lastRepeatableValue); colorUpdated(CALL_MODE_BUTTON);
}
else if (lastRepeatableAction == ACTION_INTENSITY_DOWN )
{
changeEffectIntensity(lastRepeatableValue); colorUpdated(CALL_MODE_BUTTON);
}
if (lastValidCode == IR40_WPLUS)
{
relativeChangeWhite(10); colorUpdated(CALL_MODE_BUTTON);
}
else if (lastValidCode == IR40_WMINUS)
{
relativeChangeWhite(-10, 5); colorUpdated(CALL_MODE_BUTTON);
}
else if ((lastValidCode == IR24_ON || lastValidCode == IR40_ON) && irTimesRepeated > 7 )
{
nightlightActive = true; nightlightActive = true;
nightlightStartTime = millis(); nightlightStartTime = millis();
colorUpdated(CALL_MODE_BUTTON); colorUpdated(CALL_MODE_BUTTON);
} }
} }
}
void decodeIR24(uint32_t code) void decodeIR24(uint32_t code)
{ {