🧑💻 Remove servo macros
This commit is contained in:
parent
76a0cab782
commit
e4e6abe5af
|
@ -45,7 +45,7 @@ void stop();
|
||||||
|
|
||||||
bool BLTouch::command(const BLTCommand cmd, const millis_t &ms) {
|
bool BLTouch::command(const BLTCommand cmd, const millis_t &ms) {
|
||||||
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("BLTouch Command :", cmd);
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("BLTouch Command :", cmd);
|
||||||
MOVE_SERVO(Z_PROBE_SERVO_NR, cmd);
|
servo[Z_PROBE_SERVO_NR].move(cmd);
|
||||||
safe_delay(_MAX(ms, (uint32_t)BLTOUCH_DELAY)); // BLTOUCH_DELAY is also the *minimum* delay
|
safe_delay(_MAX(ms, (uint32_t)BLTOUCH_DELAY)); // BLTOUCH_DELAY is also the *minimum* delay
|
||||||
return triggered();
|
return triggered();
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ cutter_power_t SpindleLaser::menuPower, // Power s
|
||||||
*/
|
*/
|
||||||
void SpindleLaser::init() {
|
void SpindleLaser::init() {
|
||||||
#if ENABLED(SPINDLE_SERVO)
|
#if ENABLED(SPINDLE_SERVO)
|
||||||
MOVE_SERVO(SPINDLE_SERVO_NR, SPINDLE_SERVO_MIN);
|
servo[SPINDLE_SERVO_NR].move(SPINDLE_SERVO_MIN);
|
||||||
#else
|
#else
|
||||||
OUT_WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE); // Init spindle to off
|
OUT_WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE); // Init spindle to off
|
||||||
#endif
|
#endif
|
||||||
|
@ -131,7 +131,7 @@ void SpindleLaser::apply_power(const uint8_t opwr) {
|
||||||
isReady = false;
|
isReady = false;
|
||||||
}
|
}
|
||||||
#elif ENABLED(SPINDLE_SERVO)
|
#elif ENABLED(SPINDLE_SERVO)
|
||||||
MOVE_SERVO(SPINDLE_SERVO_NR, power);
|
servo[SPINDLE_SERVO_NR].move(power);
|
||||||
#else
|
#else
|
||||||
WRITE(SPINDLE_LASER_ENA_PIN, enabled() ? SPINDLE_LASER_ACTIVE_STATE : !SPINDLE_LASER_ACTIVE_STATE);
|
WRITE(SPINDLE_LASER_ENA_PIN, enabled() ? SPINDLE_LASER_ACTIVE_STATE : !SPINDLE_LASER_ACTIVE_STATE);
|
||||||
isReady = true;
|
isReady = true;
|
||||||
|
|
|
@ -198,10 +198,10 @@ inline void servo_probe_test() {
|
||||||
uint8_t i = 0;
|
uint8_t i = 0;
|
||||||
SERIAL_ECHOLNPGM(". Deploy & stow 4 times");
|
SERIAL_ECHOLNPGM(". Deploy & stow 4 times");
|
||||||
do {
|
do {
|
||||||
MOVE_SERVO(probe_index, servo_angles[Z_PROBE_SERVO_NR][0]); // Deploy
|
servo[probe_index].move(servo_angles[Z_PROBE_SERVO_NR][0]); // Deploy
|
||||||
safe_delay(500);
|
safe_delay(500);
|
||||||
deploy_state = READ(PROBE_TEST_PIN);
|
deploy_state = READ(PROBE_TEST_PIN);
|
||||||
MOVE_SERVO(probe_index, servo_angles[Z_PROBE_SERVO_NR][1]); // Stow
|
servo[probe_index].move(servo_angles[Z_PROBE_SERVO_NR][1]); // Stow
|
||||||
safe_delay(500);
|
safe_delay(500);
|
||||||
stow_state = READ(PROBE_TEST_PIN);
|
stow_state = READ(PROBE_TEST_PIN);
|
||||||
} while (++i < 4);
|
} while (++i < 4);
|
||||||
|
@ -226,7 +226,7 @@ inline void servo_probe_test() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ask the user for a trigger event and measure the pulse width.
|
// Ask the user for a trigger event and measure the pulse width.
|
||||||
MOVE_SERVO(probe_index, servo_angles[Z_PROBE_SERVO_NR][0]); // Deploy
|
servo[probe_index].move(servo_angles[Z_PROBE_SERVO_NR][0]); // Deploy
|
||||||
safe_delay(500);
|
safe_delay(500);
|
||||||
SERIAL_ECHOLNPGM("** Please trigger probe within 30 sec **");
|
SERIAL_ECHOLNPGM("** Please trigger probe within 30 sec **");
|
||||||
uint16_t probe_counter = 0;
|
uint16_t probe_counter = 0;
|
||||||
|
@ -256,7 +256,7 @@ inline void servo_probe_test() {
|
||||||
}
|
}
|
||||||
else SERIAL_ECHOLNPGM("FAIL: Noise detected - please re-run test");
|
else SERIAL_ECHOLNPGM("FAIL: Noise detected - please re-run test");
|
||||||
|
|
||||||
MOVE_SERVO(probe_index, servo_angles[Z_PROBE_SERVO_NR][1]); // Stow
|
servo[probe_index].move(servo_angles[Z_PROBE_SERVO_NR][1]); // Stow
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,14 +56,14 @@ void GcodeSuite::M280() {
|
||||||
while (PENDING(now, end)) {
|
while (PENDING(now, end)) {
|
||||||
safe_delay(50);
|
safe_delay(50);
|
||||||
now = _MIN(millis(), end);
|
now = _MIN(millis(), end);
|
||||||
MOVE_SERVO(servo_index, LROUND(aold + (anew - aold) * (float(now - start) / t)));
|
servo[servo_index].move(LROUND(aold + (anew - aold) * (float(now - start) / t)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // POLARGRAPH
|
#endif // POLARGRAPH
|
||||||
MOVE_SERVO(servo_index, anew);
|
servo[servo_index].move(anew);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
DETACH_SERVO(servo_index);
|
servo[servo_index].detach();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
SERIAL_ECHO_MSG(" Servo ", servo_index, ": ", servo[servo_index].read());
|
SERIAL_ECHO_MSG(" Servo ", servo_index, ": ", servo[servo_index].read());
|
||||||
|
|
|
@ -36,7 +36,7 @@ void GcodeSuite::M282() {
|
||||||
|
|
||||||
const int servo_index = parser.value_int();
|
const int servo_index = parser.value_int();
|
||||||
if (WITHIN(servo_index, 0, NUM_SERVOS - 1))
|
if (WITHIN(servo_index, 0, NUM_SERVOS - 1))
|
||||||
DETACH_SERVO(servo_index);
|
servo[servo_index].detach();
|
||||||
else
|
else
|
||||||
SERIAL_ECHO_MSG("Servo ", servo_index, " out of range");
|
SERIAL_ECHO_MSG("Servo ", servo_index, " out of range");
|
||||||
|
|
||||||
|
|
|
@ -343,7 +343,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) {
|
||||||
|
|
||||||
#elif HAS_Z_SERVO_PROBE
|
#elif HAS_Z_SERVO_PROBE
|
||||||
|
|
||||||
MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][deploy ? 0 : 1]);
|
servo[Z_PROBE_SERVO_NR].move(servo_angles[Z_PROBE_SERVO_NR][deploy ? 0 : 1]);
|
||||||
|
|
||||||
#elif EITHER(TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY)
|
#elif EITHER(TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY)
|
||||||
|
|
||||||
|
|
|
@ -39,19 +39,19 @@ hal_servo_t servo[NUM_SERVOS];
|
||||||
void servo_init() {
|
void servo_init() {
|
||||||
#if NUM_SERVOS >= 1 && HAS_SERVO_0
|
#if NUM_SERVOS >= 1 && HAS_SERVO_0
|
||||||
servo[0].attach(SERVO0_PIN);
|
servo[0].attach(SERVO0_PIN);
|
||||||
DETACH_SERVO(0); // Just set up the pin. We don't have a position yet. Don't move to a random position.
|
servo[0].detach(); // Just set up the pin. We don't have a position yet. Don't move to a random position.
|
||||||
#endif
|
#endif
|
||||||
#if NUM_SERVOS >= 2 && HAS_SERVO_1
|
#if NUM_SERVOS >= 2 && HAS_SERVO_1
|
||||||
servo[1].attach(SERVO1_PIN);
|
servo[1].attach(SERVO1_PIN);
|
||||||
DETACH_SERVO(1);
|
servo[1].detach();
|
||||||
#endif
|
#endif
|
||||||
#if NUM_SERVOS >= 3 && HAS_SERVO_2
|
#if NUM_SERVOS >= 3 && HAS_SERVO_2
|
||||||
servo[2].attach(SERVO2_PIN);
|
servo[2].attach(SERVO2_PIN);
|
||||||
DETACH_SERVO(2);
|
servo[2].detach();
|
||||||
#endif
|
#endif
|
||||||
#if NUM_SERVOS >= 4 && HAS_SERVO_3
|
#if NUM_SERVOS >= 4 && HAS_SERVO_3
|
||||||
servo[3].attach(SERVO3_PIN);
|
servo[3].attach(SERVO3_PIN);
|
||||||
DETACH_SERVO(3);
|
servo[3].detach();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,14 +103,11 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
#if HAS_Z_SERVO_PROBE
|
#if HAS_Z_SERVO_PROBE
|
||||||
#define DEPLOY_Z_SERVO() MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][0])
|
#define DEPLOY_Z_SERVO() servo[Z_PROBE_SERVO_NR].move(servo_angles[Z_PROBE_SERVO_NR][0])
|
||||||
#define STOW_Z_SERVO() MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][1])
|
#define STOW_Z_SERVO() servo[Z_PROBE_SERVO_NR].move(servo_angles[Z_PROBE_SERVO_NR][1])
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // HAS_SERVO_ANGLES
|
#endif // HAS_SERVO_ANGLES
|
||||||
|
|
||||||
#define MOVE_SERVO(I, P) servo[I].move(P)
|
|
||||||
#define DETACH_SERVO(I) servo[I].detach()
|
|
||||||
|
|
||||||
extern hal_servo_t servo[NUM_SERVOS];
|
extern hal_servo_t servo[NUM_SERVOS];
|
||||||
void servo_init();
|
void servo_init();
|
||||||
|
|
|
@ -1881,7 +1881,7 @@ void Temperature::manage_heater() {
|
||||||
#endif
|
#endif
|
||||||
#if ENABLED(CHAMBER_VENT)
|
#if ENABLED(CHAMBER_VENT)
|
||||||
flag_chamber_excess_heat = false;
|
flag_chamber_excess_heat = false;
|
||||||
MOVE_SERVO(CHAMBER_VENT_SERVO_NR, 90);
|
servo[CHAMBER_VENT_SERVO_NR].move(90);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1897,7 +1897,7 @@ void Temperature::manage_heater() {
|
||||||
if (flag_chamber_excess_heat) {
|
if (flag_chamber_excess_heat) {
|
||||||
temp_chamber.soft_pwm_amount = 0;
|
temp_chamber.soft_pwm_amount = 0;
|
||||||
#if ENABLED(CHAMBER_VENT)
|
#if ENABLED(CHAMBER_VENT)
|
||||||
if (!flag_chamber_off) MOVE_SERVO(CHAMBER_VENT_SERVO_NR, temp_chamber.celsius <= temp_chamber.target ? 0 : 90);
|
if (!flag_chamber_off) servo[CHAMBER_VENT_SERVO_NR].move(temp_chamber.celsius <= temp_chamber.target ? 0 : 90);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1910,7 +1910,7 @@ void Temperature::manage_heater() {
|
||||||
temp_chamber.soft_pwm_amount = temp_chamber.celsius < temp_chamber.target ? (MAX_CHAMBER_POWER) >> 1 : 0;
|
temp_chamber.soft_pwm_amount = temp_chamber.celsius < temp_chamber.target ? (MAX_CHAMBER_POWER) >> 1 : 0;
|
||||||
#endif
|
#endif
|
||||||
#if ENABLED(CHAMBER_VENT)
|
#if ENABLED(CHAMBER_VENT)
|
||||||
if (!flag_chamber_off) MOVE_SERVO(CHAMBER_VENT_SERVO_NR, 0);
|
if (!flag_chamber_off) servo[CHAMBER_VENT_SERVO_NR].move(0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,7 @@
|
||||||
void move_extruder_servo(const uint8_t e) {
|
void move_extruder_servo(const uint8_t e) {
|
||||||
planner.synchronize();
|
planner.synchronize();
|
||||||
if ((EXTRUDERS & 1) && e < EXTRUDERS - 1) {
|
if ((EXTRUDERS & 1) && e < EXTRUDERS - 1) {
|
||||||
MOVE_SERVO(_SERVO_NR(e), servo_angles[_SERVO_NR(e)][e & 1]);
|
servo[_SERVO_NR(e)].move(servo_angles[_SERVO_NR(e)][e & 1]);
|
||||||
safe_delay(500);
|
safe_delay(500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@
|
||||||
constexpr int8_t sns_index[2] = { SWITCHING_NOZZLE_SERVO_NR, SWITCHING_NOZZLE_E1_SERVO_NR };
|
constexpr int8_t sns_index[2] = { SWITCHING_NOZZLE_SERVO_NR, SWITCHING_NOZZLE_E1_SERVO_NR };
|
||||||
constexpr int16_t sns_angles[2] = SWITCHING_NOZZLE_SERVO_ANGLES;
|
constexpr int16_t sns_angles[2] = SWITCHING_NOZZLE_SERVO_ANGLES;
|
||||||
planner.synchronize();
|
planner.synchronize();
|
||||||
MOVE_SERVO(sns_index[e], sns_angles[angle_index]);
|
servo[sns_index[e]].move(sns_angles[angle_index]);
|
||||||
safe_delay(500);
|
safe_delay(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@
|
||||||
|
|
||||||
void move_nozzle_servo(const uint8_t angle_index) {
|
void move_nozzle_servo(const uint8_t angle_index) {
|
||||||
planner.synchronize();
|
planner.synchronize();
|
||||||
MOVE_SERVO(SWITCHING_NOZZLE_SERVO_NR, servo_angles[SWITCHING_NOZZLE_SERVO_NR][angle_index]);
|
servo[SWITCHING_NOZZLE_SERVO_NR].move(servo_angles[SWITCHING_NOZZLE_SERVO_NR][angle_index]);
|
||||||
safe_delay(500);
|
safe_delay(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,7 +443,7 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0.
|
||||||
inline void switching_toolhead_lock(const bool locked) {
|
inline void switching_toolhead_lock(const bool locked) {
|
||||||
#ifdef SWITCHING_TOOLHEAD_SERVO_ANGLES
|
#ifdef SWITCHING_TOOLHEAD_SERVO_ANGLES
|
||||||
const uint16_t swt_angles[2] = SWITCHING_TOOLHEAD_SERVO_ANGLES;
|
const uint16_t swt_angles[2] = SWITCHING_TOOLHEAD_SERVO_ANGLES;
|
||||||
MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, swt_angles[locked ? 0 : 1]);
|
servo[SWITCHING_TOOLHEAD_SERVO_NR].move(swt_angles[locked ? 0 : 1]);
|
||||||
#elif PIN_EXISTS(SWT_SOLENOID)
|
#elif PIN_EXISTS(SWT_SOLENOID)
|
||||||
OUT_WRITE(SWT_SOLENOID_PIN, locked);
|
OUT_WRITE(SWT_SOLENOID_PIN, locked);
|
||||||
gcode.dwell(10);
|
gcode.dwell(10);
|
||||||
|
|
Loading…
Reference in a new issue