|
@@ -54,19 +54,15 @@
|
54
|
54
|
|
55
|
55
|
#include "../inc/MarlinConfig.h"
|
56
|
56
|
|
57
|
|
-#include "HAL.h"
|
58
|
|
-
|
59
|
57
|
#if HAS_SERVOS && !(IS_32BIT_TEENSY || defined(TARGET_LPC1768))
|
60
|
58
|
|
61
|
59
|
//#include <Arduino.h>
|
62
|
|
-
|
63
|
60
|
#include "servo.h"
|
64
|
61
|
#include "servo_private.h"
|
65
|
62
|
|
66
|
63
|
ServoInfo_t servo_info[MAX_SERVOS]; // static array of servo info structures
|
67
|
64
|
uint8_t ServoCount = 0; // the total number of attached servos
|
68
|
65
|
|
69
|
|
-
|
70
|
66
|
#define SERVO_MIN() (MIN_PULSE_WIDTH - this->min * 4) // minimum value in uS for this servo
|
71
|
67
|
#define SERVO_MAX() (MAX_PULSE_WIDTH - this->max * 4) // maximum value in uS for this servo
|
72
|
68
|
|
|
@@ -92,11 +88,11 @@ Servo::Servo() {
|
92
|
88
|
this->servoIndex = INVALID_SERVO; // too many servos
|
93
|
89
|
}
|
94
|
90
|
|
95
|
|
-int8_t Servo::attach(int pin) {
|
|
91
|
+int8_t Servo::attach(const int pin) {
|
96
|
92
|
return this->attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
|
97
|
93
|
}
|
98
|
94
|
|
99
|
|
-int8_t Servo::attach(int pin, int min, int max) {
|
|
95
|
+int8_t Servo::attach(const int pin, const int min, const int max) {
|
100
|
96
|
|
101
|
97
|
if (this->servoIndex >= MAX_SERVOS) return -1;
|
102
|
98
|
|
|
@@ -151,12 +147,12 @@ int Servo::readMicroseconds() {
|
151
|
147
|
|
152
|
148
|
bool Servo::attached() { return servo_info[this->servoIndex].Pin.isActive; }
|
153
|
149
|
|
154
|
|
-void Servo::move(int value) {
|
|
150
|
+void Servo::move(const int value) {
|
155
|
151
|
constexpr uint16_t servo_delay[] = SERVO_DELAY;
|
156
|
152
|
static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
|
157
|
153
|
if (this->attach(0) >= 0) {
|
158
|
154
|
this->write(value);
|
159
|
|
- delay(servo_delay[this->servoIndex]);
|
|
155
|
+ safe_delay(servo_delay[this->servoIndex]);
|
160
|
156
|
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
|
161
|
157
|
this->detach();
|
162
|
158
|
#endif
|