Add M42 M, improve M43 (#17173)
This commit is contained in:
parent
de45ac41ad
commit
84dec5da10
@ -67,6 +67,7 @@ inline void toggle_pins() {
|
|||||||
else {
|
else {
|
||||||
watchdog_refresh();
|
watchdog_refresh();
|
||||||
report_pin_state_extended(pin, ignore_protection, true, PSTR("Pulsing "));
|
report_pin_state_extended(pin, ignore_protection, true, PSTR("Pulsing "));
|
||||||
|
const bool prior_mode = GET_PINMODE(pin);
|
||||||
#if AVR_AT90USB1286_FAMILY // Teensy IDEs don't know about these pins so must use FASTIO
|
#if AVR_AT90USB1286_FAMILY // Teensy IDEs don't know about these pins so must use FASTIO
|
||||||
if (pin == TEENSY_E2) {
|
if (pin == TEENSY_E2) {
|
||||||
SET_OUTPUT(TEENSY_E2);
|
SET_OUTPUT(TEENSY_E2);
|
||||||
@ -95,6 +96,7 @@ inline void toggle_pins() {
|
|||||||
watchdog_refresh();
|
watchdog_refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pinMode(pin, prior_mode);
|
||||||
}
|
}
|
||||||
SERIAL_EOL();
|
SERIAL_EOL();
|
||||||
}
|
}
|
||||||
|
@ -37,16 +37,33 @@
|
|||||||
*
|
*
|
||||||
* S<byte> Pin status from 0 - 255
|
* S<byte> Pin status from 0 - 255
|
||||||
* I Flag to ignore Marlin's pin protection
|
* I Flag to ignore Marlin's pin protection
|
||||||
|
*
|
||||||
|
* M<mode> Pin mode: 0=INPUT 1=OUTPUT 2=INPUT_PULLUP 3=INPUT_PULLDOWN
|
||||||
*/
|
*/
|
||||||
void GcodeSuite::M42() {
|
void GcodeSuite::M42() {
|
||||||
if (!parser.seenval('S')) return;
|
|
||||||
const byte pin_status = parser.value_byte();
|
|
||||||
|
|
||||||
const int pin_index = PARSED_PIN_INDEX('P', GET_PIN_MAP_INDEX(LED_PIN));
|
const int pin_index = PARSED_PIN_INDEX('P', GET_PIN_MAP_INDEX(LED_PIN));
|
||||||
if (pin_index < 0) return;
|
if (pin_index < 0) return;
|
||||||
|
|
||||||
const pin_t pin = GET_PIN_MAP_PIN(pin_index);
|
const pin_t pin = GET_PIN_MAP_PIN(pin_index);
|
||||||
|
|
||||||
|
if (!parser.boolval('I') && pin_is_protected(pin)) return protected_pin_err();
|
||||||
|
|
||||||
|
if (parser.seenval('M')) {
|
||||||
|
switch (parser.value_byte()) {
|
||||||
|
case 0: pinMode(pin, INPUT); break;
|
||||||
|
case 1: pinMode(pin, OUTPUT); break;
|
||||||
|
case 2: pinMode(pin, INPUT_PULLUP); break;
|
||||||
|
#ifdef INPUT_PULLDOWN
|
||||||
|
case 3: pinMode(pin, INPUT_PULLDOWN); break;
|
||||||
|
#endif
|
||||||
|
default: SERIAL_ECHOLNPGM("Invalid Pin Mode");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!parser.seenval('S')) return;
|
||||||
|
const byte pin_status = parser.value_byte();
|
||||||
|
|
||||||
#if FAN_COUNT > 0
|
#if FAN_COUNT > 0
|
||||||
switch (pin) {
|
switch (pin) {
|
||||||
#if HAS_FAN0
|
#if HAS_FAN0
|
||||||
@ -76,8 +93,6 @@ void GcodeSuite::M42() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!parser.boolval('I') && pin_is_protected(pin)) return protected_pin_err();
|
|
||||||
|
|
||||||
pinMode(pin, OUTPUT);
|
pinMode(pin, OUTPUT);
|
||||||
extDigitalWrite(pin, pin_status);
|
extDigitalWrite(pin, pin_status);
|
||||||
analogWrite(pin, pin_status);
|
analogWrite(pin, pin_status);
|
||||||
|
Loading…
Reference in New Issue
Block a user