@@ -110,11 +110,11 @@ void WS2812FX::setUpMatrix() {
110110 releaseJSONBufferLock ();
111111 }
112112
113- uint16_t x, y, pix=0 ; // pixel
113+ unsigned x, y, pix=0 ; // pixel
114114 for (size_t pan = 0 ; pan < panel.size (); pan++) {
115115 Panel &p = panel[pan];
116- uint16_t h = p.vertical ? p.height : p.width ;
117- uint16_t v = p.vertical ? p.width : p.height ;
116+ unsigned h = p.vertical ? p.height : p.width ;
117+ unsigned v = p.vertical ? p.width : p.height ;
118118 for (size_t j = 0 ; j < v; j++){
119119 for (size_t i = 0 ; i < h; i++) {
120120 y = (p.vertical ?p.rightStart :p.bottomStart ) ? v-j-1 : j;
@@ -163,8 +163,8 @@ void WS2812FX::setUpMatrix() {
163163// XY(x,y) - gets pixel index within current segment (often used to reference leds[] array element)
164164uint16_t IRAM_ATTR Segment::XY (uint16_t x, uint16_t y)
165165{
166- uint16_t width = virtualWidth (); // segment width in logical pixels (can be 0 if segment is inactive)
167- uint16_t height = virtualHeight (); // segment height in logical pixels (is always >= 1)
166+ unsigned width = virtualWidth (); // segment width in logical pixels (can be 0 if segment is inactive)
167+ unsigned height = virtualHeight (); // segment height in logical pixels (is always >= 1)
168168 return isActive () ? (x%width) + (y%height) * width : 0 ;
169169}
170170
@@ -180,7 +180,7 @@ void IRAM_ATTR Segment::setPixelColorXY(int x, int y, uint32_t col)
180180
181181 if (reverse ) x = virtualWidth () - x - 1 ;
182182 if (reverse_y) y = virtualHeight () - y - 1 ;
183- if (transpose) { uint16_t t = x; x = y; y = t; } // swap X & Y if segment transposed
183+ if (transpose) { unsigned t = x; x = y; y = t; } // swap X & Y if segment transposed
184184
185185 x *= groupLength (); // expand to physical pixels
186186 y *= groupLength (); // expand to physical pixels
@@ -189,7 +189,7 @@ void IRAM_ATTR Segment::setPixelColorXY(int x, int y, uint32_t col)
189189 uint32_t tmpCol = col;
190190 for (int j = 0 ; j < grouping; j++) { // groupping vertically
191191 for (int g = 0 ; g < grouping; g++) { // groupping horizontally
192- uint16_t xX = (x+g), yY = (y+j);
192+ unsigned xX = (x+g), yY = (y+j);
193193 if (xX >= width () || yY >= height ()) continue ; // we have reached one dimension's end
194194
195195#ifndef WLED_DISABLE_MODE_BLEND
@@ -221,16 +221,16 @@ void Segment::setPixelColorXY(float x, float y, uint32_t col, bool aa)
221221 if (!isActive ()) return ; // not active
222222 if (x<0 .0f || x>1 .0f || y<0 .0f || y>1 .0f ) return ; // not normalized
223223
224- const uint16_t cols = virtualWidth ();
225- const uint16_t rows = virtualHeight ();
224+ const unsigned cols = virtualWidth ();
225+ const unsigned rows = virtualHeight ();
226226
227227 float fX = x * (cols-1 );
228228 float fY = y * (rows-1 );
229229 if (aa) {
230- uint16_t xL = roundf (fX -0 .49f );
231- uint16_t xR = roundf (fX +0 .49f );
232- uint16_t yT = roundf (fY -0 .49f );
233- uint16_t yB = roundf (fY +0 .49f );
230+ unsigned xL = roundf (fX -0 .49f );
231+ unsigned xR = roundf (fX +0 .49f );
232+ unsigned yT = roundf (fY -0 .49f );
233+ unsigned yB = roundf (fY +0 .49f );
234234 float dL = (fX - xL)*(fX - xL);
235235 float dR = (xR - fX )*(xR - fX );
236236 float dT = (fY - yT)*(fY - yT);
@@ -266,7 +266,7 @@ uint32_t IRAM_ATTR Segment::getPixelColorXY(int x, int y) {
266266 if (x >= virtualWidth () || y >= virtualHeight () || x<0 || y<0 ) return 0 ; // if pixel would fall out of virtual segment just exit
267267 if (reverse ) x = virtualWidth () - x - 1 ;
268268 if (reverse_y) y = virtualHeight () - y - 1 ;
269- if (transpose) { uint16_t t = x; x = y; y = t; } // swap X & Y if segment transposed
269+ if (transpose) { unsigned t = x; x = y; y = t; } // swap X & Y if segment transposed
270270 x *= groupLength (); // expand to physical pixels
271271 y *= groupLength (); // expand to physical pixels
272272 if (x >= width () || y >= height ()) return 0 ;
@@ -276,8 +276,8 @@ uint32_t IRAM_ATTR Segment::getPixelColorXY(int x, int y) {
276276// blurRow: perform a blur on a row of a rectangular matrix
277277void Segment::blurRow (uint32_t row, fract8 blur_amount, bool smear){
278278 if (!isActive () || blur_amount == 0 ) return ; // not active
279- const uint_fast16_t cols = virtualWidth ();
280- const uint_fast16_t rows = virtualHeight ();
279+ const unsigned cols = virtualWidth ();
280+ const unsigned rows = virtualHeight ();
281281
282282 if (row >= rows) return ;
283283 // blur one row
@@ -309,8 +309,8 @@ void Segment::blurRow(uint32_t row, fract8 blur_amount, bool smear){
309309// blurCol: perform a blur on a column of a rectangular matrix
310310void Segment::blurCol (uint32_t col, fract8 blur_amount, bool smear) {
311311 if (!isActive () || blur_amount == 0 ) return ; // not active
312- const uint_fast16_t cols = virtualWidth ();
313- const uint_fast16_t rows = virtualHeight ();
312+ const unsigned cols = virtualWidth ();
313+ const unsigned rows = virtualHeight ();
314314
315315 if (col >= cols) return ;
316316 // blur one column
@@ -342,34 +342,34 @@ void Segment::blurCol(uint32_t col, fract8 blur_amount, bool smear) {
342342// 1D Box blur (with added weight - blur_amount: [0=no blur, 255=max blur])
343343void Segment::box_blur (uint16_t i, bool vertical, fract8 blur_amount) {
344344 if (!isActive () || blur_amount == 0 ) return ; // not active
345- const uint16_t cols = virtualWidth ();
346- const uint16_t rows = virtualHeight ();
347- const uint16_t dim1 = vertical ? rows : cols;
348- const uint16_t dim2 = vertical ? cols : rows;
345+ const unsigned cols = virtualWidth ();
346+ const unsigned rows = virtualHeight ();
347+ const unsigned dim1 = vertical ? rows : cols;
348+ const unsigned dim2 = vertical ? cols : rows;
349349 if (i >= dim2) return ;
350350 const float seep = blur_amount/255 .f ;
351351 const float keep = 3 .f - 2 .f *seep;
352352 // 1D box blur
353353 CRGB tmp[dim1];
354- for (int j = 0 ; j < dim1; j++) {
355- uint16_t x = vertical ? i : j;
356- uint16_t y = vertical ? j : i;
357- int16_t xp = vertical ? x : x-1 ; // "signed" to prevent underflow
358- int16_t yp = vertical ? y-1 : y; // "signed" to prevent underflow
359- uint16_t xn = vertical ? x : x+1 ;
360- uint16_t yn = vertical ? y+1 : y;
354+ for (unsigned j = 0 ; j < dim1; j++) {
355+ unsigned x = vertical ? i : j;
356+ unsigned y = vertical ? j : i;
357+ int xp = vertical ? x : x-1 ; // "signed" to prevent underflow
358+ int yp = vertical ? y-1 : y; // "signed" to prevent underflow
359+ unsigned xn = vertical ? x : x+1 ;
360+ unsigned yn = vertical ? y+1 : y;
361361 CRGB curr = getPixelColorXY (x,y);
362362 CRGB prev = (xp<0 || yp<0 ) ? CRGB::Black : getPixelColorXY (xp,yp);
363363 CRGB next = ((vertical && yn>=dim1) || (!vertical && xn>=dim1)) ? CRGB::Black : getPixelColorXY (xn,yn);
364- uint16_t r, g, b;
364+ unsigned r, g, b;
365365 r = (curr.r *keep + (prev.r + next.r )*seep) / 3 ;
366366 g = (curr.g *keep + (prev.g + next.g )*seep) / 3 ;
367367 b = (curr.b *keep + (prev.b + next.b )*seep) / 3 ;
368368 tmp[j] = CRGB (r,g,b);
369369 }
370- for (int j = 0 ; j < dim1; j++) {
371- uint16_t x = vertical ? i : j;
372- uint16_t y = vertical ? j : i;
370+ for (unsigned j = 0 ; j < dim1; j++) {
371+ unsigned x = vertical ? i : j;
372+ unsigned y = vertical ? j : i;
373373 setPixelColorXY (x, y, tmp[j]);
374374 }
375375}
@@ -389,14 +389,14 @@ void Segment::box_blur(uint16_t i, bool vertical, fract8 blur_amount) {
389389// it can be used to (slowly) clear the LEDs to black.
390390
391391void Segment::blur1d (fract8 blur_amount) {
392- const uint16_t rows = virtualHeight ();
392+ const unsigned rows = virtualHeight ();
393393 for (unsigned y = 0 ; y < rows; y++) blurRow (y, blur_amount);
394394}
395395
396396void Segment::moveX (int8_t delta, bool wrap) {
397397 if (!isActive ()) return ; // not active
398- const uint16_t cols = virtualWidth ();
399- const uint16_t rows = virtualHeight ();
398+ const int cols = virtualWidth ();
399+ const int rows = virtualHeight ();
400400 if (!delta || abs (delta) >= cols) return ;
401401 uint32_t newPxCol[cols];
402402 for (int y = 0 ; y < rows; y++) {
@@ -413,8 +413,8 @@ void Segment::moveX(int8_t delta, bool wrap) {
413413
414414void Segment::moveY (int8_t delta, bool wrap) {
415415 if (!isActive ()) return ; // not active
416- const uint16_t cols = virtualWidth ();
417- const uint16_t rows = virtualHeight ();
416+ const int cols = virtualWidth ();
417+ const int rows = virtualHeight ();
418418 if (!delta || abs (delta) >= rows) return ;
419419 uint32_t newPxCol[rows];
420420 for (int x = 0 ; x < cols; x++) {
@@ -474,36 +474,36 @@ void Segment::draw_circle(uint16_t cx, uint16_t cy, uint8_t radius, CRGB col) {
474474// by stepko, taken from https://editor.soulmatelights.com/gallery/573-blobs
475475void Segment::fill_circle (uint16_t cx, uint16_t cy, uint8_t radius, CRGB col) {
476476 if (!isActive () || radius == 0 ) return ; // not active
477- const uint16_t cols = virtualWidth ();
478- const uint16_t rows = virtualHeight ();
479- for (int16_t y = -radius; y <= radius; y++) {
480- for (int16_t x = -radius; x <= radius; x++) {
477+ const int cols = virtualWidth ();
478+ const int rows = virtualHeight ();
479+ for (int y = -radius; y <= radius; y++) {
480+ for (int x = -radius; x <= radius; x++) {
481481 if (x * x + y * y <= radius * radius &&
482- int16_t (cx)+x>=0 && int16_t (cy)+y>=0 &&
483- int16_t (cx)+x<cols && int16_t (cy)+y<rows)
482+ int (cx)+x>=0 && int (cy)+y>=0 &&
483+ int (cx)+x<cols && int (cy)+y<rows)
484484 setPixelColorXY (cx + x, cy + y, col);
485485 }
486486 }
487487}
488488
489489void Segment::nscale8 (uint8_t scale) {
490490 if (!isActive ()) return ; // not active
491- const uint16_t cols = virtualWidth ();
492- const uint16_t rows = virtualHeight ();
493- for (int y = 0 ; y < rows; y++) for (int x = 0 ; x < cols; x++) {
491+ const unsigned cols = virtualWidth ();
492+ const unsigned rows = virtualHeight ();
493+ for (unsigned y = 0 ; y < rows; y++) for (unsigned x = 0 ; x < cols; x++) {
494494 setPixelColorXY (x, y, CRGB (getPixelColorXY (x, y)).nscale8 (scale));
495495 }
496496}
497497
498498// line function
499499void Segment::drawLine (uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint32_t c) {
500500 if (!isActive ()) return ; // not active
501- const uint16_t cols = virtualWidth ();
502- const uint16_t rows = virtualHeight ();
501+ const unsigned cols = virtualWidth ();
502+ const unsigned rows = virtualHeight ();
503503 if (x0 >= cols || x1 >= cols || y0 >= rows || y1 >= rows) return ;
504- const int16_t dx = abs (x1-x0), sx = x0<x1 ? 1 : -1 ;
505- const int16_t dy = abs (y1-y0), sy = y0<y1 ? 1 : -1 ;
506- int16_t err = (dx>dy ? dx : -dy)/2 , e2 ;
504+ const int dx = abs (x1-x0), sx = x0<x1 ? 1 : -1 ;
505+ const int dy = abs (y1-y0), sy = y0<y1 ? 1 : -1 ;
506+ int err = (dx>dy ? dx : -dy)/2 , e2 ;
507507 for (;;) {
508508 setPixelColorXY (x0,y0,c);
509509 if (x0==x1 && y0==y1) break ;
@@ -525,8 +525,8 @@ void Segment::drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w,
525525 if (!isActive ()) return ; // not active
526526 if (chr < 32 || chr > 126 ) return ; // only ASCII 32-126 supported
527527 chr -= 32 ; // align with font table entries
528- const uint16_t cols = virtualWidth ();
529- const uint16_t rows = virtualHeight ();
528+ const int cols = virtualWidth ();
529+ const int rows = virtualHeight ();
530530 const int font = w*h;
531531
532532 CRGB col = CRGB (color);
@@ -565,7 +565,7 @@ void Segment::drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w,
565565void Segment::wu_pixel (uint32_t x, uint32_t y, CRGB c) { // awesome wu_pixel procedure by reddit u/sutaburosu
566566 if (!isActive ()) return ; // not active
567567 // extract the fractional parts and derive their inverses
568- uint8_t xx = x & 0xff , yy = y & 0xff , ix = 255 - xx, iy = 255 - yy;
568+ unsigned xx = x & 0xff , yy = y & 0xff , ix = 255 - xx, iy = 255 - yy;
569569 // calculate the intensities for each affected pixel
570570 uint8_t wu[4 ] = {WU_WEIGHT (ix, iy), WU_WEIGHT (xx, iy),
571571 WU_WEIGHT (ix, yy), WU_WEIGHT (xx, yy)};
0 commit comments