summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorblddk <michael.andresen@gmail.com>2011-08-02 23:50:10 +0300
committerblddk <michael.andresen@gmail.com>2011-08-02 23:50:10 +0300
commitef66ecf5f1bb6c6c6819ee5c90efcb0d09419e71 (patch)
tree52c34a1e08378021d3fcde7be639f75a36025899
parent563c90f6ffc172ee671abe634ae87b3c250c7be8 (diff)
Added M42 to control non used pins example: M42 P23 S255
-rw-r--r--Sprinter/Sprinter.pde26
1 files changed, 26 insertions, 0 deletions
diff --git a/Sprinter/Sprinter.pde b/Sprinter/Sprinter.pde
index dde302c..5d40499 100644
--- a/Sprinter/Sprinter.pde
+++ b/Sprinter/Sprinter.pde
@@ -43,6 +43,7 @@
// M27 - Report SD print status
// M28 - Start SD write (M28 filename.g)
// M29 - Stop SD write
+// M42 - Set output on free pins, on a non pwm pin (over pin 13 on an arduino mega) use S255 to turn it on and S0 to turn it off. Use P to decide the pin (M42 P23 S255) would turn pin 23 on
// M81 - Turn off Power Supply
// M82 - Set E codes absolute (default)
// M83 - Set E codes relative while in Absolute Coordinates (G90) mode
@@ -721,6 +722,31 @@ inline void process_commands()
//savetosd = false;
break;
#endif
+ case 42: //M42 -Change pin status via gcode
+ if (code_seen('S'))
+ {
+ int pin_status = code_value();
+ if (code_seen('P') && pin_status >= 0 && pin_status <= 255)
+ {
+ int pin_number = code_value();
+ for(int i = 0; i < sizeof(sensitive_pins); i++)
+ {
+ if (sensitive_pins[i] == pin_number)
+ {
+ pin_number = -1;
+ break;
+ }
+ }
+
+ if (pin_number > -1)
+ {
+ pinMode(pin_number, OUTPUT);
+ digitalWrite(pin_number, pin_status);
+ analogWrite(pin_number, pin_status);
+ }
+ }
+ }
+ break;
case 104: // M104
if (code_seen('S')) target_raw = temp2analogh(code_value());
#ifdef WATCHPERIOD