Avoid shadowing global col[]
This commit is contained in:
		| @@ -40,7 +40,7 @@ void longPressAction(uint8_t b) | ||||
| { | ||||
|   if (!macroLongPress[b]) { | ||||
|     switch (b) { | ||||
|       case 0: setRandomColor(col); colorUpdated(CALL_MODE_BUTTON); break; | ||||
|       case 0: setRandomColor(colPri); colorUpdated(CALL_MODE_BUTTON); break; | ||||
|       case 1:  | ||||
|         if(buttonBriDirection) { | ||||
|           if (bri == 255) break; // avoid unnecessary updates to brightness | ||||
| @@ -230,7 +230,7 @@ void handleAnalog(uint8_t b) | ||||
|       effectPalette = constrain(effectPalette, 0, strip.getPaletteCount()-1);  // map is allowed to "overshoot", so we need to contrain the result | ||||
|     } else if (macroDoublePress[b] == 200) { | ||||
|       // primary color, hue, full saturation | ||||
|       colorHStoRGB(aRead*256,255,col); | ||||
|       colorHStoRGB(aRead*256,255,colPri); | ||||
|     } else { | ||||
|       // otherwise use "double press" for segment selection | ||||
|       Segment& seg = strip.getSegment(macroDoublePress[b]); | ||||
|   | ||||
| @@ -9,10 +9,10 @@ void setValuesFromFirstSelectedSeg() { setValuesFromSegment(strip.getFirstSelect | ||||
| void setValuesFromSegment(uint8_t s) | ||||
| { | ||||
|   Segment& seg = strip.getSegment(s); | ||||
|   col[0] = R(seg.colors[0]); | ||||
|   col[1] = G(seg.colors[0]); | ||||
|   col[2] = B(seg.colors[0]); | ||||
|   col[3] = W(seg.colors[0]); | ||||
|   colPri[0] = R(seg.colors[0]); | ||||
|   colPri[1] = G(seg.colors[0]); | ||||
|   colPri[2] = B(seg.colors[0]); | ||||
|   colPri[3] = W(seg.colors[0]); | ||||
|   colSec[0] = R(seg.colors[1]); | ||||
|   colSec[1] = G(seg.colors[1]); | ||||
|   colSec[2] = B(seg.colors[1]); | ||||
| @@ -39,7 +39,7 @@ void applyValuesToSelectedSegs() | ||||
|     if (effectIntensity != selsegPrev.intensity) {seg.intensity = effectIntensity; stateChanged = true;} | ||||
|     if (effectPalette   != selsegPrev.palette)   {seg.setPalette(effectPalette);} | ||||
|     if (effectCurrent   != selsegPrev.mode)      {seg.setMode(effectCurrent);} | ||||
|     uint32_t col0 = RGBW32(   col[0],    col[1],    col[2],    col[3]); | ||||
|     uint32_t col0 = RGBW32(colPri[0], colPri[1], colPri[2], colPri[3]); | ||||
|     uint32_t col1 = RGBW32(colSec[0], colSec[1], colSec[2], colSec[3]); | ||||
|     if (col0 != selsegPrev.colors[0])            {seg.setColor(0, col0);} | ||||
|     if (col1 != selsegPrev.colors[1])            {seg.setColor(1, col1);} | ||||
| @@ -158,7 +158,7 @@ void updateInterfaces(uint8_t callMode) { | ||||
|   #ifndef WLED_DISABLE_ALEXA | ||||
|   if (espalexaDevice != nullptr && callMode != CALL_MODE_ALEXA) { | ||||
|     espalexaDevice->setValue(bri); | ||||
|     espalexaDevice->setColor(col[0], col[1], col[2]); | ||||
|     espalexaDevice->setColor(colPri[0], colPri[1], colPri[2]); | ||||
|   } | ||||
|   #endif | ||||
|   #ifndef WLED_DISABLE_MQTT | ||||
| @@ -212,7 +212,7 @@ void handleNightlight() { | ||||
|       nightlightDelayMs = (unsigned)(nightlightDelayMins*60000); | ||||
|       nightlightActiveOld = true; | ||||
|       briNlT = bri; | ||||
|       for (unsigned i=0; i<4; i++) colNlT[i] = col[i]; // remember starting color | ||||
|       for (unsigned i=0; i<4; i++) colNlT[i] = colPri[i]; // remember starting color | ||||
|       if (nightlightMode == NL_MODE_SUN) | ||||
|       { | ||||
|         //save current | ||||
| @@ -237,7 +237,7 @@ void handleNightlight() { | ||||
|       bri = briNlT + ((nightlightTargetBri - briNlT)*nper); | ||||
|       if (nightlightMode == NL_MODE_COLORFADE)                                         // color fading only is enabled with "NF=2" | ||||
|       { | ||||
|         for (unsigned i=0; i<4; i++) col[i] = colNlT[i]+ ((colSec[i] - colNlT[i])*nper);   // fading from actual color to secondary color | ||||
|         for (unsigned i=0; i<4; i++) colPri[i] = colNlT[i]+ ((colSec[i] - colNlT[i])*nper);   // fading from actual color to secondary color | ||||
|       } | ||||
|       colorUpdated(CALL_MODE_NO_NOTIFY); | ||||
|     } | ||||
|   | ||||
| @@ -103,7 +103,7 @@ static void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProp | ||||
|   //Prefix is stripped from the topic at this point | ||||
|  | ||||
|   if (strcmp_P(topic, PSTR("/col")) == 0) { | ||||
|     colorFromDecOrHexString(col, payloadStr); | ||||
|     colorFromDecOrHexString(colPri, payloadStr); | ||||
|     colorUpdated(CALL_MODE_DIRECT_CHANGE); | ||||
|   } else if (strcmp_P(topic, PSTR("/api")) == 0) { | ||||
|     if (requestJSONBufferLock(15)) { | ||||
| @@ -169,7 +169,7 @@ void publishMqtt() | ||||
|   strcat_P(subuf, PSTR("/g")); | ||||
|   mqtt->publish(subuf, 0, retainMqttMsg, s);         // optionally retain message (#2263) | ||||
|  | ||||
|   sprintf_P(s, PSTR("#%06X"), (col[3] << 24) | (col[0] << 16) | (col[1] << 8) | (col[2])); | ||||
|   sprintf_P(s, PSTR("#%06X"), (colPri[3] << 24) | (colPri[0] << 16) | (colPri[1] << 8) | (colPri[2])); | ||||
|   strlcpy(subuf, mqttDeviceTopic, MQTT_MAX_TOPIC_LEN + 1); | ||||
|   strcat_P(subuf, PSTR("/c")); | ||||
|   mqtt->publish(subuf, 0, retainMqttMsg, s);         // optionally retain message (#2263) | ||||
|   | ||||
| @@ -1191,7 +1191,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply) | ||||
|   } | ||||
|   // you can add more if you need | ||||
|  | ||||
|   // global col[], effectCurrent, ... are updated in stateChanged() | ||||
|   // global colPri[], effectCurrent, ... are updated in stateChanged() | ||||
|   if (!apply) return true; // when called by JSON API, do not call colorUpdated() here | ||||
|  | ||||
|   pos = req.indexOf(F("&NN")); //do not send UDP notifications this time | ||||
|   | ||||
| @@ -550,7 +550,7 @@ void WLED::beginStrip() | ||||
|         Segment &seg = strip.getSegment(i); | ||||
|         if (seg.isActive()) seg.colors[0] = BLACK; | ||||
|       } | ||||
|       col[0] = col[1] = col[2] = col[3] = 0;  // needed for colorUpdated() | ||||
|       colPri[0] = colPri[1] = colPri[2] = colPri[3] = 0;  // needed for colorUpdated() | ||||
|     } | ||||
|     briLast = briS; bri = 0; | ||||
|     strip.fill(BLACK); | ||||
|   | ||||
| @@ -411,7 +411,7 @@ WLED_GLOBAL bool gammaCorrectCol    _INIT(true);  // use gamma correction on col | ||||
| WLED_GLOBAL bool gammaCorrectBri    _INIT(false); // use gamma correction on brightness | ||||
| WLED_GLOBAL float gammaCorrectVal   _INIT(2.8f);  // gamma correction value | ||||
|  | ||||
| WLED_GLOBAL byte col[]    _INIT_N(({ 255, 160, 0, 0 }));  // current RGB(W) primary color. col[] should be updated if you want to change the color. | ||||
| WLED_GLOBAL byte colPri[] _INIT_N(({ 255, 160, 0, 0 }));  // current RGB(W) primary color. colPri[] should be updated if you want to change the color. | ||||
| WLED_GLOBAL byte colSec[] _INIT_N(({ 0, 0, 0, 0 }));      // current RGB(W) secondary color | ||||
|  | ||||
| WLED_GLOBAL byte nightlightTargetBri _INIT(0);      // brightness after nightlight is over | ||||
|   | ||||
| @@ -11,7 +11,7 @@ void XML_response(Print& dest) | ||||
|   dest.printf_P(PSTR("<?xml version=\"1.0\" ?><vs><ac>%d</ac>"), (nightlightActive && nightlightMode > NL_MODE_SET) ? briT : bri); | ||||
|   for (int i = 0; i < 3; i++) | ||||
|   { | ||||
|    dest.printf_P(PSTR("<cl>%d</cl>"), col[i]); | ||||
|    dest.printf_P(PSTR("<cl>%d</cl>"), colPri[i]); | ||||
|   } | ||||
|   for (int i = 0; i < 3; i++) | ||||
|   { | ||||
| @@ -20,7 +20,7 @@ void XML_response(Print& dest) | ||||
|   dest.printf_P(PSTR("<ns>%d</ns><nr>%d</nr><nl>%d</nl><nf>%d</nf><nd>%d</nd><nt>%d</nt><fx>%d</fx><sx>%d</sx><ix>%d</ix><fp>%d</fp><wv>%d</wv><ws>%d</ws><ps>%d</ps><cy>%d</cy><ds>%s%s</ds><ss>%d</ss></vs>"), | ||||
|     notifyDirect, receiveGroups!=0, nightlightActive, nightlightMode > NL_MODE_SET, nightlightDelayMins, | ||||
|     nightlightTargetBri, effectCurrent, effectSpeed, effectIntensity, effectPalette, | ||||
|     strip.hasWhiteChannel() ? col[3] : -1, colSec[3], currentPreset, currentPlaylist >= 0, | ||||
|     strip.hasWhiteChannel() ? colPri[3] : -1, colSec[3], currentPreset, currentPlaylist >= 0, | ||||
|     serverDescription, realtimeMode ? PSTR(" (live)") : "", | ||||
|     strip.getFirstSelectedSegId() | ||||
|   ); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Blaž Kristan
					Blaž Kristan