Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch LED types from Bus classes (dynamic UI) #4129

Merged
merged 29 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6f3267a
Dynamic bus config
blazoncek Aug 22, 2024
dbb47d5
Bus manager rework
blazoncek Aug 24, 2024
8818a9e
Remove erroneous debug
blazoncek Aug 24, 2024
f55e2fc
Merge branch '0_15' into bus-config
blazoncek Aug 25, 2024
865e3dc
getNumberOfPins
blazoncek Aug 25, 2024
820df0c
PinManager update
blazoncek Aug 26, 2024
b2e00eb
Introduce network type (previous virtual)
blazoncek Aug 27, 2024
c51ce2e
Fix C/P error
blazoncek Aug 27, 2024
0d035a0
Dithering support & bugfix in UI
blazoncek Aug 30, 2024
2ca034b
Remove ledc_set_duty_and_update
blazoncek Sep 1, 2024
a3b2887
Dirty fix for newer framework
blazoncek Sep 1, 2024
85e2f7e
fixed offsets and inverted signal plus dead time
DedeHai Sep 2, 2024
be7475f
bugfixes, removed debug printout
DedeHai Sep 2, 2024
2cc0ace
Bugfixes
DedeHai Sep 3, 2024
b1e58dd
Optimisations
blazoncek Sep 3, 2024
d3c31c5
found a better way of deadTime subtraction, fixed inverted signals
DedeHai Sep 4, 2024
092a5a1
Unsigned fix
blazoncek Sep 4, 2024
55d98ff
Merge pull request #4126 from DedeHai/PWM-fixes
blazoncek Sep 5, 2024
9cc333b
Move LED types to individual bus type
blazoncek Sep 5, 2024
43cc4ec
Increase oappend buffer on ESP8266
blazoncek Sep 5, 2024
ac689a9
Remove array, un-inline calculateCCT
blazoncek Sep 6, 2024
c5b31e2
Bugfix
blazoncek Sep 6, 2024
b431515
Add numPins()
blazoncek Sep 8, 2024
5df1a22
Pre-allocate COM vector
blazoncek Sep 11, 2024
6169c45
Remove void
blazoncek Sep 12, 2024
5b8d9d1
Merge branch '0_15' into bus-config
blazoncek Sep 12, 2024
f12de61
Merge branch '0_15' into bus-config
blazoncek Sep 12, 2024
ec7f69d
Merge branch '0_15' into bus-config
blazoncek Sep 12, 2024
49d51c5
Hot
blazoncek Sep 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions wled00/FX_fcn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1249,12 +1249,12 @@ void WS2812FX::finalizeInit(void) {
//RGBW mode is enabled if at least one of the strips is RGBW
_hasWhiteChannel |= bus->hasWhite();
//refresh is required to remain off if at least one of the strips requires the refresh.
_isOffRefreshRequired |= bus->isOffRefreshRequired();
_isOffRefreshRequired |= bus->isOffRefreshRequired() && !bus->isPWM(); // use refresh bit for phase shift with analog
unsigned busEnd = bus->getStart() + bus->getLength();
if (busEnd > _length) _length = busEnd;
#ifdef ESP8266
// why do we need to reinitialise GPIO3???
//if ((!IS_DIGITAL(bus->getType()) || IS_2PIN(bus->getType()))) continue;
//if (!bus->isDigital() || bus->is2Pin()) continue;
//uint8_t pins[5];
//if (!bus->getPins(pins)) continue;
//BusDigital* bd = static_cast<BusDigital*>(bus);
Expand Down
352 changes: 242 additions & 110 deletions wled00/bus_manager.cpp

Large diffs are not rendered by default.

355 changes: 192 additions & 163 deletions wled00/bus_manager.h

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions wled00/bus_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -1314,8 +1314,8 @@ class PolyBus {

//gives back the internal type index (I_XX_XXX_X above) for the input
static uint8_t getI(uint8_t busType, uint8_t* pins, uint8_t num = 0) {
if (!IS_DIGITAL(busType)) return I_NONE;
if (IS_2PIN(busType)) { //SPI LED chips
if (!Bus::isDigital(busType)) return I_NONE;
if (Bus::is2Pin(busType)) { //SPI LED chips
bool isHSPI = false;
#ifdef ESP8266
if (pins[0] == P_8266_HS_MOSI && pins[1] == P_8266_HS_CLK) isHSPI = true;
Expand Down
13 changes: 4 additions & 9 deletions wled00/cfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
for (JsonObject elm : ins) {
unsigned type = elm["type"] | TYPE_WS2812_RGB;
unsigned len = elm["len"] | DEFAULT_LED_COUNT;
if (!IS_DIGITAL(type)) continue;
if (!IS_2PIN(type)) {
if (!Bus::isDigital(type)) continue;
if (!Bus::is2Pin(type)) {
digitalCount++;
unsigned channels = Bus::getNumberOfChannels(type);
if (len > maxLedsOnBus) maxLedsOnBus = len;
Expand Down Expand Up @@ -215,7 +215,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
uint8_t maPerLed = elm[F("ledma")] | LED_MILLIAMPS_DEFAULT;
uint16_t maMax = elm[F("maxpwr")] | (ablMilliampsMax * length) / total; // rough (incorrect?) per strip ABL calculation when no config exists
// To disable brightness limiter we either set output max current to 0 or single LED current to 0 (we choose output max current)
if (IS_PWM(ledType) || IS_ONOFF(ledType) || IS_VIRTUAL(ledType)) { // analog and virtual
if (Bus::isPWM(ledType) || Bus::isOnOff(ledType) || Bus::isVirtual(ledType)) { // analog and virtual
maPerLed = 0;
maMax = 0;
}
Expand Down Expand Up @@ -244,17 +244,12 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
// read color order map configuration
JsonArray hw_com = hw[F("com")];
if (!hw_com.isNull()) {
ColorOrderMap com = {};
unsigned s = 0;
for (JsonObject entry : hw_com) {
if (s > WLED_MAX_COLOR_ORDER_MAPPINGS) break;
uint16_t start = entry["start"] | 0;
uint16_t len = entry["len"] | 0;
uint8_t colorOrder = (int)entry[F("order")];
com.add(start, len, colorOrder);
s++;
if (!BusManager::getColorOrderMap().add(start, len, colorOrder)) break;
}
BusManager::updateColorOrderMap(com);
}

// read multiple button configuration
Expand Down
29 changes: 23 additions & 6 deletions wled00/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,28 @@
#define WLED_MAX_BUSSES 4 // will allow 3 digital & 1 analog RGB
#define WLED_MIN_VIRTUAL_BUSSES 2
#else
#define WLED_MAX_ANALOG_CHANNELS (LEDC_CHANNEL_MAX*LEDC_SPEED_MODE_MAX)
#if defined(CONFIG_IDF_TARGET_ESP32C3) // 2 RMT, 6 LEDC, only has 1 I2S but NPB does not support it ATM
#define WLED_MAX_BUSSES 4 // will allow 2 digital & 2 analog RGB
#define WLED_MAX_DIGITAL_CHANNELS 2
#define WLED_MAX_ANALOG_CHANNELS 6
//#define WLED_MAX_ANALOG_CHANNELS 6
#define WLED_MIN_VIRTUAL_BUSSES 3
#elif defined(CONFIG_IDF_TARGET_ESP32S2) // 4 RMT, 8 LEDC, only has 1 I2S bus, supported in NPB
// the 5th bus (I2S) will prevent Audioreactive usermod from functioning (it is last used though)
#define WLED_MAX_BUSSES 7 // will allow 5 digital & 2 analog RGB
#define WLED_MAX_DIGITAL_CHANNELS 5
#define WLED_MAX_ANALOG_CHANNELS 8
//#define WLED_MAX_ANALOG_CHANNELS 8
#define WLED_MIN_VIRTUAL_BUSSES 3
#elif defined(CONFIG_IDF_TARGET_ESP32S3) // 4 RMT, 8 LEDC, has 2 I2S but NPB does not support them ATM
#define WLED_MAX_BUSSES 6 // will allow 4 digital & 2 analog RGB
#define WLED_MAX_DIGITAL_CHANNELS 4
#define WLED_MAX_ANALOG_CHANNELS 8
//#define WLED_MAX_ANALOG_CHANNELS 8
#define WLED_MIN_VIRTUAL_BUSSES 4
#else
// the last digital bus (I2S0) will prevent Audioreactive usermod from functioning
#define WLED_MAX_BUSSES 20 // will allow 17 digital & 3 analog RGB
#define WLED_MAX_DIGITAL_CHANNELS 17
#define WLED_MAX_ANALOG_CHANNELS 10
//#define WLED_MAX_ANALOG_CHANNELS 16
#define WLED_MIN_VIRTUAL_BUSSES 4
#endif
#endif
Expand Down Expand Up @@ -281,6 +282,7 @@
#define TYPE_NONE 0 //light is not configured
#define TYPE_RESERVED 1 //unused. Might indicate a "virtual" light
//Digital types (data pin only) (16-39)
#define TYPE_DIGITAL_MIN 16 // first usable digital type
#define TYPE_WS2812_1CH 18 //white-only chips (1 channel per IC) (unused)
#define TYPE_WS2812_1CH_X3 19 //white-only chips (3 channels per IC)
#define TYPE_WS2812_2CH_X3 20 //CCT chips (1st IC controls WW + CW of 1st zone and CW of 2nd zone, 2nd IC controls WW of 2nd zone and WW + CW of 3rd zone)
Expand All @@ -298,26 +300,36 @@
#define TYPE_WS2805 32 //RGB + WW + CW
#define TYPE_TM1914 33 //RGB
#define TYPE_SM16825 34 //RGB + WW + CW
#define TYPE_DIGITAL_MAX 39 // last usable digital type
//"Analog" types (40-47)
#define TYPE_ONOFF 40 //binary output (relays etc.; NOT PWM)
#define TYPE_ANALOG_MIN 41 // first usable analog type
#define TYPE_ANALOG_1CH 41 //single channel PWM. Uses value of brightest RGBW channel
#define TYPE_ANALOG_2CH 42 //analog WW + CW
#define TYPE_ANALOG_3CH 43 //analog RGB
#define TYPE_ANALOG_4CH 44 //analog RGBW
#define TYPE_ANALOG_5CH 45 //analog RGB + WW + CW
#define TYPE_ANALOG_6CH 46 //analog RGB + A + WW + CW
#define TYPE_ANALOG_MAX 47 // last usable analog type
//Digital types (data + clock / SPI) (48-63)
#define TYPE_2PIN_MIN 48
#define TYPE_WS2801 50
#define TYPE_APA102 51
#define TYPE_LPD8806 52
#define TYPE_P9813 53
#define TYPE_LPD6803 54
#define TYPE_2PIN_MAX 63
//Network types (master broadcast) (80-95)
#define TYPE_VIRTUAL_MIN 80
#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, unused)
#define TYPE_NET_ARTNET_RGB 82 //network ArtNet RGB bus (master broadcast bus, unused)
#define TYPE_NET_DDP_RGBW 88 //network DDP RGBW bus (master broadcast bus)
#define TYPE_NET_ARTNET_RGBW 89 //network ArtNet RGB bus (master broadcast bus, unused)
#define TYPE_VIRTUAL_MAX 95

/*
// old macros that have been moved to Bus class
blazoncek marked this conversation as resolved.
Show resolved Hide resolved
#define IS_TYPE_VALID(t) ((t) > 15 && (t) < 128)
#define IS_DIGITAL(t) (((t) > 15 && (t) < 40) || ((t) > 47 && (t) < 64)) //digital are 16-39 and 48-63
#define IS_2PIN(t) ((t) > 47 && (t) < 64)
Expand All @@ -326,6 +338,7 @@
#define IS_PWM(t) ((t) > 40 && (t) < 46) //does not include on/Off type
#define NUM_PWM_PINS(t) ((t) - 40) //for analog PWM 41-45 only
#define IS_VIRTUAL(t) ((t) >= 80 && (t) < 96) //this was a poor choice a better would be 96-111
*/

//Color orders
#define COL_ORDER_GRB 0 //GRB(w),defaut
Expand Down Expand Up @@ -480,7 +493,7 @@

// string temp buffer (now stored in stack locally)
#ifdef ESP8266
#define SETTINGS_STACK_BUF_SIZE 2048
#define SETTINGS_STACK_BUF_SIZE 2560
#else
#define SETTINGS_STACK_BUF_SIZE 3840 // warning: quite a large value for stack (640 * WLED_MAX_USERMODS)
#endif
Expand Down Expand Up @@ -520,7 +533,11 @@
#ifdef ESP8266
#define WLED_PWM_FREQ 880 //PWM frequency proven as good for LEDs
#else
#define WLED_PWM_FREQ 19531
#ifdef SOC_LEDC_SUPPORT_XTAL_CLOCK
#define WLED_PWM_FREQ 9765 // XTAL clock is 40MHz (this will allow 12 bit resolution)
#else
#define WLED_PWM_FREQ 19531 // APB clock is 80MHz
#endif
#endif
#endif

Expand Down
Loading