File syn_servo.c¶
FileList > motor > syn_servo.c
Go to the source code of this file
Servo controller implementation.
#include "../util/syn_assert.h"#include "syn_servo.h"#include <string.h>
Public Functions¶
| Type | Name |
|---|---|
| void | syn_servo_init (SYN_Servo * servo, uint16_t pulse_min, uint16_t pulse_max, uint16_t angle_range) Initialize a servo. |
| void | syn_servo_move_to (SYN_Servo * servo, uint16_t angle, uint16_t duration) Start a smooth move to an angle. |
| void | syn_servo_set_angle (SYN_Servo * servo, uint16_t angle) Set servo position by angle (immediate). |
| void | syn_servo_set_pulse (SYN_Servo * servo, uint16_t us) Set servo position by raw pulse width (immediate). |
| void | syn_servo_update (SYN_Servo * servo) Update servo position for smooth movement. |
Public Static Functions¶
| Type | Name |
|---|---|
| uint16_t | angle_to_us (const SYN_Servo * s, uint16_t angle) Convert angle to pulse width in microseconds. |
| uint16_t | clamp_us (const SYN_Servo * s, uint16_t us) Clamp pulse width to min/max range. |
Public Functions Documentation¶
function syn_servo_init¶
Initialize a servo.
void syn_servo_init (
SYN_Servo * servo,
uint16_t pulse_min,
uint16_t pulse_max,
uint16_t angle_range
)
Parameters:
servoServo instance.pulse_minMinimum pulse width in µs (0° position).pulse_maxMaximum pulse width in µs (max angle position).angle_rangeFull angular range in degrees.
function syn_servo_move_to¶
Start a smooth move to an angle.
Parameters:
servoServo.angleTarget angle.durationMovement duration in milliseconds.
function syn_servo_set_angle¶
Set servo position by angle (immediate).
Parameters:
servoServo handle.angleAngle in degrees (0 to angle_range).
function syn_servo_set_pulse¶
Set servo position by raw pulse width (immediate).
Parameters:
servoServo handle.usPulse width in microseconds.
function syn_servo_update¶
Update servo position for smooth movement.
Call periodically (e.g., every 10–20ms) while a smooth move is active.
Parameters:
servoServo instance.
Public Static Functions Documentation¶
function angle_to_us¶
Convert angle to pulse width in microseconds.
Parameters:
sServo instance.angleAngle (0 to angle_range).
Returns:
Pulse width in µs.
function clamp_us¶
Clamp pulse width to min/max range.
Parameters:
sServo instance.usPulse width in µs.
Returns:
Clamped pulse width.
The documentation for this class was generated from the following file src/syntropic/motor/syn_servo.c