Disable onboard LED when LEDs are not in use (#1245)

* Disable onboard LED when LEDs are not in use

* Remove unused variable

* Only disable onboard LED if LEDPIN == LED_BUILTIN

* Change LEDPIN to LED_BUILTIN
This commit is contained in:
Jeff Rescignano 2020-10-12 14:13:13 -04:00 committed by GitHub
parent 3d04541ee3
commit 13f18492ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 4 deletions

View File

@ -650,6 +650,7 @@ class WS2812FX {
void handle_palette(void);
bool
shouldStartBus = false,
_useRgbw = false,
_skipFirstMode,
_triggered;

View File

@ -396,6 +396,18 @@ void WS2812FX::setBrightness(uint8_t b) {
{
_segments[i].setOption(SEG_OPTION_FREEZE, false);
}
#if LEDPIN == LED_BUILTIN
if (!shouldStartBus)
shouldStartBus = true;
#endif
} else {
#if LEDPIN == LED_BUILTIN
if (shouldStartBus) {
shouldStartBus = false;
const uint8_t ty = _useRgbw ? 2 : 1;
bus->Begin((NeoPixelType)ty, _lengthRaw);
}
#endif
}
if (SEGENV.next_time > millis() + 22 && millis() - _lastShow > MIN_SHOW_DELAY) show();//apply brightness change immediately if no refresh soon
}

View File

@ -95,9 +95,15 @@ void handleIO()
}
} else if (millis() - lastOnTime > 600)
{
#if RLYPIN >= 0
if (!offMode) digitalWrite(RLYPIN, !RLYMDE);
#endif
if (!offMode) {
#if LEDPIN == LED_BUILTIN
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
#endif
#if RLYPIN >= 0
digitalWrite(RLYPIN, !RLYMDE);
#endif
}
offMode = true;
}