From 7d6d9eddc4ed79752269dab415fa7799e7ba15db Mon Sep 17 00:00:00 2001 From: cschwinne Date: Wed, 6 Oct 2021 14:30:41 +0200 Subject: [PATCH] Change virtual bus type range --- wled00/bus_manager.h | 13 ++++++------ wled00/const.h | 24 ++++++++++++--------- wled00/data/settings_leds.htm | 40 +++++++++++++++++------------------ wled00/html_settings.h | 6 +++--- wled00/udp.cpp | 2 +- wled00/xml.cpp | 4 ++-- 6 files changed, 46 insertions(+), 43 deletions(-) diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index 035e1225..380959c1 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -37,7 +37,7 @@ struct BusConfig { type = busType; count = len; start = pstart; colorOrder = pcolorOrder; reversed = rev; skipAmount = skip; uint8_t nPins = 1; - if (type >= 10 && type <= 15) nPins = 4; //virtual network bus. 4 "pins" store IP address + if (type >= TYPE_NET_DDP_RGB && type < 96) nPins = 4; //virtual network bus. 4 "pins" store IP address else if (type > 47) nPins = 2; else if (type > 40 && type < 46) nPins = NUM_PWM_PINS(type); for (uint8_t i = 0; i < nPins; i++) pins[i] = ppins[i]; @@ -150,7 +150,7 @@ class BusDigital : public Bus { _busPtr = PolyBus::create(_iType, _pins, _len, nr); _valid = (_busPtr != nullptr); _colorOrder = bc.colorOrder; - DEBUG_PRINTF("Successfully inited strip %u (len %u) with type %u and pins %u,%u (itype %u)\n",nr, len, type, pins[0],pins[1],_iType); + DEBUG_PRINTF("Successfully inited strip %u (len %u) with type %u and pins %u,%u (itype %u)\n",nr, _len, bc.type, _pins[0],_pins[1],_iType); }; inline void show() { @@ -319,6 +319,7 @@ class BusPwm : public Bus { } uint8_t getPins(uint8_t* pinArray) { + if (!_valid) return 0; uint8_t numPins = NUM_PWM_PINS(_type); for (uint8_t i = 0; i < numPins; i++) pinArray[i] = _pins[i]; return numPins; @@ -389,7 +390,7 @@ class BusNetwork : public Bus { if (_data == nullptr) return; memset(_data, 0, bc.count * _UDPchannels); _len = bc.count; - _colorOrder = bc.colorOrder; + //_colorOrder = bc.colorOrder; _client = IPAddress(bc.pins[0],bc.pins[1],bc.pins[2],bc.pins[3]); _broadcastLock = false; _valid = true; @@ -460,7 +461,7 @@ class BusNetwork : public Bus { private: IPAddress _client; uint16_t _len = 0; - uint8_t _colorOrder; + //uint8_t _colorOrder; uint8_t _bri = 255; uint8_t _UDPtype; uint8_t _UDPchannels; @@ -480,7 +481,7 @@ class BusManager { static uint32_t memUsage(BusConfig &bc) { uint8_t type = bc.type; uint16_t len = bc.count; - if (type > 15 && type < 32) { + if (type < 32) { #ifdef ESP8266 if (bc.pins[0] == 3) { //8266 DMA uses 5x the mem if (type > 29) return len*20; //RGBW @@ -500,7 +501,7 @@ class BusManager { int add(BusConfig &bc) { if (numBusses >= WLED_MAX_BUSSES) return -1; - if (bc.type>=10 && bc.type<=15) { + if (bc.type >= TYPE_NET_DDP_RGB && bc.type < 96) { busses[numBusses] = new BusNetwork(bc); } else if (IS_DIGITAL(bc.type)) { busses[numBusses] = new BusDigital(bc, numBusses); diff --git a/wled00/const.h b/wled00/const.h index ef9f085a..56bd7233 100644 --- a/wled00/const.h +++ b/wled00/const.h @@ -112,20 +112,20 @@ #define DMX_MODE_MULTIPLE_DRGB 5 //every LED is addressed with its own RGB and share a master dimmer (ledCount * 3 + 1 channels) #define DMX_MODE_MULTIPLE_RGBW 6 //every LED is addressed with its own RGBW (ledCount * 4 channels) -//Light capability byte (unused) 0bRRCCTTTT +//Light capability byte (unused) 0bRCCCTTTT //bits 0/1/2/3: specifies a type of LED driver. A single "driver" may have different chip models but must have the same protocol/behavior -//bits 4/5: specifies the class of LED driver - 0b00 (dec. 0-15) unconfigured/reserved -// - 0b01 (dec. 16-31) digital (data pin only) -// - 0b10 (dec. 32-47) analog (PWM) -// - 0b11 (dec. 48-63) digital (data + clock / SPI) -//bits 6/7 are reserved and set to 0b00 +//bits 4/5/6: specifies the class of LED driver - 0b000 (dec. 0-15) unconfigured/reserved +// - 0b001 (dec. 16-31) digital (data pin only) +// - 0b010 (dec. 32-47) analog (PWM) +// - 0b011 (dec. 48-63) digital (data + clock / SPI) +// - 0b100 (dec. 64-79) unused/reserved +// - 0b101 (dec. 80-95) digital (data + clock / SPI) +// - 0b110 (dec. 96-111) unused/reserved +// - 0b111 (dec. 112-127) unused/reserved +//bit 7 is reserved and set to 0 #define TYPE_NONE 0 //light is not configured #define TYPE_RESERVED 1 //unused. Might indicate a "virtual" light -//network types (master broadcast) (10-15) -#define TYPE_NET_DDP_RGB 10 //network DDP RGB bus (master broadcast bus) -#define TYPE_NET_E131_RGB 11 //network E131 RGB bus (master broadcast bus) -#define TYPE_NET_ARTNET_RGB 12 //network ArtNet RGB bus (master broadcast bus) //Digital types (data pin only) (16-31) #define TYPE_WS2812_1CH 20 //white-only chips #define TYPE_WS2812_WWA 21 //amber + warm + cold white @@ -146,6 +146,10 @@ #define TYPE_APA102 51 #define TYPE_LPD8806 52 #define TYPE_P9813 53 +//Network types (master broadcast) (80-95) +#define TYPE_NET_DDP_RGB 80 //network DDP RGB bus (master broadcast bus) +#define TYPE_NET_E131_RGB 81 //network E131 RGB bus (master broadcast bus) +#define TYPE_NET_ARTNET_RGB 82 //network ArtNet RGB bus (master broadcast bus) #define IS_DIGITAL(t) ((t) & 0x10) //digital are 16-31 and 48-63 #define IS_PWM(t) ((t) > 40 && (t) < 46) diff --git a/wled00/data/settings_leds.htm b/wled00/data/settings_leds.htm index 6b8f86f6..bbcfc88d 100644 --- a/wled00/data/settings_leds.htm +++ b/wled00/data/settings_leds.htm @@ -40,7 +40,7 @@ if (nm=="L0" || nm=="L1" || nm=="L2" || nm=="L3") { var n = LCs[i].name.substring(2); var t = parseInt(d.getElementsByName("LT"+n)[0].value, 10); // LED type SELECT - if (t<16) continue; + if (t>=80) continue; } //check for pin conflicts if (nm=="L0" || nm=="L1" || nm=="L2" || nm=="L3" || nm=="L4" || nm=="RL" || nm=="BT" || nm=="IR") @@ -105,7 +105,7 @@ } //returns mem usage function getMem(t, len, p0) { - if (t > 15 && t < 32) { + if (t < 32) { if (maxM < 10000 && p0==3) { //8266 DMA uses 5x the mem if (t > 29) return len*20; //RGBW return len*15; @@ -137,8 +137,8 @@ if (s[i].name.substring(0,2)=="LT") { var n = s[i].name.substring(2); var t = parseInt(s[i].value,10); - gId("p0d"+n).innerHTML = (t>=10 && t<=15) ? "IP address:" : (t > 49) ? "Data GPIO:" : (t >41) ? "GPIOs:" : "GPIO:"; - gId("p1d"+n).innerHTML = (t > 49) ? "Clk GPIO:" : ""; + gId("p0d"+n).innerHTML = (t>=80 && t<96) ? "IP address:" : (t > 49) ? "Data GPIO:" : (t >41) ? "GPIOs:" : "GPIO:"; + gId("p1d"+n).innerHTML = (t> 49 && t<64) ? "Clk GPIO:" : ""; var LK = d.getElementsByName("L1"+n)[0]; // clock pin memu += getMem(t, d.getElementsByName("LC"+n)[0].value, d.getElementsByName("L0"+n)[0].value); // calc memory @@ -147,7 +147,7 @@ for (p=1; p<5; p++) { var LK = d.getElementsByName("L"+p+n)[0]; // secondary pins if (!LK) continue; - if (((t>=10 && t<=15) && p<4) || (t>49 && p==1) || (t>41 && t < 50 && (p+40 < t))) // TYPE_xxxx values from const.h + if (((t>=80 && t<96) && p<4) || (t>49 && p==1) || (t>41 && t < 50 && (p+40 < t))) // TYPE_xxxx values from const.h { // display pin field LK.style.display = "inline"; @@ -163,10 +163,10 @@ if (t > 31 && t < 48) d.getElementsByName("LC"+n)[0].value = 1; // for sanity change analog count just to 1 LED } isRGBW |= (t == 30 || t == 31 || (t > 40 && t < 46 && t != 43)); // RGBW checkbox, TYPE_xxxx values from const.h - gId("co"+n).style.display = (t<16 || t == 41 || t == 42) ? "none":"inline"; // hide color order for PWM W & WW/CW + gId("co"+n).style.display = ((t>=80 && t<96) || t == 41 || t == 42) ? "none":"inline"; // hide color order for PWM W & WW/CW gId("dig"+n+"c").style.display = (t > 40 && t < 48) ? "none":"inline"; // hide count for analog - gId("dig"+n+"r").style.display = (t<16) ? "none":"inline"; // hide reversed for virtual - gId("dig"+n+"s").style.display = (t<16 || (t > 40 && t < 48)) ? "none":"inline"; // hide skip 1st for virtual & analog + gId("dig"+n+"r").style.display = (t>=80 && t<96) ? "none":"inline"; // hide reversed for virtual + gId("dig"+n+"s").style.display = ((t>=80 && t<96) || (t > 40 && t < 48)) ? "none":"inline"; // hide skip 1st for virtual & analog gId("rev"+n).innerHTML = (t > 40 && t < 48) ? "Inverted output":"Reversed (rotated 180°)"; // change reverse text for analog gId("psd"+n).innerHTML = (t > 40 && t < 48) ? "Index:":"Start:"; // change analog start description } @@ -193,7 +193,7 @@ if (s+c > sLC) sLC = s+c; if(c>maxLC)maxLC=c; var t = parseInt(d.getElementsByName("LT"+n)[0].value); // LED type SELECT - if (t>16) sPC+=c; //virtual out busses do not count towards physical LEDs + if (t<80) sPC+=c; //virtual out busses do not count towards physical LEDs } // increase led count continue; } @@ -205,7 +205,7 @@ // ignore IP address (stored in pins for virtual busses) if (nm=="L0" || nm=="L1" || nm=="L2" || nm=="L3") { var t = parseInt(d.getElementsByName("LT"+n)[0].value); // LED type SELECT - if (t<16) { + if (t>=80) { LCs[i].max = 255; LCs[i].min = 0; continue; // do not check conflicts @@ -226,7 +226,7 @@ if (n2.substring(0,1)==="L") { var m = LCs[j].name.substring(2); var t2 = parseInt(d.getElementsByName("LT"+m)[0].value, 10); - if (t2<16) continue; + if (t2>=80) continue; } if (LCs[j].value!="" && LCs[j].value!="-1") p.push(parseInt(LCs[j].value,10)); // add current pin } @@ -278,10 +278,8 @@ if (isNaN(v)) return 0; return v; } - function addLEDs(n) + function addLEDs(n,init=true) { - if (n>1) {maxB=n; gId("+").style.display="inline"; return;} - var o = d.getElementsByClassName("iST"); var i = o.length; @@ -307,9 +305,9 @@ ${i+1}: - - - + + +  
Color Order: