diff --git a/platformio.ini b/platformio.ini index ca3fc3aed..c9c8291de 100644 --- a/platformio.ini +++ b/platformio.ini @@ -53,13 +53,14 @@ extra_configs = arduino_core_2_6_3 = espressif8266@2.3.3 arduino_core_2_7_4 = espressif8266@2.6.2 arduino_core_3_0_0 = espressif8266@3.0.0 +arduino_core_3_2_0 = espressif8266@3.2.0 # Development platforms arduino_core_develop = https://github.com/platformio/platform-espressif8266#develop arduino_core_git = https://github.com/platformio/platform-espressif8266#feature/stage # Platform to use for ESP8266 -platform_wled_default = ${common.arduino_core_2_7_4} +platform_wled_default = ${common.arduino_core_3_2_0} # We use 2.7.4.7 for all, includes PWM flicker fix and Wstring optimization platform_packages = tasmota/framework-arduinoespressif8266 @ 3.20704.7 platformio/toolchain-xtensa @ ~2.40802.200502 diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index f607a0015..015e07921 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -10,6 +10,20 @@ #include "bus_wrapper.h" #include +// enable additional debug output +#ifdef WLED_DEBUG + #ifndef ESP8266 + #include + #endif + #define DEBUG_PRINT(x) Serial.print(x) + #define DEBUG_PRINTLN(x) Serial.println(x) + #define DEBUG_PRINTF(x...) Serial.printf(x) +#else + #define DEBUG_PRINT(x) + #define DEBUG_PRINTLN(x) + #define DEBUG_PRINTF(x...) +#endif + #define GET_BIT(var,bit) (((var)>>(bit))&0x01) #define SET_BIT(var,bit) ((var)|=(uint16_t)(0x0001<<(bit))) #define UNSET_BIT(var,bit) ((var)&=(~(uint16_t)(0x0001<<(bit)))) @@ -29,7 +43,8 @@ struct BusConfig { type = busType & 0x7F; // bit 7 may be/is hacked to include RGBW info (1=RGBW, 0=RGB) count = len; start = pstart; colorOrder = pcolorOrder; reversed = rev; skipAmount = skip; uint8_t nPins = 1; - if (type > 47) nPins = 2; + if (type >= 10 || type <= 15) nPins = 4; + 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]; } @@ -353,6 +368,103 @@ class BusPwm : public Bus { } }; + +class BusNetwork : public Bus { + public: + BusNetwork(BusConfig &bc) : Bus(bc.type, bc.start) { + _valid = false; + _data = (byte *)malloc(bc.count * (_rgbw ? 4 : 3)); + if (_data == nullptr) return; + memset(_data, 0, bc.count * (_rgbw ? 4 : 3)); + _len = bc.count; + _rgbw = false; + //_rgbw = bc.rgbwOverride; // RGBW override in bit 7 or can have a special type + _colorOrder = bc.colorOrder; + _client = IPAddress(bc.pins[0],bc.pins[1],bc.pins[2],bc.pins[3]); + _broadcastLock = false; + _valid = true; + }; + + void setPixelColor(uint16_t pix, uint32_t c) { + if (!_valid || pix >= _len) return; + uint16_t offset = pix*(_rgbw?4:3); + _data[offset] = 0xFF & (c >> 16); + _data[offset+1] = 0xFF & (c >> 8); + _data[offset+2] = 0xFF & (c ); + if (_rgbw) _data[offset+3] = 0xFF & (c >> 24); + } + + uint32_t getPixelColor(uint16_t pix) { + if (!_valid || pix >= _len) return 0; + uint16_t offset = pix*(_rgbw?4:3); + return ((_rgbw?(_data[offset+3] << 24):0) | (_data[offset] << 16) | (_data[offset+1] << 8) | (_data[offset+2])); + } + + void show() { + uint8_t type; + if (!_valid || _broadcastLock) return; + _broadcastLock = true; + switch (_type) { + case TYPE_NET_ARTNET_RGB: type = 2; break; + case TYPE_NET_E131_RGB: type = 1; break; + case TYPE_NET_DDP_RGB: + default: type = 0; break; + } + realtimeBroadcast(type, _client, _len, _data, _rgbw); + _broadcastLock = false; + } + + inline bool canShow() { + return !_broadcastLock; + } + + inline void setBrightness(uint8_t b) { + // not sure if this is correctly implemented + for (uint16_t pix=0; pix<_len; pix++) { + uint16_t offset = pix*(_rgbw?4:3); + _data[offset ] = scale8(_data[offset ], b); + _data[offset+1] = scale8(_data[offset+1], b); + _data[offset+2] = scale8(_data[offset+2], b); + if (_rgbw) _data[offset+3] = scale8(_data[offset+3], b); + } + } + + uint8_t getPins(uint8_t* pinArray) { + for (uint8_t i = 0; i < 4; i++) { + pinArray[i] = _client[i]; + } + return 4; + } + + inline bool isRgbw() { + return _rgbw; + } + + inline uint16_t getLength() { + return _len; + } + + void cleanup() { + _type = I_NONE; + _valid = false; + if (_data != nullptr) free(_data); + _data = nullptr; + } + + ~BusNetwork() { + cleanup(); + } + + private: + IPAddress _client; + uint16_t _len = 0; + uint8_t _colorOrder; + bool _rgbw; + bool _broadcastLock; + byte* _data; +}; + + class BusManager { public: BusManager() { @@ -363,7 +475,7 @@ class BusManager { static uint32_t memUsage(BusConfig &bc) { uint8_t type = bc.type; uint16_t len = bc.count; - if (type < 32) { + if (type > 15 && type < 32) { #ifdef ESP8266 if (bc.pins[0] == 3) { //8266 DMA uses 5x the mem if (type > 29) return len*20; //RGBW @@ -379,12 +491,14 @@ class BusManager { if (type > 31 && type < 48) return 5; if (type == 44 || type == 45) return len*4; //RGBW - return len*3; + return len*3; //RGB } int add(BusConfig &bc) { if (numBusses >= WLED_MAX_BUSSES) return -1; - if (IS_DIGITAL(bc.type)) { + if (bc.type>=10 && bc.type<=15) { + busses[numBusses] = new BusNetwork(bc); + } else if (IS_DIGITAL(bc.type)) { busses[numBusses] = new BusDigital(bc, numBusses); } else { busses[numBusses] = new BusPwm(bc); diff --git a/wled00/const.h b/wled00/const.h index db63b7c4a..eb3edd1b0 100644 --- a/wled00/const.h +++ b/wled00/const.h @@ -122,6 +122,10 @@ #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 diff --git a/wled00/data/index.css b/wled00/data/index.css index 150472dc5..0902a9b5e 100644 --- a/wled00/data/index.css +++ b/wled00/data/index.css @@ -419,11 +419,11 @@ button { overflow: auto; } -#info { +#info, #nodes { z-index: 3; } -#rover, #nodes { +#rover { z-index: 2; } diff --git a/wled00/data/settings_leds.htm b/wled00/data/settings_leds.htm index 3ba144c4d..95ac482f4 100644 --- a/wled00/data/settings_leds.htm +++ b/wled00/data/settings_leds.htm @@ -1,459 +1,501 @@ - - - - - - LED Settings - - - - -
-
-
-
-
-

