Menu items for Separate NeoPixel (#19280)

This commit is contained in:
Zachary Annand 2020-09-06 20:00:24 -05:00 committed by Scott Lahteine
parent 83dba77955
commit a8db9f52ec
5 changed files with 67 additions and 11 deletions

View file

@ -183,8 +183,18 @@ void LEDLights::set_color(const LEDColor &incol
: neo2.Color(incol.r, incol.g, incol.b, incol.w);
neo2.set_brightness(incol.i);
neo2.set_color(neocolor);
#if ENABLED(LED_CONTROL_MENU)
// Don't update the color when OFF
lights_on = !incol.is_off();
if (lights_on) color = incol;
#endif
}
#if ENABLED(LED_CONTROL_MENU)
void LEDLights2::toggle() { if (lights_on) set_off(); else update(); }
#endif
#endif // NEOPIXEL2_SEPARATE
#endif // HAS_COLOR_LEDS

View file

@ -240,7 +240,7 @@ extern LEDLights leds;
static inline void set_violet() { set_color(LEDColorViolet()); }
#endif
#if ENABLED(LED_CONTROL_MENU)
#if ENABLED(NEOPIXEL2_SEPARATE)
static LEDColor color; // last non-off color
static bool lights_on; // the last set color was "on"
static void toggle(); // swap "off" with color

View file

@ -2119,18 +2119,20 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
#if !(_RGB_TEST && PIN_EXISTS(RGB_LED_W))
#error "RGBW_LED requires RGB_LED_R_PIN, RGB_LED_G_PIN, RGB_LED_B_PIN, and RGB_LED_W_PIN."
#endif
#elif ENABLED(NEOPIXEL_LED)
#if !(PIN_EXISTS(NEOPIXEL) && NEOPIXEL_PIXELS > 0)
#endif
#undef _RGB_TEST
// NeoPixel requirements
#if ENABLED(NEOPIXEL_LED)
#if !PIN_EXISTS(NEOPIXEL) || NEOPIXEL_PIXELS == 0
#error "NEOPIXEL_LED requires NEOPIXEL_PIN and NEOPIXEL_PIXELS."
#endif
#elif ENABLED(NEOPIXEL2_SEPARATE)
#if !(PIN_EXISTS(NEOPIXEL2) && NEOPIXEL2_PIXELS > 0)
#error "NEOPIXEL2 requires NEOPIXEL2_PIN and NEOPIXEL2_PIXELS."
#elif ENABLED(NEOPIXEL2_SEPARATE) && !(NEOPIXEL2_TYPE && PIN_EXISTS(NEOPIXEL2) && NEOPIXEL2_PIXELS > 0)
#error "NEOPIXEL2_SEPARATE requires NEOPIXEL2_PIN, NEOPIXEL2_TYPE and NEOPIXEL2_PIXELS."
#elif ENABLED(NEO2_COLOR_PRESETS) && DISABLED(NEOPIXEL2_SEPARATE)
#error "NEO2_COLOR_PRESETS requires NEOPIXEL2_SEPARATE to be enabled."
#endif
#endif
#undef _RGB_TEST
#if DISABLED(NO_COMPILE_TIME_PWM)
#define _TEST_PWM(P) PWM_PIN(P)
#else

View file

@ -222,6 +222,10 @@ namespace Language_en {
PROGMEM Language_Str MSG_SET_LEDS_VIOLET = _UxGT("Violet");
PROGMEM Language_Str MSG_SET_LEDS_WHITE = _UxGT("White");
PROGMEM Language_Str MSG_SET_LEDS_DEFAULT = _UxGT("Default");
PROGMEM Language_Str MSG_LED_CHANNEL_N = _UxGT("Channel =");
PROGMEM Language_Str MSG_LEDS2 = _UxGT("Lights #2");
PROGMEM Language_Str MSG_NEO2_PRESETS = _UxGT("Light #2 Presets");
PROGMEM Language_Str MSG_NEO2_BRIGHTNESS = _UxGT("Brightness");
PROGMEM Language_Str MSG_CUSTOM_LEDS = _UxGT("Custom Lights");
PROGMEM Language_Str MSG_INTENSITY_R = _UxGT("Red Intensity");
PROGMEM Language_Str MSG_INTENSITY_G = _UxGT("Green Intensity");

View file

@ -54,9 +54,33 @@
#endif
#if ENABLED(NEO2_COLOR_PRESETS)
void menu_leds2_presets() {
START_MENU();
#if LCD_HEIGHT > 2
STATIC_ITEM(MSG_NEO2_PRESETS, SS_DEFAULT|SS_INVERT);
#endif
BACK_ITEM(MSG_LED_CONTROL);
ACTION_ITEM(MSG_SET_LEDS_WHITE, leds2.set_white);
ACTION_ITEM(MSG_SET_LEDS_RED, leds2.set_red);
ACTION_ITEM(MSG_SET_LEDS_ORANGE, leds2.set_orange);
ACTION_ITEM(MSG_SET_LEDS_YELLOW, leds2.set_yellow);
ACTION_ITEM(MSG_SET_LEDS_GREEN, leds2.set_green);
ACTION_ITEM(MSG_SET_LEDS_BLUE, leds2.set_blue);
ACTION_ITEM(MSG_SET_LEDS_INDIGO, leds2.set_indigo);
ACTION_ITEM(MSG_SET_LEDS_VIOLET, leds2.set_violet);
END_MENU();
}
#endif
void menu_led_custom() {
START_MENU();
BACK_ITEM(MSG_LED_CONTROL);
#if ENABLED(NEOPIXEL2_SEPARATE)
STATIC_ITEM_N(MSG_LED_CHANNEL_N, 1, SS_DEFAULT|SS_INVERT);
#endif
EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds.color.r, 0, 255, leds.update, true);
EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds.color.g, 0, 255, leds.update, true);
EDIT_ITEM(uint8, MSG_INTENSITY_B, &leds.color.b, 0, 255, leds.update, true);
@ -66,6 +90,14 @@
EDIT_ITEM(uint8, MSG_LED_BRIGHTNESS, &leds.color.i, 0, 255, leds.update, true);
#endif
#endif
#if ENABLED(NEOPIXEL2_SEPARATE)
STATIC_ITEM_N(MSG_LED_CHANNEL_N, 2, SS_DEFAULT|SS_INVERT);
EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds2.color.r, 0, 255, leds2.update, true);
EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds2.color.g, 0, 255, leds2.update, true);
EDIT_ITEM(uint8, MSG_INTENSITY_B, &leds2.color.b, 0, 255, leds2.update, true);
EDIT_ITEM(uint8, MSG_INTENSITY_W, &leds2.color.w, 0, 255, leds2.update, true);
EDIT_ITEM(uint8, MSG_NEO2_BRIGHTNESS, &leds2.color.i, 0, 255, leds2.update, true);
#endif
END_MENU();
}
#endif
@ -89,12 +121,20 @@ void menu_led() {
BACK_ITEM(MSG_MAIN);
#if ENABLED(LED_CONTROL_MENU)
bool led_on = leds.lights_on;
EDIT_ITEM(bool, MSG_LEDS, &led_on, leds.toggle);
editable.state = leds.lights_on;
EDIT_ITEM(bool, MSG_LEDS, &editable.state, leds.toggle);
ACTION_ITEM(MSG_SET_LEDS_DEFAULT, leds.set_default);
#if ENABLED(NEOPIXEL2_SEPARATE)
editable.state = leds2.lights_on;
EDIT_ITEM(bool, MSG_LEDS2, &editable.state, leds2.toggle);
ACTION_ITEM(MSG_SET_LEDS_DEFAULT, leds2.set_default);
#endif
#if ENABLED(LED_COLOR_PRESETS)
SUBMENU(MSG_LED_PRESETS, menu_led_presets);
#endif
#if ENABLED(NEO2_COLOR_PRESETS)
SUBMENU(MSG_NEO2_PRESETS, menu_leds2_presets);
#endif
SUBMENU(MSG_CUSTOM_LEDS, menu_led_custom);
#endif