Add support for an RGBW LED

2.0.x
Scott Lahteine 8 years ago
parent e7746ffee4
commit dac21ec680

@ -386,6 +386,6 @@
#define HAS_SOFTWARE_ENDSTOPS (ENABLED(MIN_SOFTWARE_ENDSTOPS) || ENABLED(MAX_SOFTWARE_ENDSTOPS))
#define HAS_RESUME_CONTINUE (ENABLED(NEWPANEL) || ENABLED(EMERGENCY_PARSER))
#define HAS_COLOR_LEDS (ENABLED(BLINKM) || ENABLED(RGB_LED))
#define HAS_COLOR_LEDS (ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED))
#endif //CONDITIONALS_LCD_H

@ -1532,10 +1532,12 @@
*
*/
//#define RGB_LED
#if ENABLED(RGB_LED)
//#define RGBW_LED
#if ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#define RGB_LED_W_PIN -1
#endif
/**
@ -1549,7 +1551,7 @@
* - Change to green once print has finished
* - Turn off after the print has finished and the user has pushed a button
*/
#if ENABLED(BLINKM) || ENABLED(RGB_LED)
#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define PRINTER_EVENT_LEDS
#endif

@ -947,7 +947,12 @@ void servo_init() {
#if HAS_COLOR_LEDS
void set_led_color(const uint8_t r, const uint8_t g, const uint8_t b) {
void set_led_color(
const uint8_t r, const uint8_t g, const uint8_t b
#if ENABLED(RGBW_LED)
, const uint8_t w=0
#endif
) {
#if ENABLED(BLINKM)
@ -965,6 +970,11 @@ void servo_init() {
analogWrite(RGB_LED_G_PIN, g);
analogWrite(RGB_LED_B_PIN, b);
#if ENABLED(RGBW_LED)
digitalWrite(RGB_LED_W_PIN, w ? HIGH : LOW);
analogWrite(RGB_LED_W_PIN, w);
#endif
#endif
}
@ -1156,7 +1166,7 @@ inline void get_serial_commands() {
card.printingHasFinished();
#if ENABLED(PRINTER_EVENT_LEDS)
LCD_MESSAGEPGM(MSG_INFO_COMPLETED_PRINTS);
set_led_color(0, 255, 0);
set_led_color(0, 255, 0); // Green
#if HAS_RESUME_CONTINUE
KEEPALIVE_STATE(PAUSED_FOR_USER);
wait_for_user = true;
@ -1165,7 +1175,7 @@ inline void get_serial_commands() {
#else
safe_delay(1000);
#endif
set_led_color(0, 0, 0);
set_led_color(0, 0, 0); // OFF
#endif
card.checkautostart(true);
}
@ -6199,7 +6209,11 @@ inline void gcode_M109() {
if (wait_for_heatup) {
LCD_MESSAGEPGM(MSG_HEATING_COMPLETE);
#if ENABLED(PRINTER_EVENT_LEDS)
set_led_color(255, 255, 255); // Set LEDs ALL WHITE
#if ENABLED(RGBW_LED)
set_led_color(0, 0, 0, 255); // Turn on the WHITE LED
#else
set_led_color(255, 255, 255); // Set LEDs All On
#endif
#endif
}
@ -6844,9 +6858,9 @@ inline void gcode_M121() { endstops.enable_globally(false); }
#if HAS_COLOR_LEDS
/**
* M150: Set Status LED Color - Use R-U-B for R-G-B
* M150: Set Status LED Color - Use R-U-B-W for R-G-B-W
*
* Always sets all 3 components. If a component is left out, set to 0.
* Always sets all 3 or 4 components. If a component is left out, set to 0.
*
* Examples:
*
@ -6854,6 +6868,7 @@ inline void gcode_M121() { endstops.enable_globally(false); }
* M150 R255 U127 ; Turn LED orange (PWM only)
* M150 ; Turn LED off
* M150 R U B ; Turn LED white
* M150 W ; Turn LED white using a white LED
*
*/
inline void gcode_M150() {
@ -6861,6 +6876,9 @@ inline void gcode_M121() { endstops.enable_globally(false); }
code_seen('R') ? (code_has_value() ? code_value_byte() : 255) : 0,
code_seen('U') ? (code_has_value() ? code_value_byte() : 255) : 0,
code_seen('B') ? (code_has_value() ? code_value_byte() : 255) : 0
#if ENABLED(RGBW_LED)
, code_seen('W') ? (code_has_value() ? code_value_byte() : 255) : 0
#endif
);
}

@ -34,10 +34,10 @@
#endif
/**
* We try our best to include sanity checks for all the changes configuration
* directives because people have a tendency to use outdated config files with
* the bleding edge source code, but sometimes this is not enough. This check
* will force a minimum config file revision, otherwise Marlin will not build.
* We try our best to include sanity checks for all changed configuration
* directives because users have a tendency to use outdated config files with
* the bleeding-edge source code, but sometimes this is not enough. This check
* forces a minimum config file revision. Otherwise Marlin will not build.
*/
#if ! defined(CONFIGURATION_H_VERSION) || CONFIGURATION_H_VERSION < REQUIRED_CONFIGURATION_H_VERSION
#error "You are using an old Configuration.h file, update it before building Marlin."
@ -951,14 +951,23 @@ static_assert(1 >= 0
/**
* RGB_LED Requirements
*/
#define _RGB_TEST (PIN_EXISTS(RGB_LED_R) && PIN_EXISTS(RGB_LED_G) && PIN_EXISTS(RGB_LED_B))
#if ENABLED(RGB_LED)
#if !(PIN_EXISTS(RGB_LED_R) && PIN_EXISTS(RGB_LED_G) && PIN_EXISTS(RGB_LED_B))
#if !_RGB_TEST
#error "RGB_LED requires RGB_LED_R_PIN, RGB_LED_G_PIN, and RGB_LED_B_PIN."
#elif ENABLED(RGBW_LED)
#error "Please enable only one of RGB_LED and RGBW_LED."
#elif ENABLED(BLINKM)
#error "RGB_LED and BLINKM are currently incompatible (both use M150)."
#endif
#elif ENABLED(RGBW_LED)
#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."
#elif ENABLED(BLINKM)
#error "RGBW_LED and BLINKM are currently incompatible (both use M150)."
#endif
#elif DISABLED(BLINKM) && ENABLED(PRINTER_EVENT_LEDS)
#error "PRINTER_EVENT_LEDS requires BLINKM or RGB_LED."
#error "PRINTER_EVENT_LEDS requires BLINKM, RGB_LED, or RGBW_LED."
#endif
/**

@ -1531,10 +1531,12 @@
*
*/
//#define RGB_LED
#if ENABLED(RGB_LED)
//#define RGBW_LED
#if ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#define RGB_LED_W_PIN -1
#endif
/**
@ -1548,7 +1550,7 @@
* - Change to green once print has finished
* - Turn off after the print has finished and the user has pushed a button
*/
#if ENABLED(BLINKM) || ENABLED(RGB_LED)
#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define PRINTER_EVENT_LEDS
#endif

@ -1515,10 +1515,12 @@
*
*/
//#define RGB_LED
#if ENABLED(RGB_LED)
//#define RGBW_LED
#if ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#define RGB_LED_W_PIN -1
#endif
/**
@ -1532,7 +1534,7 @@
* - Change to green once print has finished
* - Turn off after the print has finished and the user has pushed a button
*/
#if ENABLED(BLINKM) || ENABLED(RGB_LED)
#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define PRINTER_EVENT_LEDS
#endif

@ -1515,10 +1515,12 @@
*
*/
//#define RGB_LED
#if ENABLED(RGB_LED)
//#define RGBW_LED
#if ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#define RGB_LED_W_PIN -1
#endif
/**
@ -1532,7 +1534,7 @@
* - Change to green once print has finished
* - Turn off after the print has finished and the user has pushed a button
*/
#if ENABLED(BLINKM) || ENABLED(RGB_LED)
#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define PRINTER_EVENT_LEDS
#endif

@ -1523,10 +1523,12 @@
*
*/
//#define RGB_LED
#if ENABLED(RGB_LED)
//#define RGBW_LED
#if ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#define RGB_LED_W_PIN -1
#endif
/**
@ -1540,7 +1542,7 @@
* - Change to green once print has finished
* - Turn off after the print has finished and the user has pushed a button
*/
#if ENABLED(BLINKM) || ENABLED(RGB_LED)
#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define PRINTER_EVENT_LEDS
#endif

@ -1526,10 +1526,12 @@
*
*/
//#define RGB_LED
#if ENABLED(RGB_LED)
//#define RGBW_LED
#if ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#define RGB_LED_W_PIN -1
#endif
/**
@ -1543,7 +1545,7 @@
* - Change to green once print has finished
* - Turn off after the print has finished and the user has pushed a button
*/
#if ENABLED(BLINKM) || ENABLED(RGB_LED)
#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define PRINTER_EVENT_LEDS
#endif

@ -1566,10 +1566,12 @@
*
*/
//#define RGB_LED
#if ENABLED(RGB_LED)
//#define RGBW_LED
#if ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#define RGB_LED_W_PIN -1
#endif
/**
@ -1583,7 +1585,7 @@
* - Change to green once print has finished
* - Turn off after the print has finished and the user has pushed a button
*/
#if ENABLED(BLINKM) || ENABLED(RGB_LED)
#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define PRINTER_EVENT_LEDS
#endif

@ -1532,10 +1532,12 @@
*
*/
//#define RGB_LED
#if ENABLED(RGB_LED)
//#define RGBW_LED
#if ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#define RGB_LED_W_PIN -1
#endif
/**
@ -1549,7 +1551,7 @@
* - Change to green once print has finished
* - Turn off after the print has finished and the user has pushed a button
*/
#if ENABLED(BLINKM) || ENABLED(RGB_LED)
#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define PRINTER_EVENT_LEDS
#endif

@ -1532,10 +1532,12 @@
*
*/
//#define RGB_LED
#if ENABLED(RGB_LED)
//#define RGBW_LED
#if ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#define RGB_LED_W_PIN -1
#endif
/**
@ -1549,7 +1551,7 @@
* - Change to green once print has finished
* - Turn off after the print has finished and the user has pushed a button
*/
#if ENABLED(BLINKM) || ENABLED(RGB_LED)
#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define PRINTER_EVENT_LEDS
#endif

@ -1532,10 +1532,12 @@
*
*/
//#define RGB_LED
#if ENABLED(RGB_LED)
//#define RGBW_LED
#if ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#define RGB_LED_W_PIN -1
#endif
/**
@ -1549,7 +1551,7 @@
* - Change to green once print has finished
* - Turn off after the print has finished and the user has pushed a button
*/
#if ENABLED(BLINKM) || ENABLED(RGB_LED)
#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define PRINTER_EVENT_LEDS
#endif

@ -1533,10 +1533,12 @@
*
*/
//#define RGB_LED
#if ENABLED(RGB_LED)
//#define RGBW_LED
#if ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#define RGB_LED_W_PIN -1
#endif
/**
@ -1550,7 +1552,7 @@
* - Change to green once print has finished
* - Turn off after the print has finished and the user has pushed a button
*/
#if ENABLED(BLINKM) || ENABLED(RGB_LED)
#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define PRINTER_EVENT_LEDS
#endif

@ -1547,10 +1547,12 @@
*
*/
//#define RGB_LED
#if ENABLED(RGB_LED)
//#define RGBW_LED
#if ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#define RGB_LED_W_PIN -1
#endif
/**
@ -1564,7 +1566,7 @@
* - Change to green once print has finished
* - Turn off after the print has finished and the user has pushed a button
*/
#if ENABLED(BLINKM) || ENABLED(RGB_LED)
#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define PRINTER_EVENT_LEDS
#endif

@ -1552,10 +1552,12 @@
*
*/
//#define RGB_LED
#if ENABLED(RGB_LED)
//#define RGBW_LED
#if ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#define RGB_LED_W_PIN -1
#endif
/**
@ -1569,7 +1571,7 @@
* - Change to green once print has finished
* - Turn off after the print has finished and the user has pushed a button
*/
#if ENABLED(BLINKM) || ENABLED(RGB_LED)
#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define PRINTER_EVENT_LEDS
#endif

@ -1588,10 +1588,12 @@
*
*/
//#define RGB_LED
#if ENABLED(RGB_LED)
//#define RGBW_LED
#if ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#define RGB_LED_W_PIN -1
#endif
/**
@ -1605,7 +1607,7 @@
* - Change to green once print has finished
* - Turn off after the print has finished and the user has pushed a button
*/
#if ENABLED(BLINKM) || ENABLED(RGB_LED)
#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define PRINTER_EVENT_LEDS
#endif

@ -1523,10 +1523,12 @@
*
*/
//#define RGB_LED
#if ENABLED(RGB_LED)
//#define RGBW_LED
#if ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#define RGB_LED_W_PIN -1
#endif
/**
@ -1540,7 +1542,7 @@
* - Change to green once print has finished
* - Turn off after the print has finished and the user has pushed a button
*/
#if ENABLED(BLINKM) || ENABLED(RGB_LED)
#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define PRINTER_EVENT_LEDS
#endif

@ -1532,10 +1532,12 @@
*
*/
//#define RGB_LED
#if ENABLED(RGB_LED)
//#define RGBW_LED
#if ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#define RGB_LED_W_PIN -1
#endif
/**
@ -1549,7 +1551,7 @@
* - Change to green once print has finished
* - Turn off after the print has finished and the user has pushed a button
*/
#if ENABLED(BLINKM) || ENABLED(RGB_LED)
#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define PRINTER_EVENT_LEDS
#endif

@ -1648,10 +1648,12 @@
*
*/
//#define RGB_LED
#if ENABLED(RGB_LED)
//#define RGBW_LED
#if ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#define RGB_LED_W_PIN -1
#endif
/**
@ -1665,7 +1667,7 @@
* - Change to green once print has finished
* - Turn off after the print has finished and the user has pushed a button
*/
#if ENABLED(BLINKM) || ENABLED(RGB_LED)
#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define PRINTER_EVENT_LEDS
#endif

@ -1634,10 +1634,12 @@
*
*/
//#define RGB_LED
#if ENABLED(RGB_LED)
//#define RGBW_LED
#if ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#define RGB_LED_W_PIN -1
#endif
/**
@ -1651,7 +1653,7 @@
* - Change to green once print has finished
* - Turn off after the print has finished and the user has pushed a button
*/
#if ENABLED(BLINKM) || ENABLED(RGB_LED)
#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define PRINTER_EVENT_LEDS
#endif

@ -1630,10 +1630,12 @@
*
*/
//#define RGB_LED
#if ENABLED(RGB_LED)
//#define RGBW_LED
#if ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#define RGB_LED_W_PIN -1
#endif
/**
@ -1647,7 +1649,7 @@
* - Change to green once print has finished
* - Turn off after the print has finished and the user has pushed a button
*/
#if ENABLED(BLINKM) || ENABLED(RGB_LED)
#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define PRINTER_EVENT_LEDS
#endif

@ -1638,10 +1638,12 @@
*
*/
//#define RGB_LED
#if ENABLED(RGB_LED)
//#define RGBW_LED
#if ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#define RGB_LED_W_PIN -1
#endif
/**
@ -1655,7 +1657,7 @@
* - Change to green once print has finished
* - Turn off after the print has finished and the user has pushed a button
*/
#if ENABLED(BLINKM) || ENABLED(RGB_LED)
#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define PRINTER_EVENT_LEDS
#endif

@ -1645,10 +1645,12 @@
*
*/
//#define RGB_LED
#if ENABLED(RGB_LED)
//#define RGBW_LED
#if ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#define RGB_LED_W_PIN -1
#endif
/**
@ -1662,7 +1664,7 @@
* - Change to green once print has finished
* - Turn off after the print has finished and the user has pushed a button
*/
#if ENABLED(BLINKM) || ENABLED(RGB_LED)
#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define PRINTER_EVENT_LEDS
#endif

@ -1535,10 +1535,12 @@
*
*/
//#define RGB_LED
#if ENABLED(RGB_LED)
//#define RGBW_LED
#if ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#define RGB_LED_W_PIN -1
#endif
/**
@ -1552,7 +1554,7 @@
* - Change to green once print has finished
* - Turn off after the print has finished and the user has pushed a button
*/
#if ENABLED(BLINKM) || ENABLED(RGB_LED)
#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define PRINTER_EVENT_LEDS
#endif

@ -1528,10 +1528,12 @@
*
*/
//#define RGB_LED
#if ENABLED(RGB_LED)
//#define RGBW_LED
#if ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#define RGB_LED_W_PIN -1
#endif
/**
@ -1545,7 +1547,7 @@
* - Change to green once print has finished
* - Turn off after the print has finished and the user has pushed a button
*/
#if ENABLED(BLINKM) || ENABLED(RGB_LED)
#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define PRINTER_EVENT_LEDS
#endif

@ -1521,10 +1521,27 @@
// Support for an RGB LED using 3 separate pins with optional PWM
//#define RGB_LED
#if ENABLED(RGB_LED)
//#define RGBW_LED
#if ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#define RGB_LED_W_PIN -1
#endif
/**
* Printer Event LEDs
*
* During printing, the LEDs will reflect the printer status:
*
* - Gradually change from blue to violet as the heated bed gets to target temp
* - Gradually change from violet to red as the hotend gets to temperature
* - Change to white to illuminate work surface
* - Change to green once print has finished
* - Turn off after the print has finished and the user has pushed a button
*/
#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define PRINTER_EVENT_LEDS
#endif
/*********************************************************************\

Loading…
Cancel
Save