Converted indentation tabs to spaces.

pull/2427/head
Blaž Kristan 2022-01-25 12:47:14 +01:00
rodzic 5f0b102671
commit 7f6adfa331
3 zmienionych plików z 80 dodań i 80 usunięć

Wyświetl plik

@ -8,7 +8,7 @@
bool getVal(JsonVariant elem, byte* val, byte vmin=0, byte vmax=255) { bool getVal(JsonVariant elem, byte* val, byte vmin=0, byte vmax=255) {
if (elem.is<int>()) { if (elem.is<int>()) {
if (elem < 0) return false; //ignore e.g. {"ps":-1} if (elem < 0) return false; //ignore e.g. {"ps":-1}
*val = elem; *val = elem;
return true; return true;
} else if (elem.is<const char*>()) { } else if (elem.is<const char*>()) {
@ -82,7 +82,7 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
uint16_t grp = elem["grp"] | seg.grouping; uint16_t grp = elem["grp"] | seg.grouping;
uint16_t spc = elem[F("spc")] | seg.spacing; uint16_t spc = elem[F("spc")] | seg.spacing;
uint16_t of = seg.offset; uint16_t of = seg.offset;
if (!(elem[F("spc")].isNull() && elem["grp"].isNull())) effectChanged = true; //send UDP if (!(elem[F("spc")].isNull() && elem["grp"].isNull())) effectChanged = true; //send UDP
uint16_t len = 1; uint16_t len = 1;
@ -95,7 +95,7 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
of = offsetAbs; of = offsetAbs;
} }
if (stop > start && of > len -1) of = len -1; if (stop > start && of > len -1) of = len -1;
strip.setSegment(id, start, stop, grp, spc, of); strip.setSegment(id, start, stop, grp, spc, of);
byte segbri = 0; byte segbri = 0;
if (getVal(elem["bri"], &segbri)) { if (getVal(elem["bri"], &segbri)) {
@ -110,9 +110,9 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
if (elem["frz"].is<const char*>() && elem["frz"].as<const char*>()[0] == 't') frz = !seg.getOption(SEG_OPTION_FREEZE); if (elem["frz"].is<const char*>() && elem["frz"].as<const char*>()[0] == 't') frz = !seg.getOption(SEG_OPTION_FREEZE);
seg.setOption(SEG_OPTION_FREEZE, frz, id); seg.setOption(SEG_OPTION_FREEZE, frz, id);
uint8_t cctPrev = seg.cct; uint8_t cctPrev = seg.cct;
seg.setCCT(elem["cct"] | seg.cct, id); seg.setCCT(elem["cct"] | seg.cct, id);
if (seg.cct != cctPrev && id == strip.getMainSegmentId()) effectChanged = true; //send UDP if (seg.cct != cctPrev && id == strip.getMainSegmentId()) effectChanged = true; //send UDP
JsonArray colarr = elem["col"]; JsonArray colarr = elem["col"];
if (!colarr.isNull()) if (!colarr.isNull())
@ -398,12 +398,12 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
void serializeSegment(JsonObject& root, WS2812FX::Segment& seg, byte id, bool forPreset, bool segmentBounds) void serializeSegment(JsonObject& root, WS2812FX::Segment& seg, byte id, bool forPreset, bool segmentBounds)
{ {
root["id"] = id; root["id"] = id;
if (segmentBounds) { if (segmentBounds) {
root["start"] = seg.start; root["start"] = seg.start;
root["stop"] = seg.stop; root["stop"] = seg.stop;
} }
if (!forPreset) root[F("len")] = seg.stop - seg.start; if (!forPreset) root[F("len")] = seg.stop - seg.start;
root["grp"] = seg.grouping; root["grp"] = seg.grouping;
root[F("spc")] = seg.spacing; root[F("spc")] = seg.spacing;
root[F("of")] = seg.offset; root[F("of")] = seg.offset;
@ -438,12 +438,12 @@ void serializeSegment(JsonObject& root, WS2812FX::Segment& seg, byte id, bool fo
strcat_P(colstr, PSTR("]")); strcat_P(colstr, PSTR("]"));
root["col"] = serialized(colstr); root["col"] = serialized(colstr);
root["fx"] = seg.mode; root["fx"] = seg.mode;
root[F("sx")] = seg.speed; root[F("sx")] = seg.speed;
root[F("ix")] = seg.intensity; root[F("ix")] = seg.intensity;
root["pal"] = seg.palette; root["pal"] = seg.palette;
root[F("sel")] = seg.isSelected(); root[F("sel")] = seg.isSelected();
root["rev"] = seg.getOption(SEG_OPTION_REVERSED); root["rev"] = seg.getOption(SEG_OPTION_REVERSED);
root[F("mi")] = seg.getOption(SEG_OPTION_MIRROR); root[F("mi")] = seg.getOption(SEG_OPTION_MIRROR);
} }
@ -527,12 +527,12 @@ void serializeInfo(JsonObject root)
leds[F("rgbw")] = strip.isRgbw; leds[F("rgbw")] = strip.isRgbw;
leds[F("wv")] = false; leds[F("wv")] = false;
leds["cct"] = correctWB || strip.hasCCTBus(); leds["cct"] = correctWB || strip.hasCCTBus();
switch (Bus::getAutoWhiteMode()) { switch (Bus::getAutoWhiteMode()) {
case RGBW_MODE_MANUAL_ONLY: case RGBW_MODE_MANUAL_ONLY:
case RGBW_MODE_DUAL: case RGBW_MODE_DUAL:
if (strip.isRgbw) leds[F("wv")] = true; if (strip.isRgbw) leds[F("wv")] = true;
break; break;
} }
leds[F("pwr")] = strip.currentMilliamps; leds[F("pwr")] = strip.currentMilliamps;
leds["fps"] = strip.getFps(); leds["fps"] = strip.getFps();

Wyświetl plik

@ -130,7 +130,7 @@ void colorUpdated(int callMode)
void updateInterfaces(uint8_t callMode) void updateInterfaces(uint8_t callMode)
{ {
sendDataWs(); sendDataWs();
lastInterfaceUpdate = millis(); lastInterfaceUpdate = millis();
if (callMode == CALL_MODE_WS_SEND) return; if (callMode == CALL_MODE_WS_SEND) return;
#ifndef WLED_DISABLE_ALEXA #ifndef WLED_DISABLE_ALEXA

Wyświetl plik

@ -19,7 +19,7 @@ void notify(byte callMode, bool followUp)
case CALL_MODE_INIT: return; case CALL_MODE_INIT: return;
case CALL_MODE_DIRECT_CHANGE: if (!notifyDirect) return; break; case CALL_MODE_DIRECT_CHANGE: if (!notifyDirect) return; break;
case CALL_MODE_BUTTON: if (!notifyButton) return; break; case CALL_MODE_BUTTON: if (!notifyButton) return; break;
case CALL_MODE_BUTTON_PRESET: if (!notifyButton) return; break; case CALL_MODE_BUTTON_PRESET: if (!notifyButton) return; break;
case CALL_MODE_NIGHTLIGHT: if (!notifyDirect) return; break; case CALL_MODE_NIGHTLIGHT: if (!notifyDirect) return; break;
case CALL_MODE_HUE: if (!notifyHue) return; break; case CALL_MODE_HUE: if (!notifyHue) return; break;
case CALL_MODE_PRESET_CYCLE: if (!notifyDirect) return; break; case CALL_MODE_PRESET_CYCLE: if (!notifyDirect) return; break;
@ -28,7 +28,7 @@ void notify(byte callMode, bool followUp)
default: return; default: return;
} }
byte udpOut[WLEDPACKETSIZE]; byte udpOut[WLEDPACKETSIZE];
WS2812FX::Segment& mainseg = strip.getSegment(strip.getMainSegmentId()); WS2812FX::Segment& mainseg = strip.getSegment(strip.getMainSegmentId());
udpOut[0] = 0; //0: wled notifier protocol 1: WARLS protocol udpOut[0] = 0; //0: wled notifier protocol 1: WARLS protocol
udpOut[1] = callMode; udpOut[1] = callMode;
udpOut[2] = bri; udpOut[2] = bri;
@ -81,22 +81,22 @@ void notify(byte callMode, bool followUp)
//sync groups //sync groups
udpOut[36] = syncGroups; udpOut[36] = syncGroups;
//Might be changed to Kelvin in the future, receiver code should handle that case
//0: byte 38 contains 0-255 value, 255: no valid CCT, 1-254: Kelvin value MSB
udpOut[37] = strip.hasCCTBus() ? 0 : 255; //check this is 0 for the next value to be significant
udpOut[38] = mainseg.cct;
udpOut[39] = strip.getMaxSegments(); //Might be changed to Kelvin in the future, receiver code should handle that case
udpOut[40] = UDP_SEG_SIZE; //size of each loop iteration (one segment) //0: byte 38 contains 0-255 value, 255: no valid CCT, 1-254: Kelvin value MSB
udpOut[37] = strip.hasCCTBus() ? 0 : 255; //check this is 0 for the next value to be significant
udpOut[38] = mainseg.cct;
udpOut[39] = strip.getMaxSegments();
udpOut[40] = UDP_SEG_SIZE; //size of each loop iteration (one segment)
for (uint8_t i = 0; i < strip.getMaxSegments(); i++) { for (uint8_t i = 0; i < strip.getMaxSegments(); i++) {
WS2812FX::Segment &selseg = strip.getSegment(i); WS2812FX::Segment &selseg = strip.getSegment(i);
uint16_t ofs = 41 + i*UDP_SEG_SIZE; //start of segment offset byte uint16_t ofs = 41 + i*UDP_SEG_SIZE; //start of segment offset byte
udpOut[0 +ofs] = i; udpOut[0 +ofs] = i;
udpOut[1 +ofs] = selseg.start >> 8; udpOut[1 +ofs] = selseg.start >> 8;
udpOut[2 +ofs] = selseg.start & 0xFF; udpOut[2 +ofs] = selseg.start & 0xFF;
udpOut[3 +ofs] = selseg.stop >> 8; udpOut[3 +ofs] = selseg.stop >> 8;
udpOut[4 +ofs] = selseg.stop & 0xFF; udpOut[4 +ofs] = selseg.stop & 0xFF;
udpOut[5 +ofs] = selseg.grouping; udpOut[5 +ofs] = selseg.grouping;
udpOut[6 +ofs] = selseg.spacing; udpOut[6 +ofs] = selseg.spacing;
udpOut[7 +ofs] = selseg.offset >> 8; udpOut[7 +ofs] = selseg.offset >> 8;
@ -119,11 +119,11 @@ void notify(byte callMode, bool followUp)
udpOut[24+ofs] = G(selseg.colors[2]); udpOut[24+ofs] = G(selseg.colors[2]);
udpOut[25+ofs] = B(selseg.colors[2]); udpOut[25+ofs] = B(selseg.colors[2]);
udpOut[26+ofs] = W(selseg.colors[2]); udpOut[26+ofs] = W(selseg.colors[2]);
udpOut[27+ofs] = selseg.cct; udpOut[27+ofs] = selseg.cct;
} }
//uint16_t offs = SEG_OFFSET; //uint16_t offs = SEG_OFFSET;
//next value to be added has index: udpOut[offs + 0] //next value to be added has index: udpOut[offs + 0]
IPAddress broadcastIp; IPAddress broadcastIp;
broadcastIp = ~uint32_t(Network.subnetMask()) | uint32_t(Network.gatewayIP()); broadcastIp = ~uint32_t(Network.subnetMask()) | uint32_t(Network.gatewayIP());
@ -290,9 +290,9 @@ void handleNotifications()
//apply colors from notification to main segment, only if not syncing full segments //apply colors from notification to main segment, only if not syncing full segments
if ((receiveNotificationColor || !someSel) && (version < 11 || !receiveSegmentOptions)) { if ((receiveNotificationColor || !someSel) && (version < 11 || !receiveSegmentOptions)) {
col[0] = udpIn[3]; col[0] = udpIn[3];
col[1] = udpIn[4]; col[1] = udpIn[4];
col[2] = udpIn[5]; col[2] = udpIn[5];
if (version > 0) //sending module's white val is intended if (version > 0) //sending module's white val is intended
{ {
col[3] = udpIn[10]; col[3] = udpIn[10];
@ -304,59 +304,59 @@ void handleNotifications()
} }
if (version > 6) { if (version > 6) {
strip.setColor(2, RGBW32(udpIn[20], udpIn[21], udpIn[22], udpIn[23])); //tertiary color strip.setColor(2, RGBW32(udpIn[20], udpIn[21], udpIn[22], udpIn[23])); //tertiary color
if (version > 9 && version < 200 && udpIn[37] < 255) { //valid CCT/Kelvin value if (version > 9 && version < 200 && udpIn[37] < 255) { //valid CCT/Kelvin value
uint8_t cct = udpIn[38]; uint8_t cct = udpIn[38];
if (udpIn[37] > 0) { //Kelvin if (udpIn[37] > 0) { //Kelvin
cct = (((udpIn[37] << 8) + udpIn[38]) - 1900) >> 5; cct = (((udpIn[37] << 8) + udpIn[38]) - 1900) >> 5;
} }
uint8_t segid = strip.getMainSegmentId(); uint8_t segid = strip.getMainSegmentId();
strip.getSegment(segid).setCCT(cct, segid); strip.getSegment(segid).setCCT(cct, segid);
} }
} }
} }
} }
bool timebaseUpdated = false; bool timebaseUpdated = false;
//apply effects from notification //apply effects from notification
bool applyEffects = (receiveNotificationEffects || !someSel); bool applyEffects = (receiveNotificationEffects || !someSel);
if (version < 200) if (version < 200)
{ {
if (applyEffects && currentPlaylist >= 0) unloadPlaylist(); if (applyEffects && currentPlaylist >= 0) unloadPlaylist();
if (version > 10 && receiveSegmentOptions) { if (version > 10 && receiveSegmentOptions) {
//does not sync start & stop //does not sync start & stop
uint8_t srcSegs = udpIn[39]; uint8_t srcSegs = udpIn[39];
//if (srcSegs > strip.getMaxSegments()) srcSegs = strip.getMaxSegments(); //if (srcSegs > strip.getMaxSegments()) srcSegs = strip.getMaxSegments();
for (uint8_t i = 0; i < srcSegs; i++) { for (uint8_t i = 0; i < srcSegs; i++) {
uint16_t ofs = 41 + i*udpIn[40]; //start of segment offset byte uint16_t ofs = 41 + i*udpIn[40]; //start of segment offset byte
uint8_t id = udpIn[0 +ofs]; uint8_t id = udpIn[0 +ofs];
if (id > strip.getMaxSegments()) continue; if (id > strip.getMaxSegments()) continue;
WS2812FX::Segment& selseg = strip.getSegment(id); WS2812FX::Segment& selseg = strip.getSegment(id);
//bytes 1+2 contain start, 3+4 stop, unused at this time //bytes 1+2 contain start, 3+4 stop, unused at this time
for (uint8_t j = 0; j<4; j++) selseg.setOption(j, (udpIn[9 +ofs] >> j) & 0x01); //only take into account mirrored, selected, on, reversed for (uint8_t j = 0; j<4; j++) selseg.setOption(j, (udpIn[9 +ofs] >> j) & 0x01); //only take into account mirrored, selected, on, reversed
selseg.setOpacity(udpIn[10+ofs], id); selseg.setOpacity(udpIn[10+ofs], id);
if (applyEffects) { if (applyEffects) {
strip.setMode(id, udpIn[11+ofs]); strip.setMode(id, udpIn[11+ofs]);
selseg.speed = udpIn[12+ofs]; selseg.speed = udpIn[12+ofs];
selseg.intensity = udpIn[13+ofs]; selseg.intensity = udpIn[13+ofs];
selseg.palette = udpIn[14+ofs]; selseg.palette = udpIn[14+ofs];
} }
if (receiveNotificationColor || !someSel) { if (receiveNotificationColor || !someSel) {
selseg.setColor(0, RGBW32(udpIn[15+ofs],udpIn[16+ofs],udpIn[17+ofs],udpIn[18+ofs]), id); selseg.setColor(0, RGBW32(udpIn[15+ofs],udpIn[16+ofs],udpIn[17+ofs],udpIn[18+ofs]), id);
selseg.setColor(1, RGBW32(udpIn[19+ofs],udpIn[20+ofs],udpIn[21+ofs],udpIn[22+ofs]), id); selseg.setColor(1, RGBW32(udpIn[19+ofs],udpIn[20+ofs],udpIn[21+ofs],udpIn[22+ofs]), id);
selseg.setColor(2, RGBW32(udpIn[23+ofs],udpIn[24+ofs],udpIn[25+ofs],udpIn[26+ofs]), id); selseg.setColor(2, RGBW32(udpIn[23+ofs],udpIn[24+ofs],udpIn[25+ofs],udpIn[26+ofs]), id);
selseg.setCCT(udpIn[27+ofs], id); selseg.setCCT(udpIn[27+ofs], id);
} }
strip.setSegment(id, selseg.start, selseg.stop, udpIn[5+ofs], udpIn[6+ofs], (udpIn[7+ofs]<<8 | udpIn[8+ofs])); //also properly resets segments strip.setSegment(id, selseg.start, selseg.stop, udpIn[5+ofs], udpIn[6+ofs], (udpIn[7+ofs]<<8 | udpIn[8+ofs])); //also properly resets segments
} }
setValuesFromMainSeg(); setValuesFromMainSeg();
effectChanged = true; effectChanged = true;
colorChanged = true; colorChanged = true;
} else if (applyEffects) { //simple effect sync, applies to all selected } else if (applyEffects) { //simple effect sync, applies to all selected
if (udpIn[8] < strip.getModeCount()) effectCurrent = udpIn[8]; if (udpIn[8] < strip.getModeCount()) effectCurrent = udpIn[8];
effectSpeed = udpIn[9]; effectSpeed = udpIn[9];
if (version > 2) effectIntensity = udpIn[16]; if (version > 2) effectIntensity = udpIn[16];
if (version > 4 && udpIn[19] < strip.getPaletteCount()) effectPalette = udpIn[19]; if (version > 4 && udpIn[19] < strip.getPaletteCount()) effectPalette = udpIn[19];
} }
if (applyEffects && version > 5) { if (applyEffects && version > 5) {
uint32_t t = (udpIn[25] << 24) | (udpIn[26] << 16) | (udpIn[27] << 8) | (udpIn[28]); uint32_t t = (udpIn[25] << 24) | (udpIn[26] << 16) | (udpIn[27] << 8) | (udpIn[28]);