Activate the new servo.move() function

by replacing the sequences (attach, write, delay, detach), and their conditions with the new function in Marlin.main.cpp
and removing the old configuration in the ABL part of Configuration.h
This commit is contained in:
AnHardt 2015-07-13 00:16:06 +02:00 committed by Richard Wackerbarth
parent 40b6edcad7
commit 49609f6c14
2 changed files with 7 additions and 39 deletions

View File

@ -504,13 +504,6 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
//#define Z_PROBE_SLED // turn on if you have a z-probe mounted on a sled like those designed by Charles Bell //#define Z_PROBE_SLED // turn on if you have a z-probe mounted on a sled like those designed by Charles Bell
//#define SLED_DOCKING_OFFSET 5 // the extra distance the X axis must travel to pickup the sled. 0 should be fine but you can push it further if you'd like. //#define SLED_DOCKING_OFFSET 5 // the extra distance the X axis must travel to pickup the sled. 0 should be fine but you can push it further if you'd like.
//If defined, the Probe servo will be turned on only during movement and then turned off to avoid jerk
//The value is the delay to turn the servo off after powered on - depends on the servo speed; 300ms is good value, but you can try lower it.
// You MUST HAVE the SERVO_ENDSTOPS defined to use here a value higher than zero otherwise your code will not compile.
// #define PROBE_SERVO_DEACTIVATION_DELAY 300
//If you have enabled the Bed Auto Leveling and are using the same Z Probe for Z Homing, //If you have enabled the Bed Auto Leveling and are using the same Z Probe for Z Homing,
//it is highly recommended you let this Z_SAFE_HOMING enabled!!! //it is highly recommended you let this Z_SAFE_HOMING enabled!!!

View File

@ -36,7 +36,7 @@
#endif #endif
#endif // ENABLE_AUTO_BED_LEVELING #endif // ENABLE_AUTO_BED_LEVELING
#define SERVO_LEVELING (defined(ENABLE_AUTO_BED_LEVELING) && PROBE_SERVO_DEACTIVATION_DELAY > 0) #define SERVO_LEVELING (defined(ENABLE_AUTO_BED_LEVELING) && defined(DEACTIVATE_SERVOS_AFTER_MOVE))
#ifdef MESH_BED_LEVELING #ifdef MESH_BED_LEVELING
#include "mesh_bed_leveling.h" #include "mesh_bed_leveling.h"
@ -570,13 +570,9 @@ void servo_init() {
#ifdef SERVO_ENDSTOPS #ifdef SERVO_ENDSTOPS
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
if (servo_endstops[i] >= 0) if (servo_endstops[i] >= 0)
servo[servo_endstops[i]].write(servo_endstop_angles[i * 2 + 1]); servo[servo_endstops[i]].move(0, servo_endstop_angles[i * 2 + 1]);
#endif #endif
#if SERVO_LEVELING
delay(PROBE_SERVO_DEACTIVATION_DELAY);
servo[servo_endstops[Z_AXIS]].detach();
#endif
} }
/** /**
@ -1315,14 +1311,7 @@ static void setup_for_endstop_move() {
// Engage Z Servo endstop if enabled // Engage Z Servo endstop if enabled
if (servo_endstops[Z_AXIS] >= 0) { if (servo_endstops[Z_AXIS] >= 0) {
Servo *srv = &servo[servo_endstops[Z_AXIS]]; Servo *srv = &servo[servo_endstops[Z_AXIS]];
#if SERVO_LEVELING srv->move(0, servo_endstop_angles[Z_AXIS * 2]);
srv->attach(0);
#endif
srv->write(servo_endstop_angles[Z_AXIS * 2]);
#if SERVO_LEVELING
delay(PROBE_SERVO_DEACTIVATION_DELAY);
srv->detach();
#endif
} }
#elif defined(Z_PROBE_ALLEN_KEY) #elif defined(Z_PROBE_ALLEN_KEY)
@ -1424,14 +1413,7 @@ static void setup_for_endstop_move() {
// Change the Z servo angle // Change the Z servo angle
Servo *srv = &servo[servo_endstops[Z_AXIS]]; Servo *srv = &servo[servo_endstops[Z_AXIS]];
#if SERVO_LEVELING srv->move(0, servo_endstop_angles[Z_AXIS * 2 + 1]);
srv->attach(0);
#endif
srv->write(servo_endstop_angles[Z_AXIS * 2 + 1]);
#if SERVO_LEVELING
delay(PROBE_SERVO_DEACTIVATION_DELAY);
srv->detach();
#endif
} }
#elif defined(Z_PROBE_ALLEN_KEY) #elif defined(Z_PROBE_ALLEN_KEY)
@ -1683,7 +1665,7 @@ static void homeaxis(AxisEnum axis) {
if (axis != Z_AXIS) { if (axis != Z_AXIS) {
// Engage Servo endstop if enabled // Engage Servo endstop if enabled
if (servo_endstops[axis] > -1) if (servo_endstops[axis] > -1)
servo[servo_endstops[axis]].write(servo_endstop_angles[axis * 2]); servo[servo_endstops[axis]].move(0, servo_endstop_angles[axis * 2]);
} }
#endif #endif
@ -1786,7 +1768,7 @@ static void homeaxis(AxisEnum axis) {
{ {
// Retract Servo endstop if enabled // Retract Servo endstop if enabled
if (servo_endstops[axis] > -1) if (servo_endstops[axis] > -1)
servo[servo_endstops[axis]].write(servo_endstop_angles[axis * 2 + 1]); servo[servo_endstops[axis]].move(0, servo_endstop_angles[axis * 2 + 1]);
} }
#endif #endif
@ -4354,14 +4336,7 @@ inline void gcode_M226() {
servo_position = code_value_short(); servo_position = code_value_short();
if (servo_index >= 0 && servo_index < NUM_SERVOS) { if (servo_index >= 0 && servo_index < NUM_SERVOS) {
Servo *srv = &servo[servo_index]; Servo *srv = &servo[servo_index];
#if SERVO_LEVELING srv->move(0, servo_position);
srv->attach(0);
#endif
srv->write(servo_position);
#if SERVO_LEVELING
delay(PROBE_SERVO_DEACTIVATION_DELAY);
srv->detach();
#endif
} }
else { else {
SERIAL_ECHO_START; SERIAL_ECHO_START;