update code base to Marlin 2.0.9.2

This commit is contained in:
Stefan Kalscheuer
2021-10-03 18:57:12 +02:00
parent b9d7ba838e
commit 7077da3591
2617 changed files with 332093 additions and 103438 deletions

53
Marlin/src/gcode/control/M280.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* 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/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
@@ -26,30 +26,51 @@
#include "../gcode.h"
#include "../../module/servo.h"
#include "../../module/planner.h"
/**
* M280: Get or set servo position. P<index> [S<angle>]
* M280: Get or set servo position.
* P<index> - Servo index
* S<angle> - Angle to set, omit to read current angle, or use -1 to detach
*
* With POLARGRAPH:
* T<ms> - Duration of servo move
*/
void GcodeSuite::M280() {
if (!parser.seen('P')) return;
if (!parser.seenval('P')) return;
TERN_(POLARGRAPH, planner.synchronize());
const int servo_index = parser.value_int();
if (WITHIN(servo_index, 0, NUM_SERVOS - 1)) {
if (parser.seen('S')) {
const int a = parser.value_int();
if (a == -1)
servo[servo_index].detach();
if (parser.seenval('S')) {
const int anew = parser.value_int();
if (anew >= 0) {
#if ENABLED(POLARGRAPH)
if (parser.seen('T')) { // (ms) Total duration of servo move
const int16_t t = constrain(parser.value_int(), 0, 10000);
const int aold = servo[servo_index].read();
millis_t now = millis();
const millis_t start = now, end = start + t;
while (PENDING(now, end)) {
safe_delay(50);
now = _MIN(millis(), end);
MOVE_SERVO(servo_index, LROUND(aold + (anew - aold) * (float(now - start) / t)));
}
}
#endif // POLARGRAPH
MOVE_SERVO(servo_index, anew);
}
else
MOVE_SERVO(servo_index, a);
}
else {
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(" Servo ", servo_index, ": ", servo[servo_index].read());
DETACH_SERVO(servo_index);
}
else
SERIAL_ECHO_MSG(" Servo ", servo_index, ": ", servo[servo_index].read());
}
else {
SERIAL_ERROR_START();
SERIAL_ECHOLNPAIR("Servo ", servo_index, " out of range");
}
else
SERIAL_ERROR_MSG("Servo ", servo_index, " out of range");
}
#endif // HAS_SERVOS