Browse Source

Merge pull request #5330 from thinkyhead/rc_rgb_led

Support for an RGB LED using 3 pins
pull/1/head
Scott Lahteine 8 years ago
committed by GitHub
parent
commit
415294801f
  1. 8
      Marlin/Configuration.h
  2. 61
      Marlin/Marlin_main.cpp
  3. 11
      Marlin/SanityCheck.h
  4. 8
      Marlin/example_configurations/Cartesio/Configuration.h
  5. 8
      Marlin/example_configurations/Felix/Configuration.h
  6. 8
      Marlin/example_configurations/Felix/DUAL/Configuration.h
  7. 8
      Marlin/example_configurations/Hephestos/Configuration.h
  8. 8
      Marlin/example_configurations/Hephestos_2/Configuration.h
  9. 8
      Marlin/example_configurations/K8200/Configuration.h
  10. 8
      Marlin/example_configurations/K8400/Configuration.h
  11. 8
      Marlin/example_configurations/K8400/Dual-head/Configuration.h
  12. 8
      Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h
  13. 8
      Marlin/example_configurations/RigidBot/Configuration.h
  14. 8
      Marlin/example_configurations/SCARA/Configuration.h
  15. 8
      Marlin/example_configurations/TAZ4/Configuration.h
  16. 8
      Marlin/example_configurations/WITBOX/Configuration.h
  17. 8
      Marlin/example_configurations/adafruit/ST7565/Configuration.h
  18. 8
      Marlin/example_configurations/delta/biv2.5/Configuration.h
  19. 8
      Marlin/example_configurations/delta/generic/Configuration.h
  20. 8
      Marlin/example_configurations/delta/kossel_mini/Configuration.h
  21. 8
      Marlin/example_configurations/delta/kossel_pro/Configuration.h
  22. 8
      Marlin/example_configurations/delta/kossel_xl/Configuration.h
  23. 8
      Marlin/example_configurations/makibox/Configuration.h
  24. 8
      Marlin/example_configurations/tvrrug/Round2/Configuration.h

8
Marlin/Configuration.h

