Macros | Functions
servo_dec.c File Reference
#include "servo_dec.h"
#include "stm32f4xx_conf.h"
#include "ch.h"
#include "hal.h"
#include "hw.h"
#include "utils.h"

Macros

#define SERVO_NUM   1
 
#define TIMER_FREQ   1000000
 

Functions

void servodec_init (void(*d_func)(void))
 
void servodec_set_pulse_options (float start, float end, bool median_filter)
 
float servodec_get_servo (int servo_num)
 
uint32_t servodec_get_time_since_update (void)
 
float servodec_get_last_pulse_len (int servo_num)
 

Macro Definition Documentation

#define SERVO_NUM   1
#define TIMER_FREQ   1000000

Function Documentation

float servodec_get_last_pulse_len ( int  servo_num)

Get the length of the last received pulse.

Parameters
servo_numThe servo index. If it is out of range, 0.0 will be returned.
Returns
The length of the last received pulse.
float servodec_get_servo ( int  servo_num)

Get a decoded servo value.

Parameters
servo_numThe servo index. If it is out of range, 0.0 will be returned.
Returns
The servo value in the range [-1.0 1.0].
uint32_t servodec_get_time_since_update ( void  )

Get the amount of milliseconds that has passed since the last time servo positions were received.

Returns
The amount of milliseconds that have passed since an update.
void servodec_init ( void(*)(void)  d_func)

Initialize the serve decoding driver.

Parameters
d_funcA function that should be called every time the servo signals have been decoded. Can be NULL.
void servodec_set_pulse_options ( float  start,
float  end,
bool  median_filter 
)

Change the limits of how the servo pulses should be decoded.

Parameters
startThe amount of milliseconds the pulse starts at (default is 1.0)
endhe amount of milliseconds the pulse ends at (default is 2.0)