From 176b9e877cc715ed7944a13481ed0fe0c091105e Mon Sep 17 00:00:00 2001 From: Ewoud Date: Mon, 4 Mar 2024 23:05:13 +0100 Subject: [PATCH] set for loops and stack variables to unsigned (WIP) create stackUnsigned8 16 and 32 all for experiments and temporary, defines will go away eventually and be replaced by the optimal type --- src/App/LedEffects.h | 184 ++++++++++++++++++------------------ src/App/LedFixture.cpp | 40 ++++---- src/App/LedLeds.cpp | 8 +- src/App/LedLeds.h | 18 ++-- src/App/LedModEffects.h | 20 ++-- src/App/LedModFixture.h | 4 +- src/App/LedModFixtureGen.h | 106 ++++++++++----------- src/Sys/SysModAI.h | 4 +- src/Sys/SysModFiles.cpp | 6 +- src/Sys/SysModPins.cpp | 6 +- src/Sys/SysModPins.h | 8 +- src/Sys/SysModUI.cpp | 8 +- src/Sys/SysModUI.h | 2 +- src/Sys/SysModWeb.cpp | 2 +- src/SysModule.h | 5 + src/SysModules.cpp | 6 +- src/User/UserModArtNet.h | 2 +- src/User/UserModDDP.h | 2 +- src/User/UserModE131.h | 8 +- src/User/UserModInstances.h | 20 ++-- 20 files changed, 232 insertions(+), 227 deletions(-) diff --git a/src/App/LedEffects.h b/src/App/LedEffects.h index fb559b93..7105514e 100644 --- a/src/App/LedEffects.h +++ b/src/App/LedEffects.h @@ -73,9 +73,9 @@ class SolidEffect: public Effect { return "Solid 1D"; } void loop(Leds &leds) { - unsigned8 red = mdl->getValue("Red"); - unsigned8 green = mdl->getValue("Green"); - unsigned8 blue = mdl->getValue("Blue"); + stackUnsigned8 red = mdl->getValue("Red"); + stackUnsigned8 green = mdl->getValue("Green"); + stackUnsigned8 blue = mdl->getValue("Blue"); CRGB color = CRGB(red, green, blue); leds.fill_solid(color); @@ -181,9 +181,9 @@ class BPMEffect: public Effect { CRGBPalette16 pal = getPalette(); // colored stripes pulsing at a defined Beats-Per-Minute (BPM) - unsigned8 BeatsPerMinute = 62; - unsigned8 beat = beatsin8( BeatsPerMinute, 64, 255); - for (unsigned16 i = 0; i < leds.nrOfLeds; i++) { //9948 + stackUnsigned8 BeatsPerMinute = 62; + stackUnsigned8 beat = beatsin8( BeatsPerMinute, 64, 255); + for (forUnsigned16 i = 0; i < leds.nrOfLeds; i++) { //9948 leds[i] = ColorFromPalette(pal, gHue+(i*2), beat-gHue+(i*10)); } } @@ -200,8 +200,8 @@ class JuggleEffect: public Effect { void loop(Leds &leds) { // eight colored dots, weaving in and out of sync with each other leds.fadeToBlackBy(20); - unsigned8 dothue = 0; - for (unsigned8 i = 0; i < 8; i++) { + stackUnsigned8 dothue = 0; + for (forUnsigned8 i = 0; i < 8; i++) { leds[beatsin16( i+7, 0, leds.nrOfLeds-1 )] |= CHSV(dothue, 200, 255); dothue += 32; } @@ -214,8 +214,8 @@ class Ripples3DEffect: public Effect { return "Ripples 3D"; } void loop(Leds &leds) { - unsigned8 interval = mdl->getValue("interval"); - unsigned8 speed = mdl->getValue("speed"); + stackUnsigned8 interval = mdl->getValue("interval"); + stackUnsigned8 speed = mdl->getValue("speed"); float ripple_interval = 1.3f * (interval/128.0f); @@ -223,13 +223,13 @@ class Ripples3DEffect: public Effect { Coord3D pos = {0,0,0}; for (pos.z=0; pos.zdistance(3.5f, 3.5f, 0.0f, (float)pos.x, (float)pos.z, 0.0f) / 9.899495f * leds.size.x; - unsigned32 time_interval = now/(100 - speed)/((256.0f-128.0f)/20.0f); - pos.x = floor(leds.size.x/2.0f + sinf(d/ripple_interval + time_interval) * leds.size.x/2.0f); //between 0 and leds.size.x + for (pos.y=0; pos.ydistance(3.5f, 3.5f, 0.0f, (float)pos.x, (float)pos.z, 0.0f) / 9.899495f * leds.size.x; + stackUnsigned32 time_interval = now/(100 - speed)/((256.0f-128.0f)/20.0f); + pos.x = floor(leds.size.x/2.0f + sinf(d/ripple_interval + time_interval) * leds.size.x/2.0f); //between 0 and leds.size.x - leds[pos] = CHSV( gHue + random8(64), 200, 255);// ColorFromPalette(pal,call, bri, LINEARBLEND); - } + leds[pos] = CHSV( gHue + random8(64), 200, 255);// ColorFromPalette(pal,call, bri, LINEARBLEND); + } } } void controls(JsonObject parentVar) { @@ -244,11 +244,11 @@ class SphereMove3DEffect: public Effect { return "SphereMove 3D"; } void loop(Leds &leds) { - unsigned8 speed = mdl->getValue("speed"); + stackUnsigned8 speed = mdl->getValue("speed"); leds.fill_solid(CRGB::Black); - unsigned32 time_interval = now/(100 - speed)/((256.0f-128.0f)/20.0f); + stackUnsigned32 time_interval = now/(100 - speed)/((256.0f-128.0f)/20.0f); Coord3D origin; origin.x = 3.5f+sinf(time_interval)*2.5f; @@ -262,7 +262,7 @@ class SphereMove3DEffect: public Effect { for (pos.x=0; pos.xdistance(pos.x, pos.y, pos.z, origin.x, origin.y, origin.z); + stackUnsigned16 d = leds.fixture->distance(pos.x, pos.y, pos.z, origin.x, origin.y, origin.z); if (d>diameter && dgetValue("BPM"); - unsigned16 intensity = mdl->getValue("intensity"); + stackUnsigned8 bpm = mdl->getValue("BPM"); + stackUnsigned8 intensity = mdl->getValue("intensity"); CRGBPalette16 pal = getPalette(); - for (size_t i = 8; i > 0; i--) { + for (int i = 8; i > 0; i--) { Coord3D pos = {0,0,0}; pos.x = beatsin8(bpm/8 + i, 0, leds.size.x - 1); pos.y = beatsin8(intensity/8 - i, 0, leds.size.y - 1); @@ -351,27 +351,27 @@ class DistortionWaves2D: public Effect { void loop(Leds &leds) { - unsigned8 speed = mdl->getValue("speed").as()/32; - unsigned8 scale = mdl->getValue("scale").as()/32; + stackUnsigned8 speed = mdl->getValue("speed"); + stackUnsigned8 scale = mdl->getValue("scale"); - unsigned8 w = 2; + stackUnsigned8 w = 2; - unsigned16 a = now/32; - unsigned16 a2 = a/2; - unsigned16 a3 = a/3; + stackUnsigned16 a = now/32; + stackUnsigned16 a2 = a/2; + stackUnsigned16 a3 = a/3; - unsigned16 cx = beatsin8(10-speed,0,leds.size.x-1)*scale; - unsigned16 cy = beatsin8(12-speed,0,leds.size.y-1)*scale; - unsigned16 cx1 = beatsin8(13-speed,0,leds.size.x-1)*scale; - unsigned16 cy1 = beatsin8(15-speed,0,leds.size.y-1)*scale; - unsigned16 cx2 = beatsin8(17-speed,0,leds.size.x-1)*scale; - unsigned16 cy2 = beatsin8(14-speed,0,leds.size.y-1)*scale; + stackUnsigned16 cx = beatsin8(10-speed,0,leds.size.x-1)*scale; + stackUnsigned16 cy = beatsin8(12-speed,0,leds.size.y-1)*scale; + stackUnsigned16 cx1 = beatsin8(13-speed,0,leds.size.x-1)*scale; + stackUnsigned16 cy1 = beatsin8(15-speed,0,leds.size.y-1)*scale; + stackUnsigned16 cx2 = beatsin8(17-speed,0,leds.size.x-1)*scale; + stackUnsigned16 cy2 = beatsin8(14-speed,0,leds.size.y-1)*scale; - unsigned16 xoffs = 0; + stackUnsigned16 xoffs = 0; Coord3D pos = {0,0,0}; for (pos.x = 0; pos.x < leds.size.x; pos.x++) { xoffs += scale; - unsigned16 yoffs = 0; + stackUnsigned16 yoffs = 0; for (pos.y = 0; pos.y < leds.size.y; pos.y++) { yoffs += scale; @@ -393,8 +393,8 @@ class DistortionWaves2D: public Effect { } } void controls(JsonObject parentVar) { - ui->initSlider(parentVar, "speed", 128); - ui->initSlider(parentVar, "scale", 128); + ui->initSlider(parentVar, "speed", 4, 0, 8); + ui->initSlider(parentVar, "scale", 4, 0, 8); } }; // DistortionWaves2D @@ -413,15 +413,15 @@ class Octopus2D: public Effect { void loop(Leds &leds) { - const unsigned8 mapp = 180 / max(leds.size.x,leds.size.y); + const stackUnsigned8 mapp = 180 / max(leds.size.x,leds.size.y); - // unsigned8 *speed2 = leds.sharedData.bind(speed2); + // stackUnsigned8 *speed2 = leds.sharedData.bind(speed2); // // USER_PRINTF(" %d:%d", speed2, *speed2); - unsigned8 speed = mdl->getValue("speed"); - unsigned8 offsetX = mdl->getValue("Offset X"); - unsigned8 offsetY = mdl->getValue("Offset Y"); - unsigned8 legs = mdl->getValue("Legs"); + stackUnsigned8 speed = mdl->getValue("speed"); + stackUnsigned8 offsetX = mdl->getValue("Offset X"); + stackUnsigned8 offsetY = mdl->getValue("Offset Y"); + stackUnsigned8 legs = mdl->getValue("Legs"); CRGBPalette16 pal = getPalette(); map_t *rMap = leds.sharedData.bind(rMap, leds.size.x * leds.size.y); //array @@ -429,7 +429,7 @@ class Octopus2D: public Effect { uint8_t *offsY = leds.sharedData.bind(offsY); uint16_t *aux0 = leds.sharedData.bind(aux0); uint16_t *aux1 = leds.sharedData.bind(aux1); - unsigned32 *step = leds.sharedData.bind(step); + stackUnsigned32 *step = leds.sharedData.bind(step); Coord3D pos = {0,0,0}; @@ -440,8 +440,8 @@ class Octopus2D: public Effect { *aux1 = leds.size.y; *offsX = offsetX; *offsY = offsetY; - const unsigned8 C_X = leds.size.x / 2 + (offsetX - 128)*leds.size.x/255; - const unsigned8 C_Y = leds.size.y / 2 + (offsetY - 128)*leds.size.y/255; + const stackUnsigned8 C_X = leds.size.x / 2 + (offsetX - 128)*leds.size.x/255; + const stackUnsigned8 C_Y = leds.size.y / 2 + (offsetY - 128)*leds.size.y/255; for (pos.x = 0; pos.x < leds.size.x; pos.x++) { for (pos.y = 0; pos.y < leds.size.y; pos.y++) { rMap[leds.XY(pos.x, pos.y)].angle = 40.7436f * atan2f(pos.y - C_Y, pos.x - C_X); // avoid 128*atan2()/PI @@ -467,7 +467,7 @@ class Octopus2D: public Effect { void controls(JsonObject parentVar) { //bind the variables to sharedData... - // unsigned8 *speed2 = leds.sharedData.bind(speed2); + // stackUnsigned8 *speed2 = leds.sharedData.bind(speed2); // USER_PRINTF("(bind %d) %d %d\n", speed2, leds.sharedData.index, leds.sharedData.bytesAllocated); // USER_PRINTF("bind %d->%d %d\n", index, newIndex, bytesAllocated); @@ -499,9 +499,9 @@ class Lissajous2D: public Effect { void loop(Leds &leds) { - unsigned8 freqX = mdl->getValue("X frequency"); - unsigned8 fadeRate = mdl->getValue("Fade rate"); - unsigned8 speed = mdl->getValue("speed"); + stackUnsigned8 freqX = mdl->getValue("X frequency"); + stackUnsigned8 fadeRate = mdl->getValue("Fade rate"); + stackUnsigned8 speed = mdl->getValue("speed"); bool smooth = mdl->getValue("Smooth"); CRGBPalette16 pal = getPalette(); @@ -513,7 +513,7 @@ class Lissajous2D: public Effect { if (smooth) { // WLEDMM: this is the original "float" code featuring anti-aliasing int maxLoops = max(192U, 4U*(leds.size.x+leds.size.y)); maxLoops = ((maxLoops / 128) +1) * 128; // make sure whe have half or full turns => multiples of 128 - for (int i=0; i < maxLoops; i ++) { + for (int i=0; i < maxLoops; i++) { locn.x = float(sin8(phase/2 + (i* freqX)/64)) / 255.0f; // WLEDMM align speed with original effect locn.y = float(cos8(phase/2 + i*2)) / 255.0f; //SEGMENT.setPixelColorXY(xlocn, ylocn, SEGMENT.color_from_palette(strip.now/100+i, false, PALETTE_SOLID_WRAP, 0)); // draw pixel with anti-aliasing @@ -559,8 +559,8 @@ class BouncingBalls1D: public Effect { } void loop(Leds &leds) { - unsigned8 grav = mdl->getValue("gravity"); - unsigned8 numBalls = mdl->getValue("balls"); + stackUnsigned8 grav = mdl->getValue("gravity"); + stackUnsigned8 numBalls = mdl->getValue("balls"); CRGBPalette16 pal = getPalette(); Ball *balls = leds.sharedData.bind(balls, maxNumBalls); //array @@ -597,7 +597,7 @@ class BouncingBalls1D: public Effect { continue; // do not draw OOB ball } - // unsigned32 color = SEGCOLOR(0); + // stackUnsigned32 color = SEGCOLOR(0); // if (SEGMENT.palette) { // color = SEGMENT.color_wheel(i*(256/MAX(numBalls, 8))); // } @@ -607,7 +607,7 @@ class BouncingBalls1D: public Effect { int pos = roundf(balls[i].height * (leds.nrOfLeds - 1)); - CRGB color = ColorFromPalette(pal, i*(256/max(numBalls, (unsigned8)8)), 255); + CRGB color = ColorFromPalette(pal, i*(256/max(numBalls, (stackUnsigned8)8)), 255); leds[pos] = color; // if (SEGLEN<32) SEGMENT.setPixelColor(indexToVStrip(pos, stripNr), color); // encode virtual strip into index @@ -638,7 +638,7 @@ class RingRandomFlow:public RingEffect { } void loop(Leds &leds) { - unsigned8 *hue = leds.sharedData.bind(hue, leds.nrOfLeds); //array + stackUnsigned8 *hue = leds.sharedData.bind(hue, leds.nrOfLeds); //array hue[0] = random(0, 255); for (int r = 0; r < leds.nrOfLeds; r++) { @@ -658,8 +658,8 @@ class ScrollingText2D: public Effect { } void loop(Leds &leds) { - unsigned8 speed = mdl->getValue("speed"); - unsigned8 font = mdl->getValue("font"); + stackUnsigned8 speed = mdl->getValue("speed"); + stackUnsigned8 font = mdl->getValue("font"); const char * text = mdl->getValue("text"); // text might be nullified by selecting other effects and if effect is selected, controls are run afterwards @@ -697,8 +697,8 @@ class Waverly2D: public Effect { void loop(Leds &leds) { CRGBPalette16 pal = getPalette(); - unsigned8 amplification = mdl->getValue("Amplification"); - unsigned8 sensitivity = mdl->getValue("Sensitivity"); + stackUnsigned8 amplification = mdl->getValue("Amplification"); + stackUnsigned8 sensitivity = mdl->getValue("Sensitivity"); bool noClouds = mdl->getValue("No Clouds"); // bool soundPressure = mdl->getValue("Sound Pressure"); // bool agcDebug = mdl->getValue("AGC debug"); @@ -711,8 +711,8 @@ class Waverly2D: public Effect { long t = now / 2; Coord3D pos; for (pos.x = 0; pos.x < leds.size.x; pos.x++) { - unsigned16 thisVal = wledAudioMod->sync.volumeSmth*sensitivity/64 * inoise8(pos.x * 45 , t , t)/64; // WLEDMM back to SR code - unsigned16 thisMax = min(map(thisVal, 0, 512, 0, leds.size.y), (long)leds.size.x); + stackUnsigned16 thisVal = wledAudioMod->sync.volumeSmth*sensitivity/64 * inoise8(pos.x * 45 , t , t)/64; // WLEDMM back to SR code + stackUnsigned16 thisMax = min(map(thisVal, 0, 512, 0, leds.size.y), (long)leds.size.x); for (pos.y = 0; pos.y < thisMax; pos.y++) { CRGB color = ColorFromPalette(pal, map(pos.y, 0, thisMax, 250, 0), 255, LINEARBLEND); @@ -755,8 +755,8 @@ class PopCorn1D: public Effect { void loop(Leds &leds) { CRGBPalette16 pal = getPalette(); - unsigned8 speed = mdl->getValue("speed"); - unsigned8 intensity = mdl->getValue("intensity"); + stackUnsigned8 speed = mdl->getValue("speed"); + stackUnsigned8 intensity = mdl->getValue("intensity"); bool useaudio = mdl->getValue("useaudio"); Spark *popcorn = leds.sharedData.bind(popcorn, maxNumPopcorn); //array @@ -764,10 +764,10 @@ class PopCorn1D: public Effect { float gravity = -0.0001 - (speed/200000.0); // m/s/s gravity *= leds.nrOfLeds; - unsigned8 numPopcorn = intensity*maxNumPopcorn/255; + stackUnsigned8 numPopcorn = intensity*maxNumPopcorn/255; if (numPopcorn == 0) numPopcorn = 1; - for(int i = 0; i < numPopcorn; i++) { + for (int i = 0; i < numPopcorn; i++) { if (popcorn[i].pos >= 0.0f) { // if kernel is active, update its position popcorn[i].pos += popcorn[i].vel; popcorn[i].vel += gravity; @@ -787,7 +787,7 @@ class PopCorn1D: public Effect { if (doPopCorn) { // POP!!! popcorn[i].pos = 0.01f; - unsigned16 peakHeight = 128 + random8(128); //0-255 + stackUnsigned16 peakHeight = 128 + random8(128); //0-255 peakHeight = (peakHeight * (leds.nrOfLeds -1)) >> 8; popcorn[i].vel = sqrtf(-2.0f * gravity * peakHeight); @@ -802,9 +802,9 @@ class PopCorn1D: public Effect { } } if (popcorn[i].pos >= 0.0f) { // draw now active popcorn (either active before or just popped) - // unsigned32 col = SEGMENT.color_wheel(popcorn[i].colIndex); + // stackUnsigned32 col = SEGMENT.color_wheel(popcorn[i].colIndex); // if (!SEGMENT.palette && popcorn[i].colIndex < NUM_COLORS) col = SEGCOLOR(popcorn[i].colIndex); - unsigned16 ledIndex = popcorn[i].pos; + stackUnsigned16 ledIndex = popcorn[i].pos; CRGB col = ColorFromPalette(pal, popcorn[i].colIndex*(256/maxNumPopcorn), 255); if (ledIndex < leds.nrOfLeds) leds.setPixelColor(ledIndex, col); } @@ -835,17 +835,17 @@ class GEQEffect:public Effect { void loop(Leds &leds) { - unsigned16 *previousBarHeight = leds.sharedData.bind(previousBarHeight, leds.size.x); //array - unsigned32 *step = leds.sharedData.bind(step); + stackUnsigned16 *previousBarHeight = leds.sharedData.bind(previousBarHeight, leds.size.x); //array + stackUnsigned32 *step = leds.sharedData.bind(step); const int NUM_BANDS = NUM_GEQ_CHANNELS ; // map(SEGMENT.custom1, 0, 255, 1, 16); #ifdef SR_DEBUG - unsigned8 samplePeak = *(unsigned8*)um_data->u_data[3]; + stackUnsigned8 samplePeak = *(unsigned8*)um_data->u_data[3]; #endif - unsigned8 fadeOut = mdl->getValue("fadeOut"); - unsigned8 ripple = mdl->getValue("ripple"); + stackUnsigned8 fadeOut = mdl->getValue("fadeOut"); + stackUnsigned8 ripple = mdl->getValue("ripple"); bool colorBars = mdl->getValue("colorBars"); bool smoothBars = mdl->getValue("smoothBars"); CRGBPalette16 pal = getPalette(); @@ -861,12 +861,12 @@ class GEQEffect:public Effect { if ((fadeoutDelay <= 1 ) || (beat == 0)) leds.fadeToBlackBy(fadeOut); - unsigned16 lastBandHeight = 0; // WLEDMM: for smoothing out bars + stackUnsigned16 lastBandHeight = 0; // WLEDMM: for smoothing out bars //WLEDMM: evenly ditribut bands float bandwidth = (float)leds.size.x / NUM_BANDS; float remaining = bandwidth; - unsigned8 band = 0; + stackUnsigned8 band = 0; Coord3D pos = {0,0,0}; for (pos.x=0; pos.x < leds.size.x; pos.x++) { //WLEDMM if not enough remaining @@ -874,25 +874,25 @@ class GEQEffect:public Effect { remaining--; //consume remaining // USER_PRINTF("x %d b %d n %d w %f %f\n", x, band, NUM_BANDS, bandwidth, remaining); - unsigned8 frBand = ((NUM_BANDS < 16) && (NUM_BANDS > 1)) ? map(band, 0, NUM_BANDS - 1, 0, 15):band; // always use full range. comment out this line to get the previous behaviour. + stackUnsigned8 frBand = ((NUM_BANDS < 16) && (NUM_BANDS > 1)) ? map(band, 0, NUM_BANDS - 1, 0, 15):band; // always use full range. comment out this line to get the previous behaviour. // frBand = constrain(frBand, 0, 15); //WLEDMM can never be out of bounds (I think...) - unsigned16 colorIndex = frBand * 17; //WLEDMM 0.255 - unsigned16 bandHeight = wledAudioMod->fftResults[frBand]; // WLEDMM we use the original ffResult, to preserve accuracy + stackUnsigned16 colorIndex = frBand * 17; //WLEDMM 0.255 + stackUnsigned16 bandHeight = wledAudioMod->fftResults[frBand]; // WLEDMM we use the original ffResult, to preserve accuracy // WLEDMM begin - smooth out bars if ((pos.x > 0) && (pos.x < (leds.size.x-1)) && (smoothBars)) { // get height of next (right side) bar - unsigned8 nextband = (remaining < 1)? band +1: band; + stackUnsigned8 nextband = (remaining < 1)? band +1: band; nextband = constrain(nextband, 0, 15); // just to be sure frBand = ((NUM_BANDS < 16) && (NUM_BANDS > 1)) ? map(nextband, 0, NUM_BANDS - 1, 0, 15):nextband; // always use full range. comment out this line to get the previous behaviour. - unsigned16 nextBandHeight = wledAudioMod->fftResults[frBand]; + stackUnsigned16 nextBandHeight = wledAudioMod->fftResults[frBand]; // smooth Band height bandHeight = (7*bandHeight + 3*lastBandHeight + 3*nextBandHeight) / 12; // yeees, its 12 not 13 (10% amplification) bandHeight = constrain(bandHeight, 0, 255); // remove potential over/underflows colorIndex = map(pos.x, 0, leds.size.x-1, 0, 255); //WLEDMM } lastBandHeight = bandHeight; // remember BandHeight (left side) for next iteration - unsigned16 barHeight = map(bandHeight, 0, 255, 0, leds.size.y); // Now we map bandHeight to barHeight. do not subtract -1 from leds.size.y here + stackUnsigned16 barHeight = map(bandHeight, 0, 255, 0, leds.size.y); // Now we map bandHeight to barHeight. do not subtract -1 from leds.size.y here // WLEDMM end if (barHeight > leds.size.y) barHeight = leds.size.y; // WLEDMM map() can "overshoot" due to rounding errors @@ -998,15 +998,15 @@ class FreqMatrix:public Effect { void loop(Leds &leds) { - unsigned8 *aux0 = leds.sharedData.bind(aux0); + stackUnsigned8 *aux0 = leds.sharedData.bind(aux0); - unsigned8 speed = mdl->getValue("speed"); - unsigned8 fx = mdl->getValue("Sound effect"); - unsigned8 lowBin = mdl->getValue("Low bin"); - unsigned8 highBin = mdl->getValue("High bin"); - unsigned8 sensitivity10 = mdl->getValue("Sensivity"); + stackUnsigned8 speed = mdl->getValue("speed"); + stackUnsigned8 fx = mdl->getValue("Sound effect"); + stackUnsigned8 lowBin = mdl->getValue("Low bin"); + stackUnsigned8 highBin = mdl->getValue("High bin"); + stackUnsigned8 sensitivity10 = mdl->getValue("Sensivity"); - unsigned8 secondHand = (speed < 255) ? (micros()/(256-speed)/500 % 16) : 0; + stackUnsigned8 secondHand = (speed < 255) ? (micros()/(256-speed)/500 % 16) : 0; if((speed > 254) || (*aux0 != secondHand)) { // WLEDMM allow run run at full speed *aux0 = secondHand; @@ -1026,9 +1026,9 @@ class FreqMatrix:public Effect { // Pixel color (hue) based on major frequency int upperLimit = 80 + 42 * highBin; int lowerLimit = 80 + 3 * lowBin; - //unsigned8 i = lowerLimit!=upperLimit ? map(FFT_MajorPeak, lowerLimit, upperLimit, 0, 255) : FFT_MajorPeak; // (original formula) may under/overflow - so we enforce unsigned8 + //stackUnsigned8 i = lowerLimit!=upperLimit ? map(FFT_MajorPeak, lowerLimit, upperLimit, 0, 255) : FFT_MajorPeak; // (original formula) may under/overflow - so we enforce unsigned8 int freqMapped = lowerLimit!=upperLimit ? map(wledAudioMod->sync.FFT_MajorPeak, lowerLimit, upperLimit, 0, 255) : wledAudioMod->sync.FFT_MajorPeak; // WLEDMM preserve overflows - unsigned8 i = abs(freqMapped) & 0xFF; // WLEDMM we embrace overflow ;-) by "modulo 256" + stackUnsigned8 i = abs(freqMapped) & 0xFF; // WLEDMM we embrace overflow ;-) by "modulo 256" color = CHSV(i, 240, (unsigned8)pixVal); // implicit conversion to RGB supplied by FastLED } diff --git a/src/App/LedFixture.cpp b/src/App/LedFixture.cpp index 6e70c29f..44ed78ad 100644 --- a/src/App/LedFixture.cpp +++ b/src/App/LedFixture.cpp @@ -39,7 +39,7 @@ void Fixture::projectAndMap() { StarModJson starModJson(fileName); //open fileName for deserialize // for (std::vector::iterator leds=ledsList.begin(); leds!=ledsList.end() && leds->doMap; ++leds) { - unsigned8 rowNr = 0; + stackUnsigned8 rowNr = 0; for (Leds *leds: ledsList) { if (leds->doMap) { USER_PRINTF("Leds pre [%d] f:%d p:%d s:%d\n", rowNr, leds->fx, leds->projectionNr, ledsList.size()); @@ -57,16 +57,16 @@ void Fixture::projectAndMap() { } //deallocate all led pins - unsigned8 pinNr = 0; + stackUnsigned8 pinNr = 0; for (PinObject pinObject: pins->pinObjects) { if (strcmp(pinObject.owner, "Leds") == 0) pins->deallocatePin(pinNr, "Leds"); pinNr++; } - unsigned16 indexP = 0; - unsigned16 prevIndexP = 0; - unsigned16 currPin; + stackUnsigned16 indexP = 0; + stackUnsigned16 prevIndexP = 0; + unsigned16 currPin; //lookFor needs u16 //what to deserialize starModJson.lookFor("width", &size.x); @@ -78,7 +78,7 @@ void Fixture::projectAndMap() { //lookFor leds array and for each item in array call lambdo to make a projection starModJson.lookFor("leds", [this, &prevIndexP, &indexP, &currPin](std::vector uint16CollectList) { //this will be called for each tuple of coordinates! // USER_PRINTF("funList "); - // for (unsigned16 num:uint16CollectList) + // for (forUnsigned16 num:uint16CollectList) // USER_PRINTF(" %d", num); // USER_PRINTF("\n"); @@ -93,7 +93,7 @@ void Fixture::projectAndMap() { //vector iterator needed to get the pointer to leds as we need to update leds, also vector iteration on classes is faster!!! //search: ^(?=.*\bfor\b)(?=.*\b:\b).*$ - unsigned8 rowNr = 0; + stackUnsigned8 rowNr = 0; for (Leds *leds: ledsList) { if (leds->doMap) { @@ -103,7 +103,7 @@ void Fixture::projectAndMap() { Coord3D projSize = (endPosAdjusted - startPosAdjusted)/10 + Coord3D{1,1,1}; // 0 to 3D depending on start and endpos (e.g. to display ScrollingText on one side of a cube) - unsigned8 projectionDimension = 0; + stackUnsigned8 projectionDimension = 0; if (projSize.x > 1) projectionDimension++; if (projSize.y > 1) projectionDimension++; if (projSize.z > 1) projectionDimension++; @@ -116,7 +116,7 @@ void Fixture::projectAndMap() { // if (indexP == 0) //first { - unsigned16 maxDistance = distance(endPosAdjusted, startPosAdjusted) / 10; + stackUnsigned16 maxDistance = distance(endPosAdjusted, startPosAdjusted) / 10; // USER_PRINTF("maxDistance %d %d,%d,%d %d,%d,%d %d,%d,%d\n", maxDistance, pixel.x, pixel.y, pixel.z, startPosAdjusted.x, startPosAdjusted.y, startPosAdjusted.z, endPosAdjusted.x, endPosAdjusted.y, endPosAdjusted.z); float scale = 1; @@ -194,7 +194,7 @@ void Fixture::projectAndMap() { Coord3D midPoint = (startPosAdjusted + endPosAdjusted) / 2; //calculate the indexV to add to current physical led to - unsigned16 indexV = UINT16_MAX; + stackUnsigned16 indexV = UINT16_MAX; switch(leds->projectionNr) { case p_None: break; @@ -289,8 +289,8 @@ void Fixture::projectAndMap() { case _2D: float minDistance = 10; // USER_PRINTF("checking indexV %d\n", indexV); - for (unsigned16 y=0; y 0.5; y++) - for (unsigned16 x=0; x 0.5; x++) { + for (forUnsigned16 y=0; y 0.5; y++) + for (forUnsigned16 x=0; x 0.5; x++) { float xNew = sinf(x * TWO_PI / (float)(size.x-1)) * size.x; float yNew = cosf(x * TWO_PI / (float)(size.x-1)) * size.y; @@ -367,9 +367,9 @@ void Fixture::projectAndMap() { char * before; before = after; after = strtok(NULL, " "); - unsigned16 startLed = atoi(before); - unsigned16 nrOfLeds = atoi(after) - atoi(before) + 1; - print->fFormat(details, sizeof(details)-1, "%d-%d", min(prevIndexP, startLed), max((unsigned16)(indexP - 1), nrOfLeds)); //careful: LedModEffects:loop uses this to assign to FastLed + stackUnsigned16 startLed = atoi(before); + stackUnsigned16 nrOfLeds = atoi(after) - atoi(before) + 1; + print->fFormat(details, sizeof(details)-1, "%d-%d", min(prevIndexP, startLed), max((stackUnsigned16)(indexP - 1), nrOfLeds)); //careful: LedModEffects:loop uses this to assign to FastLed USER_PRINTF("pins extend leds %d: %s\n", currPin, details); //tbd: more check @@ -390,14 +390,14 @@ void Fixture::projectAndMap() { if (starModJson.deserialize(false)) { //this will call above function parameter for each led - unsigned8 rowNr = 0; + stackUnsigned8 rowNr = 0; // for (std::vector::iterator leds=ledsList.begin(); leds!=ledsList.end() && leds->doMap; ++leds) { for (Leds *leds: ledsList) { if (leds->doMap) { USER_PRINTF("Leds pre [%d] f:%d p:%d s:%d\n", rowNr, leds->fx, leds->projectionNr, ledsList.size()); - unsigned16 nrOfMappings = 0; - unsigned16 nrOfPixels = 0; + stackUnsigned16 nrOfMappings = 0; + stackUnsigned16 nrOfPixels = 0; if (leds->projectionNr == p_Random || leds->projectionNr == p_None) { @@ -417,12 +417,12 @@ void Fixture::projectAndMap() { leds->nrOfLeds = leds->mappingTable.size(); - unsigned16 indexV = 0; + stackUnsigned16 indexV = 0; for (std::vector* physMap:leds->mappingTable) { if (physMap && physMap->size()) { // USER_PRINTF("ledV %d mapping: #ledsP (%d):", indexV, physMap->size()); - for (unsigned16 indexP:*physMap) { + for (forUnsigned16 indexP:*physMap) { // USER_PRINTF(" %d", indexP); nrOfPixels++; } diff --git a/src/App/LedLeds.cpp b/src/App/LedLeds.cpp index 57d43a88..bc2ca181 100644 --- a/src/App/LedLeds.cpp +++ b/src/App/LedLeds.cpp @@ -27,7 +27,7 @@ void Leds::setPixelColor(unsigned16 indexV, CRGB color, unsigned8 blendAmount) { if (indexV < mappingTable.size()) { std::vector* physMap = mappingTable[indexV]; if (physMap) - for (unsigned16 indexP:*physMap) { + for (forUnsigned16 indexP:*physMap) { fixture->ledsP[indexP] = blend(color, fixture->ledsP[indexP], blendAmount==UINT8_MAX?fixture->globalBlend:blendAmount); } } @@ -59,7 +59,7 @@ void Leds::fadeToBlackBy(unsigned8 fadeBy) { } else { for (std::vector* physMap:mappingTable) { if (physMap) - for (unsigned16 indexP:*physMap) { + for (forUnsigned16 indexP:*physMap) { CRGB oldValue = fixture->ledsP[indexP]; fixture->ledsP[indexP].nscale8(255-fadeBy); //this overrides the old value fixture->ledsP[indexP] = blend(fixture->ledsP[indexP], oldValue, fixture->globalBlend); // we want to blend in the old value @@ -74,7 +74,7 @@ void Leds::fill_solid(const struct CRGB& color) { } else { for (std::vector* physMap:mappingTable) { if (physMap) - for (unsigned16 indexP:*physMap) { + for (forUnsigned16 indexP:*physMap) { fixture->ledsP[indexP] = blend(color, fixture->ledsP[indexP], fixture->globalBlend); } } @@ -92,7 +92,7 @@ void Leds::fill_rainbow(unsigned8 initialhue, unsigned8 deltahue) { for (std::vector* physMap:mappingTable) { if (physMap) - for (unsigned16 indexP:*physMap) { + for (forUnsigned16 indexP:*physMap) { fixture->ledsP[indexP] = blend(hsv, fixture->ledsP[indexP], fixture->globalBlend); } hsv.hue += deltahue; diff --git a/src/App/LedLeds.h b/src/App/LedLeds.h index aacec217..a55b331a 100644 --- a/src/App/LedLeds.h +++ b/src/App/LedLeds.h @@ -258,17 +258,17 @@ class Leds { void blurRows(unsigned8 width, unsigned8 height, fract8 blur_amount) { - /* for( unsigned8 row = 0; row < height; row++) { + /* for (forUnsigned8 row = 0; row < height; row++) { CRGB* rowbase = leds + (row * width); blur1d( rowbase, width, blur_amount); } */ // blur rows same as columns, for irregular matrix - unsigned8 keep = 255 - blur_amount; - unsigned8 seep = blur_amount >> 1; - for( unsigned8 row = 0; row < height; row++) { + stackUnsigned8 keep = 255 - blur_amount; + stackUnsigned8 seep = blur_amount >> 1; + for (forUnsigned8 row = 0; row < height; row++) { CRGB carryover = CRGB::Black; - for( unsigned8 i = 0; i < width; i++) { + for (forUnsigned8 i = 0; i < width; i++) { CRGB cur = getPixelColor(XY(i,row)); CRGB part = cur; part.nscale8( seep); @@ -285,11 +285,11 @@ class Leds { void blurColumns(unsigned8 width, unsigned8 height, fract8 blur_amount) { // blur columns - unsigned8 keep = 255 - blur_amount; - unsigned8 seep = blur_amount >> 1; - for( unsigned8 col = 0; col < width; ++col) { + stackUnsigned8 keep = 255 - blur_amount; + stackUnsigned8 seep = blur_amount >> 1; + for (forUnsigned8 col = 0; col < width; ++col) { CRGB carryover = CRGB::Black; - for( unsigned8 i = 0; i < height; ++i) { + for (forUnsigned8 i = 0; i < height; ++i) { CRGB cur = getPixelColor(XY(col,i)); CRGB part = cur; part.nscale8( seep); diff --git a/src/App/LedModEffects.h b/src/App/LedModEffects.h index c4d0b9cc..a779c5f0 100644 --- a/src/App/LedModEffects.h +++ b/src/App/LedModEffects.h @@ -91,7 +91,7 @@ class LedModEffects:public SysModule { currentVar = ui->initSelect(tableVar, "fx", 0, false, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case f_ValueFun: - for (unsigned8 rowNr = 0; rowNr < fixture.ledsList.size(); rowNr++) + for (forUnsigned8 rowNr = 0; rowNr < fixture.ledsList.size(); rowNr++) mdl->setValue(var, fixture.ledsList[rowNr]->fx, rowNr); return true; case f_UIFun: { @@ -121,7 +121,7 @@ class LedModEffects:public SysModule { currentVar = ui->initSelect(tableVar, "pro", 2, false, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case f_ValueFun: - for (unsigned8 rowNr = 0; rowNr < fixture.ledsList.size(); rowNr++) + for (forUnsigned8 rowNr = 0; rowNr < fixture.ledsList.size(); rowNr++) mdl->setValue(var, fixture.ledsList[rowNr]->projectionNr, rowNr); return true; case f_UIFun: { @@ -147,7 +147,7 @@ class LedModEffects:public SysModule { if (rowNr < fixture.ledsList.size()) { fixture.ledsList[rowNr]->doMap = true; - unsigned8 proValue = mdl->getValue(var, rowNr); + stackUnsigned8 proValue = mdl->getValue(var, rowNr); fixture.ledsList[rowNr]->projectionNr = proValue; mdl->varPreDetails(var, rowNr); //set all positive var N orders to negative @@ -194,7 +194,7 @@ class LedModEffects:public SysModule { ui->initCoord3D(tableVar, "fxStart", {0,0,0}, 0, NUM_LEDS_Max, false, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case f_ValueFun: - for (unsigned8 rowNr = 0; rowNr < fixture.ledsList.size(); rowNr++) { + for (forUnsigned8 rowNr = 0; rowNr < fixture.ledsList.size(); rowNr++) { USER_PRINTF("fxStart[%d] valueFun %d,%d,%d\n", rowNr, fixture.ledsList[rowNr]->startPos.x, fixture.ledsList[rowNr]->startPos.y, fixture.ledsList[rowNr]->startPos.z); mdl->setValue(var, fixture.ledsList[rowNr]->startPos, rowNr); } @@ -222,7 +222,7 @@ class LedModEffects:public SysModule { ui->initCoord3D(tableVar, "fxEnd", {8,8,0}, 0, NUM_LEDS_Max, false, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case f_ValueFun: - for (unsigned8 rowNr = 0; rowNr < fixture.ledsList.size(); rowNr++) { + for (forUnsigned8 rowNr = 0; rowNr < fixture.ledsList.size(); rowNr++) { USER_PRINTF("fxEnd[%d] valueFun %d,%d,%d\n", rowNr, fixture.ledsList[rowNr]->endPos.x, fixture.ledsList[rowNr]->endPos.y, fixture.ledsList[rowNr]->endPos.z); mdl->setValue(var, fixture.ledsList[rowNr]->endPos, rowNr); } @@ -248,10 +248,10 @@ class LedModEffects:public SysModule { default: return false; }}); - ui->initText(tableVar, "fxSize", nullptr, 32, true, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun + ui->initText(tableVar, "fxSize", nullptr, 32, true, [this](JsonObject var, stackUnsigned8 rowNr, stackUnsigned8 funType) { switch (funType) { //varFun case f_ValueFun: { // for (std::vector::iterator leds=fixture.ledsList.begin(); leds!=fixture.ledsList.end(); ++leds) { - unsigned8 rowNr = 0; + stackUnsigned8 rowNr = 0; for (Leds *leds: fixture.ledsList) { char message[32]; print->fFormat(message, sizeof(message)-1, "%d x %d x %d = %d", leds->size.x, leds->size.y, leds->size.z, leds->nrOfLeds); @@ -324,7 +324,7 @@ class LedModEffects:public SysModule { // run the next frame of the effect // vector iteration on classes is faster!!! (22 vs 30 fps !!!!) // for (std::vector::iterator leds=fixture.ledsList.begin(); leds!=fixture.ledsList.end(); ++leds) { - unsigned8 rowNr = 0; + stackUnsigned8 rowNr = 0; for (Leds *leds: fixture.ledsList) { if (!leds->doMap) { // don't run effect while remapping // USER_PRINTF(" %d %d,%d,%d - %d,%d,%d (%d,%d,%d)", leds->fx, leds->startPos.x, leds->startPos.y, leds->startPos.z, leds->endPos.x, leds->endPos.y, leds->endPos.z, leds->size.x, leds->size.y, leds->size.z ); @@ -393,8 +393,8 @@ class LedModEffects:public SysModule { before = after; after = strtok(NULL, " "); - unsigned16 startLed = atoi(before); - unsigned16 nrOfLeds = atoi(after) - atoi(before) + 1; + stackUnsigned16 startLed = atoi(before); + stackUnsigned16 nrOfLeds = atoi(after) - atoi(before) + 1; USER_PRINTF("FastLED.addLeds new %d: %d-%d\n", pinNr, startLed, nrOfLeds); //commented pins: error: static assertion failed: Invalid pin specified diff --git a/src/App/LedModFixture.h b/src/App/LedModFixture.h index b629cc00..8fd698d4 100644 --- a/src/App/LedModFixture.h +++ b/src/App/LedModFixture.h @@ -37,9 +37,9 @@ class LedModFixture:public SysModule { ui->setLabel(var, "Brightness"); return true; case f_ChangeFun: { - unsigned8 bri = var["value"]; + stackUnsigned8 bri = var["value"]; - unsigned8 result = mdl->getValue("on").as()?linearToLogarithm(var, bri):0; + stackUnsigned8 result = mdl->getValue("on").as()?linearToLogarithm(var, bri):0; FastLED.setBrightness(result); diff --git a/src/App/LedModFixtureGen.h b/src/App/LedModFixtureGen.h index bc85730c..31e3d185 100644 --- a/src/App/LedModFixtureGen.h +++ b/src/App/LedModFixtureGen.h @@ -139,12 +139,12 @@ class GenFix { // Coord3D pixel = first; - unsigned8 rowDimension; //in what dimension the row will advance (x=0, y=1, z=2), now only one should differ + stackUnsigned8 rowDimension; //in what dimension the row will advance (x=0, y=1, z=2), now only one should differ if (first.x != rowEnd.x) rowDimension = 0; if (first.y != rowEnd.y) rowDimension = 1; // if (first.z != rowEnd.z) rowDimension = 2; - unsigned8 colDimension; //in what dimension the col will advance, not the rowDimension + stackUnsigned8 colDimension; //in what dimension the col will advance, not the rowDimension if (first.x != colEnd.x && rowDimension != 0) colDimension = 0; // if (first.y != colEnd.y && rowDimension != 1) colDimension = 1; if (first.z != colEnd.z && rowDimension != 2) colDimension = 2; @@ -164,7 +164,7 @@ class GenFix { } Coord3D colPixel = Coord3D{(rowDimension==0)?colEnd.x:first.x, (rowDimension==1)?colEnd.y:first.y, (rowDimension==2)?colEnd.z:first.z}; - unsigned8 colNr = 0; + stackUnsigned8 colNr = 0; while (true) { // colPixel is not advancing over the dimension of the row but advances over it's own dimension towards the colEnd @@ -204,8 +204,8 @@ class GenFix { float ringDiam = 10 * ledCount / 2 / M_PI; //in mm for (int i=0; i 1 // {1, 8}, //1 -> 8 // {9, 20}, //2 -> 12 @@ -228,14 +228,14 @@ class GenFix { openPin(pin); // in2out or out2in - unsigned16 size = ringDiams[nrOfRings-1]; //size if the biggest ring + stackUnsigned16 size = ringDiams[nrOfRings-1]; //size if the biggest ring for (int j=0; jgetValue("in2out"); for (int j=0; jinitUserMod(parentVar, name, 1300); + parentVar = ui->initUserMod(parentVar, name, 1300); //created as a usermod, not an appmod to have it in the usermods tab ui->initSelect(parentVar, "fixtureGen", 0, false, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case f_UIFun: { @@ -508,7 +508,7 @@ class LedModFixtureGen:public SysModule { JsonObject panelVar = mdl->findVar("panels"); // JsonObject parentVar = mdl->findVar(var["id"]); //local parentVar - unsigned8 fgValue = fixtureGenVar["value"]; + stackUnsigned8 fgValue = fixtureGenVar["value"]; fixtureGenVar.remove("n"); //tbd: we should also remove the varFun !! @@ -580,46 +580,46 @@ class LedModFixtureGen:public SysModule { options.add("Great Plains"); return true; } case f_ChangeFun: { - unsigned8 optionNr = 1; // 0 is none, maintain the same order here as the options - unsigned8 panel = 0; + stackUnsigned8 optionNr = 1; // 0 is none, maintain the same order here as the options + stackUnsigned8 panel = 0; if (var["value"] == optionNr++) { //16x16 - unsigned8 lengthMinOne = 15; + stackUnsigned8 lengthMinOne = 15; panel = 0; mdl->setValue("pnlFirst", Coord3D{0,0,0}, panel++); panel = 0; mdl->setValue("mrxRowEnd", Coord3D{0,lengthMinOne,0}, panel++); panel = 0; mdl->setValue("mrxColEnd", Coord3D{lengthMinOne,lengthMinOne,0}, panel++); panel = 0; mdl->setValue("fixPin", 2, panel++); // default per board... } if (var["value"] == optionNr++) { //4x16x16 - unsigned8 lengthMinOne = 15; unsigned8 size = lengthMinOne + 1; + stackUnsigned8 lengthMinOne = 15; stackUnsigned8 size = lengthMinOne + 1; panel = 0; mdl->setValue("pnlFirst", Coord3D{0,0,0}, panel++); mdl->setValue("pnlFirst", Coord3D{16,0,0}, panel++); mdl->setValue("pnlFirst", Coord3D{0,16,0}, panel++); mdl->setValue("pnlFirst", Coord3D{16,16,0}, panel++); panel = 0; mdl->setValue("mrxRowEnd", Coord3D{0,lengthMinOne,0}, panel++); mdl->setValue("mrxRowEnd", Coord3D{16,lengthMinOne,0}, panel++); mdl->setValue("mrxRowEnd", Coord3D{0,31,0}, panel++); mdl->setValue("mrxRowEnd", Coord3D{16,31,0}, panel++); panel = 0; mdl->setValue("mrxColEnd", Coord3D{lengthMinOne,lengthMinOne,0}, panel++); mdl->setValue("mrxColEnd", Coord3D{31,lengthMinOne,0}, panel++); mdl->setValue("mrxColEnd", Coord3D{lengthMinOne,31,0}, panel++); mdl->setValue("mrxColEnd", Coord3D{31,31,0}, panel++); panel = 0; mdl->setValue("fixPin", 2, panel++); mdl->setValue("fixPin", 2, panel++); mdl->setValue("fixPin", 2, panel++); mdl->setValue("fixPin", 2, panel++); } if (var["value"] == optionNr++) { //4x32x8 - unsigned8 lengthMinOne = 31; + stackUnsigned8 lengthMinOne = 31; panel = 0; mdl->setValue("pnlFirst", Coord3D{lengthMinOne,lengthMinOne,0}, panel++); mdl->setValue("pnlFirst", Coord3D{lengthMinOne,23,0}, panel++); mdl->setValue("pnlFirst", Coord3D{lengthMinOne,15,0}, panel++); mdl->setValue("pnlFirst", Coord3D{lengthMinOne,7,0}, panel++); panel = 0; mdl->setValue("mrxRowEnd", Coord3D{lengthMinOne,24,0}, panel++); mdl->setValue("mrxRowEnd", Coord3D{lengthMinOne,16,0}, panel++); mdl->setValue("mrxRowEnd", Coord3D{lengthMinOne,8,0}, panel++); mdl->setValue("mrxRowEnd", Coord3D{lengthMinOne,0,0}, panel++); panel = 0; mdl->setValue("mrxColEnd", Coord3D{0,lengthMinOne,0}, panel++); mdl->setValue("mrxColEnd", Coord3D{0,23,0}, panel++); mdl->setValue("mrxColEnd", Coord3D{0,15,0}, panel++); mdl->setValue("mrxColEnd", Coord3D{0,7,0}, panel++); panel = 0; mdl->setValue("fixPin", 2, panel++); mdl->setValue("fixPin", 2, panel++); mdl->setValue("fixPin", 2, panel++); mdl->setValue("fixPin", 2, panel++); } else if (var["value"] == optionNr++) { //Human Sized Cube - unsigned8 length = 20; unsigned8 size = length + 1; + stackUnsigned8 length = 20; stackUnsigned8 size = length + 1; panel = 0; mdl->setValue("pnlFirst", Coord3D{1,1,size}, panel++); mdl->setValue("pnlFirst", Coord3D{0,1,1}, panel++); mdl->setValue("pnlFirst", Coord3D{1,1,0}, panel++); mdl->setValue("pnlFirst", Coord3D{size,1,1}, panel++); mdl->setValue("pnlFirst", Coord3D{1,0,1}, panel++); panel = 0; mdl->setValue("mrxRowEnd", Coord3D{1,length,size}, panel++); mdl->setValue("mrxRowEnd", Coord3D{0,length,1}, panel++); mdl->setValue("mrxRowEnd", Coord3D{1,length,0}, panel++); mdl->setValue("mrxRowEnd", Coord3D{size,length,1}, panel++); mdl->setValue("mrxRowEnd", Coord3D{1,0,length}, panel++); panel = 0; mdl->setValue("mrxColEnd", Coord3D{length,length,size}, panel++); mdl->setValue("mrxColEnd", Coord3D{0,length,length}, panel++); mdl->setValue("mrxColEnd", Coord3D{length,length,0}, panel++); mdl->setValue("mrxColEnd", Coord3D{size,length,length}, panel++); mdl->setValue("mrxColEnd", Coord3D{length,0,length}, panel++); panel = 0; mdl->setValue("fixPin", 16, panel++); mdl->setValue("fixPin", 14, panel++); mdl->setValue("fixPin", 32, panel++); mdl->setValue("fixPin", 3, panel++); mdl->setValue("fixPin", 15, panel++); } else if (var["value"] == optionNr++) { //Cube 6 x 8 x 8 - unsigned8 length = 8; unsigned8 size = length + 1; + stackUnsigned8 length = 8; stackUnsigned8 size = length + 1; panel = 0; mdl->setValue("pnlFirst", Coord3D{1,1,0}, panel++); mdl->setValue("pnlFirst", Coord3D{length, size, length}, panel++); mdl->setValue("pnlFirst", Coord3D{size, 1, 1}, panel++); mdl->setValue("pnlFirst", Coord3D{0, length, length}, panel++); mdl->setValue("pnlFirst", Coord3D{length, 1, size}, panel++); mdl->setValue("pnlFirst", Coord3D{1, 0, length}, panel++); panel = 0; mdl->setValue("mrxRowEnd", Coord3D{1,length,0}, panel++); mdl->setValue("mrxRowEnd", Coord3D{1, size, length}, panel++); mdl->setValue("mrxRowEnd", Coord3D{size, 1, length}, panel++); mdl->setValue("mrxRowEnd", Coord3D{0, 1, length}, panel++); mdl->setValue("mrxRowEnd", Coord3D{1, 1, size}, panel++); mdl->setValue("mrxRowEnd", Coord3D{length, 0, length}, panel++); panel = 0; mdl->setValue("mrxColEnd", Coord3D{length,length,0}, panel++); mdl->setValue("mrxColEnd", Coord3D{1, size, 1}, panel++); mdl->setValue("mrxColEnd", Coord3D{size, length, length}, panel++); mdl->setValue("mrxColEnd", Coord3D{0, 1, 1}, panel++); mdl->setValue("mrxColEnd", Coord3D{1, length, size}, panel++); mdl->setValue("mrxColEnd", Coord3D{length, 0, 1}, panel++); panel = 0; mdl->setValue("fixPin", 12, panel++); mdl->setValue("fixPin", 12, panel++); mdl->setValue("fixPin", 13, panel++); mdl->setValue("fixPin", 13, panel++); mdl->setValue("fixPin", 14, panel++); mdl->setValue("fixPin", 14, panel++); } else if (var["value"] == optionNr++) { //Cube 3D - unsigned8 length = 8; unsigned8 size = length -1; - for (unsigned8 panel=0; panel < length; panel++) { + stackUnsigned8 length = 8; stackUnsigned8 size = length -1; + for (forUnsigned8 panel=0; panel < length; panel++) { mdl->setValue("pnlFirst", Coord3D{0,0,panel}, panel); mdl->setValue("mrxRowEnd", Coord3D{0,size,panel}, panel); mdl->setValue("mrxColEnd", Coord3D{size,size,panel}, panel); @@ -627,9 +627,9 @@ class LedModFixtureGen:public SysModule { } } else if (var["value"] == optionNr++) { //Sticks - unsigned8 length = 16; - unsigned8 height = 54; - for (unsigned8 panel=0; panel < length; panel++) { + stackUnsigned8 length = 16; + stackUnsigned8 height = 54; + for (forUnsigned8 panel=0; panel < length; panel++) { mdl->setValue("pnlFirst", Coord3D{(unsigned16)(panel*5), height, 0}, panel); mdl->setValue("mrxRowEnd", Coord3D{(unsigned16)(panel*5), height, 0}, panel); mdl->setValue("mrxColEnd", Coord3D{(unsigned16)(panel*5), 0, 0}, panel); @@ -663,8 +663,8 @@ class LedModFixtureGen:public SysModule { options.add("Audi"); return true; } case f_ChangeFun: { - unsigned8 optionNr = 1; // 0 is none, maintain the same order here as the options - unsigned8 panel = 0; + stackUnsigned8 optionNr = 1; // 0 is none, maintain the same order here as the options + stackUnsigned8 panel = 0; if (var["value"] == optionNr++) { //Olympic panel = 0; mdl->setValue("pnlFirst", Coord3D{0,0,0}, panel++); mdl->setValue("pnlFirst", Coord3D{10,0,0}, panel++); mdl->setValue("pnlFirst", Coord3D{20,0,0}, panel++); mdl->setValue("pnlFirst", Coord3D{5,3,0}, panel++); mdl->setValue("pnlFirst", Coord3D{15,3,0}, panel++); panel = 0; mdl->setValue("fixLeds", 24, panel++); mdl->setValue("fixLeds", 24, panel++); mdl->setValue("fixLeds", 24, panel++); mdl->setValue("fixLeds", 24, panel++); mdl->setValue("fixLeds", 24, panel++); @@ -709,8 +709,8 @@ class LedModFixtureGen:public SysModule { options.add("HexaWall"); return true; } case f_ChangeFun: { - unsigned8 optionNr = 1; // 0 is none, maintain the same order here as the options - unsigned8 panel = 0; + stackUnsigned8 optionNr = 1; // 0 is none, maintain the same order here as the options + stackUnsigned8 panel = 0; if (var["value"] == optionNr++) { //HexaWall panel = 0; mdl->setValue("pnlFirst", Coord3D{0,0,0}, panel++); @@ -723,7 +723,7 @@ class LedModFixtureGen:public SysModule { mdl->setValue("pnlFirst", Coord3D{50,6,0}, panel++); mdl->setValue("pnlFirst", Coord3D{60,0,0}, panel++); - for (unsigned8 panel = 0; panel < 9; panel++) { + for (forUnsigned8 panel = 0; panel < 9; panel++) { mdl->setValue("ledsPerSide", 6, panel); mdl->setValue("fixPin", 2, panel); } @@ -758,7 +758,7 @@ class LedModFixtureGen:public SysModule { //tbd: move logic to pinMgr and create initPin JsonArray options = ui->setOptions(var); - for (unsigned8 pinNr = 0; pinNr < NUM_DIGITAL_PINS; pinNr++) { + for (forUnsigned8 pinNr = 0; pinNr < NUM_DIGITAL_PINS; pinNr++) { char text[32]; itoa(pinNr, text, 10); if (digitalPinIsValid(pinNr)) { @@ -796,8 +796,8 @@ class LedModFixtureGen:public SysModule { //set remaining rows to same pin JsonArray valArray = mdl->varValArray(var); - unsigned8 thisVal = var["value"]; - unsigned8 rowNrL = 0; + stackUnsigned8 thisVal = var["value"]; + stackUnsigned8 rowNrL = 0; for (JsonVariant val: valArray) { if (rowNrL > rowNr) mdl->setValue(var, valArray[rowNr].as(), rowNrL); @@ -829,7 +829,7 @@ class LedModFixtureGen:public SysModule { GenFix genFix; JsonObject presetsVar = mdl->findVar("fixPreset"); - unsigned8 presets = mdl->getValue(presetsVar); + stackUnsigned8 presets = mdl->getValue(presetsVar); //set header and file name if (presets != 0) { @@ -844,14 +844,14 @@ class LedModFixtureGen:public SysModule { ui->clearOptions(presetsVar); } else { - unsigned16 ledCount = mdl->getValue("fixLeds"); + // stackUnsigned16 ledCount = mdl->getValue("fixLeds"); genFix.openHeader(fileName); } JsonVariant pnlFirstValue = mdl->findVar("pnlFirst")["value"]; if (pnlFirstValue.is()) { - unsigned8 rowNr = 0; + stackUnsigned8 rowNr = 0; for (JsonVariant firstValueRow: pnlFirstValue.as()) { genFun(&genFix, rowNr); rowNr++; @@ -865,7 +865,7 @@ class LedModFixtureGen:public SysModule { void generateChFun(JsonObject var) { - unsigned8 fgValue = mdl->getValue("fixtureGen"); + stackUnsigned8 fgValue = mdl->getValue("fixtureGen"); if (fgValue == f_Matrix) { diff --git a/src/Sys/SysModAI.h b/src/Sys/SysModAI.h index 773c1167..6c533e48 100644 --- a/src/Sys/SysModAI.h +++ b/src/Sys/SysModAI.h @@ -41,7 +41,7 @@ struct Recommendation { ui->initText(tableVar, "aiIntel", nullptr, 32, true, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case f_ValueFun: - for (unsigned8 rowNr = 0; rowNr < recommendations.size(); rowNr++) + for (forUnsigned8 rowNr = 0; rowNr < recommendations.size(); rowNr++) mdl->setValue(var, JsonString(recommendations[rowNr].intel, JsonString::Copied), rowNr); return true; case f_UIFun: @@ -52,7 +52,7 @@ struct Recommendation { ui->initButton(tableVar, "aiButton", false, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case f_ValueFun: - for (unsigned8 rowNr = 0; rowNr < recommendations.size(); rowNr++) + for (forUnsigned8 rowNr = 0; rowNr < recommendations.size(); rowNr++) mdl->setValue(var, JsonString(recommendations[rowNr].module, JsonString::Copied), rowNr); return true; case f_UIFun: diff --git a/src/Sys/SysModFiles.cpp b/src/Sys/SysModFiles.cpp index 74cdcbf4..bfca4e16 100644 --- a/src/Sys/SysModFiles.cpp +++ b/src/Sys/SysModFiles.cpp @@ -57,7 +57,7 @@ void SysModFiles::setup() { ui->initText(tableVar, "flName", nullptr, 32, true, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case f_ValueFun: - for (unsigned8 rowNr = 0; rowNr < fileList.size(); rowNr++) + for (forUnsigned8 rowNr = 0; rowNr < fileList.size(); rowNr++) mdl->setValue(var, JsonString(fileList[rowNr].name, JsonString::Copied), rowNr); return true; case f_UIFun: @@ -68,7 +68,7 @@ void SysModFiles::setup() { ui->initNumber(tableVar, "flSize", UINT16_MAX, 0, UINT16_MAX, true, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case f_ValueFun: - for (unsigned8 rowNr = 0; rowNr < fileList.size(); rowNr++) + for (forUnsigned8 rowNr = 0; rowNr < fileList.size(); rowNr++) mdl->setValue(var, fileList[rowNr].size, rowNr); return true; case f_UIFun: @@ -79,7 +79,7 @@ void SysModFiles::setup() { ui->initURL(tableVar, "flLink", nullptr, true, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case f_ValueFun: - for (unsigned8 rowNr = 0; rowNr < fileList.size(); rowNr++) { + for (forUnsigned8 rowNr = 0; rowNr < fileList.size(); rowNr++) { char urlString[32] = "file/"; strncat(urlString, fileList[rowNr].name, sizeof(urlString)-1); mdl->setValue(var, JsonString(urlString, JsonString::Copied), rowNr); diff --git a/src/Sys/SysModPins.cpp b/src/Sys/SysModPins.cpp index a47b8edf..5dbba646 100644 --- a/src/Sys/SysModPins.cpp +++ b/src/Sys/SysModPins.cpp @@ -46,7 +46,7 @@ void SysModPins::setup() { ui->initPin(tableVar, "pinNr", UINT16_MAX, true, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case f_ValueFun: - for (unsigned8 rowNr = 0; rowNr < getNrOfAllocatedPins(); rowNr++) + for (forUnsigned8 rowNr = 0; rowNr < getNrOfAllocatedPins(); rowNr++) mdl->setValue(var, getPinNr(rowNr), rowNr); return true; case f_UIFun: @@ -57,7 +57,7 @@ void SysModPins::setup() { ui->initText(tableVar, "pinOwner", nullptr, 32, true, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case f_ValueFun: - for (unsigned8 rowNr = 0; rowNr < getNrOfAllocatedPins(); rowNr++) + for (forUnsigned8 rowNr = 0; rowNr < getNrOfAllocatedPins(); rowNr++) mdl->setValue(var, JsonString(getNthAllocatedPinObject(rowNr).owner, JsonString::Copied), rowNr); return true; case f_UIFun: @@ -68,7 +68,7 @@ void SysModPins::setup() { ui->initText(tableVar, "pinDetails", nullptr, 256, true, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case f_ValueFun: - for (unsigned8 rowNr = 0; rowNr < getNrOfAllocatedPins(); rowNr++) + for (forUnsigned8 rowNr = 0; rowNr < getNrOfAllocatedPins(); rowNr++) mdl->setValue(var, JsonString(getNthAllocatedPinObject(rowNr).details, JsonString::Copied), rowNr); return true; case f_UIFun: diff --git a/src/Sys/SysModPins.h b/src/Sys/SysModPins.h index b51085e5..5a06c231 100644 --- a/src/Sys/SysModPins.h +++ b/src/Sys/SysModPins.h @@ -36,7 +36,7 @@ class SysModPins:public SysModule { //temporary functions until we refactored the PinObject PinObject getNthAllocatedPinObject(unsigned8 rowNr) { - unsigned8 n = 0; + stackUnsigned8 n = 0; for (PinObject pinObject:pinObjects) { if (strcmp(pinObject.owner, "") != 0) { if (n == rowNr) @@ -47,7 +47,7 @@ class SysModPins:public SysModule { return PinObject(); } unsigned8 getNrOfAllocatedPins() { - unsigned8 n = 0; + stackUnsigned8 n = 0; for (PinObject pinObject:pinObjects) { if (strcmp(pinObject.owner, "") != 0) { n++; @@ -56,8 +56,8 @@ class SysModPins:public SysModule { return n; } unsigned8 getPinNr(unsigned8 rowNr) { - unsigned8 pinNr = 0; - unsigned8 n = 0; + stackUnsigned8 pinNr = 0; + stackUnsigned8 n = 0; for (PinObject pinObject:pinObjects) { if (strcmp(pinObject.owner, "") != 0) { if (n == rowNr) diff --git a/src/Sys/SysModUI.cpp b/src/Sys/SysModUI.cpp index f75d1b90..bc895a98 100644 --- a/src/Sys/SysModUI.cpp +++ b/src/Sys/SysModUI.cpp @@ -37,7 +37,7 @@ void SysModUI::setup() { initText(tableVar, "vlVar", nullptr, 32, true, [](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case f_ValueFun: - for (unsigned8 rowNr = 0; rowNr < loopFunctions.size(); rowNr++) + for (forUnsigned8 rowNr = 0; rowNr < loopFunctions.size(); rowNr++) mdl->setValue(var, JsonString(loopFunctions[rowNr].var["id"], JsonString::Copied), rowNr); return true; case f_UIFun: @@ -48,7 +48,7 @@ void SysModUI::setup() { initNumber(tableVar, "vlLoopps", UINT16_MAX, 0, 999, true, [](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case f_ValueFun: - for (unsigned8 rowNr = 0; rowNr < loopFunctions.size(); rowNr++) + for (forUnsigned8 rowNr = 0; rowNr < loopFunctions.size(); rowNr++) mdl->setValue(var, loopFunctions[rowNr].counter, rowNr); return true; case f_UIFun: @@ -178,7 +178,7 @@ void SysModUI::processJson(JsonVariant json) { if (value.is()) { JsonObject command = value; JsonObject var = mdl->findVar(command["id"]); - unsigned8 rowNr = command["rowNr"]; + stackUnsigned8 rowNr = command["rowNr"]; USER_PRINTF("processJson %s - %s [%d]\n", key, value.as().c_str(), rowNr); //first remove the deleted row both on server and on client(s) @@ -224,7 +224,7 @@ void SysModUI::processJson(JsonVariant json) { key = rowNrC; rowNrC = strtok(NULL, " "); } - unsigned8 rowNr = rowNrC?atoi(rowNrC):UINT8_MAX; + stackUnsigned8 rowNr = rowNrC?atoi(rowNrC):UINT8_MAX; JsonObject var = mdl->findVar(key); diff --git a/src/Sys/SysModUI.h b/src/Sys/SysModUI.h index 635375a2..9b6ff484 100644 --- a/src/Sys/SysModUI.h +++ b/src/Sys/SysModUI.h @@ -222,7 +222,7 @@ class SysModUI:public SysModule { } unsigned8 callVarFun(JsonObject var, unsigned8 rowNr = UINT8_MAX, unsigned8 funType = f_ValueFun) { - unsigned8 result = false; + stackUnsigned8 result = false; if (!var["fun"].isNull()) {//isNull needed here! size_t funNr = var["fun"]; diff --git a/src/Sys/SysModWeb.cpp b/src/Sys/SysModWeb.cpp index 1f9ae6a2..707003b7 100644 --- a/src/Sys/SysModWeb.cpp +++ b/src/Sys/SysModWeb.cpp @@ -346,7 +346,7 @@ void SysModWeb::wsEvent(WebSocket * ws, WebClient * client, AwsEventType type, v USER_PRINTF("💀"); if(info->opcode == WS_TEXT){ - for(size_t i=0; i < len; i++) { + for (size_t i=0; i < len; i++) { msg += (char) data[i]; } } diff --git a/src/SysModule.h b/src/SysModule.h index 832cf702..92e818b4 100644 --- a/src/SysModule.h +++ b/src/SysModule.h @@ -20,6 +20,11 @@ #define unsigned8 uint8_t #define unsigned16 uint16_t #define unsigned32 unsigned +#define forUnsigned8 unsigned +#define forUnsigned16 unsigned +#define stackUnsigned8 unsigned +#define stackUnsigned16 unsigned +#define stackUnsigned32 unsigned //tuning 2 - current goal as lowest flash size and no speed difference (runs but some effects messed up: tbd find out why) // #define unsigned8 unsigned diff --git a/src/SysModules.cpp b/src/SysModules.cpp index e117c961..fd617865 100644 --- a/src/SysModules.cpp +++ b/src/SysModules.cpp @@ -39,7 +39,7 @@ void SysModules::setup() { ui->initText(tableVar, "mdlName", nullptr, 32, true, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case f_ValueFun: - for (unsigned8 rowNr = 0; rowNr < modules.size(); rowNr++) + for (forUnsigned8 rowNr = 0; rowNr < modules.size(); rowNr++) mdl->setValue(var, JsonString(modules[rowNr]->name, JsonString::Copied), rowNr); return true; case f_UIFun: @@ -51,7 +51,7 @@ void SysModules::setup() { //UINT16_MAX: no value set ui->initCheckBox(tableVar, "mdlSuccess", UINT16_MAX, true, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case f_ValueFun: - for (unsigned8 rowNr = 0; rowNr < modules.size(); rowNr++) + for (forUnsigned8 rowNr = 0; rowNr < modules.size(); rowNr++) mdl->setValue(var, modules[rowNr]->success, rowNr); return true; case f_UIFun: @@ -63,7 +63,7 @@ void SysModules::setup() { ui->initCheckBox(tableVar, "mdlEnabled", UINT16_MAX, false, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun not readonly! (tbd) case f_ValueFun: //never a rowNr as parameter, set all - for (unsigned8 rowNr = 0; rowNr < modules.size(); rowNr++) + for (forUnsigned8 rowNr = 0; rowNr < modules.size(); rowNr++) mdl->setValue(var, modules[rowNr]->isEnabled, rowNr); return true; case f_UIFun: diff --git a/src/User/UserModArtNet.h b/src/User/UserModArtNet.h index 9b366cab..54e9f312 100644 --- a/src/User/UserModArtNet.h +++ b/src/User/UserModArtNet.h @@ -80,7 +80,7 @@ class UserModArtNet:public SysModule { const size_t ARTNET_CHANNELS_PER_PACKET = isRGBW?512:510; // 512/4=128 RGBW LEDs, 510/3=170 RGB LEDs const size_t packetCount = ((channelCount-1)/ARTNET_CHANNELS_PER_PACKET)+1; - unsigned32 channel = 0; + stackUnsigned32 channel = 0; size_t bufferOffset = 0; sequenceNumber++; diff --git a/src/User/UserModDDP.h b/src/User/UserModDDP.h index 5b2fadfa..a7159508 100644 --- a/src/User/UserModDDP.h +++ b/src/User/UserModDDP.h @@ -96,7 +96,7 @@ class UserModDDP:public SysModule { const size_t channelCount = eff->fixture.nrOfLeds * (isRGBW? 4:3); // 1 channel for every R,G,B,(W?) value const size_t packetCount = ((channelCount-1) / DDP_CHANNELS_PER_PACKET) +1; - unsigned32 channel = 0; + stackUnsigned32 channel = 0; size_t bufferOffset = 0; sequenceNumber++; diff --git a/src/User/UserModE131.h b/src/User/UserModE131.h index 4840023d..15ff4bf6 100644 --- a/src/User/UserModE131.h +++ b/src/User/UserModE131.h @@ -59,7 +59,7 @@ class UserModE131:public SysModule { ui->initNumber(tableVar, "e131Channel", UINT16_MAX, 1, 512, true, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case f_ValueFun: - for (unsigned8 rowNr = 0; rowNr < varsToWatch.size(); rowNr++) + for (forUnsigned8 rowNr = 0; rowNr < varsToWatch.size(); rowNr++) mdl->setValue(var, varsToWatch[rowNr].channel + mdl->getValue("dch").as(), rowNr); return true; case f_UIFun: @@ -70,7 +70,7 @@ class UserModE131:public SysModule { ui->initText(tableVar, "e131Name", nullptr, 32, true, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case f_ValueFun: - for (unsigned8 rowNr = 0; rowNr < varsToWatch.size(); rowNr++) + for (forUnsigned8 rowNr = 0; rowNr < varsToWatch.size(); rowNr++) mdl->setValue(var, varsToWatch[rowNr].id, rowNr); return true; case f_UIFun: @@ -81,7 +81,7 @@ class UserModE131:public SysModule { ui->initNumber(tableVar, "e131Max", UINT16_MAX, 0, UINT16_MAX, true, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case f_ValueFun: - for (unsigned8 rowNr = 0; rowNr < varsToWatch.size(); rowNr++) + for (forUnsigned8 rowNr = 0; rowNr < varsToWatch.size(); rowNr++) mdl->setValue(var, varsToWatch[rowNr].max, rowNr); return true; case f_UIFun: @@ -92,7 +92,7 @@ class UserModE131:public SysModule { ui->initNumber(tableVar, "e131Value", UINT16_MAX, 0, 255, true, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case f_ValueFun: - for (unsigned8 rowNr = 0; rowNr < varsToWatch.size(); rowNr++) + for (forUnsigned8 rowNr = 0; rowNr < varsToWatch.size(); rowNr++) mdl->setValue(var, varsToWatch[rowNr].savedValue, rowNr); return true; case f_UIFun: diff --git a/src/User/UserModInstances.h b/src/User/UserModInstances.h index 084b9ea3..a3cee9ef 100644 --- a/src/User/UserModInstances.h +++ b/src/User/UserModInstances.h @@ -208,7 +208,7 @@ class UserModInstances:public SysModule { ui->initText(tableVar, "insName", nullptr, 32, true, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case f_ValueFun: - for (unsigned8 rowNrL = 0; rowNrL < instances.size() && (rowNr == UINT8_MAX || rowNrL == rowNr); rowNrL++) + for (forUnsigned8 rowNrL = 0; rowNrL < instances.size() && (rowNr == UINT8_MAX || rowNrL == rowNr); rowNrL++) mdl->setValue(var, JsonString(instances[rowNrL].name, JsonString::Copied), rowNrL); return true; case f_UIFun: @@ -219,7 +219,7 @@ class UserModInstances:public SysModule { ui->initURL(tableVar, "insLink", nullptr, true, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case f_ValueFun: - for (unsigned8 rowNrL = 0; rowNrL < instances.size() && (rowNr == UINT8_MAX || rowNrL == rowNr); rowNrL++) { + for (forUnsigned8 rowNrL = 0; rowNrL < instances.size() && (rowNr == UINT8_MAX || rowNrL == rowNr); rowNrL++) { char urlString[32] = "http://"; strncat(urlString, instances[rowNrL].ip.toString().c_str(), sizeof(urlString)-1); mdl->setValue(var, JsonString(urlString, JsonString::Copied), rowNrL); @@ -233,7 +233,7 @@ class UserModInstances:public SysModule { ui->initText(tableVar, "insIp", nullptr, 16, true, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case f_ValueFun: - for (unsigned8 rowNrL = 0; rowNrL < instances.size() && (rowNr == UINT8_MAX || rowNrL == rowNr); rowNrL++) + for (forUnsigned8 rowNrL = 0; rowNrL < instances.size() && (rowNr == UINT8_MAX || rowNrL == rowNr); rowNrL++) mdl->setValue(var, JsonString(instances[rowNrL].ip.toString().c_str(), JsonString::Copied), rowNrL); return true; case f_UIFun: @@ -244,7 +244,7 @@ class UserModInstances:public SysModule { ui->initText(tableVar, "insType", nullptr, 16, true, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case f_ValueFun: - for (unsigned8 rowNrL = 0; rowNrL < instances.size() && (rowNr == UINT8_MAX || rowNrL == rowNr); rowNrL++) + for (forUnsigned8 rowNrL = 0; rowNrL < instances.size() && (rowNr == UINT8_MAX || rowNrL == rowNr); rowNrL++) mdl->setValue(var, instances[rowNrL].sys.type?"StarMod":"WLED", rowNrL); return true; case f_UIFun: @@ -255,7 +255,7 @@ class UserModInstances:public SysModule { ui->initNumber(tableVar, "insVersion", UINT16_MAX, 0, (unsigned long)-1, true, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case f_ValueFun: - for (unsigned8 rowNrL = 0; rowNrL < instances.size() && (rowNr == UINT8_MAX || rowNrL == rowNr); rowNrL++) + for (forUnsigned8 rowNrL = 0; rowNrL < instances.size() && (rowNr == UINT8_MAX || rowNrL == rowNr); rowNrL++) mdl->setValue(var, instances[rowNrL].version, rowNrL); return true; case f_UIFun: @@ -266,7 +266,7 @@ class UserModInstances:public SysModule { ui->initNumber(tableVar, "insUp", UINT16_MAX, 0, (unsigned long)-1, true, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case f_ValueFun: - for (unsigned8 rowNrL = 0; rowNrL < instances.size() && (rowNr == UINT8_MAX || rowNrL == rowNr); rowNrL++) + for (forUnsigned8 rowNrL = 0; rowNrL < instances.size() && (rowNr == UINT8_MAX || rowNrL == rowNr); rowNrL++) mdl->setValue(var, instances[rowNrL].sys.upTime, rowNrL); return true; case f_UIFun: @@ -313,7 +313,7 @@ class UserModInstances:public SysModule { insVar = ui->initVar(tableVar, columnVarID, var["type"], false, [this, var](JsonObject insVar, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case f_ValueFun: //should not trigger chFun - for (unsigned8 rowNrL = 0; rowNrL < instances.size() && (rowNr == UINT8_MAX || rowNrL == rowNr); rowNrL++) { + for (forUnsigned8 rowNrL = 0; rowNrL < instances.size() && (rowNr == UINT8_MAX || rowNrL == rowNr); rowNrL++) { // USER_PRINTF("initVar dash %s[%d]\n", mdl->varID(insVar), rowNrL); //do what setValue is doing except calling changeFun // insVar["value"][rowNrL] = instances[rowNrL].app.getVar(mdl->varID(var)); //only int values... @@ -454,7 +454,7 @@ class UserModInstances:public SysModule { instance->sys.upTime = (wledSyncMessage.timebase[0] * 256*256*256 + 256*256*wledSyncMessage.timebase[1] + 256*wledSyncMessage.timebase[2] + wledSyncMessage.timebase[3]) / 1000; instance->sys.syncMaster = wledSyncMessage.syncGroups; //tbd: change - unsigned8 syncMaster = mdl->getValue("sma"); + stackUnsigned8 syncMaster = mdl->getValue("sma"); if (syncMaster == remoteIp[3]) { if (instance->app.getVar("bri") != wledSyncMessage.bri) mdl->setValue("bri", wledSyncMessage.bri); //only set brightness @@ -638,7 +638,7 @@ class UserModInstances:public SysModule { } //iterate vector pointers so we can update the instances - // unsigned8 rowNr = 0; + // stackUnsigned8 rowNr = 0; for (std::vector::iterator instance=instances.begin(); instance!=instances.end(); ++instance) { if (instance->ip == messageIP) { instance->timeStamp = millis(); //update timestamp @@ -648,7 +648,7 @@ class UserModInstances:public SysModule { instance->sys = udpStarMessage.sys; //check for syncing - unsigned8 syncMaster = mdl->getValue("sma"); + stackUnsigned8 syncMaster = mdl->getValue("sma"); if (syncMaster == messageIP[3]) { //find matching var