@@ -80,15 +80,15 @@ uint8_t IRAM_ATTR ColorOrderMap::getPixelColorOrder(uint16_t pix, uint8_t defaul
8080
8181
8282uint32_t Bus::autoWhiteCalc (uint32_t c) {
83- uint8_t aWM = _autoWhiteMode;
83+ unsigned aWM = _autoWhiteMode;
8484 if (_gAWM < AW_GLOBAL_DISABLED) aWM = _gAWM;
8585 if (aWM == RGBW_MODE_MANUAL_ONLY) return c;
86- uint8_t w = W (c);
86+ unsigned w = W (c);
8787 // ignore auto-white calculation if w>0 and mode DUAL (DUAL behaves as BRIGHTER if w==0)
8888 if (w > 0 && aWM == RGBW_MODE_DUAL) return c;
89- uint8_t r = R (c);
90- uint8_t g = G (c);
91- uint8_t b = B (c);
89+ unsigned r = R (c);
90+ unsigned g = G (c);
91+ unsigned b = B (c);
9292 if (aWM == RGBW_MODE_MAX) return RGBW32 (r, g, b, r > g ? (r > b ? r : b) : (g > b ? g : b)); // brightest RGB channel
9393 w = r < g ? (r < b ? r : b) : (g < b ? g : b);
9494 if (aWM == RGBW_MODE_AUTO_ACCURATE) { r -= w; g -= w; b -= w; } // subtract w in ACCURATE mode
@@ -207,15 +207,15 @@ void BusDigital::show() {
207207 if (!_valid) return ;
208208
209209 uint8_t cctWW = 0 , cctCW = 0 ;
210- uint8_t newBri = estimateCurrentAndLimitBri (); // will fill _milliAmpsTotal
210+ unsigned newBri = estimateCurrentAndLimitBri (); // will fill _milliAmpsTotal
211211 if (newBri < _bri) PolyBus::setBrightness (_busPtr, _iType, newBri); // limit brightness to stay within current limits
212212
213213 if (_data) {
214214 size_t channels = getNumberOfChannels ();
215215 int16_t oldCCT = Bus::_cct; // temporarily save bus CCT
216216 for (size_t i=0 ; i<_len; i++) {
217217 size_t offset = i * channels;
218- uint8_t co = _colorOrderMap.getPixelColorOrder (i+_start, _colorOrder);
218+ unsigned co = _colorOrderMap.getPixelColorOrder (i+_start, _colorOrder);
219219 uint32_t c;
220220 if (_type == TYPE_WS2812_1CH_X3) { // map to correct IC, each controls 3 LEDs (_len is always a multiple of 3)
221221 switch (i%3 ) {
@@ -234,7 +234,7 @@ void BusDigital::show() {
234234 Bus::_cct = _data[offset+channels-1 ];
235235 Bus::calculateCCT (c, cctWW, cctCW);
236236 }
237- uint16_t pix = i;
237+ unsigned pix = i;
238238 if (_reversed) pix = _len - pix -1 ;
239239 pix += _skip;
240240 PolyBus::setPixelColor (_busPtr, _iType, pix, c, co, (cctCW<<8 ) | cctWW);
@@ -246,7 +246,7 @@ void BusDigital::show() {
246246 Bus::_cct = oldCCT;
247247 } else {
248248 if (newBri < _bri) {
249- uint16_t hwLen = _len;
249+ unsigned hwLen = _len;
250250 if (_type == TYPE_WS2812_1CH_X3) hwLen = NUM_ICS_WS2812_1CH_3X (_len); // only needs a third of "RGB" LEDs for NeoPixelBus
251251 for (unsigned i = 0 ; i < hwLen; i++) {
252252 // 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) {
302302 } else {
303303 if (_reversed) pix = _len - pix -1 ;
304304 pix += _skip;
305- uint8_t co = _colorOrderMap.getPixelColorOrder (pix+_start, _colorOrder);
305+ unsigned co = _colorOrderMap.getPixelColorOrder (pix+_start, _colorOrder);
306306 if (_type == TYPE_WS2812_1CH_X3) { // map to correct IC, each controls 3 LEDs
307- uint16_t pOld = pix;
307+ unsigned pOld = pix;
308308 pix = IC_INDEX_WS2812_1CH_3X (pix);
309309 uint32_t cOld = restoreColorLossy (PolyBus::getPixelColor (_busPtr, _iType, pix, co),_bri);
310310 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) {
333333 } else {
334334 if (_reversed) pix = _len - pix -1 ;
335335 pix += _skip;
336- uint8_t co = _colorOrderMap.getPixelColorOrder (pix+_start, _colorOrder);
336+ unsigned co = _colorOrderMap.getPixelColorOrder (pix+_start, _colorOrder);
337337 uint32_t c = restoreColorLossy (PolyBus::getPixelColor (_busPtr, _iType, (_type==TYPE_WS2812_1CH_X3) ? IC_INDEX_WS2812_1CH_3X (pix) : pix, co),_bri);
338338 if (_type == TYPE_WS2812_1CH_X3) { // map to correct IC, each controls 3 LEDs
339- uint8_t r = R (c);
340- uint8_t g = _reversed ? B (c) : G (c); // should G and B be switched if _reversed?
341- uint8_t b = _reversed ? G (c) : B (c);
339+ unsigned r = R (c);
340+ unsigned g = _reversed ? B (c) : G (c); // should G and B be switched if _reversed?
341+ unsigned b = _reversed ? G (c) : B (c);
342342 switch (pix % 3 ) { // get only the single channel
343343 case 0 : c = RGBW32 (g, g, g, g); break ;
344344 case 1 : c = RGBW32 (r, r, r, r); break ;
@@ -350,7 +350,7 @@ uint32_t IRAM_ATTR BusDigital::getPixelColor(uint16_t pix) {
350350}
351351
352352uint8_t BusDigital::getPins (uint8_t * pinArray) {
353- uint8_t numPins = IS_2PIN (_type) ? 2 : 1 ;
353+ unsigned numPins = IS_2PIN (_type) ? 2 : 1 ;
354354 for (unsigned i = 0 ; i < numPins; i++) pinArray[i] = _pins[i];
355355 return numPins;
356356}
@@ -382,7 +382,7 @@ BusPwm::BusPwm(BusConfig &bc)
382382: Bus(bc.type, bc.start, bc.autoWhite, 1 , bc.reversed)
383383{
384384 if (!IS_PWM (bc.type )) return ;
385- uint8_t numPins = NUM_PWM_PINS (bc.type );
385+ unsigned numPins = NUM_PWM_PINS (bc.type );
386386 _frequency = bc.frequency ? bc.frequency : WLED_PWM_FREQ;
387387
388388#ifdef ESP8266
@@ -512,7 +512,7 @@ static const uint16_t cieLUT[256] = {
512512
513513void BusPwm::show () {
514514 if (!_valid) return ;
515- uint8_t numPins = NUM_PWM_PINS (_type);
515+ unsigned numPins = NUM_PWM_PINS (_type);
516516 unsigned maxBri = (1 <<_depth) - 1 ;
517517 #ifdef ESP8266
518518 unsigned pwmBri = (unsigned )(roundf (powf ((float )_bri / 255 .0f , 1 .7f ) * (float )maxBri)); // using gamma 1.7 to extrapolate PWM duty cycle
@@ -532,15 +532,15 @@ void BusPwm::show() {
532532
533533uint8_t BusPwm::getPins (uint8_t * pinArray) {
534534 if (!_valid) return 0 ;
535- uint8_t numPins = NUM_PWM_PINS (_type);
535+ unsigned numPins = NUM_PWM_PINS (_type);
536536 for (unsigned i = 0 ; i < numPins; i++) {
537537 pinArray[i] = _pins[i];
538538 }
539539 return numPins;
540540}
541541
542542void BusPwm::deallocatePins () {
543- uint8_t numPins = NUM_PWM_PINS (_type);
543+ unsigned numPins = NUM_PWM_PINS (_type);
544544 for (unsigned i = 0 ; i < numPins; i++) {
545545 pinManager.deallocatePin (_pins[i], PinOwner::BusPwm);
546546 if (!pinManager.isPinOk (_pins[i])) continue ;
@@ -632,7 +632,7 @@ void BusNetwork::setPixelColor(uint16_t pix, uint32_t c) {
632632 if (!_valid || pix >= _len) return ;
633633 if (_rgbw) c = autoWhiteCalc (c);
634634 if (Bus::_cct >= 1900 ) c = colorBalanceFromKelvin (Bus::_cct, c); // color correction from CCT
635- uint16_t offset = pix * _UDPchannels;
635+ unsigned offset = pix * _UDPchannels;
636636 _data[offset] = R (c);
637637 _data[offset+1 ] = G (c);
638638 _data[offset+2 ] = B (c);
@@ -641,7 +641,7 @@ void BusNetwork::setPixelColor(uint16_t pix, uint32_t c) {
641641
642642uint32_t BusNetwork::getPixelColor (uint16_t pix) {
643643 if (!_valid || pix >= _len) return 0 ;
644- uint16_t offset = pix * _UDPchannels;
644+ unsigned offset = pix * _UDPchannels;
645645 return RGBW32 (_data[offset], _data[offset+1 ], _data[offset+2 ], (_rgbw ? _data[offset+3 ] : 0 ));
646646}
647647
@@ -854,7 +854,7 @@ Bus* BusManager::getBus(uint8_t busNr) {
854854
855855// semi-duplicate of strip.getLengthTotal() (though that just returns strip._length, calculated in finalizeInit())
856856uint16_t BusManager::getTotalLength () {
857- uint16_t len = 0 ;
857+ unsigned len = 0 ;
858858 for (unsigned i=0 ; i<numBusses; i++) len += busses[i]->getLength ();
859859 return len;
860860}
0 commit comments