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);
|
void handle_palette(void);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
shouldStartBus = false,
|
||||||
_useRgbw = false,
|
_useRgbw = false,
|
||||||
_skipFirstMode,
|
_skipFirstMode,
|
||||||
_triggered;
|
_triggered;
|
||||||
|
@ -396,6 +396,18 @@ void WS2812FX::setBrightness(uint8_t b) {
|
|||||||
{
|
{
|
||||||
_segments[i].setOption(SEG_OPTION_FREEZE, false);
|
_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
|
if (SEGENV.next_time > millis() + 22 && millis() - _lastShow > MIN_SHOW_DELAY) show();//apply brightness change immediately if no refresh soon
|
||||||
}
|
}
|
||||||
|
@ -95,9 +95,15 @@ void handleIO()
|
|||||||
}
|
}
|
||||||
} else if (millis() - lastOnTime > 600)
|
} else if (millis() - lastOnTime > 600)
|
||||||
{
|
{
|
||||||
#if RLYPIN >= 0
|
if (!offMode) {
|
||||||
if (!offMode) digitalWrite(RLYPIN, !RLYMDE);
|
#if LEDPIN == LED_BUILTIN
|
||||||
|
pinMode(LED_BUILTIN, OUTPUT);
|
||||||
|
digitalWrite(LED_BUILTIN, HIGH);
|
||||||
#endif
|
#endif
|
||||||
|
#if RLYPIN >= 0
|
||||||
|
digitalWrite(RLYPIN, !RLYMDE);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
offMode = true;
|
offMode = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user