LED & Hardware setup

- Total LED count:
- Recommended power supply for brightest white:
- ?
-
-
- Enable automatic brightness limiter:
-
- Maximum Current: mA
- - Automatically limits brightness to stay close to the limit.
- Keep at <1A if powering LEDs directly from the ESP 5V pin!
- If you are using an external power supply, enter its rating.
- (Current estimated usage: unknown)


- LED voltage (Max. current for a single LED):
-
- - Keep at default if you are unsure about your type of LEDs.
-
-

Hardware setup

-
LED outputs:
- -
- LED Memory Usage: 0 / ? B
-

- - Make a segment for each output:
-
-
- Touch threshold:
- IR GPIO:  ×
- -
- IR info
- Relay GPIO: invert  ×
-
-

Defaults

- Turn LEDs on after power up/reset:
- Default brightness: (0-255)

- Apply preset at boot (0 uses defaults) -

- Use Gamma correction for color: (strongly recommended)
- Use Gamma correction for brightness: (not recommended)

- Brightness factor: % -

Transitions

- Crossfade:
- Transition Time: ms
- Enable Palette transitions: -

Timed light

- Default Duration: min
- Default Target brightness:
- Mode: - -

Advanced

- Palette blending: -
- - Auto-calculate white channel from RGB:
- -

- -
- - + + + + + + LED Settings + + + + +
+
+
+
+
+

LED & Hardware setup

+ Total LED count:
+ Recommended power supply for brightest white:
+ ?
+
+
+ Enable automatic brightness limiter:
+
+ Maximum Current: mA
+ + Automatically limits brightness to stay close to the limit.
+ Keep at <1A if powering LEDs directly from the ESP 5V pin!
+ If you are using an external power supply, enter its rating.
+ (Current estimated usage: unknown)


+ LED voltage (Max. current for a single LED):
+
+ + Keep at default if you are unsure about your type of LEDs.
+
+

Hardware setup

+
LED outputs:
+
+ +
+ LED Memory Usage: 0 / ? B
+

+ +
+ Create a segment for each output:
+
+
+ Touch threshold:
+ IR GPIO:  ×
+ +
+ IR info
+ Relay GPIO: invert  ×
+
+

Defaults

+ Turn LEDs on after power up/reset:
+ Default brightness: (0-255)

+ Apply preset at boot (0 uses defaults) +

+ Use Gamma correction for color: (strongly recommended)
+ Use Gamma correction for brightness: (not recommended)

+ Brightness factor: % +

Transitions

+ Crossfade:
+ Transition Time: ms
+ Enable Palette transitions: +

Timed light

+ Default Duration: min
+ Default Target brightness:
+ Mode: + +

Advanced

+ Palette blending: +
+ + Auto-calculate white channel from RGB:
+ +

+ +
+ + diff --git a/wled00/fcn_declare.h b/wled00/fcn_declare.h index 06f80cfc8..2a065b1f5 100644 --- a/wled00/fcn_declare.h +++ b/wled00/fcn_declare.h @@ -197,6 +197,7 @@ bool updateVal(const String* req, const char* key, byte* val, byte minv=0, byte //udp.cpp void notify(byte callMode, bool followUp=false); +uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, byte *buffer, bool isRGBW=false); void realtimeLock(uint32_t timeoutMs, byte md = REALTIME_MODE_GENERIC); void handleNotifications(); void setRealtimePixel(uint16_t i, byte r, byte g, byte b, byte w); diff --git a/wled00/html_settings.h b/wled00/html_settings.h index de50889a3..48e293e84 100644 --- a/wled00/html_settings.h +++ b/wled00/html_settings.h @@ -77,15 +77,15 @@ onclick="B()">Back // Autogenerated from wled00/data/settings_leds.htm, do not edit!! const char PAGE_settings_leds[] PROGMEM = R"=====(LED Settings