diff --git a/misc/testOutput.txt b/misc/testOutput.txt index 53f22b40..505061ec 100644 --- a/misc/testOutput.txt +++ b/misc/testOutput.txt @@ -1,6 +1,6 @@ Reading model from /model.json... (deserializeConfigFromFS) File /model.json open to read, size 6847 bytes -Read model [{"id":"Preview","type":"appmod","ro":false,"o":1,"n":[{"id":"pview","type":"canvas","ro":false,"o":2,"loopFun":0,"interval":160}]},{"id":"Leds","type":"appmod","ro":false,"o":3,"n":[{"id":"on","type":"checkbox","ro":false,"o":4,"value":1,"dash":true},{"id":"bri","type":"range","ro":false,"o":5,"value":10,"max":255,"log":true,"dash":true},{"id":"ledsTbl","type":"table","ro":false,"o":6,"n":[{"id":"pro","type":"select","ro":false,"o":13,"value":2,"dash":true},{"id":"ledsStart","type":"coord3D","ro":false,"o":14,"value":[{"x":0,"y":0,"z":0}],"max":127},{"id":"ledsEnd","type":"coord3D","ro":false,"o":15,"value":[{"x":32,"y":32,"z":0}],"max":127},{"id":"ledsSize","type":"coord3D","ro":true,"o":16,"max":127},{"id":"fxCount","type":"number","ro":true,"o":17,"max":255}]},{"id":"fx","type":"select","ro":false,"o":7,"value":13,"dash":true,"n":[{"id":"pal","type":"select","ro":false,"o":8,"value":4,"dash":true},{"id":"speed","type":"range","ro":false,"o":9,"min":1,"max":255,"value":128},{"id":"Offset X","type":"range","ro":false,"o":10,"max":255,"value":128},{"id":"Offset Y","type":"range","ro":false,"o":11,"max":255,"value":128},{"id":"Legs","type":"range","ro":false,"o":12,"min":1,"max":8,"value":4}]},{"id":"fixture","type":"select","ro":false,"o":18,"value":0},{"id":"fixSize","type":"coord3D","ro":true,"o":19,"max":127},{"id":"fixCount","type":"number","ro":true,"o":20,"max":255},{"id":"fps","type":"number","ro":false,"o":21,"value":60,"min":1,"max":999},{"id":"realFps","type":"text","ro":true,"o":22,"max":10}]},{"id":"Fixture Generator","type":"usermod","ro":false,"o":23,"n":[{"id":"fixtureGen","type":"select","ro":false,"o":24,"value":0,"n":[{"id":"ledCount","type":"number","ro":false,"o":25,"min":1,"max":4096,"value":64}]},{"id":"pinList","type":"text","ro":false,"o":26,"value":"16","max":32},{"id":"generate","type":"button","ro":false,"o":27}]},{"id":"Files","type":"sysmod","ro":false,"o":28,"n":[{"id":"fileTbl","type":"table","ro":false,"o":29,"n":[{"id":"flName","type":"text","ro":true,"o":30,"max":32},{"id":"flSize","type":"number","ro":true,"o":31},{"id":"flLink","type":"url","ro":true,"o":32}]},{"id":"drsize","type":"text","ro":true,"o":33,"max":32}]},{"id":"System","type":"sysmod","ro":false,"o":34,"n":[{"id":"name","type":"text","ro":false,"o":35,"value":"StarBase16MB","max":32},{"id":"upTime","type":"text","ro":true,"o":36,"max":16},{"id":"loops","type":"text","ro":true,"o":37,"max":16},{"id":"chip","type":"text","ro":true,"o":38,"max":16},{"id":"heap","type":"text","ro":true,"o":39,"max":32},{"id":"stack","type":"text","ro":true,"o":40,"max":16},{"id":"reboot","type":"button","ro":false,"o":41},{"id":"reset0","type":"select","ro":true,"o":42},{"id":"reset1","type":"select","ro":true,"o":43},{"id":"restartReason","type":"select","ro":true,"o":44},{"id":"version","type":"text","ro":true,"o":45,"max":16}],"view":"vAll"},{"id":"Pins","type":"sysmod","ro":false,"o":46,"n":[{"id":"pinTbl","type":"table","ro":true,"o":47,"n":[{"id":"pinNr","type":"number","ro":true,"o":48,"max":50},{"id":"pinOwner","type":"text","ro":true,"o":49,"max":32},{"id":"pinDetails","type":"text","ro":true,"o":50,"max":256}]},{"id":"board","type":"canvas","ro":true,"o":51,"loopFun":1,"interval":1000},{"id":"pin19","type":"checkbox","ro":false,"o":52,"value":1}]},{"id":"Print","type":"sysmod","ro":false,"o":53,"n":[{"id":"pOut","type":"select","ro":false,"o":54,"value":1},{"id":"log","type":"textarea","ro":true,"o":55}]},{"id":"Web","type":"sysmod","ro":false,"o":56,"n":[{"id":"clTbl","type":"table","ro":true,"o":57,"n":[{"id":"clNr","type":"number","ro":true,"o":58,"max":999},{"id":"clIp","type":"text","ro":true,"o":59,"max":16},{"id":"clIsFull","type":"checkbox","ro":true,"o":60},{"id":"clStatus","type":"select","ro":true,"o":61},{"id":"clLength","type":"number","ro":true,"o":62,"max":64}]},{"id":"wsCounter","type":"text","ro":true,"o":63,"max":16},{"id":"queueLength","type":"number","ro":true,"o":64,"max":64}]},{"id":"Network","type":"sysmod","ro":false,"o":65,"n":[{"id":"ssid","type":"text","ro":false,"o":66,"value":"ewtr","max":32},{"id":"pw","type":"password","ro":false,"o":67,"value":"zonledmod"},{"id":"connect","type":"button","ro":false,"o":68},{"id":"nwstatus","type":"text","ro":true,"o":69,"max":32},{"id":"rssi","type":"text","ro":true,"o":70,"max":32}]},{"id":"DDP","type":"usermod","ro":false,"o":71,"n":[{"id":"ddpInst","type":"select","ro":false,"o":72}]},{"id":"ArtNet","type":"usermod","ro":false,"o":73,"n":[{"id":"artInst","type":"select","ro":false,"o":74}]},{"id":"E131","type":"usermod","ro":false,"o":75,"n":[{"id":"dun","type":"number","ro":false,"o":76,"value":1,"max":7},{"id":"dch","type":"number","ro":false,"o":77,"value":1,"min":1,"max":512,"dash":true},{"id":"e131Tbl","type":"table","ro":true,"o":78,"n":[{"id":"e131Channel","type":"number","ro":true,"o":79,"min":1,"max":512},{"id":"e131Name","type":"text","ro":true,"o":80,"max":32},{"id":"e131Max","type":"number","ro":true,"o":81},{"id":"e131Value","type":"number","ro":true,"o":82,"max":255}]}]},{"id":"Model","type":"sysmod","ro":false,"o":83,"n":[{"id":"mSize","type":"text","ro":true,"o":84,"max":32},{"id":"saveModel","type":"button","ro":false,"o":85},{"id":"showObsolete","type":"checkbox","ro":false,"o":86,"value":0},{"id":"deleteObsolete","type":"button","ro":false,"o":87}]},{"id":"UI","type":"sysmod","ro":false,"o":88,"n":[{"id":"vlTbl","type":"table","ro":true,"o":89,"n":[{"id":"vlVar","type":"text","ro":true,"o":90,"max":32},{"id":"vlLoopps","type":"number","ro":true,"o":91,"max":999}]}]},{"id":"Instances","type":"sysmod","ro":false,"o":92,"n":[{"id":"insTbl","type":"table","ro":true,"o":93,"n":[{"id":"insName","type":"text","ro":true,"o":94,"max":32},{"id":"insLink","type":"url","ro":true,"o":95},{"id":"insIp","type":"text","ro":true,"o":96,"max":16},{"id":"insType","type":"text","ro":true,"o":97,"max":16},{"id":"insVersion","type":"number","ro":true,"o":98,"max":-1},{"id":"insUp","type":"number","ro":true,"o":99,"max":-1},{"id":"inson","type":"checkbox","ro":false,"o":101},{"id":"insbri","type":"range","ro":false,"o":102,"max":255,"log":true},{"id":"inspro","type":"select","ro":false,"o":103},{"id":"insfx","type":"select","ro":false,"o":104},{"id":"insdch","type":"number","ro":false,"o":106,"min":1,"max":512},{"id":"inssma","type":"select","ro":false,"o":107},{"id":"inspal","type":"select","ro":false,"o":105}]},{"id":"sma","type":"select","ro":false,"o":100,"value":0,"dash":true}]},{"id":"Modules","type":"sysmod","ro":false,"o":108,"n":[{"id":"mdlTbl","type":"table","ro":true,"o":109,"n":[{"id":"mdlName","type":"text","ro":true,"o":110,"max":32},{"id":"mdlSuccess","type":"checkbox","ro":true,"o":111},{"id":"mdlEnabled","type":"checkbox","ro":false,"o":112,"value":[true,true,true,true,true,true,true,true,true,false,false,true,true,true,true,true,true]}]}]}] +Read model [{"id":"Preview","type":"appmod","ro":false,"o":1,"n":[{"id":"pview","type":"canvas","ro":false,"o":2,"loopFun":0,"interval":160}]},{"id":"Leds","type":"appmod","ro":false,"o":3,"n":[{"id":"on","type":"checkbox","ro":false,"o":4,"value":1,"dash":true},{"id":"bri","type":"range","ro":false,"o":5,"value":10,"max":255,"log":true,"dash":true},{"id":"layerTbl","type":"table","ro":false,"o":6,"n":[{"id":"pro","type":"select","ro":false,"o":13,"value":2,"dash":true},{"id":"ledsStart","type":"coord3D","ro":false,"o":14,"value":[{"x":0,"y":0,"z":0}],"max":127},{"id":"ledsEnd","type":"coord3D","ro":false,"o":15,"value":[{"x":32,"y":32,"z":0}],"max":127},{"id":"ledsSize","type":"coord3D","ro":true,"o":16,"max":127},{"id":"fxCount","type":"number","ro":true,"o":17,"max":255}]},{"id":"fx","type":"select","ro":false,"o":7,"value":13,"dash":true,"n":[{"id":"pal","type":"select","ro":false,"o":8,"value":4,"dash":true},{"id":"speed","type":"range","ro":false,"o":9,"min":1,"max":255,"value":128},{"id":"Offset X","type":"range","ro":false,"o":10,"max":255,"value":128},{"id":"Offset Y","type":"range","ro":false,"o":11,"max":255,"value":128},{"id":"Legs","type":"range","ro":false,"o":12,"min":1,"max":8,"value":4}]},{"id":"fixture","type":"select","ro":false,"o":18,"value":0},{"id":"fixSize","type":"coord3D","ro":true,"o":19,"max":127},{"id":"fixCount","type":"number","ro":true,"o":20,"max":255},{"id":"fps","type":"number","ro":false,"o":21,"value":60,"min":1,"max":999},{"id":"realFps","type":"text","ro":true,"o":22,"max":10}]},{"id":"Fixture Generator","type":"usermod","ro":false,"o":23,"n":[{"id":"fixtureGen","type":"select","ro":false,"o":24,"value":0,"n":[{"id":"ledCount","type":"number","ro":false,"o":25,"min":1,"max":4096,"value":64}]},{"id":"pinList","type":"text","ro":false,"o":26,"value":"16","max":32},{"id":"generate","type":"button","ro":false,"o":27}]},{"id":"Files","type":"sysmod","ro":false,"o":28,"n":[{"id":"fileTbl","type":"table","ro":false,"o":29,"n":[{"id":"flName","type":"text","ro":true,"o":30,"max":32},{"id":"flSize","type":"number","ro":true,"o":31},{"id":"flLink","type":"url","ro":true,"o":32}]},{"id":"drsize","type":"text","ro":true,"o":33,"max":32}]},{"id":"System","type":"sysmod","ro":false,"o":34,"n":[{"id":"name","type":"text","ro":false,"o":35,"value":"StarBase16MB","max":32},{"id":"upTime","type":"text","ro":true,"o":36,"max":16},{"id":"loops","type":"text","ro":true,"o":37,"max":16},{"id":"chip","type":"text","ro":true,"o":38,"max":16},{"id":"heap","type":"text","ro":true,"o":39,"max":32},{"id":"stack","type":"text","ro":true,"o":40,"max":16},{"id":"reboot","type":"button","ro":false,"o":41},{"id":"reset0","type":"select","ro":true,"o":42},{"id":"reset1","type":"select","ro":true,"o":43},{"id":"restartReason","type":"select","ro":true,"o":44},{"id":"version","type":"text","ro":true,"o":45,"max":16}],"view":"vAll"},{"id":"Pins","type":"sysmod","ro":false,"o":46,"n":[{"id":"pinTbl","type":"table","ro":true,"o":47,"n":[{"id":"pinNr","type":"number","ro":true,"o":48,"max":50},{"id":"pinOwner","type":"text","ro":true,"o":49,"max":32},{"id":"pinDetails","type":"text","ro":true,"o":50,"max":256}]},{"id":"board","type":"canvas","ro":true,"o":51,"loopFun":1,"interval":1000},{"id":"pin19","type":"checkbox","ro":false,"o":52,"value":1}]},{"id":"Print","type":"sysmod","ro":false,"o":53,"n":[{"id":"pOut","type":"select","ro":false,"o":54,"value":1},{"id":"log","type":"textarea","ro":true,"o":55}]},{"id":"Web","type":"sysmod","ro":false,"o":56,"n":[{"id":"clTbl","type":"table","ro":true,"o":57,"n":[{"id":"clNr","type":"number","ro":true,"o":58,"max":999},{"id":"clIp","type":"text","ro":true,"o":59,"max":16},{"id":"clIsFull","type":"checkbox","ro":true,"o":60},{"id":"clStatus","type":"select","ro":true,"o":61},{"id":"clLength","type":"number","ro":true,"o":62,"max":64}]},{"id":"wsCounter","type":"text","ro":true,"o":63,"max":16},{"id":"queueLength","type":"number","ro":true,"o":64,"max":64}]},{"id":"Network","type":"sysmod","ro":false,"o":65,"n":[{"id":"ssid","type":"text","ro":false,"o":66,"value":"ewtr","max":32},{"id":"pw","type":"password","ro":false,"o":67,"value":"zonledmod"},{"id":"connect","type":"button","ro":false,"o":68},{"id":"nwstatus","type":"text","ro":true,"o":69,"max":32},{"id":"rssi","type":"text","ro":true,"o":70,"max":32}]},{"id":"DDP","type":"usermod","ro":false,"o":71,"n":[{"id":"ddpInst","type":"select","ro":false,"o":72}]},{"id":"ArtNet","type":"usermod","ro":false,"o":73,"n":[{"id":"artInst","type":"select","ro":false,"o":74}]},{"id":"E131","type":"usermod","ro":false,"o":75,"n":[{"id":"dun","type":"number","ro":false,"o":76,"value":1,"max":7},{"id":"dch","type":"number","ro":false,"o":77,"value":1,"min":1,"max":512,"dash":true},{"id":"e131Tbl","type":"table","ro":true,"o":78,"n":[{"id":"e131Channel","type":"number","ro":true,"o":79,"min":1,"max":512},{"id":"e131Name","type":"text","ro":true,"o":80,"max":32},{"id":"e131Max","type":"number","ro":true,"o":81},{"id":"e131Value","type":"number","ro":true,"o":82,"max":255}]}]},{"id":"Model","type":"sysmod","ro":false,"o":83,"n":[{"id":"mSize","type":"text","ro":true,"o":84,"max":32},{"id":"saveModel","type":"button","ro":false,"o":85},{"id":"showObsolete","type":"checkbox","ro":false,"o":86,"value":0},{"id":"deleteObsolete","type":"button","ro":false,"o":87}]},{"id":"UI","type":"sysmod","ro":false,"o":88,"n":[{"id":"vlTbl","type":"table","ro":true,"o":89,"n":[{"id":"vlVar","type":"text","ro":true,"o":90,"max":32},{"id":"vlLoopps","type":"number","ro":true,"o":91,"max":999}]}]},{"id":"Instances","type":"sysmod","ro":false,"o":92,"n":[{"id":"insTbl","type":"table","ro":true,"o":93,"n":[{"id":"insName","type":"text","ro":true,"o":94,"max":32},{"id":"insLink","type":"url","ro":true,"o":95},{"id":"insIp","type":"text","ro":true,"o":96,"max":16},{"id":"insType","type":"text","ro":true,"o":97,"max":16},{"id":"insVersion","type":"number","ro":true,"o":98,"max":-1},{"id":"insUp","type":"number","ro":true,"o":99,"max":-1},{"id":"inson","type":"checkbox","ro":false,"o":101},{"id":"insbri","type":"range","ro":false,"o":102,"max":255,"log":true},{"id":"inspro","type":"select","ro":false,"o":103},{"id":"insfx","type":"select","ro":false,"o":104},{"id":"insdch","type":"number","ro":false,"o":106,"min":1,"max":512},{"id":"inssma","type":"select","ro":false,"o":107},{"id":"inspal","type":"select","ro":false,"o":105}]},{"id":"sma","type":"select","ro":false,"o":100,"value":0,"dash":true}]},{"id":"Modules","type":"sysmod","ro":false,"o":108,"n":[{"id":"mdlTbl","type":"table","ro":true,"o":109,"n":[{"id":"mdlName","type":"text","ro":true,"o":110,"max":32},{"id":"mdlSuccess","type":"checkbox","ro":true,"o":111},{"id":"mdlEnabled","type":"checkbox","ro":false,"o":112,"value":[true,true,true,true,true,true,true,true,true,false,false,true,true,true,true,true,true]}]}]}] sendDataWs no ws initVarAndUpdate onChange init bri v:10 Set Brightness to 10 -> b:10 r:1 @@ -110,7 +110,7 @@ sendDataWs client full or not connected client: 1 ...126 q:0 l:12 s:1 (#:1) sendDataWs client full or not connected client: 2 ...126 q:0 l:15 s:1 (#:1) αWS event data client: 2 ...126 q:0 l:16 s:1 (#:1) αseqNrToName: 2DMatrix3232.json 9640 -αWS_EVT_DATA json {"ledsTbl":{"label":"Effects","comment":"List of effects (WIP)","value":[[2,[{"x":0,"y":0,"z":0}],[{"x":32,"y":32,"z":0}],{"x":15,"y":15,"z":1},225]]},"pal":{"label":"Palette","comment":"Colors","options":["CloudColors","LavaColors","OceanColors","ForestColors","RainbowColors","RainbowStripeColors","PartyColors","HeatColors"]},"fx":{"label":"Effect","comment":"Effect to show","options":["Solid 1D","Rainbow 1D","Rainbow with glitter 1D","Sinelon 1D","Running 1D","Confetti 1D","Beats per minute 1D","Juggle 1D","Ripples 3D","SphereMove 3D","Frizzles 2D","Lines 2D","DistortionWaves 2D","Octopus 2D","Lissajous 2D","Bouncing Balls 1D","RingRandomFlow 1D","GEQ 2D","AudioRings 1D","FreqMatrix 1D"]},"fixture":{"comment":"Fixture to display effect on","options":["2DMatrix3232.json","3DCube888.json","3DSideCube205.json"]},"pview":{"file":"/2DMatrix3232.json"},"fixSize":{"label":"Size"},"fixCount":{"label":"Count","comment":"Max 4096"},"fps":{"comment":"Frames per second"},"realFps":{"comment":"f(1024 leds)"}} +αWS_EVT_DATA json {"layerTbl":{"label":"Effects","comment":"List of effects (WIP)","value":[[2,[{"x":0,"y":0,"z":0}],[{"x":32,"y":32,"z":0}],{"x":15,"y":15,"z":1},225]]},"pal":{"label":"Palette","comment":"Colors","options":["CloudColors","LavaColors","OceanColors","ForestColors","RainbowColors","RainbowStripeColors","PartyColors","HeatColors"]},"fx":{"label":"Effect","comment":"Effect to show","options":["Solid 1D","Rainbow 1D","Rainbow with glitter 1D","Sinelon 1D","Running 1D","Confetti 1D","Beats per minute 1D","Juggle 1D","Ripples 3D","SphereMove 3D","Frizzles 2D","Lines 2D","DistortionWaves 2D","Octopus 2D","Lissajous 2D","Bouncing Balls 1D","RingRandomFlow 1D","GEQ 2D","AudioRings 1D","FreqMatrix 1D"]},"fixture":{"comment":"Fixture to display effect on","options":["2DMatrix3232.json","3DCube888.json","3DSideCube205.json"]},"pview":{"file":"/2DMatrix3232.json"},"fixSize":{"label":"Size"},"fixCount":{"label":"Count","comment":"Max 4096"},"fps":{"comment":"Frames per second"},"realFps":{"comment":"f(1024 leds)"}} αWS_EVT_DATA info 1283 / 3072 (41%) (9 0 6) sendDataWs client full or not connected client: 2 ...126 q:0 l:16 s:1 (#:1) αWS event data client: 2 ...126 q:0 l:16 s:1 (#:1) diff --git a/src/App/LedEffects.h b/src/App/LedEffects.h index 0c7d1b6c..7807c90c 100644 --- a/src/App/LedEffects.h +++ b/src/App/LedEffects.h @@ -36,11 +36,11 @@ class Effect { virtual const char * tags() {return "";} virtual uint8_t dim() {return _1D;}; - virtual void setup(Leds &leds) {} + virtual void setup(LedsLayer &leds) {} - virtual void loop(Leds &leds) {} + virtual void loop(LedsLayer &leds) {} - virtual void controls(Leds &leds, JsonObject parentVar) { + virtual void controls(LedsLayer &leds, JsonObject parentVar) { ui->initSelect(parentVar, "pal", 4, false, [&leds](JsonObject var, uint8_t rowNr, uint8_t funType) { switch (funType) { //varFun case onUI: { ui->setLabel(var, "Palette"); @@ -85,7 +85,7 @@ class SolidEffect: public Effect { uint8_t dim() {return _1D;} const char * tags() {return "💡";} - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() uint8_t red = leds.effectData.read(); uint8_t green = leds.effectData.read(); @@ -95,7 +95,7 @@ class SolidEffect: public Effect { leds.fill_solid(color); } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { ui->initSlider(parentVar, "Red", leds.effectData.write(182)); ui->initSlider(parentVar, "Green", leds.effectData.write(15)); ui->initSlider(parentVar, "Blue", leds.effectData.write(98)); @@ -107,7 +107,7 @@ class RainbowEffect: public Effect { uint8_t dim() {return _1D;} const char * tags() {return "💡";} //💡 means wled origin - void loop(Leds &leds) { + void loop(LedsLayer &leds) { // UI Variables uint8_t speed = leds.effectData.read(); uint8_t scale = leds.effectData.read(); @@ -122,7 +122,7 @@ class RainbowEffect: public Effect { } } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { Effect::controls(leds, parentVar); ui->initSlider(parentVar, "Speed", leds.effectData.write(128)); ui->initSlider(parentVar, "Scale", leds.effectData.write(128)); @@ -134,7 +134,7 @@ class RainbowWithGlitterEffect: public Effect { uint8_t dim() {return _1D;} const char * tags() {return "⚡";} //⚡ means FastLED origin - void loop(Leds &leds) { + void loop(LedsLayer &leds) { uint8_t glitter = leds.effectData.read(); // built-in FastLED rainbow, plus some random sparkly glitter @@ -145,14 +145,14 @@ class RainbowWithGlitterEffect: public Effect { addGlitter(leds, 80); } - void addGlitter(Leds &leds, fract8 chanceOfGlitter) + void addGlitter(LedsLayer &leds, fract8 chanceOfGlitter) { if( random8() < chanceOfGlitter) { leds[ random16(leds.nrOfLeds) ] += CRGB::White; } } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { //no palette control is created ui->initCheckBox(parentVar, "glitter", leds.effectData.write(false)); } @@ -165,7 +165,7 @@ class FlowEffect: public Effect { uint8_t dim() {return _1D;} const char * tags() {return "💡";} //💡 means wled origin - void loop(Leds &leds) { + void loop(LedsLayer &leds) { // UI Variables uint8_t speed = leds.effectData.read(); uint8_t zonesUI = leds.effectData.read(); @@ -195,7 +195,7 @@ class FlowEffect: public Effect { } } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { Effect::controls(leds, parentVar); ui->initSlider(parentVar, "Speed", leds.effectData.write(128)); ui->initSlider(parentVar, "Zones", leds.effectData.write(128)); @@ -208,7 +208,7 @@ class SinelonEffect: public Effect { uint8_t dim() {return _1D;} const char * tags() {return "⚡";} - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() uint8_t bpm = leds.effectData.read(); @@ -218,7 +218,7 @@ class SinelonEffect: public Effect { leds[pos] += CHSV( sys->now/50, 255, 255); } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { ui->initSlider(parentVar, "BPM", leds.effectData.write(60)); } }; //Sinelon @@ -228,14 +228,14 @@ class ConfettiEffect: public Effect { uint8_t dim() {return _1D;} const char * tags() {return "⚡";} - void loop(Leds &leds) { + void loop(LedsLayer &leds) { // random colored speckles that blink in and fade smoothly leds.fadeToBlackBy(10); int pos = random16(leds.nrOfLeds); leds[pos] += CHSV( sys->now/50 + random8(64), 200, 255); } - void controls(Leds &leds, JsonObject parentVar) {} //so no palette control is created + void controls(LedsLayer &leds, JsonObject parentVar) {} //so no palette control is created }; // colored stripes pulsing at a defined Beats-Per-Minute (BPM) @@ -244,7 +244,7 @@ class BPMEffect: public Effect { uint8_t dim() {return _1D;} const char * tags() {return "⚡";} - void loop(Leds &leds) { + void loop(LedsLayer &leds) { uint8_t BeatsPerMinute = 62; uint8_t beat = beatsin8( BeatsPerMinute, 64, 255); for (forUnsigned16 i = 0; i < leds.nrOfLeds; i++) { //9948 @@ -252,7 +252,7 @@ class BPMEffect: public Effect { } } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { Effect::controls(leds, parentVar); } }; @@ -263,7 +263,7 @@ class JuggleEffect: public Effect { uint8_t dim() {return _1D;} const char * tags() {return "⚡";} - void loop(Leds &leds) { + void loop(LedsLayer &leds) { leds.fadeToBlackBy(20); uint8_t dothue = 0; for (unsigned i = 0; i < 8; i++) { @@ -272,7 +272,7 @@ class JuggleEffect: public Effect { } } - void controls(Leds &leds, JsonObject parentVar) {} //so no palette control is created + void controls(LedsLayer &leds, JsonObject parentVar) {} //so no palette control is created }; //https://www.perfectcircuit.com/signal/difference-between-waveforms @@ -281,7 +281,7 @@ class RunningEffect: public Effect { uint8_t dim() {return _1D;} const char * tags() {return "💫";} - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() uint8_t bpm = leds.effectData.read(); uint8_t fade = leds.effectData.read(); @@ -293,7 +293,7 @@ class RunningEffect: public Effect { // leds[leds.nrOfLeds -1 - pos2] = CHSV( sys->now/50, 255, 255); //make sure the right physical leds get their value } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { ui->initSlider(parentVar, "BPM", leds.effectData.write(60), 0, 255, false, [](JsonObject var, uint8_t rowNr, uint8_t funType) { switch (funType) { //varFun case onUI: ui->setComment(var, "in BPM!"); @@ -308,7 +308,7 @@ class RunningEffect: public Effect { class RingEffect: public Effect { protected: - void setRing(Leds &leds, int ring, CRGB colour) { //so britisch ;-) + void setRing(LedsLayer &leds, int ring, CRGB colour) { //so britisch ;-) leds[ring] = colour; } @@ -319,7 +319,7 @@ class RingRandomFlowEffect: public RingEffect { uint8_t dim() {return _1D;} const char * tags() {return "💫";} - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //binding of loop persistent values (pointers) uint8_t *hue = leds.effectData.readWrite(leds.nrOfLeds); //array @@ -333,7 +333,7 @@ class RingRandomFlowEffect: public RingEffect { // FastLED.delay(SPEED); } - void controls(Leds &leds, JsonObject parentVar) {} //so no palette control is created + void controls(LedsLayer &leds, JsonObject parentVar) {} //so no palette control is created }; //BouncingBalls inspired by WLED @@ -350,7 +350,7 @@ class BouncingBallsEffect: public Effect { uint8_t dim() {return _1D;} const char * tags() {return "💡";} - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() uint8_t grav = leds.effectData.read(); uint8_t numBalls = leds.effectData.read(); @@ -365,7 +365,7 @@ class BouncingBallsEffect: public Effect { // const bool hasCol2 = SEGCOLOR(2); const unsigned long time = sys->now; - //not necessary as effectData is cleared at setup(Leds &leds) + //not necessary as effectData is cleared at setup(LedsLayer &leds) // if (call == 0) { // for (size_t i = 0; i < maxNumBalls; i++) balls[i].lastBounceTime = time; // } @@ -408,14 +408,14 @@ class BouncingBallsEffect: public Effect { } //balls } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { Effect::controls(leds, parentVar); ui->initSlider(parentVar, "gravity", leds.effectData.write(128)); ui->initSlider(parentVar, "balls", leds.effectData.write(8), 1, 16); } }; // BouncingBalls -void mode_fireworks(Leds &leds, uint16_t *aux0, uint16_t *aux1, uint8_t speed, uint8_t intensity, bool useAudio = false) { +void mode_fireworks(LedsLayer &leds, uint16_t *aux0, uint16_t *aux1, uint8_t speed, uint8_t intensity, bool useAudio = false) { // fade_out(0); leds.fadeToBlackBy(10); // if (SEGENV.call == 0) { @@ -480,7 +480,7 @@ class RainEffect: public Effect { uint8_t dim() {return _1D;} const char * tags() {return "💡";} - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() uint8_t speed = leds.effectData.read(); uint8_t intensity = leds.effectData.read(); @@ -522,7 +522,7 @@ class RainEffect: public Effect { mode_fireworks(leds, aux0, aux1, speed, intensity); } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { Effect::controls(leds, parentVar); ui->initSlider(parentVar, "speed", leds.effectData.write(128), 1, 255); ui->initSlider(parentVar, "intensity", leds.effectData.write(64), 1, 128); @@ -544,7 +544,7 @@ class DripEffect: public Effect { uint8_t dim() {return _1D;} const char * tags() {return "💡💫";} - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() uint8_t grav = leds.effectData.read(); uint8_t drips = leds.effectData.read(); @@ -616,7 +616,7 @@ class DripEffect: public Effect { } } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { Effect::controls(leds, parentVar); ui->initSlider(parentVar, "gravity", leds.effectData.write(128), 1, 255); ui->initSlider(parentVar, "drips", leds.effectData.write(4), 1, 6); @@ -630,7 +630,7 @@ class HeartBeatEffect: public Effect { uint8_t dim() {return _1D;} const char * tags() {return "💡💫♥";} - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() uint8_t speed = leds.effectData.read(); uint8_t intensity = leds.effectData.read(); @@ -663,7 +663,7 @@ class HeartBeatEffect: public Effect { } } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { Effect::controls(leds, parentVar); ui->initSlider(parentVar, "speed", leds.effectData.write(15), 0, 31); ui->initSlider(parentVar, "intensity", leds.effectData.write(128)); @@ -675,11 +675,11 @@ class FreqMatrixEffect: public Effect { uint8_t dim() {return _1D;} const char * tags() {return "♪💡";} - void setup(Leds &leds) { + void setup(LedsLayer &leds) { leds.fadeToBlackBy(16); } - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() uint8_t speed = leds.effectData.read(); uint8_t fx = leds.effectData.read(); @@ -723,7 +723,7 @@ class FreqMatrixEffect: public Effect { } } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { ui->initSlider(parentVar, "speed", leds.effectData.write(255)); ui->initSlider(parentVar, "Sound effect", leds.effectData.write(128)); ui->initSlider(parentVar, "Low bin", leds.effectData.write(18)); @@ -740,7 +740,7 @@ class PopCornEffect: public Effect { uint8_t dim() {return _1D;} const char * tags() {return "♪💡";} - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() uint8_t speed = leds.effectData.read(); uint8_t numPopcorn = leds.effectData.read(); @@ -803,7 +803,7 @@ class PopCornEffect: public Effect { } } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { Effect::controls(leds, parentVar); ui->initSlider(parentVar, "speed", leds.effectData.write(128)); ui->initSlider(parentVar, "corns", leds.effectData.write(maxNumPopcorn/2), 1, maxNumPopcorn); @@ -818,7 +818,7 @@ class NoiseMeterEffect: public Effect { uint8_t dim() {return _1D;} const char * tags() {return "♪💡";} - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() uint8_t fadeRate = leds.effectData.read(); uint8_t width = leds.effectData.read(); @@ -843,7 +843,7 @@ class NoiseMeterEffect: public Effect { *aux1+=beatsin8(4,0,10); } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { Effect::controls(leds, parentVar); ui->initSlider(parentVar, "fadeRate", leds.effectData.write(248), 200, 254); ui->initSlider(parentVar, "width", leds.effectData.write(128)); @@ -855,7 +855,7 @@ class AudioRingsEffect: public RingEffect { uint8_t dim() {return _1D;} const char * tags() {return "♫💫";} - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() bool inWards = leds.effectData.read(); uint8_t nrOfRings = leds.effectData.read(); @@ -884,7 +884,7 @@ class AudioRingsEffect: public RingEffect { setRingFromFtt(leds, 0, 8); // set outer ring to bass } - void setRingFromFtt(Leds &leds, int index, int ring) { + void setRingFromFtt(LedsLayer &leds, int index, int ring) { byte val = wledAudioMod->fftResults[index]; // Visualize leds to the beat CRGB color = ColorFromPalette(leds.palette, val); @@ -892,7 +892,7 @@ class AudioRingsEffect: public RingEffect { setRing(leds, ring, color); } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { Effect::controls(leds, parentVar); ui->initCheckBox(parentVar, "inWards", leds.effectData.write(true)); ui->initSlider(parentVar, "rings", leds.effectData.write(7), 1, 50); @@ -904,11 +904,11 @@ class DJLightEffect: public Effect { uint8_t dim() {return _1D;} const char * tags() {return "♫💡";} - void setup(Leds &leds) { + void setup(LedsLayer &leds) { leds.fill_solid(CRGB::Black); } - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() uint8_t speed = leds.effectData.read(); bool candyFactory = leds.effectData.read(); @@ -970,7 +970,7 @@ class DJLightEffect: public Effect { } } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { ui->initSlider(parentVar, "speed", leds.effectData.write(255)); ui->initCheckBox(parentVar, "candyFactory", leds.effectData.write(true)); ui->initSlider(parentVar, "fade", leds.effectData.write(4), 0, 10); @@ -988,7 +988,7 @@ class LinesEffect: public Effect { uint8_t dim() {return _2D;} const char * tags() {return "💫";} - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() uint8_t bpm = leds.effectData.read(); bool vertical = leds.effectData.read(); @@ -1010,7 +1010,7 @@ class LinesEffect: public Effect { } } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { ui->initSlider(parentVar, "BPM", leds.effectData.write(60)); ui->initCheckBox(parentVar, "Vertical", leds.effectData.write(true)); } @@ -1022,7 +1022,7 @@ class BlackHoleEffect: public Effect { uint8_t dim() {return _2D;} const char * tags() {return "💡";} - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() uint8_t fade = leds.effectData.read(); uint8_t outX = leds.effectData.read(); @@ -1054,7 +1054,7 @@ class BlackHoleEffect: public Effect { } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { ui->initSlider(parentVar, "fade", leds.effectData.write(16), 0, 32); ui->initSlider(parentVar, "outX", leds.effectData.write(16), 0, 32); ui->initSlider(parentVar, "outY", leds.effectData.write(16), 0, 32); @@ -1069,7 +1069,7 @@ class DNAEffect: public Effect { uint8_t dim() {return _2D;} const char * tags() {return "💡💫";} - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() uint8_t speed = leds.effectData.read(); uint8_t blur = leds.effectData.read(); @@ -1090,7 +1090,7 @@ class DNAEffect: public Effect { leds.blur2d(blur); } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { Effect::controls(leds, parentVar); ui->initSlider(parentVar, "speed", leds.effectData.write(16), 0, 32); ui->initSlider(parentVar, "blur", leds.effectData.write(128)); @@ -1108,7 +1108,7 @@ class DistortionWavesEffect: public Effect { uint8_t dim() {return _2D;} const char * tags() {return "💡";} - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() uint8_t speed = leds.effectData.read(); uint8_t scale = leds.effectData.read(); @@ -1152,7 +1152,7 @@ class DistortionWavesEffect: public Effect { } } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { ui->initSlider(parentVar, "speed", leds.effectData.write(4), 0, 8); ui->initSlider(parentVar, "scale", leds.effectData.write(4), 0, 8); } @@ -1170,7 +1170,7 @@ class OctopusEffect: public Effect { uint8_t radius; }; - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() uint8_t speed = leds.effectData.read(); uint8_t offsetX = leds.effectData.read(); @@ -1227,7 +1227,7 @@ class OctopusEffect: public Effect { } } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { Effect::controls(leds, parentVar); //palette @@ -1253,7 +1253,7 @@ class LissajousEffect: public Effect { uint8_t dim() {return _2D;} const char * tags() {return "💡";} - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() uint8_t freqX = leds.effectData.read(); uint8_t fadeRate = leds.effectData.read(); @@ -1290,7 +1290,7 @@ class LissajousEffect: public Effect { } } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { Effect::controls(leds, parentVar); // uint8_t *freqX = ; @@ -1311,7 +1311,7 @@ class FrizzlesEffect: public Effect { uint8_t dim() {return _2D;} const char * tags() {return "💡";} - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() uint8_t bpm = leds.effectData.read(); uint8_t intensity = leds.effectData.read(); @@ -1329,7 +1329,7 @@ class FrizzlesEffect: public Effect { leds.blur2d(blur); } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { Effect::controls(leds, parentVar); ui->initSlider(parentVar, "BPM", leds.effectData.write(60)); ui->initSlider(parentVar, "intensity", leds.effectData.write(128)); @@ -1342,7 +1342,7 @@ class ScrollingTextEffect: public Effect { uint8_t dim() {return _2D;} const char * tags() {return "💫";} - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() uint8_t speed = leds.effectData.read(); uint8_t font = leds.effectData.read(); @@ -1357,7 +1357,7 @@ class ScrollingTextEffect: public Effect { } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { ui->initText(parentVar, "text", "StarLight"); //effectData to be implemented! ui->initSlider(parentVar, "speed", leds.effectData.write(128)); ui->initSelect(parentVar, "font", leds.effectData.write(0), false, [](JsonObject var, uint8_t rowNr, uint8_t funType) { switch (funType) { //varFun @@ -1380,7 +1380,7 @@ class Noise2DEffect: public Effect { uint8_t dim() {return _2D;} const char * tags() {return "💡";} - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() uint8_t speed = leds.effectData.read(); uint8_t scale = leds.effectData.read(); @@ -1394,7 +1394,7 @@ class Noise2DEffect: public Effect { } } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { Effect::controls(leds, parentVar); ui->initSlider(parentVar, "speed", leds.effectData.write(8), 0, 15); @@ -1451,7 +1451,7 @@ class GameOfLifeEffect: public Effect { uint8_t dim() {return _3D;} //supports 3D but also 2D (1D as well?) const char * tags() {return "💫";} - void placePentomino(Leds &leds, byte *futureCells, bool colorByAge) { + void placePentomino(LedsLayer &leds, byte *futureCells, bool colorByAge) { byte pattern[5][2] = {{1, 0}, {0, 1}, {1, 1}, {2, 1}, {2, 2}}; // R-pentomino if (!random8(5)) pattern[0][1] = 3; // 1/5 chance to use glider CRGB color = ColorFromPalette(leds.palette, random8()); @@ -1477,7 +1477,7 @@ class GameOfLifeEffect: public Effect { } } - void loop(Leds &leds) { + void loop(LedsLayer &leds) { // UI Variables bool *setup = leds.effectData.readWrite(); bool *ruleChanged = leds.effectData.readWrite(); @@ -1681,7 +1681,7 @@ class GameOfLifeEffect: public Effect { *step = sys->now; } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { Effect::controls(leds, parentVar); bool *setup = leds.effectData.write(true); bool *ruleChanged = leds.effectData.write(true); @@ -1849,7 +1849,7 @@ class RubiksCubeEffect: public Effect { if (width >= SIZE) rotateFace(top, !clockwise); } - void drawCube(Leds &leds) { + void drawCube(LedsLayer &leds) { int sizeX = max(leds.size.x-1, 1); int sizeY = max(leds.size.y-1, 1); int sizeZ = max(leds.size.z-1, 1); @@ -1929,7 +1929,7 @@ class RubiksCubeEffect: public Effect { return move; } - void loop(Leds &leds) { + void loop(LedsLayer &leds) { // UI control variables bool *setup = leds.effectData.readWrite(); uint8_t speed = leds.effectData.read(); @@ -1988,7 +1988,7 @@ class RubiksCubeEffect: public Effect { *step = sys->now; } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { Effect::controls(leds, parentVar); bool *setup = leds.effectData.write(true); ui->initSlider (parentVar, "Turns Per Second", leds.effectData.write(1), 0, 20); @@ -2028,7 +2028,7 @@ class ParticleTestEffect: public Effect { return Coord3D({int(round(x)), int(round(y)), int(round(z))}); } - void updatePositionandDraw(Leds &leds, int particleIndex = 0, bool debugPrint = false) { + void updatePositionandDraw(LedsLayer &leds, int particleIndex = 0, bool debugPrint = false) { if (debugPrint) ppf("Particle %d: Pos: %f, %f, %f Velocity: %f, %f, %f\n", particleIndex, x, y, z, vx, vy, vz); Coord3D prevPos = toCoord3DRounded(); @@ -2110,7 +2110,7 @@ class ParticleTestEffect: public Effect { } }; - void loop(Leds &leds) { + void loop(LedsLayer &leds) { // UI Variables bool *setup = leds.effectData.readWrite(); uint8_t speed = leds.effectData.read(); @@ -2219,7 +2219,7 @@ class ParticleTestEffect: public Effect { *step = sys->now; } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { Effect::controls(leds, parentVar); bool *setup = leds.effectData.write(true); ui->initSlider (parentVar, "Speed", leds.effectData.write(1), 0, 30); @@ -2253,7 +2253,7 @@ class WaverlyEffect: public Effect { uint8_t dim() {return _2D;} const char * tags() {return "♪💡";} - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() uint8_t amplification = leds.effectData.read(); uint8_t sensitivity = leds.effectData.read(); @@ -2282,7 +2282,7 @@ class WaverlyEffect: public Effect { leds.blur2d(16); } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { Effect::controls(leds, parentVar); ui->initSlider(parentVar, "Amplification", leds.effectData.write(128)); ui->initSlider(parentVar, "Sensitivity", leds.effectData.write(128)); @@ -2297,11 +2297,11 @@ class GEQEffect: public Effect { uint8_t dim() {return _2D;} const char * tags() {return "♫💡";} - void setup(Leds &leds) { + void setup(LedsLayer &leds) { leds.fadeToBlackBy(16); } - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() uint8_t fadeOut = leds.effectData.read(); uint8_t ripple = leds.effectData.read(); @@ -2385,7 +2385,7 @@ class GEQEffect: public Effect { } } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { Effect::controls(leds, parentVar); ui->initSlider(parentVar, "fadeOut", leds.effectData.write(255)); ui->initSlider(parentVar, "ripple", leds.effectData.write(128)); @@ -2414,11 +2414,11 @@ class LaserGEQEffect: public Effect { uint8_t dim() {return _2D;} const char * tags() {return "♫💫";} - void setup(Leds &leds) { + void setup(LedsLayer &leds) { leds.fadeToBlackBy(16); } - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() uint8_t fadeOut = leds.effectData.read(); @@ -2541,7 +2541,7 @@ class LaserGEQEffect: public Effect { } } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { Effect::controls(leds, parentVar); ui->initSlider(parentVar, "fadeOut", leds.effectData.write(255)); } @@ -2552,11 +2552,11 @@ class FunkyPlankEffect: public Effect { uint8_t dim() {return _2D;} const char * tags() {return "♫💡💫";} - void setup(Leds &leds) { + void setup(LedsLayer &leds) { leds.fill_solid(CRGB::Black); } - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() uint8_t speed = leds.effectData.read(); uint8_t num_bands = leds.effectData.read(); @@ -2590,7 +2590,7 @@ class FunkyPlankEffect: public Effect { } } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { ui->initSlider(parentVar, "speed", leds.effectData.write(255)); ui->initSlider(parentVar, "bands", leds.effectData.write(NUM_GEQ_CHANNELS), 1, NUM_GEQ_CHANNELS); } @@ -2608,7 +2608,7 @@ class RipplesEffect: public Effect { uint8_t dim() {return _3D;} const char * tags() {return "💫";} - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() uint8_t speed = leds.effectData.read(); uint8_t interval = leds.effectData.read(); @@ -2629,7 +2629,7 @@ class RipplesEffect: public Effect { } } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { ui->initSlider(parentVar, "speed", leds.effectData.write(50), 0, 99); ui->initSlider(parentVar, "interval", leds.effectData.write(128)); } @@ -2640,7 +2640,7 @@ class SphereMoveEffect: public Effect { uint8_t dim() {return _3D;} const char * tags() {return "💫";} - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() uint8_t speed = leds.effectData.read(); @@ -2669,7 +2669,7 @@ class SphereMoveEffect: public Effect { } } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { ui->initSlider(parentVar, "speed", leds.effectData.write(50), 0, 99); } }; // SphereMove3DEffect @@ -2679,7 +2679,7 @@ class PixelMapEffect: public Effect { uint8_t dim() {return _3D;} const char * tags() {return "💫";} - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() uint8_t x = leds.effectData.read(); uint8_t y = leds.effectData.read(); @@ -2691,7 +2691,7 @@ class PixelMapEffect: public Effect { leds[pos] = CHSV( sys->now/50 + random8(64), 255, 255);// ColorFromPalette(leds.palette,call, bri); } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { ui->initSlider(parentVar, "x", leds.effectData.write(0), 0, leds.size.x - 1); ui->initSlider(parentVar, "y", leds.effectData.write(0), 0, leds.size.y - 1); ui->initSlider(parentVar, "z", leds.effectData.write(0), 0, leds.size.z - 1); @@ -2703,7 +2703,7 @@ class Byte2TestEffect: public Effect { uint8_t dim() {return _2D;} const char * tags() {return "💫";} - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() bool *setup = leds.effectData.readWrite(); uint8_t speed = leds.effectData.read(); @@ -2768,7 +2768,7 @@ class Byte2TestEffect: public Effect { *step = sys->now; } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { Effect::controls(leds, parentVar); bool *setup = leds.effectData.write(true); ui->initSlider(parentVar, "Speed", leds.effectData.write(0), 0, 20); @@ -2794,7 +2794,7 @@ class Byte2TestEffect2: public Effect { uint8_t dim() {return _2D;} const char * tags() {return "💫";} - void loop(Leds &leds) { + void loop(LedsLayer &leds) { //Binding of controls. Keep before binding of vars and keep in same order as in controls() bool *setup = leds.effectData.readWrite(); uint8_t speed = leds.effectData.read(); @@ -2891,7 +2891,7 @@ class Byte2TestEffect2: public Effect { *step = sys->now; } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { Effect::controls(leds, parentVar); bool *setup = leds.effectData.write(true); ui->initSlider(parentVar, "Speed", leds.effectData.write(0), 0, 20); @@ -2931,10 +2931,10 @@ class LiveScriptEffect: public Effect { uint8_t dim() {return _2D;} const char * tags() {return "💫";} - void loop(Leds &leds) { + void loop(LedsLayer &leds) { } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { Effect::controls(leds, parentVar); ui->initSelect(parentVar, "script2", UINT16_MAX, false , [&leds](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case onUI: { @@ -2957,9 +2957,9 @@ class LiveScriptEffect: public Effect { files->seqNrToName(fileName, fileNr, ".sc"); ppf("script f:%d f:%d s:%s\n", funType, fileNr, fileName); - // in ledleds.h: void setPixelColorLive(unsigned16 indexV, uint32_t color) {setPixelColor(indexV, CRGB::Black);} - // void (Leds::*sPCCached)(unsigned16, uint32_t) = &Leds::setPixelColorLive; - // Leds *leds2 = &leds; + // in LedLayer.h: void setPixelColorLive(unsigned16 indexV, uint32_t color) {setPixelColor(indexV, CRGB::Black);} + // void (LedsLayer::*sPCCached)(unsigned16, uint32_t) = &LedsLayer::setPixelColorLive; + // LedsLayer *leds2 = &leds; // (leds2->*sPCCached)(0, 0); gLeds = &leds; //set the leds class for live script diff --git a/src/App/LedFixture.cpp b/src/App/LedFixture.cpp index 41841747..f1ac72a7 100644 --- a/src/App/LedFixture.cpp +++ b/src/App/LedFixture.cpp @@ -26,7 +26,7 @@ void Fixture::projectAndMap() { // reset leds stackUnsigned8 rowNr = 0; - for (Leds *leds: listOfLeds) { + for (LedsLayer *leds: layers) { if (leds->doMap) { leds->fill_solid(CRGB::Black); @@ -64,7 +64,7 @@ void Fixture::projectAndMap() { starJson.lookFor("nrOfLeds", &nrOfLeds); starJson.lookFor("pin", &currPin); - //lookFor leds array and for each item in array call lambdo to make a projection + //lookFor leds array and for each item in array call lambda to make a projection starJson.lookFor("leds", [this, &prevIndexP, &indexP, &currPin](std::vector uint16CollectList) { //this will be called for each tuple of coordinates! if (uint16CollectList.size()>=1) { // process one pixel @@ -79,7 +79,7 @@ void Fixture::projectAndMap() { if (indexP < NUM_LEDS_Max) { stackUnsigned8 rowNr = 0; - for (Leds *leds: listOfLeds) { + for (LedsLayer *leds: layers) { if (leds->projectionNr != p_Random && leds->projectionNr != p_None) //only real projections if (leds->doMap) { //add pixel in leds mappingtable @@ -150,7 +150,7 @@ void Fixture::projectAndMap() { } //if x,y,z between start and endpos } //if leds->doMap rowNr++; - } //for listOfLeds + } //for layers } //indexP < max else ppf("dev post indexP too high %d>=%d or %d p:%d,%d,%d\n", indexP, nrOfLeds, NUM_LEDS_Max, pixel.x, pixel.y, pixel.z); @@ -197,7 +197,7 @@ void Fixture::projectAndMap() { //after processing each led stackUnsigned8 rowNr = 0; - for (Leds *leds: listOfLeds) { + for (LedsLayer *leds: layers) { if (leds->doMap) { ppf("projectAndMap post leds[%d] fx:%d pro:%d\n", rowNr, leds->fx, leds->projectionNr); @@ -256,7 +256,7 @@ void Fixture::projectAndMap() { print->fFormat(buf, sizeof(buf)-1,"%d x %d x %d -> %d", leds->size.x, leds->size.y, leds->size.z, leds->nrOfLeds); mdl->setValue("ledsSize", JsonString(buf, JsonString::Copied), rowNr); - ppf("projectAndMap leds[%d].size = %d + m:(%d * %d) B\n", rowNr, sizeof(Leds), leds->mappingTable.size(), sizeof(PhysMap)); //44 -> 164 + ppf("projectAndMap leds[%d].size = %d + m:(%d * %d) B\n", rowNr, sizeof(LedsLayer), leds->mappingTable.size(), sizeof(PhysMap)); //44 -> 164 leds->doMap = false; } //leds->doMap diff --git a/src/App/LedFixture.h b/src/App/LedFixture.h index 5ef93c12..c9b69e6d 100644 --- a/src/App/LedFixture.h +++ b/src/App/LedFixture.h @@ -13,7 +13,7 @@ #include "../Sys/SysModModel.h" //for Coord3D -#include "LedLeds.h" +#include "LedLayer.h" #define NUM_LEDS_Max 8192 @@ -22,18 +22,18 @@ #define _3D 3 -class Leds; //forward +class LedsLayer; //forward class Projection { public: virtual const char * name() {return "noname";} virtual const char * tags() {return "";} - virtual void setup(Leds &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted, Coord3D &mapped, uint16_t &indexV) {} + virtual void setup(LedsLayer &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted, Coord3D &mapped, uint16_t &indexV) {} - virtual void adjustXYZ(Leds &leds, Coord3D &pixel) {} + virtual void adjustXYZ(LedsLayer &leds, Coord3D &pixel) {} - virtual void controls(Leds &leds, JsonObject parentVar) {} + virtual void controls(LedsLayer &leds, JsonObject parentVar) {} }; @@ -59,7 +59,7 @@ class Fixture { unsigned8 fixtureNr = -1; Coord3D fixSize = {8,8,1}; - std::vector listOfLeds; //virtual leds + std::vector layers; //virtual leds Coord3D head = {0,0,0}; diff --git a/src/App/LedLeds.cpp b/src/App/LedLayer.cpp similarity index 88% rename from src/App/LedLeds.cpp rename to src/App/LedLayer.cpp index 0a3b8ec3..31b1d5b9 100644 --- a/src/App/LedLeds.cpp +++ b/src/App/LedLayer.cpp @@ -1,6 +1,6 @@ /* @title StarLight - @file LedLeds.cpp + @file LedLayer.cpp @date 20240720 @repo https://github.com/MoonModules/StarLight @Authors https://github.com/MoonModules/StarLight/commits/main @@ -9,7 +9,7 @@ @license For non GPL-v3 usage, commercial licenses must be purchased. Contact moonmodules@icloud.com */ -#include "LedLeds.h" +#include "LedLayer.h" #include "../Sys/SysModSystem.h" //for sys->now #ifdef STARBASE_USERMOD_MPU6050 #include "../User/UserModMPU6050.h" @@ -26,12 +26,12 @@ void fastled_fill_rainbow(struct CRGB * targetArray, int numToFill, unsigned8 in fill_rainbow(targetArray, numToFill, initialhue, deltahue); } -void Leds::triggerMapping() { +void LedsLayer::triggerMapping() { doMap = true; //specify which leds to remap fixture->doMap = true; //fixture will also be remapped } -unsigned16 Leds::XYZ(Coord3D pixel) { +unsigned16 LedsLayer::XYZ(Coord3D pixel) { //as this is a call to a virtual function it reduces the theoretical (no show) speed by half, even if XYZ is not implemented // the real speed is hardly affected, but room for improvement! @@ -48,7 +48,7 @@ unsigned16 Leds::XYZ(Coord3D pixel) { } // maps the virtual led to the physical led(s) and assign a color to it -void Leds::setPixelColor(unsigned16 indexV, CRGB color) { +void LedsLayer::setPixelColor(unsigned16 indexV, CRGB color) { if (indexV < mappingTable.size()) { switch (mappingTable[indexV].mapType) { case m_color:{ @@ -79,15 +79,15 @@ void Leds::setPixelColor(unsigned16 indexV, CRGB color) { ppf(" dev sPC V:%d >= %d", indexV, NUM_LEDS_Max); } -void Leds::setPixelColorPal(unsigned16 indexV, uint8_t palIndex, uint8_t palBri) { +void LedsLayer::setPixelColorPal(unsigned16 indexV, uint8_t palIndex, uint8_t palBri) { setPixelColor(indexV, ColorFromPalette(palette, palIndex, palBri)); } -void Leds::blendPixelColor(unsigned16 indexV, CRGB color, uint8_t blendAmount) { +void LedsLayer::blendPixelColor(unsigned16 indexV, CRGB color, uint8_t blendAmount) { setPixelColor(indexV, blend(color, getPixelColor(indexV), blendAmount)); } -CRGB Leds::getPixelColor(unsigned16 indexV) { +CRGB LedsLayer::getPixelColor(unsigned16 indexV) { if (indexV < mappingTable.size()) { switch (mappingTable[indexV].mapType) { case m_onePixel: @@ -111,8 +111,8 @@ CRGB Leds::getPixelColor(unsigned16 indexV) { } } -void Leds::fadeToBlackBy(unsigned8 fadeBy) { - if (projectionNr == p_None || projectionNr == p_Random || (fixture->listOfLeds.size() == 1)) { +void LedsLayer::fadeToBlackBy(unsigned8 fadeBy) { + if (projectionNr == p_None || projectionNr == p_Random || (fixture->layers.size() == 1)) { fastled_fadeToBlackBy(fixture->ledsP, fixture->nrOfLeds, fadeBy); } else { for (uint16_t index = 0; index < mappingTable.size(); index++) { @@ -123,8 +123,8 @@ void Leds::fadeToBlackBy(unsigned8 fadeBy) { } } -void Leds::fill_solid(const struct CRGB& color) { - if (projectionNr == p_None || projectionNr == p_Random || (fixture->listOfLeds.size() == 1)) { +void LedsLayer::fill_solid(const struct CRGB& color) { + if (projectionNr == p_None || projectionNr == p_Random || (fixture->layers.size() == 1)) { fastled_fill_solid(fixture->ledsP, fixture->nrOfLeds, color); } else { for (uint16_t index = 0; index < mappingTable.size(); index++) @@ -132,8 +132,8 @@ void Leds::fill_solid(const struct CRGB& color) { } } -void Leds::fill_rainbow(unsigned8 initialhue, unsigned8 deltahue) { - if (projectionNr == p_None || projectionNr == p_Random || (fixture->listOfLeds.size() == 1)) { +void LedsLayer::fill_rainbow(unsigned8 initialhue, unsigned8 deltahue) { + if (projectionNr == p_None || projectionNr == p_Random || (fixture->layers.size() == 1)) { fastled_fill_rainbow(fixture->ledsP, fixture->nrOfLeds, initialhue, deltahue); } else { CHSV hsv; @@ -148,7 +148,7 @@ void Leds::fill_rainbow(unsigned8 initialhue, unsigned8 deltahue) { } } -void PhysMap::addIndexP(Leds &leds, uint16_t indexP) { +void PhysMap::addIndexP(LedsLayer &leds, uint16_t indexP) { // ppf("addIndexP i:%d t:%d", indexP, mapType); switch (mapType) { case m_color: diff --git a/src/App/LedLayer.h b/src/App/LedLayer.h new file mode 100644 index 00000000..cadd76f6 --- /dev/null +++ b/src/App/LedLayer.h @@ -0,0 +1,490 @@ +/* + @title StarLight + @file LedLayer.h + @date 20240720 + @repo https://github.com/MoonModules/StarLight + @Authors https://github.com/MoonModules/StarLight/commits/main + @Copyright © 2024 Github StarLight Commit Authors + @license GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 + @license For non GPL-v3 usage, commercial licenses must be purchased. Contact moonmodules@icloud.com +*/ + +#pragma once +// FastLED optional flags to configure drivers, see https://github.com/FastLED/FastLED/blob/master/src/platforms/esp/32 +// RMT driver (default) +// #define FASTLED_ESP32_FLASH_LOCK 1 // temporarily disabled FLASH file access while driving LEDs (may prevent random flicker) +// #define FASTLED_RMT_BUILTIN_DRIVER 1 // in case your app needs to use RMT units, too (slower) +// I2S parallel driver +// #define FASTLED_ESP32_I2S true // to use I2S parallel driver (instead of RMT) +// #define I2S_DEVICE 1 // I2S driver: allows to still use I2S#0 for audio (only on esp32 and esp32-s3) +// #define FASTLED_I2S_MAX_CONTROLLERS 8 // 8 LED pins should be enough (default = 24) +#include "FastLED.h" + +#include "LedFixture.h" + +#include "../data/font/console_font_4x6.h" +#include "../data/font/console_font_5x8.h" +#include "../data/font/console_font_5x12.h" +#include "../data/font/console_font_6x8.h" +#include "../data/font/console_font_7x9.h" + +#define NUM_VLEDS_Max 8192 + +enum ProjectionsE +{ + p_None, + p_Default, + p_Pinwheel, + p_Multiply, + p_TiltPanRoll, + p_DistanceFromPoint, + p_Preset1, + p_Random, + p_Reverse, + p_Mirror, + p_Grouping, + p_Spacing, + p_Transpose, + p_Kaleidoscope, + p_count // keep as last entry +}; + +// sin8/cos8 sin16/cos16 +//0: 128, 255 0 32645 +//64: 255, 128 32645 0 +//128: 128, 1 0 -32645 +//192: 1, 127 -32645 0 + +static unsigned trigoCached = 1; +static unsigned trigoUnCached = 1; + +struct Trigo { + uint16_t period = 360; //default period 360 + Trigo(uint16_t period = 360) {this->period = period;} + float sinValue[3]; uint16_t sinAngle[3] = {UINT16_MAX,UINT16_MAX,UINT16_MAX}; //caching of sinValue=sin(sinAngle) for tilt, pan and roll + float cosValue[3]; uint16_t cosAngle[3] = {UINT16_MAX,UINT16_MAX,UINT16_MAX}; //caching of cosValue=cos(cosAngle) for tilt, pan and roll + virtual float sinBase(uint16_t angle) {return sinf(M_TWOPI * angle / period);} + virtual float cosBase(uint16_t angle) {return cosf(M_TWOPI * angle / period);} + int16_t sin(int16_t factor, uint16_t angle, uint8_t cache012 = 0) { + if (sinAngle[cache012] != angle) {sinAngle[cache012] = angle; sinValue[cache012] = sinBase(angle);trigoUnCached++;} else trigoCached++; + return factor * sinValue[cache012]; + }; + int16_t cos(int16_t factor, uint16_t angle, uint8_t cache012 = 0) { + if (cosAngle[cache012] != angle) {cosAngle[cache012] = angle; cosValue[cache012] = cosBase(angle);trigoUnCached++;} else trigoCached++; + return factor * cosValue[cache012]; + }; + // https://msl.cs.uiuc.edu/planning/node102.html + Coord3D pan(Coord3D in, Coord3D middle, uint16_t angle) { + Coord3D inM = in - middle; + Coord3D out; + out.x = cos(inM.x, angle, 0) + sin(inM.z, angle, 0); + out.y = inM.y; + out.z = - sin(inM.x, angle, 0) + cos(inM.z, angle, 0); + return out + middle; + } + Coord3D tilt(Coord3D in, Coord3D middle, uint16_t angle) { + Coord3D inM = in - middle; + Coord3D out; + out.x = inM.x; + out.y = cos(inM.y, angle, 1) - sin(inM.z, angle, 1); + out.z = sin(inM.y, angle, 1) + cos(inM.z, angle, 1); + return out + middle; + } + Coord3D roll(Coord3D in, Coord3D middle, uint16_t angle) { + Coord3D inM = in - middle; + Coord3D out; + out.x = cos(inM.x, angle, 2) - sin(inM.y, angle, 2); + out.y = sin(inM.x, angle, 2) + cos(inM.y, angle, 2); + out.z = inM.z; + return out + middle; + } + Coord3D rotate(Coord3D in, Coord3D middle, uint16_t tiltAngle, uint16_t panAngle, uint16_t rollAngle, uint16_t period = 360) { + this->period = period; + return roll(pan(tilt(in, middle, tiltAngle), middle, panAngle), middle, rollAngle); + } +}; + +struct Trigo8: Trigo { //FastLed sin8 and cos8 + using Trigo::Trigo; + float sinBase(uint16_t angle) {return (sin8(256.0f * angle / period) - 128) / 127.0f;} + float cosBase(uint16_t angle) {return (cos8(256.0f * angle / period) - 128) / 127.0f;} +}; +struct Trigo16: Trigo { //FastLed sin16 and cos16 + using Trigo::Trigo; + float sinBase(uint16_t angle) {return sin16(65536.0f * angle / period) / 32645.0f;} + float cosBase(uint16_t angle) {return cos16(65536.0f * angle / period) / 32645.0f;} +}; + +static Trigo trigoTiltPanRoll(255); // Trigo8 is hardly any faster (27 vs 28 fps) (spanXY=28) + +class Fixture; //forward + + +//StarLight implementation of segment.data +class SharedData { + + private: + byte *data; + unsigned16 index = 0; + unsigned16 bytesAllocated = 0; + + public: + + SharedData() { + // ppf("SharedData constructor %d %d\n", index, bytesAllocated); + } + ~SharedData() { + // ppf("SharedData destructor WIP %d %d\n", index, bytesAllocated); + // free(data); + } + + void reset() { + memset(data, 0, bytesAllocated); + index = 0; + } + + //sets the effectData pointer back to 0 so loop effect can go through it + void begin() { + index = 0; + } + + //returns the next pointer to a specified type (length for arrays) + template + Type * readWrite(int length = 1) { + size_t newIndex = index + length * sizeof(Type); + if (newIndex > bytesAllocated) { + size_t newSize = bytesAllocated + (1 + ( newIndex - bytesAllocated)/1024) * 1024; // add a multitude of 1024 bytes + ppf("bind add more %d->%d %d->%d\n", index, newIndex, bytesAllocated, newSize); + if (bytesAllocated == 0) + data = (byte*) malloc(newSize); + else + data = (byte*)realloc(data, newSize); + bytesAllocated = newSize; + } + // ppf("bind %d->%d %d\n", index, newIndex, bytesAllocated); + Type * returnValue = reinterpret_cast(data + index); + index = newIndex; //add consumed amount of bytes, index is next byte which will be pointed to + return returnValue; + } + + //returns the next pointer initialized by a value (length for arrays not supported yet) + template + Type * write(Type initValue) { + Type * returnValue = readWrite(); + *returnValue = initValue; + return returnValue; + } + + //returns the next value (length for arrays not supported yet) + template + Type read() { + Type *result = readWrite(); //not supported for arrays yet + return *result; + } + +}; + +enum mapType { + m_color, + m_onePixel, + m_morePixels, + m_count //keep as last entry +}; + +class LedsLayer; //forward + + +struct PhysMap { + union { + struct { //condensed rgb + uint16_t rgb14: 14; //14 bits (554 RGB) + byte mapType:2; //2 bits (4) + }; //16 bits + uint16_t indexP: 14; //16384 one physical pixel (type==1) index to ledsP array + uint16_t indexes:14; //16384 multiple physical pixels (type==2) index in std::vector> mappingTableIndexes; + }; // 2 bytes + + PhysMap() { + mapType = m_color; // the default until indexP is added + rgb14 = 0; + } + + void addIndexP(LedsLayer &leds, uint16_t indexP); + +}; // 2 bytes + +class Projection; //forward for cached virtual class methods! + +class LedsLayer { + +public: + + Fixture *fixture; + + unsigned16 nrOfLeds = 64; //amount of virtual leds (calculated by projection) + + Coord3D size = {8,8,1}; //not 0,0,0 to prevent div0 eg in Octopus2D + + uint16_t fx = UINT16_MAX; + unsigned8 projectionNr = p_Default; + + //using cached virtual class methods! 4 bytes each - thats for now the price we pay for speed + void (Projection::*setupCached)(LedsLayer &, Coord3D &, Coord3D &, Coord3D &, Coord3D &, uint16_t &) = nullptr; + void (Projection::*adjustXYZCached)(LedsLayer &, Coord3D &) = nullptr; + + unsigned8 effectDimension = -1; + unsigned8 projectionDimension = -1; + + Coord3D startPos = {0,0,0}, endPos = {UINT16_MAX,UINT16_MAX,UINT16_MAX}; //default + Coord3D midPos = {0,0,0}; + #ifdef STARBASE_USERMOD_MPU6050 + bool proGyro = false; + #endif + unsigned8 proTiltSpeed = 128; + unsigned8 proPanSpeed = 128; + unsigned8 proRollSpeed = 128; + + SharedData effectData; + SharedData projectionData; + + std::vector mappingTable; + std::vector> mappingTableIndexes; + + + unsigned16 indexVLocal = 0; //set in operator[], used by operator= + + bool doMap = false; + + CRGBPalette16 palette; + + unsigned16 XY(unsigned16 x, unsigned16 y) { + return XYZ(x, y, 0); + } + + unsigned16 XYZUnprojected(Coord3D pixel) { + if (pixel >= 0 && pixel < size) + return pixel.x + pixel.y * size.x + pixel.z * size.x * size.y; + else + return UINT16_MAX; + } + + unsigned16 XYZ(unsigned16 x, unsigned16 y, unsigned16 z) { + return XYZ({x, y, z}); + } + + unsigned16 XYZ(Coord3D pixel); + + LedsLayer(Fixture &fixture) { + ppf("LedsLayer constructor (PhysMap:%d)\n", sizeof(PhysMap)); + this->fixture = &fixture; + } + + ~LedsLayer() { + ppf("LedsLayer destructor\n"); + fadeToBlackBy(); + doMap = true; // so loop is not running while deleting + for (std::vector mappingTableIndex: mappingTableIndexes) { + mappingTableIndex.clear(); + } + mappingTableIndexes.clear(); + mappingTable.clear(); + } + + void triggerMapping(); + + // indexVLocal stored to be used by other operators + LedsLayer& operator[](unsigned16 indexV) { + indexVLocal = indexV; + return *this; + } + + LedsLayer& operator[](Coord3D pos) { + indexVLocal = XYZ(pos.x, pos.y, pos.z); + return *this; + } + + // CRGB& operator[](unsigned16 indexV) { + // // indexVLocal = indexV; + // CRGB x = getPixelColor(indexV); + // return x; + // } + + // uses indexVLocal and color to call setPixelColor + LedsLayer& operator=(const CRGB color) { + setPixelColor(indexVLocal, color); + return *this; + } + + LedsLayer& operator+=(const CRGB color) { + setPixelColor(indexVLocal, getPixelColor(indexVLocal) + color); + return *this; + } + LedsLayer& operator|=(const CRGB color) { + // setPixelColor(indexVLocal, color); + setPixelColor(indexVLocal, getPixelColor(indexVLocal) | color); + return *this; + } + + // LedsLayer& operator+(const CRGB color) { + // setPixelColor(indexVLocal, getPixelColor(indexVLocal) + color); + // return *this; + // } + + + // maps the virtual led to the physical led(s) and assign a color to it + void setPixelColor(unsigned16 indexV, CRGB color); + void setPixelColor(Coord3D pixel, CRGB color) {setPixelColor(XYZ(pixel), color);} + + // temp methods until all effects have been converted to Palette / 2 byte mapping mode + void setPixelColorPal(unsigned16 indexV, uint8_t palIndex, uint8_t palBri = 255); + void setPixelColorPal(Coord3D pixel, uint8_t palIndex, uint8_t palBri = 255) {setPixelColorPal(XYZ(pixel), palIndex, palBri);} + + void blendPixelColor(unsigned16 indexV, CRGB color, uint8_t blendAmount); + void blendPixelColor(Coord3D pixel, CRGB color, uint8_t blendAmount) {blendPixelColor(XYZ(pixel), color, blendAmount);} + + CRGB getPixelColor(unsigned16 indexV); + CRGB getPixelColor(Coord3D pixel) {return getPixelColor(XYZ(pixel));} + + void addPixelColor(unsigned16 indexV, CRGB color) {setPixelColor(indexV, getPixelColor(indexV) + color);} + void addPixelColor(Coord3D pixel, CRGB color) {setPixelColor(pixel, getPixelColor(pixel) + color);} + + void drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, CRGB color) { + if (x0 >= size.x || x1 >= size.x || y0 >= size.y || y1 >= size.y) return; + const int16_t dx = abs(x1-x0), sx = x0dy ? dx : -dy)/2, e2; + for (;;) { + setPixelColor(XY(x0,y0), color); + if (x0==x1 && y0==y1) break; + e2 = err; + if (e2 >-dx) { err -= dy; x0 += sx; } + if (e2 < dy) { err += dx; y0 += sy; } + } + } + + void fadeToBlackBy(unsigned8 fadeBy = 255); + void fill_solid(const struct CRGB& color); + void fill_rainbow(unsigned8 initialhue, unsigned8 deltahue); + + //checks if a virtual pixel is mapped to a physical pixel (use with XY() or XYZ() to get the indexV) + bool isMapped(unsigned16 indexV) { + return indexV < mappingTable.size() && (mappingTable[indexV].mapType == m_onePixel || mappingTable[indexV].mapType == m_morePixels); + } + + void blur1d(fract8 blur_amount) + { + uint8_t keep = 255 - blur_amount; + uint8_t seep = blur_amount >> 1; + CRGB carryover = CRGB::Black; + for( uint16_t i = 0; i < nrOfLeds; ++i) { + CRGB cur = getPixelColor(i); + CRGB part = cur; + part.nscale8( seep); + cur.nscale8( keep); + cur += carryover; + if( i) addPixelColor(i-1, part); + setPixelColor(i, cur); + carryover = part; + } + } + + void blur2d(fract8 blur_amount) + { + blurRows(size.x, size.y, blur_amount); + blurColumns(size.x, size.y, blur_amount); + } + + void blurRows(unsigned8 width, unsigned8 height, fract8 blur_amount) + { + /* 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 + stackUnsigned8 keep = 255 - blur_amount; + stackUnsigned8 seep = blur_amount >> 1; + for (forUnsigned8 row = 0; row < height; row++) { + CRGB carryover = CRGB::Black; + for (forUnsigned8 i = 0; i < width; i++) { + CRGB cur = getPixelColor(XY(i,row)); + CRGB part = cur; + part.nscale8( seep); + cur.nscale8( keep); + cur += carryover; + if( i) addPixelColor(XY(i-1,row), part); + setPixelColor(XY(i,row), cur); + carryover = part; + } + } + } + + // blurColumns: perform a blur1d on each column of a rectangular matrix + void blurColumns(unsigned8 width, unsigned8 height, fract8 blur_amount) + { + // blur columns + stackUnsigned8 keep = 255 - blur_amount; + stackUnsigned8 seep = blur_amount >> 1; + for (forUnsigned8 col = 0; col < width; ++col) { + CRGB carryover = CRGB::Black; + for (forUnsigned8 i = 0; i < height; ++i) { + CRGB cur = getPixelColor(XY(col,i)); + CRGB part = cur; + part.nscale8( seep); + cur.nscale8( keep); + cur += carryover; + if( i) addPixelColor(XY(col,i-1), part); + setPixelColor(XY(col,i), cur); + carryover = part; + } + } + } + + //shift is used by drawText indicating which letter it is drawing + void drawCharacter(unsigned char chr, int x = 0, int16_t y = 0, unsigned8 font = 0, CRGB col = CRGB::Red, unsigned16 shiftPixel = 0, unsigned16 shiftChr = 0) { + if (chr < 32 || chr > 126) return; // only ASCII 32-126 supported + chr -= 32; // align with font table entries + + Coord3D fontSize; + switch (font%5) { + case 0: fontSize.x = 4; fontSize.y = 6; break; + case 1: fontSize.x = 5; fontSize.y = 8; break; + case 2: fontSize.x = 5; fontSize.y = 12; break; + case 3: fontSize.x = 6; fontSize.y = 8; break; + case 4: fontSize.x = 7; fontSize.y = 9; break; + } + + Coord3D chrPixel; + for (chrPixel.y = 0; chrPixel.y= 0 && pixel.y < size.y) { + byte bits = 0; + switch (font%5) { + case 0: bits = pgm_read_byte_near(&console_font_4x6[(chr * fontSize.y) + chrPixel.y]); break; + case 1: bits = pgm_read_byte_near(&console_font_5x8[(chr * fontSize.y) + chrPixel.y]); break; + case 2: bits = pgm_read_byte_near(&console_font_5x12[(chr * fontSize.y) + chrPixel.y]); break; + case 3: bits = pgm_read_byte_near(&console_font_6x8[(chr * fontSize.y) + chrPixel.y]); break; + case 4: bits = pgm_read_byte_near(&console_font_7x9[(chr * fontSize.y) + chrPixel.y]); break; + } + + for (chrPixel.x = 0; chrPixel.x= 0 && pixel.x < size.x) && ((bits>>(chrPixel.x+(8-fontSize.x))) & 0x01)) { // bit set & drawing on-screen + setPixelColor(pixel, col); + } + } + } + } + } + + void drawText(const char * text, int x = 0, int16_t y = 0, unsigned8 font = 0, CRGB col = CRGB::Red, unsigned16 shiftPixel = 0) { + const int numberOfChr = strlen(text); //Core 1 panic'ed (LoadProhibited). Exception was unhandled. - /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/strlen.S:82 + for (int shiftChr = 0; shiftChr < numberOfChr; shiftChr++) { + drawCharacter(text[shiftChr], x, y, font, col, shiftPixel, shiftChr); + } + } + +}; \ No newline at end of file diff --git a/src/App/LedLeds.h b/src/App/LedLeds.h index 40de73d0..e686cddb 100644 --- a/src/App/LedLeds.h +++ b/src/App/LedLeds.h @@ -1,6 +1,6 @@ /* @title StarLight - @file LedLeds.h + @file LedLayer.h @date 20240720 @repo https://github.com/MoonModules/StarLight @Authors https://github.com/MoonModules/StarLight/commits/main diff --git a/src/App/LedModEffects.h b/src/App/LedModEffects.h index 5a4cc925..bfc6c090 100644 --- a/src/App/LedModEffects.h +++ b/src/App/LedModEffects.h @@ -153,30 +153,30 @@ class LedModEffects:public SysModule { JsonObject currentVar; - JsonObject tableVar = ui->initTable(parentVar, "ledsTbl", nullptr, false, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun + JsonObject tableVar = ui->initTable(parentVar, "layerTbl", nullptr, false, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case onUI: - ui->setLabel(var, "Effects"); + ui->setLabel(var, "Layers"); ui->setComment(var, "List of effects"); return true; case onAddRow: { - rowNr = fixture.listOfLeds.size(); - // ppf("ledsTbl addRow %s[%d]\n", mdl->varID(var), rowNr); + rowNr = fixture.layers.size(); + // ppf("layerTbl addRow %s[%d]\n", mdl->varID(var), rowNr); web->getResponseObject()["addRow"]["rowNr"] = rowNr; - if (rowNr >= fixture.listOfLeds.size()) { - ppf("ledsTbl creating new Leds instance %d\n", rowNr); - Leds *leds = new Leds(fixture); + if (rowNr >= fixture.layers.size()) { + ppf("layerTbl creating new LedsLayer instance %d\n", rowNr); + LedsLayer *leds = new LedsLayer(fixture); leds->doMap = true; - fixture.listOfLeds.push_back(leds); + fixture.layers.push_back(leds); } return true; } case onDeleteRow: { - // ppf("ledsTbl delrow %s[%d]\n", mdl->varID(var), rowNr); + // ppf("layerTbl delrow %s[%d]\n", mdl->varID(var), rowNr); //tbd: fade to black - if (rowNr initSelect(tableVar, "fx", 0, false, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case onSetValue: - for (forUnsigned8 rowNr = 0; rowNr < fixture.listOfLeds.size(); rowNr++) - mdl->setValue(var, fixture.listOfLeds[rowNr]->fx, rowNr); + for (forUnsigned8 rowNr = 0; rowNr < fixture.layers.size(); rowNr++) + mdl->setValue(var, fixture.layers[rowNr]->fx, rowNr); return true; case onUI: { ui->setLabel(var, "Effect"); @@ -207,16 +207,16 @@ class LedModEffects:public SysModule { if (rowNr == UINT8_MAX) rowNr = 0; // in case fx without a rowNr //create a new leds instance if a new row is created - if (rowNr >= fixture.listOfLeds.size()) { - ppf("listOfLeds fx[%d] onChange %d %s\n", rowNr, fixture.listOfLeds.size(), mdl->findVar("fx")["value"].as().c_str()); - ppf("fx creating new Leds instance %d\n", rowNr); - Leds *leds = new Leds(fixture); + if (rowNr >= fixture.layers.size()) { + ppf("layers fx[%d] onChange %d %s\n", rowNr, fixture.layers.size(), mdl->findVar("fx")["value"].as().c_str()); + ppf("fx creating new LedsLayer instance %d\n", rowNr); + LedsLayer *leds = new LedsLayer(fixture); leds->doMap = true; - fixture.listOfLeds.push_back(leds); + fixture.layers.push_back(leds); } - if (rowNr < fixture.listOfLeds.size()) { - Leds *leds = fixture.listOfLeds[rowNr]; + if (rowNr < fixture.layers.size()) { + LedsLayer *leds = fixture.layers[rowNr]; leds->doMap = true; //stop the effects loop already here @@ -258,8 +258,8 @@ class LedModEffects:public SysModule { //projection, default projection is 'default' currentVar = ui->initSelect(tableVar, "pro", 1, false, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case onSetValue: - for (forUnsigned8 rowNr = 0; rowNr < fixture.listOfLeds.size(); rowNr++) - mdl->setValue(var, fixture.listOfLeds[rowNr]->projectionNr, rowNr); + for (forUnsigned8 rowNr = 0; rowNr < fixture.layers.size(); rowNr++) + mdl->setValue(var, fixture.layers[rowNr]->projectionNr, rowNr); return true; case onUI: { ui->setLabel(var, "Projection"); @@ -279,8 +279,8 @@ class LedModEffects:public SysModule { if (rowNr == UINT8_MAX) rowNr = 0; // in case fx without a rowNr - if (rowNr < fixture.listOfLeds.size()) { - Leds *leds = fixture.listOfLeds[rowNr]; + if (rowNr < fixture.layers.size()) { + LedsLayer *leds = fixture.layers[rowNr]; leds->doMap = true; //stop the effects loop already here @@ -299,7 +299,7 @@ class LedModEffects:public SysModule { projection->controls(*leds, var); mdl->varPostDetails(var, rowNr); } - // ppf("onChange pro[%d] <- %d (%d)\n", rowNr, proValue, fixture.listOfLeds.size()); + // ppf("onChange pro[%d] <- %d (%d)\n", rowNr, proValue, fixture.layers.size()); leds->triggerMapping(); } @@ -310,9 +310,9 @@ class LedModEffects:public SysModule { ui->initCoord3D(tableVar, "ledsStart", {0,0,0}, 0, NUM_LEDS_Max, false, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case onSetValue: - for (forUnsigned8 rowNr = 0; rowNr < fixture.listOfLeds.size(); rowNr++) { - ppf("ledsStart[%d] onSetValue %d,%d,%d\n", rowNr, fixture.listOfLeds[rowNr]->startPos.x, fixture.listOfLeds[rowNr]->startPos.y, fixture.listOfLeds[rowNr]->startPos.z); - mdl->setValue(var, fixture.listOfLeds[rowNr]->startPos, rowNr); + for (forUnsigned8 rowNr = 0; rowNr < fixture.layers.size(); rowNr++) { + ppf("ledsStart[%d] onSetValue %d,%d,%d\n", rowNr, fixture.layers[rowNr]->startPos.x, fixture.layers[rowNr]->startPos.y, fixture.layers[rowNr]->startPos.z); + mdl->setValue(var, fixture.layers[rowNr]->startPos, rowNr); } return true; case onUI: @@ -320,16 +320,16 @@ class LedModEffects:public SysModule { ui->setComment(var, "In pixels"); return true; case onChange: - if (rowNr < fixture.listOfLeds.size()) { - fixture.listOfLeds[rowNr]->startPos = mdl->getValue(var, rowNr).as(); + if (rowNr < fixture.layers.size()) { + fixture.layers[rowNr]->startPos = mdl->getValue(var, rowNr).as(); - ppf("ledsStart[%d] onChange %d,%d,%d\n", rowNr, fixture.listOfLeds[rowNr]->startPos.x, fixture.listOfLeds[rowNr]->startPos.y, fixture.listOfLeds[rowNr]->startPos.z); + ppf("ledsStart[%d] onChange %d,%d,%d\n", rowNr, fixture.layers[rowNr]->startPos.x, fixture.layers[rowNr]->startPos.y, fixture.layers[rowNr]->startPos.z); - fixture.listOfLeds[rowNr]->fadeToBlackBy(); - fixture.listOfLeds[rowNr]->triggerMapping(); + fixture.layers[rowNr]->fadeToBlackBy(); + fixture.layers[rowNr]->triggerMapping(); } else { - ppf("ledsStart[%d] onChange rownr not in range > %d\n", rowNr, fixture.listOfLeds.size()); + ppf("ledsStart[%d] onChange rownr not in range > %d\n", rowNr, fixture.layers.size()); } return true; default: return false; @@ -337,9 +337,9 @@ class LedModEffects:public SysModule { ui->initCoord3D(tableVar, "ledsMid", {0,0,0}, 0, NUM_LEDS_Max, false, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case onSetValue: - for (forUnsigned8 rowNr = 0; rowNr < fixture.listOfLeds.size(); rowNr++) { - ppf("ledsMid[%d] onSetValue %d,%d,%d\n", rowNr, fixture.listOfLeds[rowNr]->midPos.x, fixture.listOfLeds[rowNr]->midPos.y, fixture.listOfLeds[rowNr]->midPos.z); - mdl->setValue(var, fixture.listOfLeds[rowNr]->midPos, rowNr); + for (forUnsigned8 rowNr = 0; rowNr < fixture.layers.size(); rowNr++) { + ppf("ledsMid[%d] onSetValue %d,%d,%d\n", rowNr, fixture.layers[rowNr]->midPos.x, fixture.layers[rowNr]->midPos.y, fixture.layers[rowNr]->midPos.z); + mdl->setValue(var, fixture.layers[rowNr]->midPos, rowNr); } return true; case onUI: @@ -347,16 +347,16 @@ class LedModEffects:public SysModule { ui->setComment(var, "In pixels"); return true; case onChange: - if (rowNr < fixture.listOfLeds.size()) { - fixture.listOfLeds[rowNr]->midPos = mdl->getValue(var, rowNr).as(); + if (rowNr < fixture.layers.size()) { + fixture.layers[rowNr]->midPos = mdl->getValue(var, rowNr).as(); - ppf("ledsMid[%d] onChange %d,%d,%d\n", rowNr, fixture.listOfLeds[rowNr]->midPos.x, fixture.listOfLeds[rowNr]->midPos.y, fixture.listOfLeds[rowNr]->midPos.z); + ppf("ledsMid[%d] onChange %d,%d,%d\n", rowNr, fixture.layers[rowNr]->midPos.x, fixture.layers[rowNr]->midPos.y, fixture.layers[rowNr]->midPos.z); - fixture.listOfLeds[rowNr]->fadeToBlackBy(); - fixture.listOfLeds[rowNr]->triggerMapping(); + fixture.layers[rowNr]->fadeToBlackBy(); + fixture.layers[rowNr]->triggerMapping(); } else { - ppf("ledsMid[%d] onChange rownr not in range > %d\n", rowNr, fixture.listOfLeds.size()); + ppf("ledsMid[%d] onChange rownr not in range > %d\n", rowNr, fixture.layers.size()); } return true; default: return false; @@ -364,9 +364,9 @@ class LedModEffects:public SysModule { ui->initCoord3D(tableVar, "ledsEnd", {8,8,0}, 0, NUM_LEDS_Max, false, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case onSetValue: - for (forUnsigned8 rowNr = 0; rowNr < fixture.listOfLeds.size(); rowNr++) { - ppf("ledsEnd[%d] onSetValue %d,%d,%d\n", rowNr, fixture.listOfLeds[rowNr]->endPos.x, fixture.listOfLeds[rowNr]->endPos.y, fixture.listOfLeds[rowNr]->endPos.z); - mdl->setValue(var, fixture.listOfLeds[rowNr]->endPos, rowNr); + for (forUnsigned8 rowNr = 0; rowNr < fixture.layers.size(); rowNr++) { + ppf("ledsEnd[%d] onSetValue %d,%d,%d\n", rowNr, fixture.layers[rowNr]->endPos.x, fixture.layers[rowNr]->endPos.y, fixture.layers[rowNr]->endPos.z); + mdl->setValue(var, fixture.layers[rowNr]->endPos, rowNr); } return true; case onUI: @@ -374,16 +374,16 @@ class LedModEffects:public SysModule { ui->setComment(var, "In pixels"); return true; case onChange: - if (rowNr < fixture.listOfLeds.size()) { - fixture.listOfLeds[rowNr]->endPos = mdl->getValue(var, rowNr).as(); + if (rowNr < fixture.layers.size()) { + fixture.layers[rowNr]->endPos = mdl->getValue(var, rowNr).as(); - ppf("ledsEnd[%d] onChange %d,%d,%d\n", rowNr, fixture.listOfLeds[rowNr]->endPos.x, fixture.listOfLeds[rowNr]->endPos.y, fixture.listOfLeds[rowNr]->endPos.z); + ppf("ledsEnd[%d] onChange %d,%d,%d\n", rowNr, fixture.layers[rowNr]->endPos.x, fixture.layers[rowNr]->endPos.y, fixture.layers[rowNr]->endPos.z); - fixture.listOfLeds[rowNr]->fadeToBlackBy(); - fixture.listOfLeds[rowNr]->triggerMapping(); + fixture.layers[rowNr]->fadeToBlackBy(); + fixture.layers[rowNr]->triggerMapping(); } else { - ppf("ledsEnd[%d] onChange rownr not in range > %d\n", rowNr, fixture.listOfLeds.size()); + ppf("ledsEnd[%d] onChange rownr not in range > %d\n", rowNr, fixture.layers.size()); } return true; default: return false; @@ -391,9 +391,9 @@ class LedModEffects:public SysModule { ui->initText(tableVar, "ledsSize", nullptr, 32, true, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case onSetValue: { - // for (std::vector::iterator leds=fixture.listOfLeds.begin(); leds!=fixture.listOfLeds.end(); ++leds) { + // for (std::vector::iterator leds=fixture.layers.begin(); leds!=fixture.layers.end(); ++leds) { stackUnsigned8 rowNr = 0; - for (Leds *leds:fixture.listOfLeds) { + for (LedsLayer *leds:fixture.layers) { 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); ppf("onSetValue ledsSize[%d] = %s\n", rowNr, message); @@ -439,7 +439,7 @@ class LedModEffects:public SysModule { // } // else - // ppf("Leds e131 not enabled\n"); + // ppf("e131 not enabled\n"); #endif #ifdef STARLIGHT_CLOCKLESS_LED_DRIVER @@ -459,7 +459,7 @@ class LedModEffects:public SysModule { //reset pixelsToBlend if multiple leds effects // ppf(" %d-%d", fixture.pixelsToBlend.size(), fixture.nrOfLeds); - if (fixture.listOfLeds.size()) //if more then one effect + if (fixture.layers.size()) //if more then one effect for (uint16_t indexP=0; indexP < fixture.pixelsToBlend.size(); indexP++) fixture.pixelsToBlend[indexP] = false; @@ -470,7 +470,7 @@ class LedModEffects:public SysModule { //for each programmed effect // run the next frame of the effect stackUnsigned8 rowNr = 0; - for (Leds *leds: fixture.listOfLeds) { + for (LedsLayer *leds: fixture.layers) { if (!leds->doMap && leds->fx < effects.size()) { // don't run effect while remapping or non existing effect (default UINT16_MAX) // ppf(" %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 ); mdl->getValueRowNr = rowNr++; @@ -483,7 +483,7 @@ class LedModEffects:public SysModule { // leds->fadeToBlackBy(50); //loop over mapped pixels and set pixelsToBlend to true - if (fixture.listOfLeds.size()) { //if more then one effect + if (fixture.layers.size()) { //if more then one effect for (std::vector mappingTableIndex: leds->mappingTableIndexes) { for (uint16_t indexP: mappingTableIndex) fixture.pixelsToBlend[indexP] = true; @@ -532,8 +532,8 @@ class LedModEffects:public SysModule { ppf("LedModEffects loop canvasData %s\n", canvasData); uint8_t rowNr = 0; //currently only leds[0] supported - if (fixture.listOfLeds.size()) { //if more then one effect - fixture.listOfLeds[rowNr]->fadeToBlackBy(); + if (fixture.layers.size()) { //if more then one effect + fixture.layers[rowNr]->fadeToBlackBy(); char * token = strtok((char *)canvasData, ":"); bool isStart = strcmp(token, "start") == 0; @@ -541,7 +541,7 @@ class LedModEffects:public SysModule { Coord3D midCoord; //placeHolder for mid - Coord3D *newCoord = isStart? &fixture.listOfLeds[rowNr]->startPos: isEnd? &fixture.listOfLeds[rowNr]->endPos : &midCoord; + Coord3D *newCoord = isStart? &fixture.layers[rowNr]->startPos: isEnd? &fixture.layers[rowNr]->endPos : &midCoord; if (newCoord) { token = strtok(NULL, ","); @@ -553,7 +553,7 @@ class LedModEffects:public SysModule { mdl->setValue(isStart?"ledsStart":isEnd?"ledsEnd":"ledsMid", *newCoord, 0); //assuming row 0 for the moment - fixture.listOfLeds[rowNr]->triggerMapping(); + fixture.layers[rowNr]->triggerMapping(); } var.remove("canvasData"); //convasdata has been processed diff --git a/src/App/LedModFixture.h b/src/App/LedModFixture.h index 74d21d91..68cc9c75 100644 --- a/src/App/LedModFixture.h +++ b/src/App/LedModFixture.h @@ -156,8 +156,8 @@ class LedModFixture:public SysModule { eff->fixture.doAllocPins = true; //remap all leds - // for (std::vector::iterator leds=eff->fixture.listOfLeds.begin(); leds!=eff->fixture.listOfLeds.end(); ++leds) { - for (Leds *leds: eff->fixture.listOfLeds) { + // for (std::vector::iterator leds=eff->fixture.layers.begin(); leds!=eff->fixture.layers.end(); ++leds) { + for (LedsLayer *leds: eff->fixture.layers) { leds->triggerMapping(); } diff --git a/src/App/LedProjections.h b/src/App/LedProjections.h index a2f13833..17e9c1f8 100644 --- a/src/App/LedProjections.h +++ b/src/App/LedProjections.h @@ -16,7 +16,7 @@ class NoneProjection: public Projection { //uint8_t dim() {return _1D;} // every projection should work for all D const char * tags() {return "💫";} - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { } }; //NoneProjection @@ -26,7 +26,7 @@ class DefaultProjection: public Projection { public: - void setup(Leds &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted, Coord3D &mapped, uint16_t &indexV) { + void setup(LedsLayer &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted, Coord3D &mapped, uint16_t &indexV) { if (leds.size == Coord3D{0,0,0}) { adjustSizeAndPixel(leds, sizeAdjusted, pixelAdjusted, midPosAdjusted); leds.size = sizeAdjusted; @@ -35,7 +35,7 @@ class DefaultProjection: public Projection { indexV = leds.XYZUnprojected(mapped); } - void adjustSizeAndPixel(Leds &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted) { + void adjustSizeAndPixel(LedsLayer &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted) { // ppf ("Default Projection %dD -> %dD Effect Size: %d,%d,%d Pixel: %d,%d,%d ->", leds.projectionDimension, leds.effectDimension, sizeAdjusted.x, sizeAdjusted.y, sizeAdjusted.z, pixelAdjusted.x, pixelAdjusted.y, pixelAdjusted.z); switch (leds.effectDimension) { case _1D: // effectDimension 1DxD @@ -86,7 +86,7 @@ class DefaultProjection: public Projection { // ppf (" Size: %d,%d,%d Pixel: %d,%d,%d\n", sizeAdjusted.x, sizeAdjusted.y, sizeAdjusted.z, pixelAdjusted.x, pixelAdjusted.y, pixelAdjusted.z); } - void adjustMapped(Leds &leds, Coord3D &mapped, Coord3D sizeAdjusted, Coord3D pixelAdjusted, Coord3D midPosAdjusted) { + void adjustMapped(LedsLayer &leds, Coord3D &mapped, Coord3D sizeAdjusted, Coord3D pixelAdjusted, Coord3D midPosAdjusted) { switch (leds.effectDimension) { case _1D: // effectDimension 1DxD mapped.x = pixelAdjusted.distance(midPosAdjusted); @@ -136,7 +136,7 @@ class PinwheelProjection: public Projection { public: - void setup(Leds &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted, Coord3D &mapped, uint16_t &indexV) { + void setup(LedsLayer &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted, Coord3D &mapped, uint16_t &indexV) { if (leds.size == Coord3D{0,0,0}) { adjustSizeAndPixel(leds, sizeAdjusted, pixelAdjusted, midPosAdjusted); leds.size = sizeAdjusted; @@ -145,7 +145,7 @@ class PinwheelProjection: public Projection { indexV = leds.XYZUnprojected(mapped); } - void adjustSizeAndPixel(Leds &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted) { + void adjustSizeAndPixel(LedsLayer &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted) { if (leds.size != Coord3D{0,0,0}) return; // Adjust only on first call leds.projectionData.begin(); const int petals = leds.projectionData.read(); @@ -162,7 +162,7 @@ class PinwheelProjection: public Projection { } } - void adjustMapped(Leds &leds, Coord3D &mapped, Coord3D sizeAdjusted, Coord3D pixelAdjusted, Coord3D midPosAdjusted) { + void adjustMapped(LedsLayer &leds, Coord3D &mapped, Coord3D sizeAdjusted, Coord3D pixelAdjusted, Coord3D midPosAdjusted) { // factors of 360 const int FACTORS[24] = {360, 180, 120, 90, 72, 60, 45, 40, 36, 30, 24, 20, 18, 15, 12, 10, 9, 8, 6, 5, 4, 3, 2}; // UI Variables @@ -198,7 +198,7 @@ class PinwheelProjection: public Projection { // ppf("pixelAdjusted %2d,%2d,%2d -> %2d,%2d,%2d Angle: %3d Petal: %2d\n", pixelAdjusted.x, pixelAdjusted.y, pixelAdjusted.z, mapped.x, mapped.y, mapped.z, angle, value); } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { leds.projectionData.reset(); uint8_t *petals = leds.projectionData.write(60); // Initalize petal first for adjustSizeAndPixel @@ -209,13 +209,13 @@ class PinwheelProjection: public Projection { ui->initSlider(parentVar, "Swirl", swirlVal, 0, 60, false, [&leds](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case onChange: - leds.fixture->listOfLeds[rowNr]->triggerMapping(); + leds.fixture->layers[rowNr]->triggerMapping(); return true; default: return false; }}); ui->initCheckBox(parentVar, "Reverse", reverse, false, [&leds](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case onChange: - leds.fixture->listOfLeds[rowNr]->triggerMapping(); + leds.fixture->layers[rowNr]->triggerMapping(); return true; default: return false; }}); @@ -223,7 +223,7 @@ class PinwheelProjection: public Projection { if (leds.projectionDimension == _3D) { ui->initSlider(parentVar, "Z Twist", zTwist, 0, 42, false, [&leds](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case onChange: - leds.fixture->listOfLeds[rowNr]->triggerMapping(); + leds.fixture->layers[rowNr]->triggerMapping(); return true; default: return false; }}); @@ -231,14 +231,14 @@ class PinwheelProjection: public Projection { // Rotation symmetry. Uses factors of 360. ui->initSlider(parentVar, "Rotational Symmetry", symmetry, 1, 23, false, [&leds](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case onChange: - leds.fixture->listOfLeds[rowNr]->triggerMapping(); + leds.fixture->layers[rowNr]->triggerMapping(); return true; default: return false; }}); // Naming petals, arms, blades, rays? Controls virtual strip length. ui->initSlider(parentVar, "Petals", petals, 1, 60, false, [&leds](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case onChange: - leds.fixture->listOfLeds[rowNr]->triggerMapping(); + leds.fixture->layers[rowNr]->triggerMapping(); return true; default: return false; }}); @@ -251,13 +251,13 @@ class MultiplyProjection: public Projection { public: - void setup(Leds &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted, Coord3D &mapped, uint16_t &indexV) { + void setup(LedsLayer &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted, Coord3D &mapped, uint16_t &indexV) { adjustSizeAndPixel(leds, sizeAdjusted, pixelAdjusted, midPosAdjusted); DefaultProjection dp; dp.setup(leds, sizeAdjusted, pixelAdjusted, midPosAdjusted, mapped, indexV); } - void adjustSizeAndPixel(Leds &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted) { + void adjustSizeAndPixel(LedsLayer &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted) { // UI Variables leds.projectionData.begin(); Coord3D proMulti = leds.projectionData.read(); @@ -279,22 +279,22 @@ class MultiplyProjection: public Projection { else pixelAdjusted = pixelAdjusted % sizeAdjusted; } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { leds.projectionData.reset(); Coord3D *proMulti = leds.projectionData.write({2,2,1}); bool *mirror = leds.projectionData.write(false); ui->initCoord3D(parentVar, "proMulti", proMulti, 0, 10, false, [&leds](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case onChange: - if (rowNr < leds.fixture->listOfLeds.size()) { - leds.fixture->listOfLeds[rowNr]->triggerMapping(); + if (rowNr < leds.fixture->layers.size()) { + leds.fixture->layers[rowNr]->triggerMapping(); } return true; default: return false; }}); ui->initCheckBox(parentVar, "mirror", mirror, false, [&leds](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case onChange: - if (rowNr < leds.fixture->listOfLeds.size()) { - leds.fixture->listOfLeds[rowNr]->triggerMapping(); + if (rowNr < leds.fixture->layers.size()) { + leds.fixture->layers[rowNr]->triggerMapping(); } return true; default: return false; @@ -308,12 +308,12 @@ class TiltPanRollProjection: public Projection { public: - void setup(Leds &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted, Coord3D &mapped, uint16_t &indexV) { + void setup(LedsLayer &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted, Coord3D &mapped, uint16_t &indexV) { DefaultProjection dp; dp.setup(leds, sizeAdjusted, pixelAdjusted, midPosAdjusted, mapped, indexV); } - void adjustXYZ(Leds &leds, Coord3D &pixel) { + void adjustXYZ(LedsLayer &leds, Coord3D &pixel) { #ifdef STARBASE_USERMOD_MPU6050 if (leds.proGyro) { pixel = trigoTiltPanRoll.tilt(pixel, leds.size/2, mpu6050->gyro.x); @@ -330,28 +330,28 @@ class TiltPanRollProjection: public Projection { } } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { //tbd: implement variable by reference for rowNrs #ifdef STARBASE_USERMOD_MPU6050 ui->initCheckBox(parentVar, "proGyro", false, false, [&leds](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case onChange: - if (rowNr < leds.fixture->listOfLeds.size()) - leds.fixture->listOfLeds[rowNr]->proGyro = mdl->getValue(var, rowNr); + if (rowNr < leds.fixture->layers.size()) + leds.fixture->layers[rowNr]->proGyro = mdl->getValue(var, rowNr); return true; default: return false; }}); #endif ui->initSlider(parentVar, "proTilt", 128, 0, 254, false, [&leds](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case onChange: - if (rowNr < leds.fixture->listOfLeds.size()) - leds.fixture->listOfLeds[rowNr]->proTiltSpeed = mdl->getValue(var, rowNr); + if (rowNr < leds.fixture->layers.size()) + leds.fixture->layers[rowNr]->proTiltSpeed = mdl->getValue(var, rowNr); return true; default: return false; }}); ui->initSlider(parentVar, "proPan", 128, 0, 254, false, [&leds](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case onChange: - if (rowNr < leds.fixture->listOfLeds.size()) - leds.fixture->listOfLeds[rowNr]->proPanSpeed = mdl->getValue(var, rowNr); + if (rowNr < leds.fixture->layers.size()) + leds.fixture->layers[rowNr]->proPanSpeed = mdl->getValue(var, rowNr); return true; default: return false; }}); @@ -360,8 +360,8 @@ class TiltPanRollProjection: public Projection { ui->setLabel(var, "Roll speed"); return true; case onChange: - if (rowNr < leds.fixture->listOfLeds.size()) - leds.fixture->listOfLeds[rowNr]->proRollSpeed = mdl->getValue(var, rowNr); + if (rowNr < leds.fixture->layers.size()) + leds.fixture->layers[rowNr]->proRollSpeed = mdl->getValue(var, rowNr); return true; default: return false; }}); @@ -374,13 +374,13 @@ class DistanceFromPointProjection: public Projection { public: - void setup(Leds &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted, Coord3D &mapped, uint16_t &indexV) { + void setup(LedsLayer &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted, Coord3D &mapped, uint16_t &indexV) { DefaultProjection dp; dp.setup(leds, sizeAdjusted, pixelAdjusted, midPosAdjusted, mapped, indexV); if (leds.projectionDimension == _2D && leds.effectDimension == _2D) postProcessing(leds, indexV); } - void postProcessing(Leds &leds, uint16_t &indexV) { + void postProcessing(LedsLayer &leds, uint16_t &indexV) { //2D2D: inverse mapping Trigo trigo(leds.size.x-1); // 8 bits trigo with period leds.size.x-1 (currentl Float trigo as same performance) float minDistance = 10; @@ -427,23 +427,23 @@ class Preset1Projection: public Projection { const char * name() {return "Preset1";} const char * tags() {return "💫";} - void setup(Leds &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted, Coord3D &mapped, uint16_t &indexV) { + void setup(LedsLayer &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted, Coord3D &mapped, uint16_t &indexV) { adjustSizeAndPixel(leds, sizeAdjusted, pixelAdjusted, midPosAdjusted); DefaultProjection dp; dp.setup(leds, sizeAdjusted, pixelAdjusted, midPosAdjusted, mapped, indexV); } - void adjustSizeAndPixel(Leds &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted) { + void adjustSizeAndPixel(LedsLayer &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted) { MultiplyProjection mp; mp.adjustSizeAndPixel(leds, sizeAdjusted, pixelAdjusted, midPosAdjusted); } - void adjustXYZ(Leds &leds, Coord3D &pixel) { + void adjustXYZ(LedsLayer &leds, Coord3D &pixel) { TiltPanRollProjection tp; tp.adjustXYZ(leds, pixel); } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { MultiplyProjection mp; mp.controls(leds, parentVar); TiltPanRollProjection tp; @@ -455,7 +455,7 @@ class RandomProjection: public Projection { const char * name() {return "Random";} const char * tags() {return "💫";} - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { } }; //RandomProjection @@ -465,13 +465,13 @@ class ReverseProjection: public Projection { public: - void setup(Leds &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted, Coord3D &mapped, uint16_t &indexV) { + void setup(LedsLayer &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted, Coord3D &mapped, uint16_t &indexV) { adjustSizeAndPixel(leds, sizeAdjusted, pixelAdjusted, midPosAdjusted); DefaultProjection dp; dp.setup(leds, sizeAdjusted, pixelAdjusted, midPosAdjusted, mapped, indexV); } - void adjustSizeAndPixel(Leds &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted) { + void adjustSizeAndPixel(LedsLayer &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted) { // UI Variables leds.projectionData.begin(); bool reverseX = leds.projectionData.read(); @@ -483,7 +483,7 @@ class ReverseProjection: public Projection { if (reverseZ) pixelAdjusted.z = sizeAdjusted.z - pixelAdjusted.z - 1; } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { leds.projectionData.reset(); bool *reverseX = leds.projectionData.write(false); bool *reverseY = leds.projectionData.write(false); @@ -491,14 +491,14 @@ class ReverseProjection: public Projection { ui->initCheckBox(parentVar, "reverse X", reverseX, false, [&leds](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case onChange: - leds.fixture->listOfLeds[rowNr]->triggerMapping(); + leds.fixture->layers[rowNr]->triggerMapping(); return true; default: return false; }}); if (leds.effectDimension >= _2D || leds.projectionDimension >= _2D) { ui->initCheckBox(parentVar, "reverse Y", reverseY, false, [&leds](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case onChange: - leds.fixture->listOfLeds[rowNr]->triggerMapping(); + leds.fixture->layers[rowNr]->triggerMapping(); return true; default: return false; }}); @@ -506,7 +506,7 @@ class ReverseProjection: public Projection { if (leds.effectDimension == _3D || leds.projectionDimension == _3D) { ui->initCheckBox(parentVar, "reverse Z", reverseZ, false, [&leds](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case onChange: - leds.fixture->listOfLeds[rowNr]->triggerMapping(); + leds.fixture->layers[rowNr]->triggerMapping(); return true; default: return false; }}); @@ -520,13 +520,13 @@ class MirrorProjection: public Projection { public: - void setup(Leds &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted, Coord3D &mapped, uint16_t &indexV) { + void setup(LedsLayer &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted, Coord3D &mapped, uint16_t &indexV) { adjustSizeAndPixel(leds, sizeAdjusted, pixelAdjusted, midPosAdjusted); DefaultProjection dp; dp.setup(leds, sizeAdjusted, pixelAdjusted, midPosAdjusted, mapped, indexV); } - void adjustSizeAndPixel(Leds &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted) { + void adjustSizeAndPixel(LedsLayer &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted) { // UI Variables leds.projectionData.begin(); bool mirrorX = leds.projectionData.read(); @@ -547,21 +547,21 @@ class MirrorProjection: public Projection { } } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { leds.projectionData.reset(); bool *mirrorX = leds.projectionData.write(false); bool *mirrorY = leds.projectionData.write(false); bool *mirrorZ = leds.projectionData.write(false); ui->initCheckBox(parentVar, "mirror X", mirrorX, false, [&leds](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case onChange: - leds.fixture->listOfLeds[rowNr]->triggerMapping(); + leds.fixture->layers[rowNr]->triggerMapping(); return true; default: return false; }}); if (leds.projectionDimension >= _2D) { ui->initCheckBox(parentVar, "mirror Y", mirrorY, false, [&leds](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case onChange: - leds.fixture->listOfLeds[rowNr]->triggerMapping(); + leds.fixture->layers[rowNr]->triggerMapping(); return true; default: return false; }}); @@ -569,7 +569,7 @@ class MirrorProjection: public Projection { if (leds.projectionDimension == _3D) { ui->initCheckBox(parentVar, "mirror Z", mirrorZ, false, [&leds](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case onChange: - leds.fixture->listOfLeds[rowNr]->triggerMapping(); + leds.fixture->layers[rowNr]->triggerMapping(); return true; default: return false; }}); @@ -583,13 +583,13 @@ class GroupingProjection: public Projection { public: - void setup(Leds &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted, Coord3D &mapped, uint16_t &indexV) { + void setup(LedsLayer &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted, Coord3D &mapped, uint16_t &indexV) { adjustSizeAndPixel(leds, sizeAdjusted, pixelAdjusted, midPosAdjusted); DefaultProjection dp; dp.setup(leds, sizeAdjusted, pixelAdjusted, midPosAdjusted, mapped, indexV); } - void adjustSizeAndPixel(Leds &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted) { + void adjustSizeAndPixel(LedsLayer &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted) { // UI Variables leds.projectionData.begin(); Coord3D grouping = leds.projectionData.read(); @@ -602,12 +602,12 @@ class GroupingProjection: public Projection { sizeAdjusted = (sizeAdjusted + grouping - Coord3D{1,1,1}) / grouping; // round up } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { leds.projectionData.reset(); Coord3D *grouping = leds.projectionData.write({1,1,1}); ui->initCoord3D(parentVar, "Grouping", grouping, 0, 100, false, [&leds](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case onChange: - leds.fixture->listOfLeds[rowNr]->triggerMapping(); + leds.fixture->layers[rowNr]->triggerMapping(); return true; default: return false; }}); @@ -618,7 +618,7 @@ class SpacingProjection: public Projection { const char * name() {return "Spacing WIP";} const char * tags() {return "💡";} - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { } }; //SpacingProjection @@ -628,13 +628,13 @@ class TransposeProjection: public Projection { public: - void setup(Leds &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted, Coord3D &mapped, uint16_t &indexV) { + void setup(LedsLayer &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted, Coord3D &mapped, uint16_t &indexV) { adjustSizeAndPixel(leds, sizeAdjusted, pixelAdjusted, midPosAdjusted); DefaultProjection dp; dp.setup(leds, sizeAdjusted, pixelAdjusted, midPosAdjusted, mapped, indexV); } - void adjustSizeAndPixel(Leds &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted) { + void adjustSizeAndPixel(LedsLayer &leds, Coord3D &sizeAdjusted, Coord3D &pixelAdjusted, Coord3D &midPosAdjusted) { // UI Variables leds.projectionData.begin(); bool transposeXY = leds.projectionData.read(); @@ -646,7 +646,7 @@ class TransposeProjection: public Projection { if (transposeYZ) { int temp = pixelAdjusted.y; pixelAdjusted.y = pixelAdjusted.z; pixelAdjusted.z = temp; } } - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { leds.projectionData.reset(); bool *transposeXY = leds.projectionData.write(false); bool *transposeXZ = leds.projectionData.write(false); @@ -654,20 +654,20 @@ class TransposeProjection: public Projection { ui->initCheckBox(parentVar, "transpose XY", transposeXY, false, [&leds](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case onChange: - leds.fixture->listOfLeds[rowNr]->triggerMapping(); + leds.fixture->layers[rowNr]->triggerMapping(); return true; default: return false; }}); if (leds.effectDimension == _3D) { ui->initCheckBox(parentVar, "transpose XZ", transposeXZ, false, [&leds](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case onChange: - leds.fixture->listOfLeds[rowNr]->triggerMapping(); + leds.fixture->layers[rowNr]->triggerMapping(); return true; default: return false; }}); ui->initCheckBox(parentVar, "transpose YZ", transposeYZ, false, [&leds](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun case onChange: - leds.fixture->listOfLeds[rowNr]->triggerMapping(); + leds.fixture->layers[rowNr]->triggerMapping(); return true; default: return false; }}); @@ -679,7 +679,7 @@ class KaleidoscopeProjection: public Projection { const char * name() {return "Kaleidoscope WIP";} const char * tags() {return "💫";} - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { } }; //KaleidoscopeProjection @@ -687,6 +687,6 @@ class TestProjection: public Projection { const char * name() {return "Test";} const char * tags() {return "💡";} - void controls(Leds &leds, JsonObject parentVar) { + void controls(LedsLayer &leds, JsonObject parentVar) { } }; //TestProjection \ No newline at end of file diff --git a/src/User/UserModLive.h b/src/User/UserModLive.h index 768dfa03..cff16017 100644 --- a/src/User/UserModLive.h +++ b/src/User/UserModLive.h @@ -81,7 +81,7 @@ static float _sin(float j) {return sin(j);} //LEDS specific static CRGB POSV(uint8_t h, uint8_t s, uint8_t v) {return CHSV(h, s, v);} static uint8_t _sin8(uint8_t a) {return sin8(a);} -static Leds *gLeds = nullptr; +static LedsLayer *gLeds = nullptr; static void sPCLive(uint16_t pixel, CRGB color) { // if (pixel == 0) ppf("."); // if (pixel < 10) @@ -172,8 +172,8 @@ class UserModLive:public SysModule { addExternalFun("uint8_t", "sin8","(uint8_t a1)",(void*)_sin8); //using int here causes value must be between 0 and 16 error!!! addExternalFun("void", "sPC", "(int a1, CRGB a2)", (void *)sPCLive); //address of overloaded function with no contextual type information: setPixelColorLive - //ISO C++ forbids taking the address of a bound member function to form a pointer to member function. Say '&Leds::setPixelColorLive' [-fpermissive] - //converting from 'void (Leds::*)(uint16_t, uint32_t)' {aka 'void (Leds::*)(short unsigned int, unsigned int)'} to 'void*' [-Wpmf-conversions] + //ISO C++ forbids taking the address of a bound member function to form a pointer to member function. Say '&LedsLayer::setPixelColorLive' [-fpermissive] + //converting from 'void (LedsLayer::*)(uint16_t, uint32_t)' {aka 'void (LedsLayer::*)(short unsigned int, unsigned int)'} to 'void*' [-Wpmf-conversions] //End LEDS specific