🚸 Case Light, LED menus for E3V2 DWIN Enhanced UI (#23590)

This commit is contained in:
GHGiampy
2022-02-02 00:35:38 +01:00
committed by Scott Lahteine
parent 4ba4ab1c75
commit ac76ed7ece
19 changed files with 278 additions and 112 deletions

View File

@ -64,7 +64,17 @@ void CaseLight::update(const bool sflag) {
#endif
#if CASE_LIGHT_IS_COLOR_LED
leds.set_color(LEDColor(color.r, color.g, color.b OPTARG(HAS_WHITE_LED, color.w) OPTARG(NEOPIXEL_LED, n10ct)));
#if ENABLED(CASE_LIGHT_USE_NEOPIXEL)
if (on)
// Use current color of (NeoPixel) leds and new brightness level
leds.set_color(LEDColor(leds.color.r, leds.color.g, leds.color.b OPTARG(HAS_WHITE_LED, leds.color.w) OPTARG(NEOPIXEL_LED, n10ct)));
else
// Switch off leds
leds.set_off();
#else
// Use CaseLight color (CASE_LIGHT_DEFAULT_COLOR) and new brightness level
leds.set_color(LEDColor(color.r, color.g, color.b OPTARG(HAS_WHITE_LED, color.w) OPTARG(NEOPIXEL_LED, n10ct)));
#endif
#else // !CASE_LIGHT_IS_COLOR_LED
#if CASELIGHT_USES_BRIGHTNESS

View File

@ -27,10 +27,6 @@
#include "leds/leds.h" // for LEDColor
#endif
#if NONE(CASE_LIGHT_NO_BRIGHTNESS, CASE_LIGHT_IS_COLOR_LED) || ENABLED(CASE_LIGHT_USE_NEOPIXEL)
#define CASELIGHT_USES_BRIGHTNESS 1
#endif
class CaseLight {
public:
static bool on;

View File

@ -42,7 +42,7 @@
#include "pca9533.h"
#endif
#if ENABLED(CASE_LIGHT_USE_RGB_LED)
#if EITHER(CASE_LIGHT_USE_RGB_LED, CASE_LIGHT_USE_NEOPIXEL)
#include "../../feature/caselight.h"
#endif
@ -95,6 +95,10 @@ void LEDLights::set_color(const LEDColor &incol
#endif
#endif
#if BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL)
// Update brightness only if caselight is ON or switching leds off
if (caselight.on || incol.is_off())
#endif
neo.set_brightness(incol.i);
#if ENABLED(NEOPIXEL_IS_SEQUENTIAL)
@ -106,6 +110,10 @@ void LEDLights::set_color(const LEDColor &incol
}
#endif
#if BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL)
// Update color only if caselight is ON or switching leds off
if (caselight.on || incol.is_off())
#endif
neo.set_color(neocolor);
#endif
@ -150,7 +158,7 @@ void LEDLights::set_color(const LEDColor &incol
void LEDLights::toggle() { if (lights_on) set_off(); else update(); }
#endif
#ifdef LED_BACKLIGHT_TIMEOUT
#if LED_POWEROFF_TIMEOUT > 0
millis_t LEDLights::led_off_time; // = 0

View File

@ -157,12 +157,12 @@ public:
static void update() { set_color(color); }
#endif
#ifdef LED_BACKLIGHT_TIMEOUT
#if LED_POWEROFF_TIMEOUT > 0
private:
static millis_t led_off_time;
public:
static void reset_timeout(const millis_t &ms) {
led_off_time = ms + LED_BACKLIGHT_TIMEOUT;
led_off_time = ms + LED_POWEROFF_TIMEOUT;
if (!lights_on) update();
}
static void update_timeout(const bool power_on);

View File

@ -25,8 +25,6 @@
* NeoPixel support
*/
#define MAX_NEOPIXELS 127
#ifndef _NEOPIXEL_INCLUDE_
#error "Always include 'leds.h' and not 'neopixel.h' directly."
#endif
@ -68,7 +66,7 @@
// Types
// ------------------------
typedef IF<(MAX_NEOPIXELS > 127), int16_t, int8_t>::type pixel_index_t;
typedef IF<(TERN0(NEOPIXEL_LED, NEOPIXEL_PIXELS > 127)), int16_t, int8_t>::type pixel_index_t;
// ------------------------
// Classes