@ -1375,6 +1375,14 @@
//define BlinkM/CyzRgb Support
//#define BLINKM
// Support for an RGB LED using 3 separate pins with optional PWM
//#define RGB_LED
#if ENABLED(RGB_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#endif
/*********************************************************************\
* R/C SERVO support
* Sponsored by TrinityLabs, Reworked by codexmas

61
Marlin/Marlin_main.cpp

@ -113,7 +113,7 @@
* M108 - Break out of heating loops (M109, M190, M303). With no controller, breaks out of M0/M1. (Requires EMERGENCY_PARSER)
* M109 - Sxxx Wait for extruder current temp to reach target temp. Waits only when heating
* Rxxx Wait for extruder current temp to reach target temp. Waits when heating and cooling
* IF AUTOTEMP is enabled, S<mintemp> B<maxtemp> F<factor>. Exit autotemp by any M109 without F
* If AUTOTEMP is enabled, S<mintemp> B<maxtemp> F<factor>. Exit autotemp by any M109 without F
* M110 - Set the current line number. (Used by host printing)
* M111 - Set debug flags: "M111 S<flagbits>". See flag bits defined in enum.h.
* M112 - Emergency stop.
@ -131,7 +131,7 @@
* M140 - Set bed target temp. S<temp>
* M145 - Set heatup values for materials on the LCD. H<hotend> B<bed> F<fan speed> for S<material> (0=PLA, 1=ABS)
* M149 - Set temperature units. (Requires TEMPERATURE_UNITS_SUPPORT)
* M150 - Set BlinkM Color R<red> U<green> B<blue>. Values 0-255. (Requires BLINKM)
* M150 - Set Status LED Color as R<red> U<green> B<blue>. Values 0-255. (Requires BLINKM or RGB_LED)
* M155 - Auto-report temperatures with interval of S<seconds>. (Requires AUTO_REPORT_TEMPERATURES)
* M163 - Set a single proportion for a mixing extruder. (Requires MIXING_EXTRUDER)
* M164 - Save the mix as a virtual extruder. (Requires MIXING_EXTRUDER and MIXING_VIRTUAL_TOOLS)
@ -5958,20 +5958,55 @@ inline void gcode_M121() { endstops.enable_globally(false); }
}
#endif // HAVE_TMC2130DRIVER
#if ENABLED(BLINKM)
#if ENABLED(BLINKM) || ENABLED(RGB_LED)
void set_led_color(const uint8_t r, const uint8_t g, const uint8_t b) {
#if ENABLED(BLINKM)
// This variant uses i2c to send the RGB components to the device.
SendColors(
code_seen('R') ? code_value_byte() : 0,
code_seen('U') ? code_value_byte() : 0,
code_seen('B') ? code_value_byte() : 0
);
#else
// This variant uses 3 separate pins for the RGB components.
// If the pins can do PWM then their intensity will be set.
digitalWrite(RGB_LED_R_PIN, r ? HIGH : LOW);
digitalWrite(RGB_LED_G_PIN, g ? HIGH : LOW);
digitalWrite(RGB_LED_B_PIN, b ? HIGH : LOW);
analogWrite(RGB_LED_R_PIN, r);
analogWrite(RGB_LED_G_PIN, g);
analogWrite(RGB_LED_B_PIN, b);
#endif
}
/**
* M150: Set Status LED Color - Use R-U-B for R-G-B
*
* Always sets all 3 components. If a component is left out, set to 0.
*
* Examples:
*
* M150 R255 ; Turn LED red
* M150 R255 U127 ; Turn LED orange (PWM only)
* M150 ; Turn LED off
* M150 R U B ; Turn LED white
*
*/
inline void gcode_M150() {
SendColors(
code_seen('R') ? code_value_byte() : 0,
code_seen('U') ? code_value_byte() : 0,
code_seen('B') ? code_value_byte() : 0
set_led_color(
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
);
}
#endif // BLINKM
#endif // BLINKM || RGB_LED
/**
* M200: Set filament diameter and set E axis units to cubic units
@ -8147,9 +8182,9 @@ void process_next_command() {
break;
#endif
#if ENABLED(BLINKM)
#if ENABLED(BLINKM) || ENABLED(RGB_LED)
case 150: // M150: Set the BlinkM LCD color
case 150: // M150: Set Status LED Color
gcode_M150();
break;
@ -10071,6 +10106,12 @@ void setup() {
OUT_WRITE(STAT_LED_BLUE_PIN, LOW); // turn it off
#endif
#if ENABLED(RGB_LED)
pinMode(RGB_LED_R_PIN, OUTPUT);
pinMode(RGB_LED_G_PIN, OUTPUT);
pinMode(RGB_LED_B_PIN, OUTPUT);
#endif
lcd_init();
#if ENABLED(SHOW_BOOTSCREEN)
#if ENABLED(DOGLCD)

11
Marlin/SanityCheck.h

@ -885,6 +885,17 @@
#endif
#endif
/**
* RGB_LED Requirements
*/
#if ENABLED(RGB_LED)
#if !(PIN_EXISTS(RGB_LED_R) && PIN_EXISTS(RGB_LED_G) && PIN_EXISTS(RGB_LED_B))
#error "RGB_LED requires RGB_LED_R_PIN, RGB_LED_G_PIN, and RGB_LED_B_PIN."
#elif ENABLED(BLINKM)
#error "RGB_LED and BLINKM are currently incompatible (both use M150)."
#endif
#endif
/**
* Auto Fan check for PWM pins
*/

8
Marlin/example_configurations/Cartesio/Configuration.h

@ -1375,6 +1375,14 @@
//define BlinkM/CyzRgb Support
//#define BLINKM
// Support for an RGB LED using 3 separate pins with optional PWM
//#define RGB_LED
#if ENABLED(RGB_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#endif
/*********************************************************************\
* R/C SERVO support
* Sponsored by TrinityLabs, Reworked by codexmas

8
Marlin/example_configurations/Felix/Configuration.h

@ -1358,6 +1358,14 @@
//define BlinkM/CyzRgb Support
//#define BLINKM
// Support for an RGB LED using 3 separate pins with optional PWM
//#define RGB_LED
#if ENABLED(RGB_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#endif
/*********************************************************************\
* R/C SERVO support
* Sponsored by TrinityLabs, Reworked by codexmas

8
Marlin/example_configurations/Felix/DUAL/Configuration.h

@ -1358,6 +1358,14 @@
//define BlinkM/CyzRgb Support
//#define BLINKM
// Support for an RGB LED using 3 separate pins with optional PWM
//#define RGB_LED
#if ENABLED(RGB_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#endif
/*********************************************************************\
* R/C SERVO support
* Sponsored by TrinityLabs, Reworked by codexmas

8
Marlin/example_configurations/Hephestos/Configuration.h

@ -1367,6 +1367,14 @@
//define BlinkM/CyzRgb Support
//#define BLINKM
// Support for an RGB LED using 3 separate pins with optional PWM
//#define RGB_LED
#if ENABLED(RGB_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#endif
/*********************************************************************\
* R/C SERVO support
* Sponsored by TrinityLabs, Reworked by codexmas

8
Marlin/example_configurations/Hephestos_2/Configuration.h

@ -1369,6 +1369,14 @@
//define BlinkM/CyzRgb Support
//#define BLINKM
// Support for an RGB LED using 3 separate pins with optional PWM
//#define RGB_LED
#if ENABLED(RGB_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#endif
/*********************************************************************\
* R/C SERVO support
* Sponsored by TrinityLabs, Reworked by codexmas

8
Marlin/example_configurations/K8200/Configuration.h

@ -1409,6 +1409,14 @@
//define BlinkM/CyzRgb Support
//#define BLINKM
// Support for an RGB LED using 3 separate pins with optional PWM
//#define RGB_LED
#if ENABLED(RGB_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#endif
/*********************************************************************\
* R/C SERVO support
* Sponsored by TrinityLabs, Reworked by codexmas

8
Marlin/example_configurations/K8400/Configuration.h

@ -1375,6 +1375,14 @@
//define BlinkM/CyzRgb Support
//#define BLINKM
// Support for an RGB LED using 3 separate pins with optional PWM
//#define RGB_LED
#if ENABLED(RGB_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#endif
/*********************************************************************\
* R/C SERVO support
* Sponsored by TrinityLabs, Reworked by codexmas

8
Marlin/example_configurations/K8400/Dual-head/Configuration.h

@ -1375,6 +1375,14 @@
//define BlinkM/CyzRgb Support
//#define BLINKM
// Support for an RGB LED using 3 separate pins with optional PWM
//#define RGB_LED
#if ENABLED(RGB_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#endif
/*********************************************************************\
* R/C SERVO support
* Sponsored by TrinityLabs, Reworked by codexmas

8
Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h

@ -1375,6 +1375,14 @@
//define BlinkM/CyzRgb Support
//#define BLINKM
// Support for an RGB LED using 3 separate pins with optional PWM
//#define RGB_LED
#if ENABLED(RGB_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#endif
/*********************************************************************\
* R/C SERVO support
* Sponsored by TrinityLabs, Reworked by codexmas

8
Marlin/example_configurations/RigidBot/Configuration.h

@ -1375,6 +1375,14 @@
//define BlinkM/CyzRgb Support
//#define BLINKM
// Support for an RGB LED using 3 separate pins with optional PWM
//#define RGB_LED
#if ENABLED(RGB_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#endif
/*********************************************************************\
* R/C SERVO support
* Sponsored by TrinityLabs, Reworked by codexmas

8
Marlin/example_configurations/SCARA/Configuration.h

@ -1390,6 +1390,14 @@
//define BlinkM/CyzRgb Support
//#define BLINKM
// Support for an RGB LED using 3 separate pins with optional PWM
//#define RGB_LED
#if ENABLED(RGB_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#endif
/*********************************************************************\
* R/C SERVO support
* Sponsored by TrinityLabs, Reworked by codexmas

8
Marlin/example_configurations/TAZ4/Configuration.h

@ -1396,6 +1396,14 @@
//define BlinkM/CyzRgb Support
//#define BLINKM
// Support for an RGB LED using 3 separate pins with optional PWM
//#define RGB_LED
#if ENABLED(RGB_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#endif
/*********************************************************************\
* R/C SERVO support
* Sponsored by TrinityLabs, Reworked by codexmas

8
Marlin/example_configurations/WITBOX/Configuration.h

@ -1367,6 +1367,14 @@
//define BlinkM/CyzRgb Support
//#define BLINKM
// Support for an RGB LED using 3 separate pins with optional PWM
//#define RGB_LED
#if ENABLED(RGB_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#endif
/*********************************************************************\
* R/C SERVO support
* Sponsored by TrinityLabs, Reworked by codexmas

8
Marlin/example_configurations/adafruit/ST7565/Configuration.h

@ -1375,6 +1375,14 @@
//define BlinkM/CyzRgb Support
//#define BLINKM
// Support for an RGB LED using 3 separate pins with optional PWM
//#define RGB_LED
#if ENABLED(RGB_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#endif
/*********************************************************************\
* R/C SERVO support
* Sponsored by TrinityLabs, Reworked by codexmas

8
Marlin/example_configurations/delta/biv2.5/Configuration.h

@ -1471,6 +1471,14 @@
//define BlinkM/CyzRgb Support
//#define BLINKM
// Support for an RGB LED using 3 separate pins with optional PWM
//#define RGB_LED
#if ENABLED(RGB_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#endif
/*********************************************************************\
* R/C SERVO support
* Sponsored by TrinityLabs, Reworked by codexmas

8
Marlin/example_configurations/delta/generic/Configuration.h

@ -1465,6 +1465,14 @@
//define BlinkM/CyzRgb Support
//#define BLINKM
// Support for an RGB LED using 3 separate pins with optional PWM
//#define RGB_LED
#if ENABLED(RGB_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#endif
/*********************************************************************\
* R/C SERVO support
* Sponsored by TrinityLabs, Reworked by codexmas

8
Marlin/example_configurations/delta/kossel_mini/Configuration.h

@ -1468,6 +1468,14 @@
//define BlinkM/CyzRgb Support
//#define BLINKM
// Support for an RGB LED using 3 separate pins with optional PWM
//#define RGB_LED
#if ENABLED(RGB_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#endif
/*********************************************************************\
* R/C SERVO support
* Sponsored by TrinityLabs, Reworked by codexmas

8
Marlin/example_configurations/delta/kossel_pro/Configuration.h

@ -1467,6 +1467,14 @@
//define BlinkM/CyzRgb Support
//#define BLINKM
// Support for an RGB LED using 3 separate pins with optional PWM
//#define RGB_LED
#if ENABLED(RGB_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#endif
/*********************************************************************\
* R/C SERVO support
* Sponsored by TrinityLabs, Reworked by codexmas

8
Marlin/example_configurations/delta/kossel_xl/Configuration.h

@ -1471,6 +1471,14 @@
//define BlinkM/CyzRgb Support
//#define BLINKM
// Support for an RGB LED using 3 separate pins with optional PWM
//#define RGB_LED
#if ENABLED(RGB_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#endif
/*********************************************************************\
* R/C SERVO support
* Sponsored by TrinityLabs, Reworked by codexmas

8
Marlin/example_configurations/makibox/Configuration.h

@ -1378,6 +1378,14 @@
//define BlinkM/CyzRgb Support
//#define BLINKM
// Support for an RGB LED using 3 separate pins with optional PWM
//#define RGB_LED
#if ENABLED(RGB_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#endif
/*********************************************************************\
* R/C SERVO support
* Sponsored by TrinityLabs, Reworked by codexmas

8
Marlin/example_configurations/tvrrug/Round2/Configuration.h

@ -1371,6 +1371,14 @@
//define BlinkM/CyzRgb Support
//#define BLINKM
// Support for an RGB LED using 3 separate pins with optional PWM
//#define RGB_LED
#if ENABLED(RGB_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#endif
/*********************************************************************\
* R/C SERVO support
* Sponsored by TrinityLabs, Reworked by codexmas

Loading…
Cancel
Save