Compilation fixes

This commit is contained in:
Blaž Kristan 2025-04-23 18:38:34 +02:00
parent ee9ac947a1
commit 0f321bfb38
7 changed files with 23 additions and 26 deletions

View File

@ -1736,7 +1736,7 @@ class AudioReactive : public Usermod {
} }
void onStateChange(uint8_t callMode) override { void onStateChange(uint8_t callMode) override {
if (initDone && enabled && addPalettes && palettes==0 && strip.customPalettes.size()<10) { if (initDone && enabled && addPalettes && palettes==0 && customPalettes.size()<10) {
// if palettes were removed during JSON call re-add them // if palettes were removed during JSON call re-add them
createAudioPalettes(); createAudioPalettes();
} }
@ -1966,7 +1966,7 @@ class AudioReactive : public Usermod {
void AudioReactive::removeAudioPalettes(void) { void AudioReactive::removeAudioPalettes(void) {
DEBUG_PRINTLN(F("Removing audio palettes.")); DEBUG_PRINTLN(F("Removing audio palettes."));
while (palettes>0) { while (palettes>0) {
strip.customPalettes.pop_back(); customPalettes.pop_back();
DEBUG_PRINTLN(palettes); DEBUG_PRINTLN(palettes);
palettes--; palettes--;
} }
@ -1978,8 +1978,8 @@ void AudioReactive::createAudioPalettes(void) {
if (palettes) return; if (palettes) return;
DEBUG_PRINTLN(F("Adding audio palettes.")); DEBUG_PRINTLN(F("Adding audio palettes."));
for (int i=0; i<MAX_PALETTES; i++) for (int i=0; i<MAX_PALETTES; i++)
if (strip.customPalettes.size() < 10) { if (customPalettes.size() < 10) {
strip.customPalettes.push_back(CRGBPalette16(CRGB(BLACK))); customPalettes.push_back(CRGBPalette16(CRGB(BLACK)));
palettes++; palettes++;
DEBUG_PRINTLN(palettes); DEBUG_PRINTLN(palettes);
} else break; } else break;
@ -2016,7 +2016,7 @@ CRGB AudioReactive::getCRGBForBand(int x, int pal) {
void AudioReactive::fillAudioPalettes() { void AudioReactive::fillAudioPalettes() {
if (!palettes) return; if (!palettes) return;
size_t lastCustPalette = strip.customPalettes.size(); size_t lastCustPalette = customPalettes.size();
if (int(lastCustPalette) >= palettes) lastCustPalette -= palettes; if (int(lastCustPalette) >= palettes) lastCustPalette -= palettes;
for (int pal=0; pal<palettes; pal++) { for (int pal=0; pal<palettes; pal++) {
uint8_t tcp[16]; // Needs to be 4 times however many colors are being used. uint8_t tcp[16]; // Needs to be 4 times however many colors are being used.
@ -2045,7 +2045,7 @@ void AudioReactive::fillAudioPalettes() {
tcp[14] = rgb.g; tcp[14] = rgb.g;
tcp[15] = rgb.b; tcp[15] = rgb.b;
strip.customPalettes[lastCustPalette+pal].loadDynamicGradientPalette(tcp); customPalettes[lastCustPalette+pal].loadDynamicGradientPalette(tcp);
} }
} }

View File

@ -396,20 +396,20 @@ void RotaryEncoderUIUsermod::sortModesAndPalettes() {
modes_alpha_indexes = re_initIndexArray(strip.getModeCount()); modes_alpha_indexes = re_initIndexArray(strip.getModeCount());
re_sortModes(modes_qstrings, modes_alpha_indexes, strip.getModeCount(), MODE_SORT_SKIP_COUNT); re_sortModes(modes_qstrings, modes_alpha_indexes, strip.getModeCount(), MODE_SORT_SKIP_COUNT);
DEBUG_PRINT(F("Sorting palettes: ")); DEBUG_PRINT(strip.getPaletteCount()); DEBUG_PRINT('/'); DEBUG_PRINTLN(strip.customPalettes.size()); DEBUG_PRINT(F("Sorting palettes: ")); DEBUG_PRINT(getPaletteCount()); DEBUG_PRINT('/'); DEBUG_PRINTLN(strip.customPalettes.size());
palettes_qstrings = re_findModeStrings(JSON_palette_names, strip.getPaletteCount()); palettes_qstrings = re_findModeStrings(JSON_palette_names, getPaletteCount());
palettes_alpha_indexes = re_initIndexArray(strip.getPaletteCount()); palettes_alpha_indexes = re_initIndexArray(getPaletteCount());
if (strip.customPalettes.size()) { if (strip.customPalettes.size()) {
for (int i=0; i<strip.customPalettes.size(); i++) { for (int i=0; i<strip.customPalettes.size(); i++) {
palettes_alpha_indexes[strip.getPaletteCount()-strip.customPalettes.size()+i] = 255-i; palettes_alpha_indexes[getPaletteCount()-strip.customPalettes.size()+i] = 255-i;
palettes_qstrings[strip.getPaletteCount()-strip.customPalettes.size()+i] = PSTR("~Custom~"); palettes_qstrings[getPaletteCount()-strip.customPalettes.size()+i] = PSTR("~Custom~");
} }
} }
// How many palette names start with '*' and should not be sorted? // How many palette names start with '*' and should not be sorted?
// (Also skipping the first one, 'Default'). // (Also skipping the first one, 'Default').
int skipPaletteCount = 1; int skipPaletteCount = 1;
while (pgm_read_byte_near(palettes_qstrings[skipPaletteCount]) == '*') skipPaletteCount++; while (pgm_read_byte_near(palettes_qstrings[skipPaletteCount]) == '*') skipPaletteCount++;
re_sortModes(palettes_qstrings, palettes_alpha_indexes, strip.getPaletteCount()-strip.customPalettes.size(), skipPaletteCount); re_sortModes(palettes_qstrings, palettes_alpha_indexes, getPaletteCount()-strip.customPalettes.size(), skipPaletteCount);
} }
byte *RotaryEncoderUIUsermod::re_initIndexArray(int numModes) { byte *RotaryEncoderUIUsermod::re_initIndexArray(int numModes) {
@ -698,7 +698,7 @@ void RotaryEncoderUIUsermod::findCurrentEffectAndPalette() {
effectPaletteIndex = 0; effectPaletteIndex = 0;
DEBUG_PRINTLN(effectPalette); DEBUG_PRINTLN(effectPalette);
for (unsigned i = 0; i < strip.getPaletteCount()+strip.customPalettes.size(); i++) { for (unsigned i = 0; i < getPaletteCount()+strip.customPalettes.size(); i++) {
if (palettes_alpha_indexes[i] == effectPalette) { if (palettes_alpha_indexes[i] == effectPalette) {
effectPaletteIndex = i; effectPaletteIndex = i;
DEBUG_PRINTLN(F("Found palette.")); DEBUG_PRINTLN(F("Found palette."));
@ -888,7 +888,7 @@ void RotaryEncoderUIUsermod::changePalette(bool increase) {
} }
display->updateRedrawTime(); display->updateRedrawTime();
#endif #endif
effectPaletteIndex = max(min((unsigned)(increase ? effectPaletteIndex+1 : effectPaletteIndex-1), strip.getPaletteCount()+strip.customPalettes.size()-1), 0U); effectPaletteIndex = max(min((unsigned)(increase ? effectPaletteIndex+1 : effectPaletteIndex-1), getPaletteCount()+strip.customPalettes.size()-1), 0U);
effectPalette = palettes_alpha_indexes[effectPaletteIndex]; effectPalette = palettes_alpha_indexes[effectPaletteIndex];
stateChanged = true; stateChanged = true;
if (applyToAll) { if (applyToAll) {

View File

@ -74,7 +74,7 @@ void doublePressAction(uint8_t b)
if (!macroDoublePress[b]) { if (!macroDoublePress[b]) {
switch (b) { switch (b) {
//case 0: toggleOnOff(); colorUpdated(CALL_MODE_BUTTON); break; //instant short press on button 0 if no macro set //case 0: toggleOnOff(); colorUpdated(CALL_MODE_BUTTON); break; //instant short press on button 0 if no macro set
case 1: ++effectPalette %= strip.getPaletteCount(); colorUpdated(CALL_MODE_BUTTON); break; case 1: ++effectPalette %= getPaletteCount(); colorUpdated(CALL_MODE_BUTTON); break;
} }
} else { } else {
applyPreset(macroDoublePress[b], CALL_MODE_BUTTON_PRESET); applyPreset(macroDoublePress[b], CALL_MODE_BUTTON_PRESET);
@ -226,8 +226,8 @@ void handleAnalog(uint8_t b)
effectIntensity = aRead; effectIntensity = aRead;
} else if (macroDoublePress[b] == 247) { } else if (macroDoublePress[b] == 247) {
// selected palette // selected palette
effectPalette = map(aRead, 0, 252, 0, strip.getPaletteCount()-1); effectPalette = map(aRead, 0, 252, 0, getPaletteCount()-1);
effectPalette = constrain(effectPalette, 0, strip.getPaletteCount()-1); // map is allowed to "overshoot", so we need to contrain the result effectPalette = constrain(effectPalette, 0, getPaletteCount()-1); // map is allowed to "overshoot", so we need to contrain the result
} else if (macroDoublePress[b] == 200) { } else if (macroDoublePress[b] == 200) {
// primary color, hue, full saturation // primary color, hue, full saturation
colorHStoRGB(aRead*256,255,colPri); colorHStoRGB(aRead*256,255,colPri);

View File

@ -225,9 +225,8 @@ void onHueConnect(void* arg, AsyncClient* client);
void sendHuePoll(); void sendHuePoll();
void onHueData(void* arg, AsyncClient* client, void *data, size_t len); void onHueData(void* arg, AsyncClient* client, void *data, size_t len);
#include "FX.h" // must be below colors.cpp declarations (potentially due to duplicate declarations of e.g. color_blend)
//image_loader.cpp //image_loader.cpp
class Segment;
#ifdef WLED_ENABLE_GIF #ifdef WLED_ENABLE_GIF
bool fileSeekCallback(unsigned long position); bool fileSeekCallback(unsigned long position);
unsigned long filePositionCallback(void); unsigned long filePositionCallback(void);
@ -263,9 +262,7 @@ void handleIR();
#include "ESPAsyncWebServer.h" #include "ESPAsyncWebServer.h"
#include "src/dependencies/json/ArduinoJson-v6.h" #include "src/dependencies/json/ArduinoJson-v6.h"
#include "src/dependencies/json/AsyncJson-v6.h" #include "src/dependencies/json/AsyncJson-v6.h"
#include "FX.h"
bool deserializeSegment(JsonObject elem, byte it, byte presetId = 0);
bool deserializeState(JsonObject root, byte callMode = CALL_MODE_DIRECT_CHANGE, byte presetId = 0); bool deserializeState(JsonObject root, byte callMode = CALL_MODE_DIRECT_CHANGE, byte presetId = 0);
void serializeSegment(const JsonObject& root, const Segment& seg, byte id, bool forPreset = false, bool segmentBounds = true); void serializeSegment(const JsonObject& root, const Segment& seg, byte id, bool forPreset = false, bool segmentBounds = true);
void serializeState(JsonObject root, bool forPreset = false, bool includeBri = true, bool segmentBounds = true, bool selectedSegmentsOnly = false); void serializeState(JsonObject root, bool forPreset = false, bool includeBri = true, bool segmentBounds = true, bool selectedSegmentsOnly = false);
@ -279,8 +276,8 @@ bool serveLiveLeds(AsyncWebServerRequest* request, uint32_t wsClient = 0);
//led.cpp //led.cpp
void setValuesFromSegment(uint8_t s); void setValuesFromSegment(uint8_t s);
void setValuesFromMainSeg(); #define setValuesFromMainSeg() setValuesFromSegment(strip.getMainSegmentId())
void setValuesFromFirstSelectedSeg(); #define setValuesFromFirstSelectedSeg() setValuesFromSegment(strip.getFirstSelectedSegId())
void toggleOnOff(); void toggleOnOff();
void applyBri(); void applyBri();
void applyFinalBri(); void applyFinalBri();

View File

@ -78,7 +78,7 @@ void drawPixelCallback(int16_t x, int16_t y, uint8_t red, uint8_t green, uint8_t
byte renderImageToSegment(Segment &seg) { byte renderImageToSegment(Segment &seg) {
if (!seg.name) return IMAGE_ERROR_NO_NAME; if (!seg.name) return IMAGE_ERROR_NO_NAME;
// disable during effect transition, causes flickering, multiple allocations and depending on image, part of old FX remaining // disable during effect transition, causes flickering, multiple allocations and depending on image, part of old FX remaining
if (seg.mode != seg.currentMode()) return IMAGE_ERROR_WAITING; //if (seg.mode != seg.currentMode()) return IMAGE_ERROR_WAITING;
if (activeSeg && activeSeg != &seg) return IMAGE_ERROR_SEG_LIMIT; // only one segment at a time if (activeSeg && activeSeg != &seg) return IMAGE_ERROR_SEG_LIMIT; // only one segment at a time
activeSeg = &seg; activeSeg = &seg;

View File

@ -66,7 +66,7 @@ namespace {
} }
} }
static bool deserializeSegment(JsonObject elem, byte it, byte presetId) static bool deserializeSegment(JsonObject elem, byte it, byte presetId = 0)
{ {
byte id = elem["id"] | it; byte id = elem["id"] | it;
if (id >= WS2812FX::getMaxSegments()) return false; if (id >= WS2812FX::getMaxSegments()) return false;

View File

@ -176,7 +176,7 @@ static void handleUpload(AsyncWebServerRequest *request, const String& filename,
doReboot = true; doReboot = true;
request->send(200, FPSTR(CONTENT_TYPE_PLAIN), F("Configuration restore successful.\nRebooting...")); request->send(200, FPSTR(CONTENT_TYPE_PLAIN), F("Configuration restore successful.\nRebooting..."));
} else { } else {
if (filename.indexOf(F("palette")) >= 0 && filename.indexOf(F(".json")) >= 0) strip.loadCustomPalettes(); if (filename.indexOf(F("palette")) >= 0 && filename.indexOf(F(".json")) >= 0) loadCustomPalettes();
request->send(200, FPSTR(CONTENT_TYPE_PLAIN), F("File Uploaded!")); request->send(200, FPSTR(CONTENT_TYPE_PLAIN), F("File Uploaded!"));
} }
cacheInvalidate++; cacheInvalidate++;