Skip to content

Commit

Permalink
IR bugfix - apply presets with fallback
Browse files Browse the repository at this point in the history
preset fallbacks did not work since 0.13.2.
  • Loading branch information
softhack007 committed Sep 2, 2023
1 parent af1d65d commit be2f4e0
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions wled00/ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#if defined(WLED_DISABLE_INFRARED)
void handleIR(){}
#else
#warning IR enabled. IR Remotes are not officially supported in WLED-SR

IRrecv* irrecv;
//change pin in NpbWrapper.h
Expand Down Expand Up @@ -68,17 +69,6 @@ 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)
{
byte prevError = errorFlag;
if (!applyPreset(presetID, CALL_MODE_BUTTON_PRESET)) {
effectCurrent = effectID;
effectPalette = paletteID;
errorFlag = prevError; //clear error 12 from non-existent preset
}
}

byte relativeChange(byte property, int8_t amount, byte lowerBoundary, byte higherBoundary)
{
int16_t new_val = (int16_t) property + amount;
Expand Down Expand Up @@ -120,6 +110,19 @@ void changePalette(uint8_t pal)
stateChanged = true;
}

// 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)
{
byte prevError = errorFlag;
if (!applyPreset(presetID, CALL_MODE_BUTTON_PRESET)) {
effectCurrent = effectID;
effectPalette = paletteID;
errorFlag = prevError; //clear error 12 from non-existent preset
changeEffect(effectCurrent);
changePalette(effectPalette);
}
}

void changeEffectSpeed(int8_t amount)
{
if (effectCurrent != 0) {
Expand Down

0 comments on commit be2f4e0

Please sign in to comment.