Skip first led cleanup.

This commit is contained in:
Blaž Kristan 2021-04-01 12:53:01 +02:00
parent 0e2168392c
commit 7078c91f7d
5 changed files with 26 additions and 28 deletions

View File

@ -17,17 +17,17 @@
//temporary struct for passing bus configuration to bus
struct BusConfig {
uint8_t type = TYPE_WS2812_RGB;
uint16_t count = 1;
uint16_t start = 0;
uint8_t colorOrder = COL_ORDER_GRB;
bool reversed = false;
bool skipFirst = false;
bool rgbwOverride = false;
uint16_t count;
uint16_t start;
uint8_t colorOrder;
bool reversed;
uint8_t skipAmount;
bool rgbwOverride;
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, uint8_t skip = 0) {
rgbwOverride = (bool) 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;
count = len; start = pstart; colorOrder = pcolorOrder; reversed = rev; skipAmount = skip;
uint8_t nPins = 1;
if (type > 47) nPins = 2;
else if (type > 41 && type < 46) nPins = NUM_PWM_PINS(type);
@ -81,8 +81,8 @@ class Bus {
return false;
}
virtual bool skipFirstLed() {
return false;
virtual uint8_t skipFirstLed() {
return 0;
}
inline uint8_t getType() {
@ -116,10 +116,10 @@ class BusDigital : public Bus {
cleanup(); return;
}
}
_skip = bc.skipFirst ? LED_SKIP_AMOUNT : 0; //sacrificial pixels
_len = bc.count + _skip;
reversed = bc.reversed;
_rgbw = bc.rgbwOverride; // RGBW override in bit 7
_skip = bc.skipAmount; //sacrificial pixels
_len = bc.count + _skip;
_rgbw = bc.rgbwOverride; // RGBW override in bit 7
_iType = PolyBus::getI(type, _pins, nr, _rgbw);
if (_iType == I_NONE) return;
_busPtr = PolyBus::create(_iType, _pins, _len);
@ -181,8 +181,8 @@ class BusDigital : public Bus {
return _rgbw;
}
inline bool skipFirstLed() {
return (bool)_skip;
inline uint8_t skipFirstLed() {
return _skip;
}
inline void reinit() {

View File

@ -102,7 +102,6 @@ void deserializeConfig() {
JsonArray ins = hw_led["ins"];
uint8_t s = 0; // bus iterator
bool skipFirst = false;
strip.isRgbw = false;
busses.removeAll();
uint32_t mem = 0;
@ -123,9 +122,8 @@ void deserializeConfig() {
if (start >= lC+length) continue; // something is very wrong :)
//limit length of strip if it would exceed total configured LEDs
//if (start + length > ledCount) length = ledCount - start;
uint8_t colorOrder = (int)elm[F("order")];
//(this shouldn't have been in ins obj. but remains here for compatibility)
skipFirst = (bool) elm[F("skip")];
uint8_t colorOrder = elm[F("order")];
uint8_t skipFirst = elm[F("skip")];
uint8_t ledType = elm["type"] | TYPE_WS2812_RGB;
bool reversed = elm["rev"];
//RGBW mode is enabled if at least one of the strips is RGBW
@ -144,7 +142,7 @@ void deserializeConfig() {
JsonObject hw_btn_ins_0 = hw[F("btn")][F("ins")][0];
CJSON(buttonEnabled, hw_btn_ins_0["type"]);
int hw_btn_pin = hw_btn_ins_0["pin"][0];
if (pinManager.allocatePin(hw_btn_pin,false)) {
if (hw_btn_pin>=0 && pinManager.allocatePin(hw_btn_pin,false)) {
btnPin = hw_btn_pin;
pinMode(btnPin, INPUT_PULLUP);
} else {
@ -160,7 +158,7 @@ void deserializeConfig() {
#ifndef WLED_DISABLE_INFRARED
int hw_ir_pin = hw["ir"]["pin"] | -1; // 4
if (pinManager.allocatePin(hw_ir_pin,false)) {
if (hw_ir_pin >=0 && pinManager.allocatePin(hw_ir_pin,false)) {
irPin = hw_ir_pin;
} else {
irPin = -1;
@ -169,8 +167,8 @@ void deserializeConfig() {
CJSON(irEnabled, hw["ir"]["type"]);
JsonObject relay = hw[F("relay")];
int hw_relay_pin = relay["pin"];
if (pinManager.allocatePin(hw_relay_pin,true)) {
int hw_relay_pin = relay["pin"] | -1;
if (hw_relay_pin>=0 && pinManager.allocatePin(hw_relay_pin,true)) {
rlyPin = hw_relay_pin;
pinMode(rlyPin, OUTPUT);
} else {

View File

@ -83,9 +83,9 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
#endif
if (btnPin>=0 && pinManager.isPinAllocated(btnPin)) pinManager.deallocatePin(btnPin);
bool skip = request->hasArg(F("SL"));
strip.isRgbw = false;
uint8_t skip = request->hasArg(F("SL")) ? LED_SKIP_AMOUNT : 0;
uint8_t colorOrder, type;
uint16_t length, start;
uint8_t pins[5] = {255, 255, 255, 255, 255};
@ -99,7 +99,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
char cv[4] = "CV"; cv[2] = 48+s; cv[3] = 0; //strip reverse
char ew[4] = "EW"; ew[2] = 48+s; ew[3] = 0; //strip RGBW override
if (!request->hasArg(lp)) {
DEBUG_PRINTLN("No data."); break;
DEBUG_PRINTLN(F("No data.")); break;
}
for (uint8_t i = 0; i < 5; i++) {
lp[1] = 48+i;

View File

@ -8,7 +8,7 @@
*/
// version code in format yymmddb (b = daily build)
#define VERSION 2103312
#define VERSION 2104011
//uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG
@ -168,7 +168,7 @@
#endif
// Global Variable definitions
WLED_GLOBAL char versionString[] _INIT("0.12.0-b5");
WLED_GLOBAL char versionString[] _INIT("0.12.0-b6");
#define WLED_CODENAME "Hikari"
// AP and OTA default passwords (for maximum security change them!)

View File

@ -345,7 +345,7 @@ void getSettingsJS(byte subPage, char* dest)
sappend('v',ls,bus->getStart());
sappend('c',cv,bus->reversed);
sappend('c',ew,bus->isRgbw());
skip = skip || bus->skipFirstLed();
if (!skip) skip = bus->skipFirstLed()>0;
}
sappend('v',SET_F("MA"),strip.ablMilliampsMax);
sappend('v',SET_F("LA"),strip.milliampsPerLed);