Better handling of DMA re-init

pull/1689/head
cschwinne 2021-01-19 17:22:37 +01:00
rodzic 67833c5513
commit 849e04ab83
2 zmienionych plików z 18 dodań i 3 usunięć

Wyświetl plik

@ -62,7 +62,7 @@ void WS2812FX::init(bool supportWhite, uint16_t countPixels, bool skipFirst)
_lengthRaw += LED_SKIP_AMOUNT;
}
uint8_t pins[] = {2};
uint8_t pins[] = {LEDPIN};
while (!busses->canAllShow()) yield();
busses->removeAll();
@ -72,6 +72,17 @@ void WS2812FX::init(bool supportWhite, uint16_t countPixels, bool skipFirst)
_segments[0].stop = _length;
setBrightness(_brightness);
#ifdef ESP8266
for (uint8_t i = 0; i < busses->getNumBusses(); i++) {
Bus* b = busses->getBus(i);
if ((!IS_DIGITAL(b->getType()) || IS_2PIN(b->getType()))) continue;
uint8_t pins[5];
b->getPins(pins);
BusDigital* bd = static_cast<BusDigital*>(b);
if (pins[0] == 3) bd->reinit();
}
#endif
}
void WS2812FX::service() {

Wyświetl plik

@ -102,10 +102,10 @@ class BusDigital : public Bus {
}
void setBrightness(uint8_t b) {
//Fix for turning off onboard LED breaking bus and quick fix for DMA not initializing correctly
//Fix for turning off onboard LED breaking bus
#ifdef LED_BUILTIN
if (_bri == 0 && b > 0) {
if (_pins[0] == LED_BUILTIN || _pins[1] == LED_BUILTIN || (_pins[0] == 3 && _iType < 17)) PolyBus::begin(_busPtr, _iType);
if (_pins[0] == LED_BUILTIN || _pins[1] == LED_BUILTIN) PolyBus::begin(_busPtr, _iType);
}
#endif
_bri = b;
@ -141,6 +141,10 @@ class BusDigital : public Bus {
_colorOrder = colorOrder;
}
void reinit() {
PolyBus::begin(_busPtr, _iType);
}
void cleanup() {
//Serial.println("Digital Cleanup");
PolyBus::cleanup(_busPtr, _iType);