Subversion Repositories HomeAutomation

Rev

Rev 207 | Blame | Last modification | View Log | SVN | RSS feed

  1. #ifndef RC_SERVO_H_
  2. #define RC_SERVO_H_
  3.  
  4. /*-----------------------------------------------
  5.  * Includes
  6.  * ---------------------------------------------*/
  7. #include <stdlib.h>
  8. #include <stdio.h>
  9. #include <inttypes.h>
  10.  
  11. /*-----------------------------------------------
  12.  * Defines
  13.  * --------------------------------------------*/
  14.  
  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.  
  21. /*
  22.  * For width of the pulse that control the RC servo.
  23.  * Clock pulses.
  24.  * This is adjusted for a 8 MHz clock, to use different speeds recalculate.
  25.  */
  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)
  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
  40.