diff --git a/.travis.yml b/.travis.yml index 03f7585d0ce95982d299cf52c3af1a0f9a570f10..643517a447696fea933827b9acc03299b7946373 100644 --- a/.travis.yml +++ b/.travis.yml @@ -291,6 +291,12 @@ script: - opt_enable ULTIMAKERCONTROLLER - build_marlin # + # PCA9632 + # + - restore_configs + - opt_enable PCA9632 + - build_marlin + # # MAKRPANEL # Needs to use Melzi and Sanguino hardware # diff --git a/Marlin/Conditionals_LCD.h b/Marlin/Conditionals_LCD.h index b33499e6bff696aede1fb841b22905dd76443154..48cc0141a54f5a05226f9456c96201c659aca33a 100644 --- a/Marlin/Conditionals_LCD.h +++ b/Marlin/Conditionals_LCD.h @@ -398,6 +398,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) || ENABLED(RGBW_LED)) + #define HAS_COLOR_LEDS (ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632)) #endif // CONDITIONALS_LCD_H diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index cc422b652515c21d09266a123dd7e435141bbb9a..7d6c4a5614342e42561a6af688d332cbe8bca403 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1482,6 +1482,9 @@ //define BlinkM/CyzRgb Support //#define BLINKM +//define PCA9632 PWM LED driver Support +//#define PCA9632 + /** * RGB LED / LED Strip Control * @@ -1519,7 +1522,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) || ENABLED(RGBW_LED) +#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) #define PRINTER_EVENT_LEDS #endif diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 35a9f3e5ddf74661b88055e1242239dbf32dfd28..da3bf1a12c06f1df356d395e44d282f798df596e 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -138,7 +138,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 Status LED Color as R<red> U<green> B<blue>. Values 0-255. (Requires BLINKM or RGB_LED) + * M150 - Set Status LED Color as R<red> U<green> B<blue>. Values 0-255. (Requires BLINKM, RGB_LED, RGBW_LED, or PCA9632) * 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) @@ -280,6 +280,10 @@ #include "Wire.h" #endif +#if ENABLED(PCA9632) + #include "pca9632.h" +#endif + #if HAS_SERVOS #include "servo.h" #endif @@ -986,7 +990,9 @@ void servo_init() { // This variant uses i2c to send the RGB components to the device. SendColors(r, g, b); - #else + #endif + + #if ENABLED(RGB_LED) || ENABLED(RGBW_LED) // This variant uses 3 separate pins for the RGB components. // If the pins can do PWM then their intensity will be set. @@ -1003,6 +1009,11 @@ void servo_init() { #endif #endif + + #if ENABLED(PCA9632) + // Update I2C LED driver + PCA9632_SetColor(r, g, b); + #endif } #endif // HAS_COLOR_LEDS @@ -5893,7 +5904,7 @@ inline void gcode_M17() { if (!DEBUGGING(DRYRUN) && unload_length != 0) { #if ENABLED(PREVENT_COLD_EXTRUSION) - if (!thermalManager.allow_cold_extrude && + if (!thermalManager.allow_cold_extrude && thermalManager.degTargetHotend(active_extruder) < thermalManager.extrude_min_temp) { SERIAL_ERROR_START(); SERIAL_ERRORLNPGM(MSG_TOO_COLD_FOR_M600); @@ -8013,7 +8024,7 @@ inline void gcode_M121() { endstops.enable_globally(false); } ); } -#endif // BLINKM || RGB_LED +#endif // HAS_COLOR_LEDS /** * M200: Set filament diameter and set E axis units to cubic units @@ -10621,7 +10632,7 @@ void process_next_command() { gcode_M150(); break; - #endif // BLINKM + #endif // HAS_COLOR_LEDS #if ENABLED(MIXING_EXTRUDER) case 163: // M163: Set a component weight for mixing extruder diff --git a/Marlin/SanityCheck.h b/Marlin/SanityCheck.h index f97573336191a10ab93afc0c7ec0a71c17c437b3..de4f550d2bb3adb76b9b906e518c5670e2791370 100644 --- a/Marlin/SanityCheck.h +++ b/Marlin/SanityCheck.h @@ -1027,17 +1027,13 @@ static_assert(1 >= 0 #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, RGB_LED, or RGBW_LED." +#elif ENABLED(PRINTER_EVENT_LEDS) && DISABLED(BLINKM) && DISABLED(PCA9632) + #error "PRINTER_EVENT_LEDS requires BLINKM, PCA9632, RGB_LED, or RGBW_LED." #endif /** diff --git a/Marlin/example_configurations/CL-260/Configuration.h b/Marlin/example_configurations/CL-260/Configuration.h index 8be2b4427b8144cd179265a99c9e0219e7294c1f..fe024c71b5b33337f7d70424a441c90c4eeeb8b8 100644 --- a/Marlin/example_configurations/CL-260/Configuration.h +++ b/Marlin/example_configurations/CL-260/Configuration.h @@ -1482,6 +1482,9 @@ //define BlinkM/CyzRgb Support //#define BLINKM +//define PCA9632 PWM LED driver Support +//#define PCA9632 + /** * RGB LED / LED Strip Control * @@ -1519,7 +1522,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) || ENABLED(RGBW_LED) +#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) #define PRINTER_EVENT_LEDS #endif diff --git a/Marlin/example_configurations/Cartesio/Configuration.h b/Marlin/example_configurations/Cartesio/Configuration.h index 13929a954328e80b9a1323f98eb3dfce6133c73d..38fd64f429b72b879b5c064eb89668cf4c90d167 100644 --- a/Marlin/example_configurations/Cartesio/Configuration.h +++ b/Marlin/example_configurations/Cartesio/Configuration.h @@ -1479,6 +1479,9 @@ //define BlinkM/CyzRgb Support //#define BLINKM +//define PCA9632 PWM LED driver Support +//#define PCA9632 + /** * RGB LED / LED Strip Control * @@ -1516,7 +1519,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) || ENABLED(RGBW_LED) +#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) #define PRINTER_EVENT_LEDS #endif diff --git a/Marlin/example_configurations/Felix/Configuration.h b/Marlin/example_configurations/Felix/Configuration.h index d2fd786a5d47b82b6f7ba0c4c03be365dbf9f280..d4c3f07381e0e112aef9841b442a71457c59127b 100644 --- a/Marlin/example_configurations/Felix/Configuration.h +++ b/Marlin/example_configurations/Felix/Configuration.h @@ -1463,6 +1463,9 @@ //define BlinkM/CyzRgb Support //#define BLINKM +//define PCA9632 PWM LED driver Support +//#define PCA9632 + /** * RGB LED / LED Strip Control * @@ -1500,7 +1503,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) || ENABLED(RGBW_LED) +#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) #define PRINTER_EVENT_LEDS #endif diff --git a/Marlin/example_configurations/Felix/DUAL/Configuration.h b/Marlin/example_configurations/Felix/DUAL/Configuration.h index 5189616aadbcb42788ef237006c179b8f315ce5c..863b725e9adf7d33bfb6f350ff6a2004dbd629a5 100644 --- a/Marlin/example_configurations/Felix/DUAL/Configuration.h +++ b/Marlin/example_configurations/Felix/DUAL/Configuration.h @@ -1463,6 +1463,9 @@ //define BlinkM/CyzRgb Support //#define BLINKM +//define PCA9632 PWM LED driver Support +//#define PCA9632 + /** * RGB LED / LED Strip Control * @@ -1500,7 +1503,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) || ENABLED(RGBW_LED) +#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) #define PRINTER_EVENT_LEDS #endif diff --git a/Marlin/example_configurations/FolgerTech-i3-2020/Configuration.h b/Marlin/example_configurations/FolgerTech-i3-2020/Configuration.h index 8d72fcc27c8eae06c1b240d898e847eddbe44cd3..1f464ee041b5f5191075c2bd0acd5147eadd4db3 100644 --- a/Marlin/example_configurations/FolgerTech-i3-2020/Configuration.h +++ b/Marlin/example_configurations/FolgerTech-i3-2020/Configuration.h @@ -1485,6 +1485,9 @@ //define BlinkM/CyzRgb Support //#define BLINKM +//define PCA9632 PWM LED driver Support +//#define PCA9632 + /** * RGB LED / LED Strip Control * @@ -1522,7 +1525,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) || ENABLED(RGBW_LED) +#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) #define PRINTER_EVENT_LEDS #endif diff --git a/Marlin/example_configurations/Hephestos/Configuration.h b/Marlin/example_configurations/Hephestos/Configuration.h index ae0e3a89a5d6604340118d5236a933d00ef59210..44cc30e42e39f107444eda2a0c6e3bba501d9624 100644 --- a/Marlin/example_configurations/Hephestos/Configuration.h +++ b/Marlin/example_configurations/Hephestos/Configuration.h @@ -1471,6 +1471,9 @@ //define BlinkM/CyzRgb Support //#define BLINKM +//define PCA9632 PWM LED driver Support +//#define PCA9632 + /** * RGB LED / LED Strip Control * @@ -1508,7 +1511,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) || ENABLED(RGBW_LED) +#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) #define PRINTER_EVENT_LEDS #endif diff --git a/Marlin/example_configurations/Hephestos_2/Configuration.h b/Marlin/example_configurations/Hephestos_2/Configuration.h index aab15d09a7070b6d656190c259c543103d2e1600..04dd6842ccacaed77139ea67090aee468b52e944 100644 --- a/Marlin/example_configurations/Hephestos_2/Configuration.h +++ b/Marlin/example_configurations/Hephestos_2/Configuration.h @@ -1474,6 +1474,9 @@ //define BlinkM/CyzRgb Support //#define BLINKM +//define PCA9632 PWM LED driver Support +//#define PCA9632 + /** * RGB LED / LED Strip Control * @@ -1511,7 +1514,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) || ENABLED(RGBW_LED) +#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) #define PRINTER_EVENT_LEDS #endif diff --git a/Marlin/example_configurations/K8200/Configuration.h b/Marlin/example_configurations/K8200/Configuration.h index 2efae1810958951c2ffaa2112b110b2fe3ab5cf4..86304303e44713b22680fae2793fbe63f7372bce 100644 --- a/Marlin/example_configurations/K8200/Configuration.h +++ b/Marlin/example_configurations/K8200/Configuration.h @@ -1515,6 +1515,9 @@ //define BlinkM/CyzRgb Support //#define BLINKM +//define PCA9632 PWM LED driver Support +//#define PCA9632 + /** * RGB LED / LED Strip Control * @@ -1552,7 +1555,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) || ENABLED(RGBW_LED) +#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) #define PRINTER_EVENT_LEDS #endif diff --git a/Marlin/example_configurations/K8400/Configuration.h b/Marlin/example_configurations/K8400/Configuration.h index 8c2ed2be9f0ccc75206e010259d8f7f7e961ecda..8152f2d619912834d66fac7b6b692ef158732fbb 100644 --- a/Marlin/example_configurations/K8400/Configuration.h +++ b/Marlin/example_configurations/K8400/Configuration.h @@ -1481,6 +1481,9 @@ //define BlinkM/CyzRgb Support //#define BLINKM +//define PCA9632 PWM LED driver Support +//#define PCA9632 + /** * RGB LED / LED Strip Control * @@ -1518,7 +1521,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) || ENABLED(RGBW_LED) +#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) #define PRINTER_EVENT_LEDS #endif diff --git a/Marlin/example_configurations/K8400/Dual-head/Configuration.h b/Marlin/example_configurations/K8400/Dual-head/Configuration.h index 7236ab4968e32895b1e7666b11626e3d655fef1a..735ac65718d9efeab40f188f30dfa718e15c1a21 100644 --- a/Marlin/example_configurations/K8400/Dual-head/Configuration.h +++ b/Marlin/example_configurations/K8400/Dual-head/Configuration.h @@ -1481,6 +1481,9 @@ //define BlinkM/CyzRgb Support //#define BLINKM +//define PCA9632 PWM LED driver Support +//#define PCA9632 + /** * RGB LED / LED Strip Control * @@ -1518,7 +1521,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) || ENABLED(RGBW_LED) +#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) #define PRINTER_EVENT_LEDS #endif diff --git a/Marlin/example_configurations/M150/Configuration.h b/Marlin/example_configurations/M150/Configuration.h index 7b5321be9e5299808860985a4b4a59dfb72a3bed..75c4f4c1292bdc576262ecc1cb2be407ece47c69 100644 --- a/Marlin/example_configurations/M150/Configuration.h +++ b/Marlin/example_configurations/M150/Configuration.h @@ -1508,6 +1508,9 @@ //define BlinkM/CyzRgb Support //#define BLINKM +//define PCA9632 PWM LED driver Support +//#define PCA9632 + /** * RGB LED / LED Strip Control * @@ -1545,7 +1548,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) || ENABLED(RGBW_LED) +#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) #define PRINTER_EVENT_LEDS #endif diff --git a/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h b/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h index 409684ed8c8d7c411a4c69a94cefa634c61e37e4..fd0fedc30af53c986a0fce9f6c9c0f9f90e748c9 100644 --- a/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h +++ b/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h @@ -1481,6 +1481,9 @@ //define BlinkM/CyzRgb Support //#define BLINKM +//define PCA9632 PWM LED driver Support +//#define PCA9632 + /** * RGB LED / LED Strip Control * @@ -1518,7 +1521,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) || ENABLED(RGBW_LED) +#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) #define PRINTER_EVENT_LEDS #endif diff --git a/Marlin/example_configurations/RigidBot/Configuration.h b/Marlin/example_configurations/RigidBot/Configuration.h index ef09f4706784047f3d269deec9989de4ad951c9e..77fa6469bfe4fefd093494ea1cdb9eb81ebebbb4 100644 --- a/Marlin/example_configurations/RigidBot/Configuration.h +++ b/Marlin/example_configurations/RigidBot/Configuration.h @@ -1481,6 +1481,9 @@ //define BlinkM/CyzRgb Support //#define BLINKM +//define PCA9632 PWM LED driver Support +//#define PCA9632 + /** * RGB LED / LED Strip Control * @@ -1518,7 +1521,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) || ENABLED(RGBW_LED) +#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) #define PRINTER_EVENT_LEDS #endif diff --git a/Marlin/example_configurations/SCARA/Configuration.h b/Marlin/example_configurations/SCARA/Configuration.h index 9af3cecde5a751d4aaa0a07ae8957d30956ac55f..6f92b4f89281c80bc031d66a0e14dbce5d3e9f1c 100644 --- a/Marlin/example_configurations/SCARA/Configuration.h +++ b/Marlin/example_configurations/SCARA/Configuration.h @@ -1496,6 +1496,9 @@ //define BlinkM/CyzRgb Support //#define BLINKM +//define PCA9632 PWM LED driver Support +//#define PCA9632 + /** * RGB LED / LED Strip Control * @@ -1533,7 +1536,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) || ENABLED(RGBW_LED) +#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) #define PRINTER_EVENT_LEDS #endif diff --git a/Marlin/example_configurations/TAZ4/Configuration.h b/Marlin/example_configurations/TAZ4/Configuration.h index 46609467523fe4ddd539292c7a432629ed58fd68..845c758d2fccc2081b328164ad625da8e3d74fdc 100644 --- a/Marlin/example_configurations/TAZ4/Configuration.h +++ b/Marlin/example_configurations/TAZ4/Configuration.h @@ -1500,6 +1500,9 @@ //define BlinkM/CyzRgb Support //#define BLINKM +//define PCA9632 PWM LED driver Support +//#define PCA9632 + /** * RGB LED / LED Strip Control * @@ -1537,7 +1540,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) || ENABLED(RGBW_LED) +#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) #define PRINTER_EVENT_LEDS #endif diff --git a/Marlin/example_configurations/TinyBoy2/Configuration.h b/Marlin/example_configurations/TinyBoy2/Configuration.h index 4fefe85d6c9d0e009e7a181be9051c0e67fe6da4..0326daf299151506422557ba1abad799efb3dc14 100644 --- a/Marlin/example_configurations/TinyBoy2/Configuration.h +++ b/Marlin/example_configurations/TinyBoy2/Configuration.h @@ -1537,6 +1537,9 @@ //define BlinkM/CyzRgb Support //#define BLINKM +//define PCA9632 PWM LED driver Support +//#define PCA9632 + /** * RGB LED / LED Strip Control * @@ -1574,7 +1577,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) || ENABLED(RGBW_LED) +#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) #define PRINTER_EVENT_LEDS #endif diff --git a/Marlin/example_configurations/WITBOX/Configuration.h b/Marlin/example_configurations/WITBOX/Configuration.h index 187fb948a6b9adc9c7bd98b7c6c4400290106d8f..d090f55065b99eda07d0e76350a36b5b40770bef 100644 --- a/Marlin/example_configurations/WITBOX/Configuration.h +++ b/Marlin/example_configurations/WITBOX/Configuration.h @@ -1471,6 +1471,9 @@ //define BlinkM/CyzRgb Support //#define BLINKM +//define PCA9632 PWM LED driver Support +//#define PCA9632 + /** * RGB LED / LED Strip Control * @@ -1508,7 +1511,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) || ENABLED(RGBW_LED) +#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) #define PRINTER_EVENT_LEDS #endif diff --git a/Marlin/example_configurations/adafruit/ST7565/Configuration.h b/Marlin/example_configurations/adafruit/ST7565/Configuration.h index 0f608c7a1dcabf81c10621b4a7da054ac8f0c0d0..04c62167b0497c4196eb216863c56e0b3c9aa0c5 100644 --- a/Marlin/example_configurations/adafruit/ST7565/Configuration.h +++ b/Marlin/example_configurations/adafruit/ST7565/Configuration.h @@ -1481,6 +1481,9 @@ //define BlinkM/CyzRgb Support //#define BLINKM +//define PCA9632 PWM LED driver Support +//#define PCA9632 + /** * RGB LED / LED Strip Control * @@ -1518,7 +1521,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) || ENABLED(RGBW_LED) +#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) #define PRINTER_EVENT_LEDS #endif diff --git a/Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration.h b/Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration.h index df495943d643d1daef5229e40518adad4ef20674..840287c96f3a87dd0bb8a37ebbbebc5aa8013abe 100644 --- a/Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration.h +++ b/Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration.h @@ -1602,6 +1602,9 @@ //define BlinkM/CyzRgb Support //#define BLINKM +//define PCA9632 PWM LED driver Support +//#define PCA9632 + /** * RGB LED / LED Strip Control * @@ -1639,7 +1642,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) || ENABLED(RGBW_LED) +#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) #define PRINTER_EVENT_LEDS #endif diff --git a/Marlin/example_configurations/delta/FLSUN/kossel_mini/Configuration.h b/Marlin/example_configurations/delta/FLSUN/kossel_mini/Configuration.h index 453b0a603f3d5e20df34ad20ca5bde5fa6cce260..b7fe4eed911fc88189f3c809d88bceb48fe31c02 100644 --- a/Marlin/example_configurations/delta/FLSUN/kossel_mini/Configuration.h +++ b/Marlin/example_configurations/delta/FLSUN/kossel_mini/Configuration.h @@ -1603,6 +1603,9 @@ //define BlinkM/CyzRgb Support //#define BLINKM +//define PCA9632 PWM LED driver Support +//#define PCA9632 + /** * RGB LED / LED Strip Control * @@ -1640,7 +1643,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) || ENABLED(RGBW_LED) +#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) #define PRINTER_EVENT_LEDS #endif diff --git a/Marlin/example_configurations/delta/generic/Configuration.h b/Marlin/example_configurations/delta/generic/Configuration.h index d005b0876b5f3f025d4320959d52e984fe61c606..39500de3f93299585f0ccf0bf01997a8231f5cfc 100644 --- a/Marlin/example_configurations/delta/generic/Configuration.h +++ b/Marlin/example_configurations/delta/generic/Configuration.h @@ -1592,6 +1592,9 @@ //define BlinkM/CyzRgb Support //#define BLINKM +//define PCA9632 PWM LED driver Support +//#define PCA9632 + /** * RGB LED / LED Strip Control * @@ -1629,7 +1632,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) || ENABLED(RGBW_LED) +#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) #define PRINTER_EVENT_LEDS #endif diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration.h b/Marlin/example_configurations/delta/kossel_mini/Configuration.h index edc6ca7905d074be7b18255e5154600037b26016..4e3a7ebb69b9ccb84988dd37fe8f654d4b7d5a9c 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration.h @@ -1595,6 +1595,9 @@ //define BlinkM/CyzRgb Support //#define BLINKM +//define PCA9632 PWM LED driver Support +//#define PCA9632 + /** * RGB LED / LED Strip Control * @@ -1632,7 +1635,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) || ENABLED(RGBW_LED) +#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) #define PRINTER_EVENT_LEDS #endif diff --git a/Marlin/example_configurations/delta/kossel_pro/Configuration.h b/Marlin/example_configurations/delta/kossel_pro/Configuration.h index 42675f9fff75430116733d80c578102cbfc23870..eabdc135741b868b11644147a72ae4983ebb427b 100644 --- a/Marlin/example_configurations/delta/kossel_pro/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_pro/Configuration.h @@ -1600,6 +1600,9 @@ //define BlinkM/CyzRgb Support //#define BLINKM +//define PCA9632 PWM LED driver Support +//#define PCA9632 + /** * RGB LED / LED Strip Control * @@ -1637,7 +1640,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) || ENABLED(RGBW_LED) +#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) #define PRINTER_EVENT_LEDS #endif diff --git a/Marlin/example_configurations/delta/kossel_xl/Configuration.h b/Marlin/example_configurations/delta/kossel_xl/Configuration.h index 1427f5adbb497e43fd96ce6f9ee6551b0bce8208..acbc9e58d8bb788bdd0e385761bd90f719f2a099 100644 --- a/Marlin/example_configurations/delta/kossel_xl/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_xl/Configuration.h @@ -1658,6 +1658,9 @@ //define BlinkM/CyzRgb Support //#define BLINKM +//define PCA9632 PWM LED driver Support +//#define PCA9632 + /** * RGB LED / LED Strip Control * @@ -1695,7 +1698,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) || ENABLED(RGBW_LED) +#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) #define PRINTER_EVENT_LEDS #endif diff --git a/Marlin/example_configurations/gCreate_gMax1.5+/Configuration.h b/Marlin/example_configurations/gCreate_gMax1.5+/Configuration.h index 63a698a6c3b6c68f3ff92382faddef54c279e90d..67eb606e09e60da2cdc139dec3459d7a469e275c 100644 --- a/Marlin/example_configurations/gCreate_gMax1.5+/Configuration.h +++ b/Marlin/example_configurations/gCreate_gMax1.5+/Configuration.h @@ -1497,6 +1497,9 @@ //define BlinkM/CyzRgb Support //#define BLINKM +//define PCA9632 PWM LED driver Support +//#define PCA9632 + /** * RGB LED / LED Strip Control * @@ -1534,7 +1537,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) || ENABLED(RGBW_LED) +#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) #define PRINTER_EVENT_LEDS #endif diff --git a/Marlin/example_configurations/makibox/Configuration.h b/Marlin/example_configurations/makibox/Configuration.h index a13bb2ed5377bf9c68a6d08613c68d0b2a248b20..ae07c775bdeb3ad6b081992d38b13e389d84ff38 100644 --- a/Marlin/example_configurations/makibox/Configuration.h +++ b/Marlin/example_configurations/makibox/Configuration.h @@ -1484,6 +1484,9 @@ //define BlinkM/CyzRgb Support //#define BLINKM +//define PCA9632 PWM LED driver Support +//#define PCA9632 + /** * RGB LED / LED Strip Control * @@ -1521,7 +1524,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) || ENABLED(RGBW_LED) +#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) #define PRINTER_EVENT_LEDS #endif diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration.h b/Marlin/example_configurations/tvrrug/Round2/Configuration.h index 046a8a5e2bf6632f707eb0db0e009c3f6f9c1bb0..57a66e1756d4f47a2a8fbe10cf4dd438c50089f6 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration.h @@ -1476,6 +1476,9 @@ //define BlinkM/CyzRgb Support //#define BLINKM +//define PCA9632 PWM LED driver Support +//#define PCA9632 + /** * RGB LED / LED Strip Control * @@ -1513,7 +1516,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) || ENABLED(RGBW_LED) +#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) #define PRINTER_EVENT_LEDS #endif diff --git a/Marlin/example_configurations/wt150/Configuration.h b/Marlin/example_configurations/wt150/Configuration.h index 52fa22519770099f2d30faa58aea4765dbf40543..80addd741b8b04144495edc29bc380b83e53a537 100644 --- a/Marlin/example_configurations/wt150/Configuration.h +++ b/Marlin/example_configurations/wt150/Configuration.h @@ -1486,6 +1486,9 @@ //define BlinkM/CyzRgb Support //#define BLINKM +//define PCA9632 PWM LED driver Support +//#define PCA9632 + // Support for an RGB LED using 3 separate pins with optional PWM //#define RGB_LED //#define RGBW_LED @@ -1507,7 +1510,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) || ENABLED(RGBW_LED) +#if ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) #define PRINTER_EVENT_LEDS #endif diff --git a/Marlin/pca9632.cpp b/Marlin/pca9632.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d8853c46500dc0c0271b2f8fd7d8c3b43371bf2f --- /dev/null +++ b/Marlin/pca9632.cpp @@ -0,0 +1,115 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +/* + * Driver for the Philips PCA9632 LED driver. + * Written by Robert Mendon Feb 2017. + */ + +#include "MarlinConfig.h" + +#if ENABLED(PCA9632) + +#include "pca9632.h" + +#define PCA9632_MODE1_VALUE 0b00000001 //(ALLCALL) +#define PCA9632_MODE2_VALUE 0b00010101 //(DIMMING, INVERT, CHANGE ON STOP,TOTEM) +#define PCA9632_LEDOUT_VALUE 0b00101010 + + +/* Register addresses */ +#define PCA9632_MODE1 0x00 +#define PCA9632_MODE2 0x01 +#define PCA9632_PWM0 0x02 +#define PCA9632_PWM1 0x03 +#define PCA9632_PWM2 0x04 +#define PCA9632_PWM3 0x05 +#define PCA9632_GRPPWM 0x06 +#define PCA9632_GRPFREQ 0x07 +#define PCA9632_LEDOUT 0X08 +#define PCA9632_SUBADR1 0x09 +#define PCA9632_SUBADR2 0x0A +#define PCA9632_SUBADR3 0x0B +#define PCA9632_ALLCALLADDR 0x0C + +#define PCA9632_NO_AUTOINC 0x00 +#define PCA9632_AUTO_ALL 0x80 +#define PCA9632_AUTO_IND 0xA0 +#define PCA9632_AUTOGLO 0xC0 +#define PCA9632_AUTOGI 0xE0 + +// Red LED0 +// Green LED1 +// Blue LED2 +#define PCA9632_RED 0x00 +#define PCA9632_GRN 0x02 +#define PCA9632_BLU 0x04 + +#define LED_OFF 0x00 +#define LED_ON 0x01 +#define LED_PWM 0x02 + +#define PCA9632_ADDRESS 0b01100000 + +byte PCA_init = 0; + +static void PCA9632_WriteRegister(const byte addr, const byte regadd, const byte value) { + Wire.beginTransmission(addr); + Wire.write(regadd); + Wire.write(value); + Wire.endTransmission(); +} + +static void PCA9632_WriteAllRegisters(const byte addr, const byte regadd, const byte value1, const byte value2, const byte value3) { + Wire.beginTransmission(addr); + Wire.write(PCA9632_AUTO_IND | regadd); + Wire.write(value1); + Wire.write(value2); + Wire.write(value3); + Wire.endTransmission(); +} + +static byte PCA9632_ReadRegister(const byte addr, const byte regadd) { + Wire.beginTransmission(addr); + Wire.write(regadd); + const byte value = Wire.read(); + Wire.endTransmission(); + return value; +} + +void PCA9632_SetColor(const byte r, const byte g, const byte b) { + if (!PCA_init) { + PCA_init = 1; + Wire.begin(); + PCA9632_WriteRegister(PCA9632_ADDRESS,PCA9632_MODE1, PCA9632_MODE1_VALUE); + PCA9632_WriteRegister(PCA9632_ADDRESS,PCA9632_MODE2, PCA9632_MODE2_VALUE); + } + + const byte LEDOUT = (r ? LED_PWM << PCA9632_RED : 0) + | (g ? LED_PWM << PCA9632_GRN : 0) + | (b ? LED_PWM << PCA9632_BLU : 0); + + PCA9632_WriteAllRegisters(PCA9632_ADDRESS,PCA9632_PWM0, r, g, b); + PCA9632_WriteRegister(PCA9632_ADDRESS,PCA9632_LEDOUT, LEDOUT); +} + +#endif // PCA9632 diff --git a/Marlin/pca9632.h b/Marlin/pca9632.h new file mode 100644 index 0000000000000000000000000000000000000000..b8c78f065d1cb64db6d3c114d45ac199145ed884 --- /dev/null +++ b/Marlin/pca9632.h @@ -0,0 +1,36 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +/* + * Driver for the Philips PCA9632 LED driver. + * Written by Robert Mendon Feb 2017. + */ + +#ifndef __PCA9632_H__ +#define __PCA9632_H__ + +#include "Arduino.h" +#include "Wire.h" + +void PCA9632_SetColor(const byte r, const byte g, const byte b); + +#endif // __PCA9632_H__