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) {
7474
7575 // Write the default minimum to a servo
7676 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 );
7879 WS_DEBUG_PRINT (" [servo] Servo attached to pin: " );
7980 WS_DEBUG_PRINTLN (msg_add->servo_pin );
8081 _active_servo_pins++;
@@ -116,10 +117,6 @@ bool ServoController::Handle_Servo_Write(pb_istream_t *stream) {
116117 }
117118 // Write the pulse width to the servo
118119 _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 );
123120 return true ;
124121}
125122
Original file line number Diff line number Diff line change @@ -147,6 +147,10 @@ void ServoHardware::ServoWrite(int value) {
147147 if (value > _max_pulse_width)
148148 value = _max_pulse_width;
149149 _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);
150154#endif
151155}
152156
@@ -174,6 +178,11 @@ void ServoHardware::writeMicroseconds(int value) {
174178 ((double )value / ((double )20000 / (double )pow (2 , LEDC_TIMER_WIDTH)));
175179 if (!ledcWrite (_pin, count))
176180 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);
177186}
178187
179188/* *************************************************************************/
Original file line number Diff line number Diff line change 1919#ifdef ARDUINO_ARCH_ESP32
2020#include " esp32-hal-ledc.h"
2121#include " esp_err.h"
22-
2322#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.
2925#else
3026#include < Servo.h>
3127#endif
You can’t perform that action at this time.
0 commit comments