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:
parent
3d04541ee3
commit
13f18492ad
@ -650,6 +650,7 @@ class WS2812FX {
|
||||
void handle_palette(void);
|
||||
|
||||
bool
|
||||
shouldStartBus = false,
|
||||
_useRgbw = false,
|
||||
_skipFirstMode,
|
||||
_triggered;
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ void handleIO()
|
||||
{
|
||||
lastOnTime = millis();
|
||||
if (offMode)
|
||||
{
|
||||
{
|
||||
#if RLYPIN >= 0
|
||||
digitalWrite(RLYPIN, RLYMDE);
|
||||
#endif
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user