RGBW override cleanup, UI fix.

This commit is contained in:
Blaž Kristan 2021-02-26 08:34:38 +01:00
parent 73a99a7dea
commit 2c0c22dbf3
6 changed files with 1739 additions and 1729 deletions

View File

@ -18,13 +18,15 @@ struct BusConfig {
uint8_t colorOrder = COL_ORDER_GRB; uint8_t colorOrder = COL_ORDER_GRB;
bool reversed = false; bool reversed = false;
bool skipFirst = false; bool skipFirst = false;
bool rgbwOverride = false;
uint8_t pins[5] = {LEDPIN, 255, 255, 255, 255}; uint8_t pins[5] = {LEDPIN, 255, 255, 255, 255};
BusConfig(uint8_t busType, uint8_t* ppins, uint16_t pstart, uint16_t len = 1, uint8_t pcolorOrder = COL_ORDER_GRB, bool rev = false, bool skip = false) { BusConfig(uint8_t busType, uint8_t* ppins, uint16_t pstart, uint16_t len = 1, uint8_t pcolorOrder = COL_ORDER_GRB, bool rev = false, bool skip = false) {
type = busType; count = len; start = pstart; colorOrder = pcolorOrder; reversed = rev; skipFirst = skip; rgbwOverride = GET_BIT(busType,7);
type = busType & 0x7F; // bit 7 is hacked to include RGBW info (1=RGBW, 0=RGB)
count = len; start = pstart; colorOrder = pcolorOrder; reversed = rev; skipFirst = skip;
uint8_t nPins = 1; uint8_t nPins = 1;
// bit 7 is hacked to include RGBW info (1=RGBW, 0=RGB) if (type > 47) nPins = 2;
if ((type&0x7F) > 47) nPins = 2; else if (type > 41 && type < 46) nPins = NUM_PWM_PINS(type);
else if ((type&0x7F) > 41 && (type&0x7F) < 46) nPins = NUM_PWM_PINS((type&0x7F));
for (uint8_t i = 0; i < nPins; i++) pins[i] = ppins[i]; for (uint8_t i = 0; i < nPins; i++) pins[i] = ppins[i];
} }
}; };
@ -96,8 +98,8 @@ class Bus {
class BusDigital : public Bus { class BusDigital : public Bus {
public: public:
BusDigital(BusConfig &bc, uint8_t nr) : Bus(bc.type&0x7F, bc.start) { BusDigital(BusConfig &bc, uint8_t nr) : Bus(bc.type, bc.start) {
uint8_t type = bc.type & 0x7F; // bit 7 is hacked to include RGBW info uint8_t type = bc.type;
if (!IS_DIGITAL(type) || !bc.count) return; if (!IS_DIGITAL(type) || !bc.count) return;
_pins[0] = bc.pins[0]; _pins[0] = bc.pins[0];
if (!pinManager.allocatePin(_pins[0])) return; if (!pinManager.allocatePin(_pins[0])) return;
@ -110,7 +112,7 @@ class BusDigital : public Bus {
_skip = bc.skipFirst ? LED_SKIP_AMOUNT : 0; //sacrificial pixels _skip = bc.skipFirst ? LED_SKIP_AMOUNT : 0; //sacrificial pixels
_len = bc.count + _skip; _len = bc.count + _skip;
reversed = bc.reversed; reversed = bc.reversed;
_rgbw = (bool)((bc.type>>7) & 0x01); // RGBW override in bit 7 _rgbw = bc.rgbwOverride; // RGBW override in bit 7
_iType = PolyBus::getI(type, _pins, nr, _rgbw); _iType = PolyBus::getI(type, _pins, nr, _rgbw);
if (_iType == I_NONE) return; if (_iType == I_NONE) return;
_busPtr = PolyBus::create(_iType, _pins, _len); _busPtr = PolyBus::create(_iType, _pins, _len);
@ -202,9 +204,9 @@ class BusDigital : public Bus {
class BusPwm : public Bus { class BusPwm : public Bus {
public: public:
BusPwm(BusConfig &bc) : Bus(bc.type&0x7F, bc.start) { // bit 7 is hacked to include RGBW info BusPwm(BusConfig &bc) : Bus(bc.type, bc.start) {
if (!IS_PWM(bc.type&0x7F)) return; // bit 7 is hacked to include RGBW info if (!IS_PWM(bc.type)) return;
uint8_t numPins = NUM_PWM_PINS(bc.type&0x7F); // bit 7 is hacked to include RGBW info uint8_t numPins = NUM_PWM_PINS(bc.type);
#ifdef ESP8266 #ifdef ESP8266
analogWriteRange(255); //same range as one RGB channel analogWriteRange(255); //same range as one RGB channel
@ -319,7 +321,7 @@ class BusManager {
int add(BusConfig &bc) { int add(BusConfig &bc) {
if (numBusses >= WLED_MAX_BUSSES) return -1; if (numBusses >= WLED_MAX_BUSSES) return -1;
if (IS_DIGITAL(bc.type&0x7F)) { if (IS_DIGITAL(bc.type)) {
busses[numBusses] = new BusDigital(bc, numBusses); busses[numBusses] = new BusDigital(bc, numBusses);
} else { } else {
busses[numBusses] = new BusPwm(bc); busses[numBusses] = new BusPwm(bc);

View File

@ -294,11 +294,16 @@ button {
z-index: 1; z-index: 1;
margin: 1px auto auto; margin: 1px auto auto;
} }
/*
#staytop, #staytop1 { #staytop, #staytop1 {
background: var(--c-1); background: var(--c-1);
/* margin-top: 1px;*/
width: 310px;
margin: auto;
border-radius: 15px;
} }
*/ }
#staytop1 { #staytop1 {
top: 28px; top: 28px;
} }

View File

@ -122,6 +122,7 @@
if (change) { if (change) {
d.getElementById("ew"+n).checked = (type == 30 || type == 31 || type == 44 || type == 45); // RGBW checkbox, TYPE_xxxx values from const.h d.getElementById("ew"+n).checked = (type == 30 || type == 31 || type == 44 || type == 45); // RGBW checkbox, TYPE_xxxx values from const.h
} }
d.getElementById("ew"+n).readOnly = (type > 31 && type < 48); // analog
isRGBW |= d.getElementById("ew"+n).checked; isRGBW |= d.getElementById("ew"+n).checked;
d.getElementById("dig"+n).style.display = (type > 31 && type < 48) ? "none":"inline"; d.getElementById("dig"+n).style.display = (type > 31 && type < 48) ? "none":"inline";
d.getElementById("psd"+n).innerHTML = (type > 31 && type < 48) ? "Index:":"Start:"; d.getElementById("psd"+n).innerHTML = (type > 31 && type < 48) ? "Index:":"Start:";

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@
*/ */
// version code in format yymmddb (b = daily build) // version code in format yymmddb (b = daily build)
#define VERSION 2102250 #define VERSION 2102260
//uncomment this if you have a "my_config.h" file you'd like to use //uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG //#define WLED_USE_MY_CONFIG