RGB Caselight (#20341)

This commit is contained in:
LinFor
2021-02-28 01:06:48 +03:00
committed by GitHub
parent ee7701c15b
commit e0aa9ce372
14 changed files with 86 additions and 41 deletions

View File

@@ -21,10 +21,10 @@
*/
#pragma once
#include "../inc/MarlinConfigPre.h"
#include "../inc/MarlinConfig.h"
#if ENABLED(CASE_LIGHT_USE_NEOPIXEL)
#include "leds/leds.h"
#if CASE_LIGHT_IS_COLOR_LED
#include "leds/leds.h" // for LEDColor
#endif
#if DISABLED(CASE_LIGHT_NO_BRIGHTNESS) || ENABLED(CASE_LIGHT_USE_NEOPIXEL)
@@ -33,19 +33,25 @@
class CaseLight {
public:
#if CASELIGHT_USES_BRIGHTNESS
static uint8_t brightness;
#endif
static bool on;
TERN_(CASELIGHT_USES_BRIGHTNESS, static uint8_t brightness);
static bool pin_is_pwm() { return TERN0(NEED_CASE_LIGHT_PIN, PWM_PIN(CASE_LIGHT_PIN)); }
static bool has_brightness() { return TERN0(CASELIGHT_USES_BRIGHTNESS, TERN(CASE_LIGHT_USE_NEOPIXEL, true, pin_is_pwm())); }
static void init() {
#if NEED_CASE_LIGHT_PIN
if (pin_is_pwm()) SET_PWM(CASE_LIGHT_PIN); else SET_OUTPUT(CASE_LIGHT_PIN);
#endif
update_brightness();
}
static void update(const bool sflag);
static inline void update_brightness() { update(false); }
static inline void update_enabled() { update(true); }
static inline void update_enabled() { update(true); }
private:
#if ENABLED(CASE_LIGHT_USE_NEOPIXEL)
static LEDColor color;
#endif
TERN_(CASE_LIGHT_IS_COLOR_LED, static LEDColor color);
};
extern CaseLight caselight;