Firmware SDK
twr_servo.h
1 #ifndef _TWR_SERVO_H
2 #define _TWR_SERVO_H
3 
4 #include <twr_pwm.h>
5 
9 
10 #define TWR_SERVO_NO_ANGLE 255
11 #define TWR_SERVO_UNKNOWN_ANGLE 250
12 #define TWR_SERVO_DEFAULT_MIN 544
13 #define TWR_SERVO_DEFAULT_MAX 2400
14 
16 
17 typedef struct
18 {
19  twr_pwm_channel_t _channel;
20  uint16_t _min;
21  uint16_t _max;
22  uint8_t _angle;
23 
24 } twr_servo_t;
25 
27 
31 
32 void twr_servo_init(twr_servo_t *self, twr_pwm_channel_t channel);
33 
37 
38 void twr_servo_set_angle(twr_servo_t *self, uint8_t angle);
39 
42 
43 uint8_t twr_servo_get_angle(twr_servo_t *self);
44 
49 
50 void twr_servo_set_pulse_limits(twr_servo_t *self, uint16_t min_us, uint16_t max_us);
51 
55 
56 void twr_servo_set_microseconds(twr_servo_t *self, uint16_t us);
57 
59 
60 #endif // _TWR_SERVO_H
twr_pwm_channel_t
PWM channels.
Definition: twr_pwm.h:15
void twr_servo_set_angle(twr_servo_t *self, uint8_t angle)
Set angle.
Definition: twr_servo.c:29
void twr_servo_set_microseconds(twr_servo_t *self, uint16_t us)
Set Microseconds.
Definition: twr_servo.c:60
void twr_servo_set_pulse_limits(twr_servo_t *self, uint16_t min_us, uint16_t max_us)
Set pulse limits.
Definition: twr_servo.c:53
void twr_servo_init(twr_servo_t *self, twr_pwm_channel_t channel)
Initialize Servo.
Definition: twr_servo.c:6
uint8_t twr_servo_get_angle(twr_servo_t *self)
Get angle.
Definition: twr_servo.c:48
Servo instance.
Definition: twr_servo.h:18