From ab3f966f5fabb1fb3d2c90d7df8dc670fe835d53 Mon Sep 17 00:00:00 2001 From: Stanley Date: Wed, 5 Oct 2016 21:34:07 +0200 Subject: [PATCH 1/2] Case light G-code M355 implemented G-Code M355 into Marlin --- Marlin/Conditionals_post.h | 1 + Marlin/Configuration_adv.h | 4 ++ Marlin/Marlin_main.cpp | 56 +++++++++++++++++++ .../Cartesio/Configuration_adv.h | 4 ++ .../Felix/Configuration_adv.h | 4 ++ .../Hephestos/Configuration_adv.h | 4 ++ .../Hephestos_2/Configuration_adv.h | 4 ++ .../K8200/Configuration_adv.h | 4 ++ .../K8400/Configuration_adv.h | 4 ++ .../RigidBot/Configuration_adv.h | 4 ++ .../SCARA/Configuration_adv.h | 4 ++ .../TAZ4/Configuration_adv.h | 4 ++ .../WITBOX/Configuration_adv.h | 4 ++ .../delta/biv2.5/Configuration_adv.h | 4 ++ .../delta/generic/Configuration_adv.h | 4 ++ .../delta/kossel_mini/Configuration_adv.h | 4 ++ .../delta/kossel_pro/Configuration_adv.h | 4 ++ .../delta/kossel_xl/Configuration_adv.h | 4 ++ .../makibox/Configuration_adv.h | 4 ++ .../tvrrug/Round2/Configuration_adv.h | 4 ++ 20 files changed, 129 insertions(+) diff --git a/Marlin/Conditionals_post.h b/Marlin/Conditionals_post.h index 95054af1e..5dc5abc48 100644 --- a/Marlin/Conditionals_post.h +++ b/Marlin/Conditionals_post.h @@ -509,6 +509,7 @@ #define HAS_E4_STEP (PIN_EXISTS(E4_STEP)) #define HAS_DIGIPOTSS (PIN_EXISTS(DIGIPOTSS)) #define HAS_BUZZER (PIN_EXISTS(BEEPER) || ENABLED(LCD_USE_I2C_BUZZER)) + #define HAS_CASE_LIGHT (PIN_EXISTS(CASE_LIGHT)) #define HAS_MOTOR_CURRENT_PWM (PIN_EXISTS(MOTOR_CURRENT_PWM_XY) || PIN_EXISTS(MOTOR_CURRENT_PWM_Z) || PIN_EXISTS(MOTOR_CURRENT_PWM_E)) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 067d86c48..95eb0c4b0 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -224,6 +224,10 @@ #define EXTRUDER_AUTO_FAN_TEMPERATURE 50 #define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed +// Define a pin to turn case light on/off +//#define CASE_LIGHT_PIN 4 +//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //=========================================================================== //============================ Mechanical Settings ========================== //=========================================================================== diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 918bae1a0..a0f2b900d 100755 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -867,6 +867,18 @@ void setup_photpin() { #endif } +#if HAS_CASE_LIGHT + + void setup_case_light() { + #if ENABLED(CASE_LIGHT_DEFAULT_ON) + OUT_WRITE(CASE_LIGHT_PIN, HIGH); + #else + OUT_WRITE(CASE_LIGHT_PIN, LOW); + #endif + } + +#endif + void setup_powerhold() { #if HAS_SUICIDE OUT_WRITE(SUICIDE_PIN, HIGH); @@ -7087,6 +7099,38 @@ inline void gcode_M907() { #endif // HAS_MICROSTEPS +#if HAS_CASE_LIGHT + /** + * M355: Turn case lights on/off + * + * S change state on/off or sets PWM + * + */ + inline void gcode_M355() { + if (code_seen('S')) { + SERIAL_ECHO_START; + SERIAL_ECHOPGM("Case lights "); + byte light_pwm = code_value_byte(); + switch (light_pwm) { + case 0: // Disable lights + SERIAL_ECHOPGM("off"); + break; + case 1: // Enable lights + light_pwm = 255; + SERIAL_ECHOPGM("on"); + break; + default: // Enable lights PWM + SERIAL_ECHOPAIR("set to: ", (int)map(light_pwm, 0, 255, 0, 100)); + SERIAL_CHAR('%'); + break; + } + analogWrite(CASE_LIGHT_PIN, light_pwm); + SERIAL_EOL; + } + } + +#endif // HAS_CASE_LIGHT + #if ENABLED(MIXING_EXTRUDER) /** @@ -8195,6 +8239,14 @@ void process_next_command() { #endif // HAS_MICROSTEPS + #if HAS_CASE_LIGHT + + case 355: // M355 Turn case lights on/off + gcode_M355(); + break; + + #endif // HAS_CASE_LIGHT + case 999: // M999: Restart after being Stopped gcode_M999(); break; @@ -9696,6 +9748,10 @@ void setup() { setup_photpin(); servo_init(); + #if HAS_CASE_LIGHT + setup_case_light(); + #endif + #if HAS_BED_PROBE endstops.enable_z_probe(false); #endif diff --git a/Marlin/example_configurations/Cartesio/Configuration_adv.h b/Marlin/example_configurations/Cartesio/Configuration_adv.h index 0cef74a09..dc8b7823d 100644 --- a/Marlin/example_configurations/Cartesio/Configuration_adv.h +++ b/Marlin/example_configurations/Cartesio/Configuration_adv.h @@ -224,6 +224,10 @@ #define EXTRUDER_AUTO_FAN_TEMPERATURE 35 #define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed +// Define a pin to turn case light on/off +//#define CASE_LIGHT_PIN 4 +//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //=========================================================================== //============================ Mechanical Settings ========================== //=========================================================================== diff --git a/Marlin/example_configurations/Felix/Configuration_adv.h b/Marlin/example_configurations/Felix/Configuration_adv.h index 7139ac135..c3d24860a 100644 --- a/Marlin/example_configurations/Felix/Configuration_adv.h +++ b/Marlin/example_configurations/Felix/Configuration_adv.h @@ -224,6 +224,10 @@ #define EXTRUDER_AUTO_FAN_TEMPERATURE 50 #define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed +// Define a pin to turn case light on/off +//#define CASE_LIGHT_PIN 4 +//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //=========================================================================== //============================ Mechanical Settings ========================== //=========================================================================== diff --git a/Marlin/example_configurations/Hephestos/Configuration_adv.h b/Marlin/example_configurations/Hephestos/Configuration_adv.h index 8f04e5ea3..e86bcbe44 100644 --- a/Marlin/example_configurations/Hephestos/Configuration_adv.h +++ b/Marlin/example_configurations/Hephestos/Configuration_adv.h @@ -224,6 +224,10 @@ #define EXTRUDER_AUTO_FAN_TEMPERATURE 50 #define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed +// Define a pin to turn case light on/off +//#define CASE_LIGHT_PIN 4 +//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //=========================================================================== //============================ Mechanical Settings ========================== //=========================================================================== diff --git a/Marlin/example_configurations/Hephestos_2/Configuration_adv.h b/Marlin/example_configurations/Hephestos_2/Configuration_adv.h index b221ab74c..4ab583e3b 100644 --- a/Marlin/example_configurations/Hephestos_2/Configuration_adv.h +++ b/Marlin/example_configurations/Hephestos_2/Configuration_adv.h @@ -224,6 +224,10 @@ #define EXTRUDER_AUTO_FAN_TEMPERATURE 50 #define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed +// Define a pin to turn case light on/off +//#define CASE_LIGHT_PIN 4 +//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //=========================================================================== //============================ Mechanical Settings ========================== //=========================================================================== diff --git a/Marlin/example_configurations/K8200/Configuration_adv.h b/Marlin/example_configurations/K8200/Configuration_adv.h index 8ea34fc92..8bc63b84a 100644 --- a/Marlin/example_configurations/K8200/Configuration_adv.h +++ b/Marlin/example_configurations/K8200/Configuration_adv.h @@ -230,6 +230,10 @@ #define EXTRUDER_AUTO_FAN_TEMPERATURE 50 #define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed +// Define a pin to turn case light on/off +//#define CASE_LIGHT_PIN 4 +//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //=========================================================================== //============================ Mechanical Settings ========================== //=========================================================================== diff --git a/Marlin/example_configurations/K8400/Configuration_adv.h b/Marlin/example_configurations/K8400/Configuration_adv.h index 3cc822cc4..106193029 100644 --- a/Marlin/example_configurations/K8400/Configuration_adv.h +++ b/Marlin/example_configurations/K8400/Configuration_adv.h @@ -224,6 +224,10 @@ #define EXTRUDER_AUTO_FAN_TEMPERATURE 50 #define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed +// Define a pin to turn case light on/off +//#define CASE_LIGHT_PIN 4 +//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //=========================================================================== //============================ Mechanical Settings ========================== //=========================================================================== diff --git a/Marlin/example_configurations/RigidBot/Configuration_adv.h b/Marlin/example_configurations/RigidBot/Configuration_adv.h index 71166d48d..e77c60c9c 100644 --- a/Marlin/example_configurations/RigidBot/Configuration_adv.h +++ b/Marlin/example_configurations/RigidBot/Configuration_adv.h @@ -224,6 +224,10 @@ #define EXTRUDER_AUTO_FAN_TEMPERATURE 50 #define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed +// Define a pin to turn case light on/off +//#define CASE_LIGHT_PIN 4 +//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //=========================================================================== //============================ Mechanical Settings ========================== //=========================================================================== diff --git a/Marlin/example_configurations/SCARA/Configuration_adv.h b/Marlin/example_configurations/SCARA/Configuration_adv.h index 706f41270..f4ebfb3b7 100644 --- a/Marlin/example_configurations/SCARA/Configuration_adv.h +++ b/Marlin/example_configurations/SCARA/Configuration_adv.h @@ -224,6 +224,10 @@ #define EXTRUDER_AUTO_FAN_TEMPERATURE 50 #define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed +// Define a pin to turn case light on/off +//#define CASE_LIGHT_PIN 4 +//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //=========================================================================== //============================ Mechanical Settings ========================== //=========================================================================== diff --git a/Marlin/example_configurations/TAZ4/Configuration_adv.h b/Marlin/example_configurations/TAZ4/Configuration_adv.h index 2a39074b7..f3e15eb43 100644 --- a/Marlin/example_configurations/TAZ4/Configuration_adv.h +++ b/Marlin/example_configurations/TAZ4/Configuration_adv.h @@ -232,6 +232,10 @@ #define EXTRUDER_AUTO_FAN_TEMPERATURE 50 #define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed +// Define a pin to turn case light on/off +//#define CASE_LIGHT_PIN 4 +//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //=========================================================================== //============================ Mechanical Settings ========================== //=========================================================================== diff --git a/Marlin/example_configurations/WITBOX/Configuration_adv.h b/Marlin/example_configurations/WITBOX/Configuration_adv.h index 8f04e5ea3..e86bcbe44 100644 --- a/Marlin/example_configurations/WITBOX/Configuration_adv.h +++ b/Marlin/example_configurations/WITBOX/Configuration_adv.h @@ -224,6 +224,10 @@ #define EXTRUDER_AUTO_FAN_TEMPERATURE 50 #define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed +// Define a pin to turn case light on/off +//#define CASE_LIGHT_PIN 4 +//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //=========================================================================== //============================ Mechanical Settings ========================== //=========================================================================== diff --git a/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h b/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h index 0a0036972..3932d5920 100644 --- a/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h +++ b/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h @@ -224,6 +224,10 @@ #define EXTRUDER_AUTO_FAN_TEMPERATURE 50 #define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed +// Define a pin to turn case light on/off +//#define CASE_LIGHT_PIN 4 +//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //=========================================================================== //============================ Mechanical Settings ========================== //=========================================================================== diff --git a/Marlin/example_configurations/delta/generic/Configuration_adv.h b/Marlin/example_configurations/delta/generic/Configuration_adv.h index 009fad39a..873d634cf 100644 --- a/Marlin/example_configurations/delta/generic/Configuration_adv.h +++ b/Marlin/example_configurations/delta/generic/Configuration_adv.h @@ -224,6 +224,10 @@ #define EXTRUDER_AUTO_FAN_TEMPERATURE 50 #define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed +// Define a pin to turn case light on/off +//#define CASE_LIGHT_PIN 4 +//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //=========================================================================== //============================ Mechanical Settings ========================== //=========================================================================== diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h index 009fad39a..873d634cf 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h @@ -224,6 +224,10 @@ #define EXTRUDER_AUTO_FAN_TEMPERATURE 50 #define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed +// Define a pin to turn case light on/off +//#define CASE_LIGHT_PIN 4 +//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //=========================================================================== //============================ Mechanical Settings ========================== //=========================================================================== diff --git a/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h index 33aed463b..06a3c9798 100644 --- a/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h @@ -229,6 +229,10 @@ #define EXTRUDER_AUTO_FAN_TEMPERATURE 50 #define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed +// Define a pin to turn case light on/off +//#define CASE_LIGHT_PIN 4 +//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //=========================================================================== //============================ Mechanical Settings ========================== //=========================================================================== diff --git a/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h index 70f035f3d..17b07b5e8 100644 --- a/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h @@ -224,6 +224,10 @@ #define EXTRUDER_AUTO_FAN_TEMPERATURE 50 #define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed +// Define a pin to turn case light on/off +//#define CASE_LIGHT_PIN 4 +//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //=========================================================================== //============================ Mechanical Settings ========================== //=========================================================================== diff --git a/Marlin/example_configurations/makibox/Configuration_adv.h b/Marlin/example_configurations/makibox/Configuration_adv.h index 279fa7e32..bb6afc928 100644 --- a/Marlin/example_configurations/makibox/Configuration_adv.h +++ b/Marlin/example_configurations/makibox/Configuration_adv.h @@ -224,6 +224,10 @@ #define EXTRUDER_AUTO_FAN_TEMPERATURE 50 #define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed +// Define a pin to turn case light on/off +//#define CASE_LIGHT_PIN 4 +//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //=========================================================================== //============================ Mechanical Settings ========================== //=========================================================================== diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h index bea6cd5dd..2e57f8c7b 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h @@ -224,6 +224,10 @@ #define EXTRUDER_AUTO_FAN_TEMPERATURE 50 #define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed +// Define a pin to turn case light on/off +//#define CASE_LIGHT_PIN 4 +//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //=========================================================================== //============================ Mechanical Settings ========================== //=========================================================================== From 955d14acb090366f7733425c1ab2c9c6b068f50e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 1 Nov 2016 06:24:21 -0500 Subject: [PATCH 2/2] Patch photo pin code style --- Marlin/Marlin_main.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index a0f2b900d..0e267def6 100755 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -861,12 +861,6 @@ void setup_homepin(void) { #endif } -void setup_photpin() { - #if HAS_PHOTOGRAPH - OUT_WRITE(PHOTOGRAPH_PIN, LOW); - #endif -} - #if HAS_CASE_LIGHT void setup_case_light() { @@ -9745,9 +9739,12 @@ void setup() { #endif stepper.init(); // Initialize stepper, this enables interrupts! - setup_photpin(); servo_init(); + #if HAS_PHOTOGRAPH + OUT_WRITE(PHOTOGRAPH_PIN, LOW); + #endif + #if HAS_CASE_LIGHT setup_case_light(); #endif