@@ -45,7 +45,7 @@ class ModuleLightsControl : public Module {
4545 setPresetsFromFolder (); // set the right values during boot
4646
4747 // update presets if files changed in presets folder
48- _fileManager->addUpdateHandler ([& ](const String& originId) {
48+ _fileManager->addUpdateHandler ([this ](const String& originId) {
4949 EXT_LOGV (ML_TAG, " FileManager::updateHandler %s" , originId.c_str ());
5050 // read the file state (read all files and folders on FS and collect changes)
5151 _fileManager->read ([&](FilesState& filesState) {
@@ -65,7 +65,7 @@ class ModuleLightsControl : public Module {
6565 }
6666 });
6767 });
68- moduleIO.addUpdateHandler ([& ](const String& originId) { readPins (); }, false );
68+ moduleIO.addUpdateHandler ([this ](const String& originId) { readPins (); }, false );
6969 readPins (); // initially
7070 }
7171
@@ -156,6 +156,8 @@ class ModuleLightsControl : public Module {
156156 };
157157 layerP.lights .header .brightness = newBri;
158158 } else if (updatedItem.name == " palette" ) {
159+ const size_t nrOfPaletteEntries = sizeof (layerP.palette .entries ) / sizeof (CRGB);
160+
159161 if (updatedItem.value == 0 )
160162 layerP.palette = CloudColors_p;
161163 else if (updatedItem.value == 1 )
@@ -177,14 +179,12 @@ class ModuleLightsControl : public Module {
177179 layerP.palette [i] = CHSV (random8 (), 255 , 255 ); // take the max saturation, max brightness of the colorwheel
178180 }
179181 } else if (updatedItem.value == 9 ) { // Quin palette
180- size_t size = sizeof (layerP.palette .entries ) / sizeof (CRGB);
181- for (int i = 0 ; i < size; i++) {
182- layerP.palette [i] = CRGB (map (i, 0 , size - 1 , 255 , 0 ), map (i, 0 , size - 1 , 31 , 0 ), map (i, 0 , size - 1 , 0 , 255 )); // from orange to blue
182+ for (int i = 0 ; i < nrOfPaletteEntries; i++) {
183+ layerP.palette [i] = CRGB (map (i, 0 , nrOfPaletteEntries - 1 , 255 , 0 ), map (i, 0 , nrOfPaletteEntries - 1 , 31 , 0 ), map (i, 0 , nrOfPaletteEntries - 1 , 0 , 255 )); // from orange to blue
183184 }
184185 } else if (updatedItem.value == 10 ) { // Orange palette
185- size_t size = sizeof (layerP.palette .entries ) / sizeof (CRGB);
186- for (int i = 0 ; i < size; i++) {
187- layerP.palette [i] = CRGB (255 , map (i, 0 , size - 1 , 0 , 255 ), 0 ); // from orange to blue
186+ for (int i = 0 ; i < nrOfPaletteEntries; i++) {
187+ layerP.palette [i] = CRGB (255 , map (i, 0 , nrOfPaletteEntries - 1 , 0 , 255 ), 0 ); // from red via orange to yellow
188188 }
189189 } else {
190190 layerP.palette = PartyColors_p; // should never occur
0 commit comments