Secure STM32F1 servo code and M280 detach (#14085)

This commit is contained in:
Tanguy Pruvot
2019-05-22 23:57:19 +02:00
committed by Scott Lahteine
parent a49919396a
commit 24b1818245
3 changed files with 16 additions and 9 deletions

View File

@ -34,8 +34,13 @@ void GcodeSuite::M280() {
if (!parser.seen('P')) return;
const int servo_index = parser.value_int();
if (WITHIN(servo_index, 0, NUM_SERVOS - 1)) {
if (parser.seen('S'))
MOVE_SERVO(servo_index, parser.value_int());
if (parser.seen('S')) {
const int a = parser.value_int();
if (a == -1)
servo[servo_index].detach();
else
MOVE_SERVO(servo_index, a);
}
else {
SERIAL_ECHO_START();
SERIAL_ECHOPAIR(" Servo ", servo_index);