Skip to content

Commit 013684b

Browse files
softhack007DedeHai
authored andcommitted
making some parameters const, plus minor improvements
* changed some parameters to "pointer to const", so compiler can better optimize code size and performance - because data behind a const pointer will never be modified by the called function. * made setPixelColor `const` * fixed a few potentially uninitialized local vars (the may have random values if not initialized) * avoid shadowing "state" in handleSerial() * plus a few very minor improvements
1 parent 90c2955 commit 013684b

16 files changed

+57
-57
lines changed

wled00/FX.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -2363,7 +2363,7 @@ static const char _data_FX_MODE_LAKE[] PROGMEM = "Lake@!;Fx;!";
23632363
// send a meteor from begining to to the end of the strip with a trail that randomly decays.
23642364
// adapted from https://www.tweaking4all.com/hardware/arduino/adruino-led-strip-effects/#LEDStripEffectMeteorRain
23652365
uint16_t mode_meteor() {
2366-
if (SEGLEN == 1) return mode_static();
2366+
if (SEGLEN <= 1) return mode_static();
23672367
if (!SEGENV.allocateData(SEGLEN)) return mode_static(); //allocation failed
23682368
const bool meteorSmooth = SEGMENT.check3;
23692369
byte* trail = SEGENV.data;
@@ -2531,7 +2531,7 @@ static uint16_t ripple_base(uint8_t blurAmount = 0) {
25312531

25322532

25332533
uint16_t mode_ripple(void) {
2534-
if (SEGLEN == 1) return mode_static();
2534+
if (SEGLEN <= 1) return mode_static();
25352535
if(SEGMENT.custom1 || SEGMENT.check2) // blur or overlay
25362536
SEGMENT.fade_out(250);
25372537
else
@@ -2543,7 +2543,7 @@ static const char _data_FX_MODE_RIPPLE[] PROGMEM = "Ripple@!,Wave #,Blur,,,,Over
25432543

25442544

25452545
uint16_t mode_ripple_rainbow(void) {
2546-
if (SEGLEN == 1) return mode_static();
2546+
if (SEGLEN <= 1) return mode_static();
25472547
if (SEGENV.call ==0) {
25482548
SEGENV.aux0 = hw_random8();
25492549
SEGENV.aux1 = hw_random8();
@@ -3984,7 +3984,7 @@ static const char _data_FX_MODE_HEARTBEAT[] PROGMEM = "Heartbeat@!,!;!,!;!;01;m1
39843984
// Modified for WLED, based on https://github.com/FastLED/FastLED/blob/master/examples/Pacifica/Pacifica.ino
39853985
//
39863986
// Add one layer of waves into the led array
3987-
static CRGB pacifica_one_layer(uint16_t i, CRGBPalette16& p, uint16_t cistart, uint16_t wavescale, uint8_t bri, uint16_t ioff)
3987+
static CRGB pacifica_one_layer(uint16_t i, const CRGBPalette16& p, uint16_t cistart, uint16_t wavescale, uint8_t bri, uint16_t ioff)
39883988
{
39893989
unsigned ci = cistart;
39903990
unsigned waveangle = ioff;

wled00/FX.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ typedef struct Segment {
460460
{}
461461
} *_t;
462462

463-
[[gnu::hot]] void _setPixelColorXY_raw(int& x, int& y, uint32_t& col) const; // set pixel without mapping (internal use only)
463+
[[gnu::hot]] void _setPixelColorXY_raw(const int& x, const int& y, uint32_t& col) const; // set pixel without mapping (internal use only)
464464

465465
public:
466466

@@ -588,7 +588,7 @@ typedef struct Segment {
588588
inline void handleTransition() { updateTransitionProgress(); if (progress() == 0xFFFFU) stopTransition(); }
589589
#ifndef WLED_DISABLE_MODE_BLEND
590590
void swapSegenv(tmpsegd_t &tmpSegD); // copies segment data into specifed buffer, if buffer is not a transition buffer, segment data is overwritten from transition buffer
591-
void restoreSegenv(tmpsegd_t &tmpSegD); // restores segment data from buffer, if buffer is not transition buffer, changed values are copied to transition buffer
591+
void restoreSegenv(const tmpsegd_t &tmpSegD); // restores segment data from buffer, if buffer is not transition buffer, changed values are copied to transition buffer
592592
#endif
593593
[[gnu::hot]] void updateTransitionProgress(); // set current progression of transition
594594
inline uint16_t progress() const { return _transitionprogress; }; // transition progression between 0-65535
@@ -643,11 +643,11 @@ typedef struct Segment {
643643
}
644644
#ifndef WLED_DISABLE_2D
645645
[[gnu::hot]] uint16_t XY(int x, int y) const; // support function to get relative index within segment
646-
[[gnu::hot]] void setPixelColorXY(int x, int y, uint32_t c); // set relative pixel within segment with color
647-
inline void setPixelColorXY(unsigned x, unsigned y, uint32_t c) { setPixelColorXY(int(x), int(y), c); }
648-
inline void setPixelColorXY(int x, int y, byte r, byte g, byte b, byte w = 0) { setPixelColorXY(x, y, RGBW32(r,g,b,w)); }
649-
inline void setPixelColorXY(int x, int y, CRGB c) { setPixelColorXY(x, y, RGBW32(c.r,c.g,c.b,0)); }
650-
inline void setPixelColorXY(unsigned x, unsigned y, CRGB c) { setPixelColorXY(int(x), int(y), RGBW32(c.r,c.g,c.b,0)); }
646+
[[gnu::hot]] void setPixelColorXY(int x, int y, uint32_t c) const; // set relative pixel within segment with color
647+
inline void setPixelColorXY(unsigned x, unsigned y, uint32_t c) const { setPixelColorXY(int(x), int(y), c); }
648+
inline void setPixelColorXY(int x, int y, byte r, byte g, byte b, byte w = 0) const { setPixelColorXY(x, y, RGBW32(r,g,b,w)); }
649+
inline void setPixelColorXY(int x, int y, CRGB c) const { setPixelColorXY(x, y, RGBW32(c.r,c.g,c.b,0)); }
650+
inline void setPixelColorXY(unsigned x, unsigned y, CRGB c) const { setPixelColorXY(int(x), int(y), RGBW32(c.r,c.g,c.b,0)); }
651651
#ifdef WLED_USE_AA_PIXELS
652652
void setPixelColorXY(float x, float y, uint32_t c, bool aa = true);
653653
inline void setPixelColorXY(float x, float y, byte r, byte g, byte b, byte w = 0, bool aa = true) { setPixelColorXY(x, y, RGBW32(r,g,b,w), aa); }

wled00/FX_2Dfcn.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ uint16_t IRAM_ATTR_YN Segment::XY(int x, int y) const
154154
}
155155

156156
// raw setColor function without checks (checks are done in setPixelColorXY())
157-
void IRAM_ATTR_YN Segment::_setPixelColorXY_raw(int& x, int& y, uint32_t& col) const
157+
void IRAM_ATTR_YN Segment::_setPixelColorXY_raw(const int& x, const int& y, uint32_t& col) const
158158
{
159159
const int baseX = start + x;
160160
const int baseY = startY + y;
@@ -179,7 +179,7 @@ void IRAM_ATTR_YN Segment::_setPixelColorXY_raw(int& x, int& y, uint32_t& col) c
179179
}
180180
}
181181

182-
void IRAM_ATTR_YN Segment::setPixelColorXY(int x, int y, uint32_t col)
182+
void IRAM_ATTR_YN Segment::setPixelColorXY(int x, int y, uint32_t col) const
183183
{
184184
if (!isActive()) return; // not active
185185

@@ -276,8 +276,8 @@ void Segment::blur2D(uint8_t blur_x, uint8_t blur_y, bool smear) {
276276
if (!isActive()) return; // not active
277277
const unsigned cols = vWidth();
278278
const unsigned rows = vHeight();
279-
uint32_t lastnew;
280-
uint32_t last;
279+
uint32_t lastnew = BLACK;
280+
uint32_t last = BLACK;
281281
if (blur_x) {
282282
const uint8_t keepx = smear ? 255 : 255 - blur_x;
283283
const uint8_t seepx = blur_x >> 1;

wled00/FX_fcn.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ void Segment::swapSegenv(tmpsegd_t &tmpSeg) {
347347
}
348348
}
349349

350-
void Segment::restoreSegenv(tmpsegd_t &tmpSeg) {
350+
void Segment::restoreSegenv(const tmpsegd_t &tmpSeg) {
351351
//DEBUG_PRINTF_P(PSTR("-- Restoring temp seg: %p->(%p) [%d->%p]\n"), &tmpSeg, this, _dataLen, data);
352352
if (_t && &(_t->_segT) != &tmpSeg) {
353353
// update possibly changed variables to keep old effect running correctly
@@ -1134,8 +1134,8 @@ void Segment::blur(uint8_t blur_amount, bool smear) {
11341134
uint8_t seep = blur_amount >> 1;
11351135
unsigned vlength = vLength();
11361136
uint32_t carryover = BLACK;
1137-
uint32_t lastnew;
1138-
uint32_t last;
1137+
uint32_t lastnew = BLACK;
1138+
uint32_t last = BLACK;
11391139
uint32_t curnew = BLACK;
11401140
for (unsigned i = 0; i < vlength; i++) {
11411141
uint32_t cur = getPixelColor(i);

wled00/bus_manager.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extern bool cctICused;
2727
uint32_t colorBalanceFromKelvin(uint16_t kelvin, uint32_t rgb);
2828

2929
//udp.cpp
30-
uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, byte *buffer, uint8_t bri=255, bool isRGBW=false);
30+
uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, const uint8_t* buffer, uint8_t bri=255, bool isRGBW=false);
3131

3232
// enable additional debug output
3333
#if defined(WLED_DEBUG_HOST)
@@ -121,7 +121,7 @@ uint8_t *Bus::allocateData(size_t size) {
121121
}
122122

123123

124-
BusDigital::BusDigital(BusConfig &bc, uint8_t nr, const ColorOrderMap &com)
124+
BusDigital::BusDigital(const BusConfig &bc, uint8_t nr, const ColorOrderMap &com)
125125
: Bus(bc.type, bc.start, bc.autoWhite, bc.count, bc.reversed, (bc.refreshReq || bc.type == TYPE_TM1814))
126126
, _skip(bc.skipAmount) //sacrificial pixels
127127
, _colorOrder(bc.colorOrder)
@@ -448,7 +448,7 @@ void BusDigital::cleanup() {
448448
#endif
449449
#endif
450450

451-
BusPwm::BusPwm(BusConfig &bc)
451+
BusPwm::BusPwm(const BusConfig &bc)
452452
: Bus(bc.type, bc.start, bc.autoWhite, 1, bc.reversed, bc.refreshReq) // hijack Off refresh flag to indicate usage of dithering
453453
{
454454
if (!isPWM(bc.type)) return;
@@ -646,7 +646,7 @@ void BusPwm::deallocatePins() {
646646
}
647647

648648

649-
BusOnOff::BusOnOff(BusConfig &bc)
649+
BusOnOff::BusOnOff(const BusConfig &bc)
650650
: Bus(bc.type, bc.start, bc.autoWhite, 1, bc.reversed)
651651
, _onoffdata(0)
652652
{
@@ -699,7 +699,7 @@ std::vector<LEDType> BusOnOff::getLEDTypes() {
699699
};
700700
}
701701

702-
BusNetwork::BusNetwork(BusConfig &bc)
702+
BusNetwork::BusNetwork(const BusConfig &bc)
703703
: Bus(bc.type, bc.start, bc.autoWhite, bc.count)
704704
, _broadcastLock(false)
705705
{
@@ -778,7 +778,7 @@ void BusNetwork::cleanup() {
778778

779779

780780
//utility to get the approx. memory usage of a given BusConfig
781-
uint32_t BusManager::memUsage(BusConfig &bc) {
781+
uint32_t BusManager::memUsage(const BusConfig &bc) {
782782
if (Bus::isOnOff(bc.type) || Bus::isPWM(bc.type)) return OUTPUT_MAX_PINS;
783783

784784
unsigned len = bc.count + bc.skipAmount;
@@ -803,7 +803,7 @@ uint32_t BusManager::memUsage(unsigned maxChannels, unsigned maxCount, unsigned
803803
return (maxChannels * maxCount * minBuses * multiplier);
804804
}
805805

806-
int BusManager::add(BusConfig &bc) {
806+
int BusManager::add(const BusConfig &bc) {
807807
if (getNumBusses() - getNumVirtualBusses() >= WLED_MAX_BUSSES) return -1;
808808
if (Bus::isVirtual(bc.type)) {
809809
busses[numBusses] = new BusNetwork(bc);

wled00/bus_manager.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class Bus {
198198

199199
class BusDigital : public Bus {
200200
public:
201-
BusDigital(BusConfig &bc, uint8_t nr, const ColorOrderMap &com);
201+
BusDigital(const BusConfig &bc, uint8_t nr, const ColorOrderMap &com);
202202
~BusDigital() { cleanup(); }
203203

204204
void show() override;
@@ -250,7 +250,7 @@ class BusDigital : public Bus {
250250

251251
class BusPwm : public Bus {
252252
public:
253-
BusPwm(BusConfig &bc);
253+
BusPwm(const BusConfig &bc);
254254
~BusPwm() { cleanup(); }
255255

256256
void setPixelColor(unsigned pix, uint32_t c) override;
@@ -277,7 +277,7 @@ class BusPwm : public Bus {
277277

278278
class BusOnOff : public Bus {
279279
public:
280-
BusOnOff(BusConfig &bc);
280+
BusOnOff(const BusConfig &bc);
281281
~BusOnOff() { cleanup(); }
282282

283283
void setPixelColor(unsigned pix, uint32_t c) override;
@@ -296,7 +296,7 @@ class BusOnOff : public Bus {
296296

297297
class BusNetwork : public Bus {
298298
public:
299-
BusNetwork(BusConfig &bc);
299+
BusNetwork(const BusConfig &bc);
300300
~BusNetwork() { cleanup(); }
301301

302302
bool canShow() const override { return !_broadcastLock; } // this should be a return value from UDP routine if it is still sending data out
@@ -379,12 +379,12 @@ class BusManager {
379379
BusManager() {};
380380

381381
//utility to get the approx. memory usage of a given BusConfig
382-
static uint32_t memUsage(BusConfig &bc);
382+
static uint32_t memUsage(const BusConfig &bc);
383383
static uint32_t memUsage(unsigned channels, unsigned count, unsigned buses = 1);
384384
static uint16_t currentMilliamps() { return _milliAmpsUsed + MA_FOR_ESP; }
385385
static uint16_t ablMilliampsMax() { return _milliAmpsMax; }
386386

387-
static int add(BusConfig &bc);
387+
static int add(const BusConfig &bc);
388388
static void useParallelOutput(); // workaround for inaccessible PolyBus
389389

390390
//do not call this method from system context (network callback)

wled00/colors.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void setRandomColor(byte* rgb)
122122
* generates a random palette based on harmonic color theory
123123
* takes a base palette as the input, it will choose one color of the base palette and keep it
124124
*/
125-
CRGBPalette16 generateHarmonicRandomPalette(CRGBPalette16 &basepalette)
125+
CRGBPalette16 generateHarmonicRandomPalette(const CRGBPalette16 &basepalette)
126126
{
127127
CHSV palettecolors[4]; // array of colors for the new palette
128128
uint8_t keepcolorposition = hw_random8(4); // color position of current random palette to keep
@@ -391,7 +391,7 @@ void colorXYtoRGB(float x, float y, byte* rgb) //coordinates to rgb (https://www
391391
rgb[2] = byte(255.0f*b);
392392
}
393393

394-
void colorRGBtoXY(byte* rgb, float* xy) //rgb to coordinates (https://www.developers.meethue.com/documentation/color-conversions-rgb-xy)
394+
void colorRGBtoXY(const byte* rgb, float* xy) //rgb to coordinates (https://www.developers.meethue.com/documentation/color-conversions-rgb-xy)
395395
{
396396
float X = rgb[0] * 0.664511f + rgb[1] * 0.154324f + rgb[2] * 0.162028f;
397397
float Y = rgb[0] * 0.283881f + rgb[1] * 0.668433f + rgb[2] * 0.047685f;
@@ -402,7 +402,7 @@ void colorRGBtoXY(byte* rgb, float* xy) //rgb to coordinates (https://www.develo
402402
#endif // WLED_DISABLE_HUESYNC
403403

404404
//RRGGBB / WWRRGGBB order for hex
405-
void colorFromDecOrHexString(byte* rgb, char* in)
405+
void colorFromDecOrHexString(byte* rgb, const char* in)
406406
{
407407
if (in[0] == 0) return;
408408
char first = in[0];

wled00/fcn_declare.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ inline uint32_t color_blend16(uint32_t c1, uint32_t c2, uint16_t b) { return col
166166
[[gnu::hot]] uint32_t color_add(uint32_t, uint32_t, bool preserveCR = false);
167167
[[gnu::hot]] uint32_t color_fade(uint32_t c1, uint8_t amount, bool video=false);
168168
[[gnu::hot]] uint32_t ColorFromPaletteWLED(const CRGBPalette16 &pal, unsigned index, uint8_t brightness = (uint8_t)255U, TBlendType blendType = LINEARBLEND);
169-
CRGBPalette16 generateHarmonicRandomPalette(CRGBPalette16 &basepalette);
169+
CRGBPalette16 generateHarmonicRandomPalette(const CRGBPalette16 &basepalette);
170170
CRGBPalette16 generateRandomPalette();
171171
inline uint32_t colorFromRgbw(byte* rgbw) { return uint32_t((byte(rgbw[3]) << 24) | (byte(rgbw[0]) << 16) | (byte(rgbw[1]) << 8) | (byte(rgbw[2]))); }
172172
void hsv2rgb(const CHSV32& hsv, uint32_t& rgb);
@@ -177,7 +177,7 @@ void colorKtoRGB(uint16_t kelvin, byte* rgb);
177177
void colorCTtoRGB(uint16_t mired, byte* rgb); //white spectrum to rgb
178178
void colorXYtoRGB(float x, float y, byte* rgb); // only defined if huesync disabled TODO
179179
void colorRGBtoXY(byte* rgb, float* xy); // only defined if huesync disabled TODO
180-
void colorFromDecOrHexString(byte* rgb, char* in);
180+
void colorFromDecOrHexString(byte* rgb, const char* in);
181181
bool colorFromHexString(byte* rgb, const char* in);
182182
uint32_t colorBalanceFromKelvin(uint16_t kelvin, uint32_t rgb);
183183
uint16_t approximateKelvinFromRGB(uint32_t rgb);
@@ -200,14 +200,14 @@ void sendArtnetPollReply(ArtPollReply* reply, IPAddress ipAddress, uint16_t port
200200

201201
//file.cpp
202202
bool handleFileRead(AsyncWebServerRequest*, String path);
203-
bool writeObjectToFileUsingId(const char* file, uint16_t id, JsonDocument* content);
204-
bool writeObjectToFile(const char* file, const char* key, JsonDocument* content);
203+
bool writeObjectToFileUsingId(const char* file, uint16_t id, const JsonDocument* content);
204+
bool writeObjectToFile(const char* file, const char* key, const JsonDocument* content);
205205
bool readObjectFromFileUsingId(const char* file, uint16_t id, JsonDocument* dest);
206206
bool readObjectFromFile(const char* file, const char* key, JsonDocument* dest);
207207
void updateFSInfo();
208208
void closeFile();
209-
inline bool writeObjectToFileUsingId(const String &file, uint16_t id, JsonDocument* content) { return writeObjectToFileUsingId(file.c_str(), id, content); };
210-
inline bool writeObjectToFile(const String &file, const char* key, JsonDocument* content) { return writeObjectToFile(file.c_str(), key, content); };
209+
inline bool writeObjectToFileUsingId(const String &file, uint16_t id, const JsonDocument* content) { return writeObjectToFileUsingId(file.c_str(), id, content); };
210+
inline bool writeObjectToFile(const String &file, const char* key, const JsonDocument* content) { return writeObjectToFile(file.c_str(), key, content); };
211211
inline bool readObjectFromFileUsingId(const String &file, uint16_t id, JsonDocument* dest) { return readObjectFromFileUsingId(file.c_str(), id, dest); };
212212
inline bool readObjectFromFile(const String &file, const char* key, JsonDocument* dest) { return readObjectFromFile(file.c_str(), key, dest); };
213213

@@ -248,7 +248,7 @@ void handleIR();
248248

249249
bool deserializeSegment(JsonObject elem, byte it, byte presetId = 0);
250250
bool deserializeState(JsonObject root, byte callMode = CALL_MODE_DIRECT_CHANGE, byte presetId = 0);
251-
void serializeSegment(JsonObject& root, Segment& seg, byte id, bool forPreset = false, bool segmentBounds = true);
251+
void serializeSegment(const JsonObject& root, const Segment& seg, byte id, bool forPreset = false, bool segmentBounds = true);
252252
void serializeState(JsonObject root, bool forPreset = false, bool includeBri = true, bool segmentBounds = true, bool selectedSegmentsOnly = false);
253253
void serializeInfo(JsonObject root);
254254
void serializeModeNames(JsonArray root);
@@ -333,7 +333,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply=tru
333333

334334
//udp.cpp
335335
void notify(byte callMode, bool followUp=false);
336-
uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, uint8_t *buffer, uint8_t bri=255, bool isRGBW=false);
336+
uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, const uint8_t* buffer, uint8_t bri=255, bool isRGBW=false);
337337
void realtimeLock(uint32_t timeoutMs, byte md = REALTIME_MODE_GENERIC);
338338
void exitRealtime();
339339
void handleNotifications();

wled00/file.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ static void writeSpace(size_t l)
176176
if (knownLargestSpace < l) knownLargestSpace = l;
177177
}
178178

179-
bool appendObjectToFile(const char* key, JsonDocument* content, uint32_t s, uint32_t contentLen = 0)
179+
bool appendObjectToFile(const char* key, const JsonDocument* content, uint32_t s, uint32_t contentLen = 0)
180180
{
181181
#ifdef WLED_DEBUG_FS
182182
DEBUGFS_PRINTLN(F("Append"));
@@ -255,14 +255,14 @@ bool appendObjectToFile(const char* key, JsonDocument* content, uint32_t s, uint
255255
return true;
256256
}
257257

258-
bool writeObjectToFileUsingId(const char* file, uint16_t id, JsonDocument* content)
258+
bool writeObjectToFileUsingId(const char* file, uint16_t id, const JsonDocument* content)
259259
{
260260
char objKey[10];
261261
sprintf(objKey, "\"%d\":", id);
262262
return writeObjectToFile(file, objKey, content);
263263
}
264264

265-
bool writeObjectToFile(const char* file, const char* key, JsonDocument* content)
265+
bool writeObjectToFile(const char* file, const char* key, const JsonDocument* content)
266266
{
267267
uint32_t s = 0; //timing
268268
#ifdef WLED_DEBUG_FS

wled00/json.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
493493
return stateResponse;
494494
}
495495

496-
void serializeSegment(JsonObject& root, Segment& seg, byte id, bool forPreset, bool segmentBounds)
496+
void serializeSegment(const JsonObject& root, const Segment& seg, byte id, bool forPreset, bool segmentBounds)
497497
{
498498
root["id"] = id;
499499
if (segmentBounds) {

wled00/ntp.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ void sendNTPPacket()
224224
ntpUdp.endPacket();
225225
}
226226

227-
static bool isValidNtpResponse(byte * ntpPacket) {
227+
static bool isValidNtpResponse(const byte* ntpPacket) {
228228
// Perform a few validity checks on the packet
229229
// based on https://github.com/taranais/NTPClient/blob/master/NTPClient.cpp
230230
if((ntpPacket[0] & 0b11000000) == 0b11000000) return false; //reject LI=UNSYNC

wled00/set.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -990,18 +990,18 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
990990
//set color from HEX or 32bit DEC
991991
pos = req.indexOf(F("CL="));
992992
if (pos > 0) {
993-
colorFromDecOrHexString(colIn, (char*)req.substring(pos + 3).c_str());
993+
colorFromDecOrHexString(colIn, (const char*)req.substring(pos + 3).c_str());
994994
col0Changed = true;
995995
}
996996
pos = req.indexOf(F("C2="));
997997
if (pos > 0) {
998-
colorFromDecOrHexString(colInSec, (char*)req.substring(pos + 3).c_str());
998+
colorFromDecOrHexString(colInSec, (const char*)req.substring(pos + 3).c_str());
999999
col1Changed = true;
10001000
}
10011001
pos = req.indexOf(F("C3="));
10021002
if (pos > 0) {
10031003
byte tmpCol[4];
1004-
colorFromDecOrHexString(tmpCol, (char*)req.substring(pos + 3).c_str());
1004+
colorFromDecOrHexString(tmpCol, (const char*)req.substring(pos + 3).c_str());
10051005
col2 = RGBW32(tmpCol[0], tmpCol[1], tmpCol[2], tmpCol[3]);
10061006
selseg.setColor(2, col2); // defined above (SS= or main)
10071007
col2Changed = true;

0 commit comments

Comments
 (0)