Subversion Repositories HomeAutomation

Rev

Details | Last modification | View Log | SVN | RSS feed

Rev Author Line No. Line
207 eqlazer 1
#ifndef RC_SERVO_H_
2
#define RC_SERVO_H_
3
 
4
/*-----------------------------------------------
5
 * Includes
6
 * ---------------------------------------------*/
7
#include <stdlib.h>
209 eqlazer 8
#include <stdio.h>
207 eqlazer 9
#include <inttypes.h>
10
 
11
/*-----------------------------------------------
12
 * Defines
13
 * --------------------------------------------*/
14
 
209 eqlazer 15
/*
16
 * If using both OC1A and OC1B set DOUBLE_PWM
17
 * On NodeGeneric it's only possible to use OC1A
18
 */
19
#define DOUBLE_PWM 0
20
 
207 eqlazer 21
/*
22
 * For width of the pulse that control the RC servo.
209 eqlazer 23
 * Clock pulses.
24
 * This is adjusted for a 8 MHz clock, to use different speeds recalculate.
207 eqlazer 25
 */
209 eqlazer 26
#define PWM_MAX_PULSE   1000
27
#define PWM_MIN_PULSE   2000
28
#define PWM_CENTER_PULSE ((PWM_MAX_PULSE - PWM_MIN_PULSE)/2 + PWM_MIN_PULSE)
29
#define STEP            ((PWM_MAX_PULSE - PWM_MIN_PULSE)/256)
207 eqlazer 30
 
31
/*-----------------------------------------------
32
 * Functions
33
 * ---------------------------------------------*/
34
void rcServoInit();
35
void setPosition(int8_t abs_pos);
36
void alterPosition(int8_t rel_pos);
37
int8_t getPosition();
38
 
39
#endif