File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ class ServoImpl {
7
7
mbed::DigitalOut *pin;
8
8
mbed::Timeout timeout; // calls a callback once when a timeout expires
9
9
mbed::Ticker ticker; // calls a callback repeatedly with a timeout
10
- uint32_t duration;
11
10
12
11
public:
13
12
ServoImpl (PinName _pin) {
@@ -34,9 +33,7 @@ class ServoImpl {
34
33
*pin = !*pin;
35
34
}
36
35
37
- uint32_t read () {
38
- return duration;
39
- }
36
+ int32_t duration = -1 ;
40
37
};
41
38
42
39
static ServoImpl* servos[MAX_SERVOS]; // static array of servo structures
@@ -107,7 +104,10 @@ void Servo::writeMicroseconds(int value)
107
104
value = SERVO_MAX ();
108
105
109
106
value = value - TRIM_DURATION;
110
- servos[this ->servoIndex ]->start (value);
107
+ if (servos[this ->servoIndex ]->duration == -1 ) {
108
+ servos[this ->servoIndex ]->start (value);
109
+ }
110
+ servos[this ->servoIndex ]->duration = value;
111
111
}
112
112
}
113
113
@@ -121,7 +121,7 @@ int Servo::readMicroseconds()
121
121
if (!servos[this ->servoIndex ]) {
122
122
return 0 ;
123
123
}
124
- return servos[this ->servoIndex ]->read () ;
124
+ return servos[this ->servoIndex ]->duration ;
125
125
}
126
126
127
127
bool Servo::attached ()
You can’t perform that action at this time.
0 commit comments