mirror of
https://github.com/wled/WLED.git
synced 2025-07-21 17:56:33 +00:00
Size optimisations
This commit is contained in:
parent
551b8af76d
commit
efa32ed4f6
@ -80,15 +80,15 @@ uint8_t IRAM_ATTR ColorOrderMap::getPixelColorOrder(uint16_t pix, uint8_t defaul
|
||||
|
||||
|
||||
uint32_t Bus::autoWhiteCalc(uint32_t c) {
|
||||
uint8_t aWM = _autoWhiteMode;
|
||||
unsigned aWM = _autoWhiteMode;
|
||||
if (_gAWM < AW_GLOBAL_DISABLED) aWM = _gAWM;
|
||||
if (aWM == RGBW_MODE_MANUAL_ONLY) return c;
|
||||
uint8_t w = W(c);
|
||||
unsigned w = W(c);
|
||||
//ignore auto-white calculation if w>0 and mode DUAL (DUAL behaves as BRIGHTER if w==0)
|
||||
if (w > 0 && aWM == RGBW_MODE_DUAL) return c;
|
||||
uint8_t r = R(c);
|
||||
uint8_t g = G(c);
|
||||
uint8_t b = B(c);
|
||||
unsigned r = R(c);
|
||||
unsigned g = G(c);
|
||||
unsigned b = B(c);
|
||||
if (aWM == RGBW_MODE_MAX) return RGBW32(r, g, b, r > g ? (r > b ? r : b) : (g > b ? g : b)); // brightest RGB channel
|
||||
w = r < g ? (r < b ? r : b) : (g < b ? g : b);
|
||||
if (aWM == RGBW_MODE_AUTO_ACCURATE) { r -= w; g -= w; b -= w; } //subtract w in ACCURATE mode
|
||||
@ -207,7 +207,7 @@ void BusDigital::show() {
|
||||
if (!_valid) return;
|
||||
|
||||
uint8_t cctWW = 0, cctCW = 0;
|
||||
uint8_t newBri = estimateCurrentAndLimitBri(); // will fill _milliAmpsTotal
|
||||
unsigned newBri = estimateCurrentAndLimitBri(); // will fill _milliAmpsTotal
|
||||
if (newBri < _bri) PolyBus::setBrightness(_busPtr, _iType, newBri); // limit brightness to stay within current limits
|
||||
|
||||
if (_data) {
|
||||
@ -215,7 +215,7 @@ void BusDigital::show() {
|
||||
int16_t oldCCT = Bus::_cct; // temporarily save bus CCT
|
||||
for (size_t i=0; i<_len; i++) {
|
||||
size_t offset = i * channels;
|
||||
uint8_t co = _colorOrderMap.getPixelColorOrder(i+_start, _colorOrder);
|
||||
unsigned co = _colorOrderMap.getPixelColorOrder(i+_start, _colorOrder);
|
||||
uint32_t c;
|
||||
if (_type == TYPE_WS2812_1CH_X3) { // map to correct IC, each controls 3 LEDs (_len is always a multiple of 3)
|
||||
switch (i%3) {
|
||||
@ -234,7 +234,7 @@ void BusDigital::show() {
|
||||
Bus::_cct = _data[offset+channels-1];
|
||||
Bus::calculateCCT(c, cctWW, cctCW);
|
||||
}
|
||||
uint16_t pix = i;
|
||||
unsigned pix = i;
|
||||
if (_reversed) pix = _len - pix -1;
|
||||
pix += _skip;
|
||||
PolyBus::setPixelColor(_busPtr, _iType, pix, c, co, (cctCW<<8) | cctWW);
|
||||
@ -246,7 +246,7 @@ void BusDigital::show() {
|
||||
Bus::_cct = oldCCT;
|
||||
} else {
|
||||
if (newBri < _bri) {
|
||||
uint16_t hwLen = _len;
|
||||
unsigned hwLen = _len;
|
||||
if (_type == TYPE_WS2812_1CH_X3) hwLen = NUM_ICS_WS2812_1CH_3X(_len); // only needs a third of "RGB" LEDs for NeoPixelBus
|
||||
for (unsigned i = 0; i < hwLen; i++) {
|
||||
// use 0 as color order, actual order does not matter here as we just update the channel values as-is
|
||||
@ -302,9 +302,9 @@ void IRAM_ATTR BusDigital::setPixelColor(uint16_t pix, uint32_t c) {
|
||||
} else {
|
||||
if (_reversed) pix = _len - pix -1;
|
||||
pix += _skip;
|
||||
uint8_t co = _colorOrderMap.getPixelColorOrder(pix+_start, _colorOrder);
|
||||
unsigned co = _colorOrderMap.getPixelColorOrder(pix+_start, _colorOrder);
|
||||
if (_type == TYPE_WS2812_1CH_X3) { // map to correct IC, each controls 3 LEDs
|
||||
uint16_t pOld = pix;
|
||||
unsigned pOld = pix;
|
||||
pix = IC_INDEX_WS2812_1CH_3X(pix);
|
||||
uint32_t cOld = restoreColorLossy(PolyBus::getPixelColor(_busPtr, _iType, pix, co),_bri);
|
||||
switch (pOld % 3) { // change only the single channel (TODO: this can cause loss because of get/set)
|
||||
@ -333,12 +333,12 @@ uint32_t IRAM_ATTR BusDigital::getPixelColor(uint16_t pix) {
|
||||
} else {
|
||||
if (_reversed) pix = _len - pix -1;
|
||||
pix += _skip;
|
||||
uint8_t co = _colorOrderMap.getPixelColorOrder(pix+_start, _colorOrder);
|
||||
unsigned co = _colorOrderMap.getPixelColorOrder(pix+_start, _colorOrder);
|
||||
uint32_t c = restoreColorLossy(PolyBus::getPixelColor(_busPtr, _iType, (_type==TYPE_WS2812_1CH_X3) ? IC_INDEX_WS2812_1CH_3X(pix) : pix, co),_bri);
|
||||
if (_type == TYPE_WS2812_1CH_X3) { // map to correct IC, each controls 3 LEDs
|
||||
uint8_t r = R(c);
|
||||
uint8_t g = _reversed ? B(c) : G(c); // should G and B be switched if _reversed?
|
||||
uint8_t b = _reversed ? G(c) : B(c);
|
||||
unsigned r = R(c);
|
||||
unsigned g = _reversed ? B(c) : G(c); // should G and B be switched if _reversed?
|
||||
unsigned b = _reversed ? G(c) : B(c);
|
||||
switch (pix % 3) { // get only the single channel
|
||||
case 0: c = RGBW32(g, g, g, g); break;
|
||||
case 1: c = RGBW32(r, r, r, r); break;
|
||||
@ -350,7 +350,7 @@ uint32_t IRAM_ATTR BusDigital::getPixelColor(uint16_t pix) {
|
||||
}
|
||||
|
||||
uint8_t BusDigital::getPins(uint8_t* pinArray) {
|
||||
uint8_t numPins = IS_2PIN(_type) ? 2 : 1;
|
||||
unsigned numPins = IS_2PIN(_type) ? 2 : 1;
|
||||
for (unsigned i = 0; i < numPins; i++) pinArray[i] = _pins[i];
|
||||
return numPins;
|
||||
}
|
||||
@ -382,7 +382,7 @@ BusPwm::BusPwm(BusConfig &bc)
|
||||
: Bus(bc.type, bc.start, bc.autoWhite, 1, bc.reversed)
|
||||
{
|
||||
if (!IS_PWM(bc.type)) return;
|
||||
uint8_t numPins = NUM_PWM_PINS(bc.type);
|
||||
unsigned numPins = NUM_PWM_PINS(bc.type);
|
||||
_frequency = bc.frequency ? bc.frequency : WLED_PWM_FREQ;
|
||||
|
||||
#ifdef ESP8266
|
||||
@ -512,7 +512,7 @@ static const uint16_t cieLUT[256] = {
|
||||
|
||||
void BusPwm::show() {
|
||||
if (!_valid) return;
|
||||
uint8_t numPins = NUM_PWM_PINS(_type);
|
||||
unsigned numPins = NUM_PWM_PINS(_type);
|
||||
unsigned maxBri = (1<<_depth) - 1;
|
||||
#ifdef ESP8266
|
||||
unsigned pwmBri = (unsigned)(roundf(powf((float)_bri / 255.0f, 1.7f) * (float)maxBri)); // using gamma 1.7 to extrapolate PWM duty cycle
|
||||
@ -532,7 +532,7 @@ void BusPwm::show() {
|
||||
|
||||
uint8_t BusPwm::getPins(uint8_t* pinArray) {
|
||||
if (!_valid) return 0;
|
||||
uint8_t numPins = NUM_PWM_PINS(_type);
|
||||
unsigned numPins = NUM_PWM_PINS(_type);
|
||||
for (unsigned i = 0; i < numPins; i++) {
|
||||
pinArray[i] = _pins[i];
|
||||
}
|
||||
@ -540,7 +540,7 @@ uint8_t BusPwm::getPins(uint8_t* pinArray) {
|
||||
}
|
||||
|
||||
void BusPwm::deallocatePins() {
|
||||
uint8_t numPins = NUM_PWM_PINS(_type);
|
||||
unsigned numPins = NUM_PWM_PINS(_type);
|
||||
for (unsigned i = 0; i < numPins; i++) {
|
||||
pinManager.deallocatePin(_pins[i], PinOwner::BusPwm);
|
||||
if (!pinManager.isPinOk(_pins[i])) continue;
|
||||
@ -632,7 +632,7 @@ void BusNetwork::setPixelColor(uint16_t pix, uint32_t c) {
|
||||
if (!_valid || pix >= _len) return;
|
||||
if (_rgbw) c = autoWhiteCalc(c);
|
||||
if (Bus::_cct >= 1900) c = colorBalanceFromKelvin(Bus::_cct, c); //color correction from CCT
|
||||
uint16_t offset = pix * _UDPchannels;
|
||||
unsigned offset = pix * _UDPchannels;
|
||||
_data[offset] = R(c);
|
||||
_data[offset+1] = G(c);
|
||||
_data[offset+2] = B(c);
|
||||
@ -641,7 +641,7 @@ void BusNetwork::setPixelColor(uint16_t pix, uint32_t c) {
|
||||
|
||||
uint32_t BusNetwork::getPixelColor(uint16_t pix) {
|
||||
if (!_valid || pix >= _len) return 0;
|
||||
uint16_t offset = pix * _UDPchannels;
|
||||
unsigned offset = pix * _UDPchannels;
|
||||
return RGBW32(_data[offset], _data[offset+1], _data[offset+2], (_rgbw ? _data[offset+3] : 0));
|
||||
}
|
||||
|
||||
@ -854,7 +854,7 @@ Bus* BusManager::getBus(uint8_t busNr) {
|
||||
|
||||
//semi-duplicate of strip.getLengthTotal() (though that just returns strip._length, calculated in finalizeInit())
|
||||
uint16_t BusManager::getTotalLength() {
|
||||
uint16_t len = 0;
|
||||
unsigned len = 0;
|
||||
for (unsigned i=0; i<numBusses; i++) len += busses[i]->getLength();
|
||||
return len;
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ void doublePressAction(uint8_t b)
|
||||
bool isButtonPressed(uint8_t i)
|
||||
{
|
||||
if (btnPin[i]<0) return false;
|
||||
uint8_t pin = btnPin[i];
|
||||
unsigned pin = btnPin[i];
|
||||
|
||||
switch (buttonType[i]) {
|
||||
case BTN_TYPE_NONE:
|
||||
@ -171,7 +171,7 @@ void handleAnalog(uint8_t b)
|
||||
{
|
||||
static uint8_t oldRead[WLED_MAX_BUTTONS] = {0};
|
||||
static float filteredReading[WLED_MAX_BUTTONS] = {0.0f};
|
||||
uint16_t rawReading; // raw value from analogRead, scaled to 12bit
|
||||
unsigned rawReading; // raw value from analogRead, scaled to 12bit
|
||||
|
||||
DEBUG_PRINT(F("Analog: Reading button ")); DEBUG_PRINTLN(b);
|
||||
|
||||
@ -184,7 +184,7 @@ void handleAnalog(uint8_t b)
|
||||
yield(); // keep WiFi task running - analog read may take several millis on ESP8266
|
||||
|
||||
filteredReading[b] += POT_SMOOTHING * ((float(rawReading) / 16.0f) - filteredReading[b]); // filter raw input, and scale to [0..255]
|
||||
uint16_t aRead = max(min(int(filteredReading[b]), 255), 0); // squash into 8bit
|
||||
unsigned aRead = max(min(int(filteredReading[b]), 255), 0); // squash into 8bit
|
||||
if(aRead <= POT_SENSITIVITY) aRead = 0; // make sure that 0 and 255 are used
|
||||
if(aRead >= 255-POT_SENSITIVITY) aRead = 255;
|
||||
|
||||
@ -260,7 +260,7 @@ void handleButton()
|
||||
if (strip.isUpdating() && (now - lastRun < ANALOG_BTN_READ_CYCLE+1)) return; // don't interfere with strip update (unless strip is updating continuously, e.g. very long strips)
|
||||
lastRun = now;
|
||||
|
||||
for (uint8_t b=0; b<WLED_MAX_BUTTONS; b++) {
|
||||
for (unsigned b=0; b<WLED_MAX_BUTTONS; b++) {
|
||||
#ifdef ESP8266
|
||||
if ((btnPin[b]<0 && !(buttonType[b] == BTN_TYPE_ANALOG || buttonType[b] == BTN_TYPE_ANALOG_INVERTED)) || buttonType[b] == BTN_TYPE_NONE) continue;
|
||||
#else
|
||||
|
@ -9,7 +9,7 @@
|
||||
*/
|
||||
uint32_t color_blend(uint32_t color1, uint32_t color2, uint16_t blend, bool b16) {
|
||||
if(blend == 0) return color1;
|
||||
uint16_t blendmax = b16 ? 0xFFFF : 0xFF;
|
||||
unsigned blendmax = b16 ? 0xFFFF : 0xFF;
|
||||
if(blend == blendmax) return color2;
|
||||
uint8_t shift = b16 ? 16 : 8;
|
||||
|
||||
@ -52,7 +52,7 @@ uint32_t color_add(uint32_t c1, uint32_t c2, bool fast)
|
||||
uint32_t g = G(c1) + G(c2);
|
||||
uint32_t b = B(c1) + B(c2);
|
||||
uint32_t w = W(c1) + W(c2);
|
||||
uint16_t max = r;
|
||||
unsigned max = r;
|
||||
if (g > max) max = g;
|
||||
if (b > max) max = b;
|
||||
if (w > max) max = w;
|
||||
|
@ -26,22 +26,21 @@ void handleDDPPacket(e131_packet_t* p) {
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t ddpChannelsPerLed = ((p->dataType & 0b00111000)>>3 == 0b011) ? 4 : 3; // data type 0x1B (formerly 0x1A) is RGBW (type 3, 8 bit/channel)
|
||||
unsigned ddpChannelsPerLed = ((p->dataType & 0b00111000)>>3 == 0b011) ? 4 : 3; // data type 0x1B (formerly 0x1A) is RGBW (type 3, 8 bit/channel)
|
||||
|
||||
uint32_t start = htonl(p->channelOffset) / ddpChannelsPerLed;
|
||||
start += DMXAddress / ddpChannelsPerLed;
|
||||
uint16_t stop = start + htons(p->dataLen) / ddpChannelsPerLed;
|
||||
unsigned stop = start + htons(p->dataLen) / ddpChannelsPerLed;
|
||||
uint8_t* data = p->data;
|
||||
uint16_t c = 0;
|
||||
unsigned c = 0;
|
||||
if (p->flags & DDP_TIMECODE_FLAG) c = 4; //packet has timecode flag, we do not support it, but data starts 4 bytes later
|
||||
|
||||
if (realtimeMode != REALTIME_MODE_DDP) ddpSeenPush = false; // just starting, no push yet
|
||||
realtimeLock(realtimeTimeoutMs, REALTIME_MODE_DDP);
|
||||
|
||||
if (!realtimeOverride || (realtimeMode && useMainSegmentOnly)) {
|
||||
for (uint16_t i = start; i < stop; i++) {
|
||||
for (unsigned i = start; i < stop; i++, c += ddpChannelsPerLed) {
|
||||
setRealtimePixel(i, data[c], data[c+1], data[c+2], ddpChannelsPerLed >3 ? data[c+3] : 0);
|
||||
c += ddpChannelsPerLed;
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,7 +48,7 @@ void handleDDPPacket(e131_packet_t* p) {
|
||||
ddpSeenPush |= push;
|
||||
if (!ddpSeenPush || push) { // if we've never seen a push, or this is one, render display
|
||||
e131NewData = true;
|
||||
byte sn = p->sequenceNum & 0xF;
|
||||
int sn = p->sequenceNum & 0xF;
|
||||
if (sn) e131LastSequenceNumber[0] = sn;
|
||||
}
|
||||
}
|
||||
@ -57,9 +56,9 @@ void handleDDPPacket(e131_packet_t* p) {
|
||||
//E1.31 and Art-Net protocol support
|
||||
void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){
|
||||
|
||||
uint16_t uni = 0, dmxChannels = 0;
|
||||
unsigned uni = 0, dmxChannels = 0;
|
||||
uint8_t* e131_data = nullptr;
|
||||
uint8_t seq = 0, mde = REALTIME_MODE_E131;
|
||||
unsigned seq = 0, mde = REALTIME_MODE_E131;
|
||||
|
||||
if (protocol == P_ARTNET)
|
||||
{
|
||||
@ -105,7 +104,7 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){
|
||||
// only listen for universes we're handling & allocated memory
|
||||
if (uni < e131Universe || uni >= (e131Universe + E131_MAX_UNIVERSE_COUNT)) return;
|
||||
|
||||
uint8_t previousUniverses = uni - e131Universe;
|
||||
unsigned previousUniverses = uni - e131Universe;
|
||||
|
||||
if (e131SkipOutOfSequence)
|
||||
if (seq < e131LastSequenceNumber[previousUniverses] && seq > 20 && e131LastSequenceNumber[previousUniverses] < 250){
|
||||
@ -123,12 +122,12 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){
|
||||
// update status info
|
||||
realtimeIP = clientIP;
|
||||
byte wChannel = 0;
|
||||
uint16_t totalLen = strip.getLengthTotal();
|
||||
uint16_t availDMXLen = 0;
|
||||
uint16_t dataOffset = DMXAddress;
|
||||
unsigned totalLen = strip.getLengthTotal();
|
||||
unsigned availDMXLen = 0;
|
||||
unsigned dataOffset = DMXAddress;
|
||||
|
||||
// For legacy DMX start address 0 the available DMX length offset is 0
|
||||
const uint16_t dmxLenOffset = (DMXAddress == 0) ? 0 : 1;
|
||||
const unsigned dmxLenOffset = (DMXAddress == 0) ? 0 : 1;
|
||||
|
||||
// Check if DMX start address fits in available channels
|
||||
if (dmxChannels >= DMXAddress) {
|
||||
@ -154,7 +153,7 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){
|
||||
if (realtimeOverride && !(realtimeMode && useMainSegmentOnly)) return;
|
||||
|
||||
wChannel = (availDMXLen > 3) ? e131_data[dataOffset+3] : 0;
|
||||
for (uint16_t i = 0; i < totalLen; i++)
|
||||
for (unsigned i = 0; i < totalLen; i++)
|
||||
setRealtimePixel(i, e131_data[dataOffset+0], e131_data[dataOffset+1], e131_data[dataOffset+2], wChannel);
|
||||
break;
|
||||
|
||||
@ -171,7 +170,7 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){
|
||||
strip.setBrightness(bri, true);
|
||||
}
|
||||
|
||||
for (uint16_t i = 0; i < totalLen; i++)
|
||||
for (unsigned i = 0; i < totalLen; i++)
|
||||
setRealtimePixel(i, e131_data[dataOffset+1], e131_data[dataOffset+2], e131_data[dataOffset+3], wChannel);
|
||||
break;
|
||||
|
||||
@ -180,7 +179,7 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){
|
||||
if (uni != e131Universe || availDMXLen < 2) return;
|
||||
|
||||
// limit max. selectable preset to 250, even though DMX max. val is 255
|
||||
uint8_t dmxValPreset = (e131_data[dataOffset+1] > 250 ? 250 : e131_data[dataOffset+1]);
|
||||
unsigned dmxValPreset = (e131_data[dataOffset+1] > 250 ? 250 : e131_data[dataOffset+1]);
|
||||
|
||||
// only apply preset if value changed
|
||||
if (dmxValPreset != 0 && dmxValPreset != currentPreset &&
|
||||
@ -207,8 +206,8 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){
|
||||
{
|
||||
if (uni != e131Universe) return;
|
||||
bool isSegmentMode = DMXMode == DMX_MODE_EFFECT_SEGMENT || DMXMode == DMX_MODE_EFFECT_SEGMENT_W;
|
||||
uint8_t dmxEffectChannels = (DMXMode == DMX_MODE_EFFECT || DMXMode == DMX_MODE_EFFECT_SEGMENT) ? 15 : 18;
|
||||
for (uint8_t id = 0; id < strip.getSegmentsNum(); id++) {
|
||||
unsigned dmxEffectChannels = (DMXMode == DMX_MODE_EFFECT || DMXMode == DMX_MODE_EFFECT_SEGMENT) ? 15 : 18;
|
||||
for (unsigned id = 0; id < strip.getSegmentsNum(); id++) {
|
||||
Segment& seg = strip.getSegment(id);
|
||||
if (isSegmentMode)
|
||||
dataOffset = DMXAddress + id * (dmxEffectChannels + DMXSegmentSpacing);
|
||||
@ -271,10 +270,10 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){
|
||||
case DMX_MODE_MULTIPLE_RGBW:
|
||||
{
|
||||
bool is4Chan = (DMXMode == DMX_MODE_MULTIPLE_RGBW);
|
||||
const uint16_t dmxChannelsPerLed = is4Chan ? 4 : 3;
|
||||
const uint16_t ledsPerUniverse = is4Chan ? MAX_4_CH_LEDS_PER_UNIVERSE : MAX_3_CH_LEDS_PER_UNIVERSE;
|
||||
const unsigned dmxChannelsPerLed = is4Chan ? 4 : 3;
|
||||
const unsigned ledsPerUniverse = is4Chan ? MAX_4_CH_LEDS_PER_UNIVERSE : MAX_3_CH_LEDS_PER_UNIVERSE;
|
||||
uint8_t stripBrightness = bri;
|
||||
uint16_t previousLeds, dmxOffset, ledsTotal;
|
||||
unsigned previousLeds, dmxOffset, ledsTotal;
|
||||
|
||||
if (previousUniverses == 0) {
|
||||
if (availDMXLen < 1) return;
|
||||
@ -290,8 +289,8 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){
|
||||
} else {
|
||||
// All subsequent universes start at the first channel.
|
||||
dmxOffset = (protocol == P_ARTNET) ? 0 : 1;
|
||||
const uint16_t dimmerOffset = (DMXMode == DMX_MODE_MULTIPLE_DRGB) ? 1 : 0;
|
||||
uint16_t ledsInFirstUniverse = (((MAX_CHANNELS_PER_UNIVERSE - DMXAddress) + dmxLenOffset) - dimmerOffset) / dmxChannelsPerLed;
|
||||
const unsigned dimmerOffset = (DMXMode == DMX_MODE_MULTIPLE_DRGB) ? 1 : 0;
|
||||
unsigned ledsInFirstUniverse = (((MAX_CHANNELS_PER_UNIVERSE - DMXAddress) + dmxLenOffset) - dimmerOffset) / dmxChannelsPerLed;
|
||||
previousLeds = ledsInFirstUniverse + (previousUniverses - 1) * ledsPerUniverse;
|
||||
ledsTotal = previousLeds + (dmxChannels / dmxChannelsPerLed);
|
||||
}
|
||||
@ -316,12 +315,12 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){
|
||||
}
|
||||
|
||||
if (!is4Chan) {
|
||||
for (uint16_t i = previousLeds; i < ledsTotal; i++) {
|
||||
for (unsigned i = previousLeds; i < ledsTotal; i++) {
|
||||
setRealtimePixel(i, e131_data[dmxOffset], e131_data[dmxOffset+1], e131_data[dmxOffset+2], 0);
|
||||
dmxOffset+=3;
|
||||
}
|
||||
} else {
|
||||
for (uint16_t i = previousLeds; i < ledsTotal; i++) {
|
||||
for (unsigned i = previousLeds; i < ledsTotal; i++) {
|
||||
setRealtimePixel(i, e131_data[dmxOffset], e131_data[dmxOffset+1], e131_data[dmxOffset+2], e131_data[dmxOffset+3]);
|
||||
dmxOffset+=4;
|
||||
}
|
||||
@ -341,8 +340,8 @@ void handleArtnetPollReply(IPAddress ipAddress) {
|
||||
ArtPollReply artnetPollReply;
|
||||
prepareArtnetPollReply(&artnetPollReply);
|
||||
|
||||
uint16_t startUniverse = e131Universe;
|
||||
uint16_t endUniverse = e131Universe;
|
||||
unsigned startUniverse = e131Universe;
|
||||
unsigned endUniverse = e131Universe;
|
||||
|
||||
switch (DMXMode) {
|
||||
case DMX_MODE_DISABLED:
|
||||
@ -362,15 +361,15 @@ void handleArtnetPollReply(IPAddress ipAddress) {
|
||||
case DMX_MODE_MULTIPLE_RGBW:
|
||||
{
|
||||
bool is4Chan = (DMXMode == DMX_MODE_MULTIPLE_RGBW);
|
||||
const uint16_t dmxChannelsPerLed = is4Chan ? 4 : 3;
|
||||
const uint16_t dimmerOffset = (DMXMode == DMX_MODE_MULTIPLE_DRGB) ? 1 : 0;
|
||||
const uint16_t dmxLenOffset = (DMXAddress == 0) ? 0 : 1; // For legacy DMX start address 0
|
||||
const uint16_t ledsInFirstUniverse = (((MAX_CHANNELS_PER_UNIVERSE - DMXAddress) + dmxLenOffset) - dimmerOffset) / dmxChannelsPerLed;
|
||||
const uint16_t totalLen = strip.getLengthTotal();
|
||||
const unsigned dmxChannelsPerLed = is4Chan ? 4 : 3;
|
||||
const unsigned dimmerOffset = (DMXMode == DMX_MODE_MULTIPLE_DRGB) ? 1 : 0;
|
||||
const unsigned dmxLenOffset = (DMXAddress == 0) ? 0 : 1; // For legacy DMX start address 0
|
||||
const unsigned ledsInFirstUniverse = (((MAX_CHANNELS_PER_UNIVERSE - DMXAddress) + dmxLenOffset) - dimmerOffset) / dmxChannelsPerLed;
|
||||
const unsigned totalLen = strip.getLengthTotal();
|
||||
|
||||
if (totalLen > ledsInFirstUniverse) {
|
||||
const uint16_t ledsPerUniverse = is4Chan ? MAX_4_CH_LEDS_PER_UNIVERSE : MAX_3_CH_LEDS_PER_UNIVERSE;
|
||||
const uint16_t remainLED = totalLen - ledsInFirstUniverse;
|
||||
const unsigned ledsPerUniverse = is4Chan ? MAX_4_CH_LEDS_PER_UNIVERSE : MAX_3_CH_LEDS_PER_UNIVERSE;
|
||||
const unsigned remainLED = totalLen - ledsInFirstUniverse;
|
||||
|
||||
endUniverse += (remainLED / ledsPerUniverse);
|
||||
|
||||
@ -391,7 +390,7 @@ void handleArtnetPollReply(IPAddress ipAddress) {
|
||||
}
|
||||
|
||||
if (DMXMode != DMX_MODE_DISABLED) {
|
||||
for (uint16_t i = startUniverse; i <= endUniverse; ++i) {
|
||||
for (unsigned i = startUniverse; i <= endUniverse; ++i) {
|
||||
sendArtnetPollReply(&artnetPollReply, ipAddress, i);
|
||||
}
|
||||
}
|
||||
@ -417,7 +416,7 @@ void prepareArtnetPollReply(ArtPollReply *reply) {
|
||||
reply->reply_opcode = ARTNET_OPCODE_OPPOLLREPLY;
|
||||
|
||||
IPAddress localIP = Network.localIP();
|
||||
for (uint8_t i = 0; i < 4; i++) {
|
||||
for (unsigned i = 0; i < 4; i++) {
|
||||
reply->reply_ip[i] = localIP[i];
|
||||
}
|
||||
|
||||
@ -493,7 +492,7 @@ void prepareArtnetPollReply(ArtPollReply *reply) {
|
||||
|
||||
Network.localMAC(reply->reply_mac);
|
||||
|
||||
for (uint8_t i = 0; i < 4; i++) {
|
||||
for (unsigned i = 0; i < 4; i++) {
|
||||
reply->reply_bind_ip[i] = localIP[i];
|
||||
}
|
||||
|
||||
@ -517,7 +516,7 @@ void prepareArtnetPollReply(ArtPollReply *reply) {
|
||||
// Node does not support fail-over
|
||||
reply->reply_status_3 = 0x00;
|
||||
|
||||
for (uint8_t i = 0; i < 21; i++) {
|
||||
for (unsigned i = 0; i < 21; i++) {
|
||||
reply->reply_filler[i] = 0x00;
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ static bool bufferedFindObjectEnd() {
|
||||
|
||||
if (!f || !f.size()) return false;
|
||||
|
||||
uint16_t objDepth = 0; //num of '{' minus num of '}'. return once 0
|
||||
unsigned objDepth = 0; //num of '{' minus num of '}'. return once 0
|
||||
//size_t start = f.position();
|
||||
byte buf[FS_BUFSIZE];
|
||||
|
||||
|
@ -42,12 +42,12 @@ void handleImprovPacket() {
|
||||
uint8_t header[6] = {'I','M','P','R','O','V'};
|
||||
|
||||
bool timeout = false;
|
||||
uint8_t waitTime = 25;
|
||||
uint16_t packetByte = 0;
|
||||
uint8_t packetLen = 9;
|
||||
uint8_t checksum = 0;
|
||||
unsigned waitTime = 25;
|
||||
unsigned packetByte = 0;
|
||||
unsigned packetLen = 9;
|
||||
unsigned checksum = 0;
|
||||
|
||||
uint8_t rpcCommandType = 0;
|
||||
unsigned rpcCommandType = 0;
|
||||
char rpcData[128];
|
||||
rpcData[0] = 0;
|
||||
|
||||
@ -92,7 +92,7 @@ void handleImprovPacket() {
|
||||
switch (rpcCommandType) {
|
||||
case ImprovRPCType::Command_Wifi: parseWiFiCommand(rpcData); break;
|
||||
case ImprovRPCType::Request_State: {
|
||||
uint8_t improvState = 0x02; //authorized
|
||||
unsigned improvState = 0x02; //authorized
|
||||
if (WLED_WIFI_CONFIGURED) improvState = 0x03; //provisioning
|
||||
if (Network.isConnected()) improvState = 0x04; //provisioned
|
||||
sendImprovStateResponse(improvState, false);
|
||||
@ -136,8 +136,8 @@ void sendImprovStateResponse(uint8_t state, bool error) {
|
||||
out[8] = 1;
|
||||
out[9] = state;
|
||||
|
||||
uint8_t checksum = 0;
|
||||
for (uint8_t i = 0; i < 10; i++) checksum += out[i];
|
||||
unsigned checksum = 0;
|
||||
for (unsigned i = 0; i < 10; i++) checksum += out[i];
|
||||
out[10] = checksum;
|
||||
Serial.write((uint8_t*)out, 11);
|
||||
Serial.write('\n');
|
||||
@ -146,16 +146,16 @@ void sendImprovStateResponse(uint8_t state, bool error) {
|
||||
// used by sendImprovIPRPCResult(), sendImprovInfoResponse(), and handleImprovWifiScan()
|
||||
void sendImprovRPCResult(ImprovRPCType type, uint8_t n_strings, const char **strings) {
|
||||
if (improvError > 0 && improvError < 3) sendImprovStateResponse(0x00, true);
|
||||
uint8_t packetLen = 12;
|
||||
unsigned packetLen = 12;
|
||||
char out[256] = {'I','M','P','R','O','V'};
|
||||
out[6] = IMPROV_VERSION;
|
||||
out[7] = ImprovPacketType::RPC_Response;
|
||||
//out[8] = 2; //Length (set below)
|
||||
out[9] = type;
|
||||
//out[10] = 0; //Data len (set below)
|
||||
uint16_t pos = 11;
|
||||
unsigned pos = 11;
|
||||
|
||||
for (uint8_t s = 0; s < n_strings; s++) {
|
||||
for (unsigned s = 0; s < n_strings; s++) {
|
||||
size_t len = strlen(strings[s]);
|
||||
if (pos + len > 254) continue; // simple buffer overflow guard
|
||||
out[pos++] = len;
|
||||
@ -167,8 +167,8 @@ void sendImprovRPCResult(ImprovRPCType type, uint8_t n_strings, const char **str
|
||||
out[8] = pos -9; // Length of packet (excluding first 9 header bytes and final checksum byte)
|
||||
out[10] = pos -11; // Data len
|
||||
|
||||
uint8_t checksum = 0;
|
||||
for (uint8_t i = 0; i < packetLen -1; i++) checksum += out[i];
|
||||
unsigned checksum = 0;
|
||||
for (unsigned i = 0; i < packetLen -1; i++) checksum += out[i];
|
||||
out[packetLen -1] = checksum;
|
||||
Serial.write((uint8_t*)out, packetLen);
|
||||
Serial.write('\n');
|
||||
@ -181,7 +181,7 @@ void sendImprovIPRPCResult(ImprovRPCType type) {
|
||||
{
|
||||
char urlStr[64];
|
||||
IPAddress localIP = Network.localIP();
|
||||
uint8_t len = sprintf(urlStr, "http://%d.%d.%d.%d", localIP[0], localIP[1], localIP[2], localIP[3]);
|
||||
unsigned len = sprintf(urlStr, "http://%d.%d.%d.%d", localIP[0], localIP[1], localIP[2], localIP[3]);
|
||||
if (len > 24) return; //sprintf fail?
|
||||
const char *str[1] = {urlStr};
|
||||
sendImprovRPCResult(type, 1, str);
|
||||
@ -254,17 +254,17 @@ void handleImprovWifiScan() {}
|
||||
#endif
|
||||
|
||||
void parseWiFiCommand(char* rpcData) {
|
||||
uint8_t len = rpcData[0];
|
||||
unsigned len = rpcData[0];
|
||||
if (!len || len > 126) return;
|
||||
|
||||
uint8_t ssidLen = rpcData[1];
|
||||
unsigned ssidLen = rpcData[1];
|
||||
if (ssidLen > len -1 || ssidLen > 32) return;
|
||||
memset(multiWiFi[0].clientSSID, 0, 32);
|
||||
memcpy(multiWiFi[0].clientSSID, rpcData+2, ssidLen);
|
||||
|
||||
memset(multiWiFi[0].clientPass, 0, 64);
|
||||
if (len > ssidLen +1) {
|
||||
uint8_t passLen = rpcData[2+ssidLen];
|
||||
unsigned passLen = rpcData[2+ssidLen];
|
||||
memset(multiWiFi[0].clientPass, 0, 64);
|
||||
memcpy(multiWiFi[0].clientPass, rpcData+3+ssidLen, passLen);
|
||||
}
|
||||
|
@ -37,14 +37,14 @@ bool deserializeSegment(JsonObject elem, byte it, byte presetId)
|
||||
Segment prev = seg; //make a backup so we can tell if something changed (calling copy constructor)
|
||||
//DEBUG_PRINTF_P(PSTR("-- Duplicate segment: %p (%p)\n"), &prev, prev.data);
|
||||
|
||||
uint16_t start = elem["start"] | seg.start;
|
||||
unsigned start = elem["start"] | seg.start;
|
||||
if (stop < 0) {
|
||||
int len = elem["len"];
|
||||
stop = (len > 0) ? start + len : seg.stop;
|
||||
}
|
||||
// 2D segments
|
||||
uint16_t startY = elem["startY"] | seg.startY;
|
||||
uint16_t stopY = elem["stopY"] | seg.stopY;
|
||||
unsigned startY = elem["startY"] | seg.startY;
|
||||
unsigned stopY = elem["stopY"] | seg.stopY;
|
||||
|
||||
//repeat, multiplies segment until all LEDs are used, or max segments reached
|
||||
bool repeat = elem["rpt"] | false;
|
||||
@ -52,7 +52,7 @@ bool deserializeSegment(JsonObject elem, byte it, byte presetId)
|
||||
elem.remove("id"); // remove for recursive call
|
||||
elem.remove("rpt"); // remove for recursive call
|
||||
elem.remove("n"); // remove for recursive call
|
||||
uint16_t len = stop - start;
|
||||
unsigned len = stop - start;
|
||||
for (size_t i=id+1; i<strip.getMaxSegments(); i++) {
|
||||
start = start + len;
|
||||
if (start >= strip.getLengthTotal()) break;
|
||||
@ -105,7 +105,7 @@ bool deserializeSegment(JsonObject elem, byte it, byte presetId)
|
||||
uint8_t set = elem[F("set")] | seg.set;
|
||||
seg.set = constrain(set, 0, 3);
|
||||
|
||||
uint16_t len = 1;
|
||||
unsigned len = 1;
|
||||
if (stop > start) len = stop - start;
|
||||
int offset = elem[F("of")] | INT32_MAX;
|
||||
if (offset != INT32_MAX) {
|
||||
@ -659,12 +659,12 @@ void serializeInfo(JsonObject root)
|
||||
}
|
||||
#endif
|
||||
|
||||
uint8_t totalLC = 0;
|
||||
unsigned totalLC = 0;
|
||||
JsonArray lcarr = leds.createNestedArray(F("seglc"));
|
||||
size_t nSegs = strip.getSegmentsNum();
|
||||
for (size_t s = 0; s < nSegs; s++) {
|
||||
if (!strip.getSegment(s).isActive()) continue;
|
||||
uint8_t lc = strip.getSegment(s).getLightCapabilities();
|
||||
unsigned lc = strip.getSegment(s).getLightCapabilities();
|
||||
totalLC |= lc;
|
||||
lcarr.add(lc);
|
||||
}
|
||||
@ -847,7 +847,7 @@ void setPaletteColors(JsonArray json, byte* tcp)
|
||||
TRGBGradientPaletteEntryUnion u;
|
||||
|
||||
// Count entries
|
||||
uint16_t count = 0;
|
||||
unsigned count = 0;
|
||||
do {
|
||||
u = *(ent + count);
|
||||
count++;
|
||||
@ -1166,8 +1166,8 @@ bool serveLiveLeds(AsyncWebServerRequest* request, uint32_t wsClient)
|
||||
}
|
||||
#endif
|
||||
|
||||
uint16_t used = strip.getLengthTotal();
|
||||
uint16_t n = (used -1) /MAX_LIVE_LEDS +1; //only serve every n'th LED if count over MAX_LIVE_LEDS
|
||||
unsigned used = strip.getLengthTotal();
|
||||
unsigned n = (used -1) /MAX_LIVE_LEDS +1; //only serve every n'th LED if count over MAX_LIVE_LEDS
|
||||
#ifndef WLED_DISABLE_2D
|
||||
if (strip.isMatrix) {
|
||||
// ignore anything behid matrix (i.e. extra strip)
|
||||
|
@ -29,9 +29,9 @@ void setValuesFromSegment(uint8_t s)
|
||||
void applyValuesToSelectedSegs()
|
||||
{
|
||||
// copy of first selected segment to tell if value was updated
|
||||
uint8_t firstSel = strip.getFirstSelectedSegId();
|
||||
unsigned firstSel = strip.getFirstSelectedSegId();
|
||||
Segment selsegPrev = strip.getSegment(firstSel);
|
||||
for (uint8_t i = 0; i < strip.getSegmentsNum(); i++) {
|
||||
for (unsigned i = 0; i < strip.getSegmentsNum(); i++) {
|
||||
Segment& seg = strip.getSegment(i);
|
||||
if (i != firstSel && (!seg.isActive() || !seg.isSelected())) continue;
|
||||
|
||||
@ -70,7 +70,7 @@ void toggleOnOff()
|
||||
//scales the brightness with the briMultiplier factor
|
||||
byte scaledBri(byte in)
|
||||
{
|
||||
uint16_t val = ((uint16_t)in*briMultiplier)/100;
|
||||
unsigned val = ((uint16_t)in*briMultiplier)/100;
|
||||
if (val > 255) val = 255;
|
||||
return (byte)val;
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
||||
pinManager.deallocatePin(irPin, PinOwner::IR);
|
||||
}
|
||||
#endif
|
||||
for (uint8_t s=0; s<WLED_MAX_BUTTONS; s++) {
|
||||
for (unsigned s=0; s<WLED_MAX_BUTTONS; s++) {
|
||||
if (btnPin[s]>=0 && pinManager.isPinAllocated(btnPin[s], PinOwner::Button)) {
|
||||
pinManager.deallocatePin(btnPin[s], PinOwner::Button);
|
||||
#ifdef SOC_TOUCH_VERSION_2 // ESP32 S2 and S3 have a function to check touch state, detach interrupt
|
||||
@ -123,11 +123,11 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t colorOrder, type, skip, awmode, channelSwap, maPerLed;
|
||||
uint16_t length, start, maMax;
|
||||
unsigned colorOrder, type, skip, awmode, channelSwap, maPerLed;
|
||||
unsigned length, start, maMax;
|
||||
uint8_t pins[5] = {255, 255, 255, 255, 255};
|
||||
|
||||
uint16_t ablMilliampsMax = request->arg(F("MA")).toInt();
|
||||
unsigned ablMilliampsMax = request->arg(F("MA")).toInt();
|
||||
BusManager::setMilliampsMax(ablMilliampsMax);
|
||||
|
||||
autoSegments = request->hasArg(F("MS"));
|
||||
@ -505,7 +505,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
||||
macroAlexaOff = request->arg(F("A1")).toInt();
|
||||
macroCountdown = request->arg(F("MC")).toInt();
|
||||
macroNl = request->arg(F("MN")).toInt();
|
||||
for (uint8_t i=0; i<WLED_MAX_BUTTONS; i++) {
|
||||
for (unsigned i=0; i<WLED_MAX_BUTTONS; i++) {
|
||||
char mp[4] = "MP"; mp[2] = (i<10?48:55)+i; mp[3] = 0; // short
|
||||
char ml[4] = "ML"; ml[2] = (i<10?48:55)+i; ml[3] = 0; // long
|
||||
char md[4] = "MD"; md[2] = (i<10?48:55)+i; md[3] = 0; // double
|
||||
@ -555,10 +555,10 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
||||
|
||||
if (request->hasArg(F("PIN"))) {
|
||||
const char *pin = request->arg(F("PIN")).c_str();
|
||||
uint8_t pinLen = strlen(pin);
|
||||
unsigned pinLen = strlen(pin);
|
||||
if (pinLen == 4 || pinLen == 0) {
|
||||
uint8_t numZeros = 0;
|
||||
for (uint8_t i = 0; i < pinLen; i++) numZeros += (pin[i] == '0');
|
||||
unsigned numZeros = 0;
|
||||
for (unsigned i = 0; i < pinLen; i++) numZeros += (pin[i] == '0');
|
||||
if (numZeros < pinLen || pinLen == 0) { // ignore 0000 input (placeholder)
|
||||
strlcpy(settingsPIN, pin, 5);
|
||||
}
|
||||
@ -682,7 +682,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
||||
JsonObject um = pDoc->createNestedObject("um");
|
||||
|
||||
size_t args = request->args();
|
||||
uint16_t j=0;
|
||||
unsigned j=0;
|
||||
for (size_t i=0; i<args; i++) {
|
||||
String name = request->argName(i);
|
||||
String value = request->arg(i);
|
||||
@ -763,12 +763,12 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
||||
if (strip.isMatrix) {
|
||||
strip.panels = MAX(1,MIN(WLED_MAX_PANELS,request->arg(F("MPC")).toInt()));
|
||||
strip.panel.reserve(strip.panels); // pre-allocate memory
|
||||
for (uint8_t i=0; i<strip.panels; i++) {
|
||||
for (unsigned i=0; i<strip.panels; i++) {
|
||||
WS2812FX::Panel p;
|
||||
char pO[8] = { '\0' };
|
||||
snprintf_P(pO, 7, PSTR("P%d"), i); // MAX_PANELS is 64 so pO will always only be 4 characters or less
|
||||
pO[7] = '\0';
|
||||
uint8_t l = strlen(pO);
|
||||
unsigned l = strlen(pO);
|
||||
// create P0B, P1B, ..., P63B, etc for other PxxX
|
||||
pO[l] = 'B'; if (!request->hasArg(pO)) break;
|
||||
pO[l] = 'B'; p.bottomStart = request->arg(pO).toInt();
|
||||
@ -822,7 +822,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
|
||||
|
||||
pos = req.indexOf(F("SS="));
|
||||
if (pos > 0) {
|
||||
byte t = getNumVal(&req, pos);
|
||||
unsigned t = getNumVal(&req, pos);
|
||||
if (t < strip.getSegmentsNum()) {
|
||||
selectedSeg = t;
|
||||
singleSegment = true;
|
||||
@ -832,8 +832,8 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
|
||||
Segment& selseg = strip.getSegment(selectedSeg);
|
||||
pos = req.indexOf(F("SV=")); //segment selected
|
||||
if (pos > 0) {
|
||||
byte t = getNumVal(&req, pos);
|
||||
if (t == 2) for (uint8_t i = 0; i < strip.getSegmentsNum(); i++) strip.getSegment(i).selected = false; // unselect other segments
|
||||
unsigned t = getNumVal(&req, pos);
|
||||
if (t == 2) for (unsigned i = 0; i < strip.getSegmentsNum(); i++) strip.getSegment(i).selected = false; // unselect other segments
|
||||
selseg.selected = t;
|
||||
}
|
||||
|
||||
@ -1009,7 +1009,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
|
||||
pos = req.indexOf(F("SC"));
|
||||
if (pos > 0) {
|
||||
byte temp;
|
||||
for (uint8_t i=0; i<4; i++) {
|
||||
for (unsigned i=0; i<4; i++) {
|
||||
temp = colIn[i];
|
||||
colIn[i] = colInSec[i];
|
||||
colInSec[i] = temp;
|
||||
@ -1050,7 +1050,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
|
||||
stateChanged |= (fxModeChanged || speedChanged || intensityChanged || paletteChanged || custom1Changed || custom2Changed || custom3Changed || check1Changed || check2Changed || check3Changed);
|
||||
|
||||
// apply to main and all selected segments to prevent #1618.
|
||||
for (uint8_t i = 0; i < strip.getSegmentsNum(); i++) {
|
||||
for (unsigned i = 0; i < strip.getSegmentsNum(); i++) {
|
||||
Segment& seg = strip.getSegment(i);
|
||||
if (i != selectedSeg && (singleSegment || !seg.isActive() || !seg.isSelected())) continue; // skip non main segments if not applying to all
|
||||
if (fxModeChanged) seg.setMode(effectIn, req.indexOf(F("FXD="))>0); // apply defaults if FXD= is specified
|
||||
|
@ -106,7 +106,7 @@ void notify(byte callMode, bool followUp)
|
||||
for (size_t i = 0; i < nsegs; i++) {
|
||||
Segment &selseg = strip.getSegment(i);
|
||||
if (!selseg.isActive()) continue;
|
||||
uint16_t ofs = 41 + s*UDP_SEG_SIZE; //start of segment offset byte
|
||||
unsigned ofs = 41 + s*UDP_SEG_SIZE; //start of segment offset byte
|
||||
udpOut[0 +ofs] = s;
|
||||
udpOut[1 +ofs] = selseg.start >> 8;
|
||||
udpOut[2 +ofs] = selseg.start & 0xFF;
|
||||
@ -241,7 +241,7 @@ void parseNotifyPacket(uint8_t *udpIn) {
|
||||
if (version > 6) {
|
||||
strip.setColor(2, RGBW32(udpIn[20], udpIn[21], udpIn[22], udpIn[23])); // tertiary color
|
||||
if (version > 9 && udpIn[37] < 255) { // valid CCT/Kelvin value
|
||||
uint16_t cct = udpIn[38];
|
||||
unsigned cct = udpIn[38];
|
||||
if (udpIn[37] > 0) { //Kelvin
|
||||
cct |= (udpIn[37] << 8);
|
||||
}
|
||||
@ -255,7 +255,7 @@ void parseNotifyPacket(uint8_t *udpIn) {
|
||||
bool applyEffects = (receiveNotificationEffects || !someSel);
|
||||
if (applyEffects && currentPlaylist >= 0) unloadPlaylist();
|
||||
if (version > 10 && (receiveSegmentOptions || receiveSegmentBounds)) {
|
||||
uint8_t numSrcSegs = udpIn[39];
|
||||
unsigned numSrcSegs = udpIn[39];
|
||||
DEBUG_PRINT(F("UDP segments: ")); DEBUG_PRINTLN(numSrcSegs);
|
||||
// are we syncing bounds and slave has more active segments than master?
|
||||
if (receiveSegmentBounds && numSrcSegs < strip.getActiveSegmentsNum()) {
|
||||
@ -268,8 +268,8 @@ void parseNotifyPacket(uint8_t *udpIn) {
|
||||
}
|
||||
size_t inactiveSegs = 0;
|
||||
for (size_t i = 0; i < numSrcSegs && i < strip.getMaxSegments(); i++) {
|
||||
uint16_t ofs = 41 + i*udpIn[40]; //start of segment offset byte
|
||||
uint8_t id = udpIn[0 +ofs];
|
||||
unsigned ofs = 41 + i*udpIn[40]; //start of segment offset byte
|
||||
unsigned id = udpIn[0 +ofs];
|
||||
DEBUG_PRINT(F("UDP segment received: ")); DEBUG_PRINTLN(id);
|
||||
if (id > strip.getSegmentsNum()) break;
|
||||
else if (id == strip.getSegmentsNum()) {
|
||||
@ -405,7 +405,7 @@ void parseNotifyPacket(uint8_t *udpIn) {
|
||||
void realtimeLock(uint32_t timeoutMs, byte md)
|
||||
{
|
||||
if (!realtimeMode && !realtimeOverride) {
|
||||
uint16_t stop, start;
|
||||
unsigned stop, start;
|
||||
if (useMainSegmentOnly) {
|
||||
Segment& mainseg = strip.getMainSegment();
|
||||
start = mainseg.start;
|
||||
@ -505,8 +505,8 @@ void handleNotifications()
|
||||
rgbUdp.read(lbuf, packetSize);
|
||||
realtimeLock(realtimeTimeoutMs, REALTIME_MODE_HYPERION);
|
||||
if (realtimeOverride && !(realtimeMode && useMainSegmentOnly)) return;
|
||||
uint16_t id = 0;
|
||||
uint16_t totalLen = strip.getLengthTotal();
|
||||
unsigned id = 0;
|
||||
unsigned totalLen = strip.getLengthTotal();
|
||||
for (size_t i = 0; i < packetSize -2; i += 3)
|
||||
{
|
||||
setRealtimePixel(id, lbuf[i], lbuf[i+1], lbuf[i+2], 0);
|
||||
@ -523,7 +523,7 @@ void handleNotifications()
|
||||
if (!isSupp && notifierUdp.remoteIP() == localIP) return; //don't process broadcasts we send ourselves
|
||||
|
||||
uint8_t udpIn[packetSize +1];
|
||||
uint16_t len;
|
||||
unsigned len;
|
||||
if (isSupp) len = notifier2Udp.read(udpIn, packetSize);
|
||||
else len = notifierUdp.read(udpIn, packetSize);
|
||||
|
||||
@ -531,7 +531,7 @@ void handleNotifications()
|
||||
if (isSupp && udpIn[0] == 255 && udpIn[1] == 1 && len >= 40) {
|
||||
if (!nodeListEnabled || notifier2Udp.remoteIP() == localIP) return;
|
||||
|
||||
uint8_t unit = udpIn[39];
|
||||
unsigned unit = udpIn[39];
|
||||
NodesMap::iterator it = Nodes.find(unit);
|
||||
if (it == Nodes.end() && Nodes.size() < WLED_MAX_NODES) { // Create a new element when not present
|
||||
Nodes[unit].age = 0;
|
||||
@ -588,8 +588,8 @@ void handleNotifications()
|
||||
byte packetNum = udpIn[4]; //starts with 1!
|
||||
byte numPackets = udpIn[5];
|
||||
|
||||
uint16_t id = (tpmPayloadFrameSize/3)*(packetNum-1); //start LED
|
||||
uint16_t totalLen = strip.getLengthTotal();
|
||||
unsigned id = (tpmPayloadFrameSize/3)*(packetNum-1); //start LED
|
||||
unsigned totalLen = strip.getLengthTotal();
|
||||
for (size_t i = 6; i < tpmPayloadFrameSize + 4U; i += 3)
|
||||
{
|
||||
if (id < totalLen)
|
||||
@ -623,7 +623,7 @@ void handleNotifications()
|
||||
}
|
||||
if (realtimeOverride && !(realtimeMode && useMainSegmentOnly)) return;
|
||||
|
||||
uint16_t totalLen = strip.getLengthTotal();
|
||||
unsigned totalLen = strip.getLengthTotal();
|
||||
if (udpIn[0] == 1 && packetSize > 5) //warls
|
||||
{
|
||||
for (size_t i = 2; i < packetSize -3; i += 4)
|
||||
@ -632,7 +632,7 @@ void handleNotifications()
|
||||
}
|
||||
} else if (udpIn[0] == 2 && packetSize > 4) //drgb
|
||||
{
|
||||
uint16_t id = 0;
|
||||
unsigned id = 0;
|
||||
for (size_t i = 2; i < packetSize -2; i += 3)
|
||||
{
|
||||
setRealtimePixel(id, udpIn[i], udpIn[i+1], udpIn[i+2], 0);
|
||||
@ -641,7 +641,7 @@ void handleNotifications()
|
||||
}
|
||||
} else if (udpIn[0] == 3 && packetSize > 6) //drgbw
|
||||
{
|
||||
uint16_t id = 0;
|
||||
unsigned id = 0;
|
||||
for (size_t i = 2; i < packetSize -3; i += 4)
|
||||
{
|
||||
setRealtimePixel(id, udpIn[i], udpIn[i+1], udpIn[i+2], udpIn[i+3]);
|
||||
@ -650,7 +650,7 @@ void handleNotifications()
|
||||
}
|
||||
} else if (udpIn[0] == 4 && packetSize > 7) //dnrgb
|
||||
{
|
||||
uint16_t id = ((udpIn[3] << 0) & 0xFF) + ((udpIn[2] << 8) & 0xFF00);
|
||||
unsigned id = ((udpIn[3] << 0) & 0xFF) + ((udpIn[2] << 8) & 0xFF00);
|
||||
for (size_t i = 4; i < packetSize -2; i += 3)
|
||||
{
|
||||
if (id >= totalLen) break;
|
||||
@ -659,7 +659,7 @@ void handleNotifications()
|
||||
}
|
||||
} else if (udpIn[0] == 5 && packetSize > 8) //dnrgbw
|
||||
{
|
||||
uint16_t id = ((udpIn[3] << 0) & 0xFF) + ((udpIn[2] << 8) & 0xFF00);
|
||||
unsigned id = ((udpIn[3] << 0) & 0xFF) + ((udpIn[2] << 8) & 0xFF00);
|
||||
for (size_t i = 4; i < packetSize -2; i += 4)
|
||||
{
|
||||
if (id >= totalLen) break;
|
||||
@ -691,7 +691,7 @@ void handleNotifications()
|
||||
|
||||
void setRealtimePixel(uint16_t i, byte r, byte g, byte b, byte w)
|
||||
{
|
||||
uint16_t pix = i + arlsOffset;
|
||||
unsigned pix = i + arlsOffset;
|
||||
if (pix < strip.getLengthTotal()) {
|
||||
if (!arlsDisableGammaCorrection && gammaCorrectCol) {
|
||||
r = gamma8(r);
|
||||
|
@ -156,7 +156,7 @@ bool oappendi(int i)
|
||||
|
||||
bool oappend(const char* txt)
|
||||
{
|
||||
uint16_t len = strlen(txt);
|
||||
unsigned len = strlen(txt);
|
||||
if ((obuf == nullptr) || (olen + len >= SETTINGS_STACK_BUF_SIZE)) { // sanity checks
|
||||
#ifdef WLED_DEBUG
|
||||
DEBUG_PRINT(F("oappend() buffer overflow. Cannot append "));
|
||||
@ -175,7 +175,7 @@ void prepareHostname(char* hostname)
|
||||
{
|
||||
sprintf_P(hostname, PSTR("wled-%*s"), 6, escapedMac.c_str() + 6);
|
||||
const char *pC = serverDescription;
|
||||
uint8_t pos = 5; // keep "wled-"
|
||||
unsigned pos = 5; // keep "wled-"
|
||||
while (*pC && pos < 24) { // while !null and not over length
|
||||
if (isalnum(*pC)) { // if the current char is alpha-numeric append it to the hostname
|
||||
hostname[pos] = *pC;
|
||||
@ -269,9 +269,9 @@ uint8_t extractModeName(uint8_t mode, const char *src, char *dest, uint8_t maxLe
|
||||
return strlen(dest);
|
||||
}
|
||||
|
||||
uint8_t qComma = 0;
|
||||
unsigned qComma = 0;
|
||||
bool insideQuotes = false;
|
||||
uint8_t printedChars = 0;
|
||||
unsigned printedChars = 0;
|
||||
char singleJsonSymbol;
|
||||
size_t len = strlen_P(src);
|
||||
|
||||
@ -308,11 +308,11 @@ uint8_t extractModeSlider(uint8_t mode, uint8_t slider, char *dest, uint8_t maxL
|
||||
if (mode < strip.getModeCount()) {
|
||||
String lineBuffer = FPSTR(strip.getModeData(mode));
|
||||
if (lineBuffer.length() > 0) {
|
||||
int16_t start = lineBuffer.indexOf('@');
|
||||
int16_t stop = lineBuffer.indexOf(';', start);
|
||||
unsigned start = lineBuffer.indexOf('@');
|
||||
unsigned stop = lineBuffer.indexOf(';', start);
|
||||
if (start>0 && stop>0) {
|
||||
String names = lineBuffer.substring(start, stop); // include @
|
||||
int16_t nameBegin = 1, nameEnd, nameDefault;
|
||||
unsigned nameBegin = 1, nameEnd, nameDefault;
|
||||
if (slider < 10) {
|
||||
for (size_t i=0; i<=slider; i++) {
|
||||
const char *tmpstr;
|
||||
|
@ -24,7 +24,7 @@ bool continuousSendLED = false;
|
||||
uint32_t lastUpdate = 0;
|
||||
|
||||
void updateBaudRate(uint32_t rate){
|
||||
uint16_t rate100 = rate/100;
|
||||
unsigned rate100 = rate/100;
|
||||
if (rate100 == currentBaud || rate100 < 96) return;
|
||||
currentBaud = rate100;
|
||||
|
||||
@ -39,9 +39,9 @@ void updateBaudRate(uint32_t rate){
|
||||
// RGB LED data return as JSON array. Slow, but easy to use on the other end.
|
||||
void sendJSON(){
|
||||
if (!pinManager.isPinAllocated(hardwareTX) || pinManager.getPinOwner(hardwareTX) == PinOwner::DebugOut) {
|
||||
uint16_t used = strip.getLengthTotal();
|
||||
unsigned used = strip.getLengthTotal();
|
||||
Serial.write('[');
|
||||
for (uint16_t i=0; i<used; i++) {
|
||||
for (unsigned i=0; i<used; i++) {
|
||||
Serial.print(strip.getPixelColor(i));
|
||||
if (i != used-1) Serial.write(',');
|
||||
}
|
||||
@ -53,11 +53,11 @@ void sendJSON(){
|
||||
void sendBytes(){
|
||||
if (!pinManager.isPinAllocated(hardwareTX) || pinManager.getPinOwner(hardwareTX) == PinOwner::DebugOut) {
|
||||
Serial.write(0xC9); Serial.write(0xDA);
|
||||
uint16_t used = strip.getLengthTotal();
|
||||
uint16_t len = used*3;
|
||||
unsigned used = strip.getLengthTotal();
|
||||
unsigned len = used*3;
|
||||
Serial.write(highByte(len));
|
||||
Serial.write(lowByte(len));
|
||||
for (uint16_t i=0; i < used; i++) {
|
||||
for (unsigned i=0; i < used; i++) {
|
||||
uint32_t c = strip.getPixelColor(i);
|
||||
Serial.write(qadd8(W(c), R(c))); //R, add white channel to RGB channels as a simple RGBW -> RGB map
|
||||
Serial.write(qadd8(W(c), G(c))); //G
|
||||
|
Loading…
x
Reference in New Issue
Block a user