File tree Expand file tree Collapse file tree 3 files changed +13
-11
lines changed Expand file tree Collapse file tree 3 files changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,8 @@ bool ServoController::Handle_Servo_Add(pb_istream_t *stream) {
74
74
75
75
// Write the default minimum to a servo
76
76
if (did_attach) {
77
- _servo_hardware[_active_servo_pins]->ServoWrite (MIN_SERVO_PULSE_WIDTH);
77
+ _servo_hardware[_active_servo_pins]->ServoWrite (
78
+ (int )msg_add->min_pulse_width );
78
79
WS_DEBUG_PRINT (" [servo] Servo attached to pin: " );
79
80
WS_DEBUG_PRINTLN (msg_add->servo_pin );
80
81
_active_servo_pins++;
@@ -116,10 +117,6 @@ bool ServoController::Handle_Servo_Write(pb_istream_t *stream) {
116
117
}
117
118
// Write the pulse width to the servo
118
119
_servo_hardware[servo_idx]->ServoWrite (msg_write->pulse_width );
119
- WS_DEBUG_PRINT (" [servo] Set Pulse Width: " );
120
- WS_DEBUG_PRINT (msg_write->pulse_width );
121
- WS_DEBUG_PRINT (" µs on pin: " );
122
- WS_DEBUG_PRINT (msg_write->servo_pin );
123
120
return true ;
124
121
}
125
122
Original file line number Diff line number Diff line change @@ -147,6 +147,10 @@ void ServoHardware::ServoWrite(int value) {
147
147
if (value > _max_pulse_width)
148
148
value = _max_pulse_width;
149
149
_servo->writeMicroseconds (value);
150
+ WS_DEBUG_PRINT (" [servo] Set Pulse Width: " );
151
+ WS_DEBUG_PRINT (value);
152
+ WS_DEBUG_PRINT (" µs on pin: " );
153
+ WS_DEBUG_PRINT (_pin);
150
154
#endif
151
155
}
152
156
@@ -174,6 +178,11 @@ void ServoHardware::writeMicroseconds(int value) {
174
178
((double )value / ((double )20000 / (double )pow (2 , LEDC_TIMER_WIDTH)));
175
179
if (!ledcWrite (_pin, count))
176
180
WS_DEBUG_PRINTLN (" [servo] Error: Failed to write to servo pin!" );
181
+
182
+ WS_DEBUG_PRINT (" [servo] Set Pulse Width: " );
183
+ WS_DEBUG_PRINT (value);
184
+ WS_DEBUG_PRINT (" uS on pin: " );
185
+ WS_DEBUG_PRINT (_pin);
177
186
}
178
187
179
188
/* *************************************************************************/
Original file line number Diff line number Diff line change 19
19
#ifdef ARDUINO_ARCH_ESP32
20
20
#include " esp32-hal-ledc.h"
21
21
#include " esp_err.h"
22
-
23
22
#define LEDC_TIMER_WIDTH \
24
- 12 // /< timer width to request from LEDC manager component, in bits (NOTE:
25
- // /< While ESP32x can go up to 16 bit timer width, ESP32-S2 does not work
26
- // /< at this resolution. So, for the purposes of keeping this library
27
- // /< compatible with multiple ESP32x platforms, the timer width has been
28
- // /< scaled down to 10 bits and the calculation adjusted accordingly)
23
+ SOC_LEDC_TIMER_BIT_WIDTH // /< Dynamically scale bit width for each ESP32-x
24
+ // /< Arch.
29
25
#else
30
26
#include < Servo.h>
31
27
#endif
You can’t perform that action at this time.
0 commit comments