Advertisement
justhrun

Arduino_IRTinyHashInt.h

Jul 11th, 2014
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.70 KB | None | 0 0
  1. #define IRremoteint_h
  2.  
  3. #include <Arduino.h>
  4.  
  5. #define CLKFUDGE 5      // fudge factor for clock interrupt overhead
  6. #define CLK 256      // max value for clock (timer 2)
  7. #define PRESCALE 8      // timer2 clock prescale
  8. #define SYSCLOCK 8000000  // main Arduino clock
  9. #define CLKSPERUSEC (SYSCLOCK/PRESCALE/1000000)   // timer clocks per microsecond
  10.  
  11. #define ERR 0
  12. #define DECODED 1
  13.  
  14. // defines for setting and clearing register bits
  15. #ifndef cbi
  16. #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
  17. #endif
  18. #ifndef sbi
  19. #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
  20. #endif
  21.  
  22. // clock timer reset value
  23. #define INIT_TIMER_COUNT2 (CLK - USECPERTICK*CLKSPERUSEC + CLKFUDGE)
  24. #define RESET_TIMER2 TCNT0 = INIT_TIMER_COUNT2
  25.  
  26. #define TOLERANCE 25  // percent tolerance in measurements
  27. #define LTOL (1.0 - TOLERANCE/100.)
  28. #define UTOL (1.0 + TOLERANCE/100.)
  29.  
  30. #define _GAP 5000 // Minimum map between transmissions
  31. #define GAP_TICKS (_GAP/USECPERTICK)
  32.  
  33. #define TICKS_LOW(us) (int) (((us)*LTOL/USECPERTICK))
  34. #define TICKS_HIGH(us) (int) (((us)*UTOL/USECPERTICK + 1))
  35.  
  36. // receiver states
  37. #define STATE_IDLE     2
  38. #define STATE_MARK     3
  39. #define STATE_SPACE    4
  40. #define STATE_STOP     5
  41.  
  42. // information for the interrupt handler
  43. typedef struct {
  44.   uint8_t recvpin;           // pin for IR data from detector
  45.   uint8_t rcvstate;          // state machine
  46.   unsigned int timer;     // state timer, counts 50uS ticks.
  47.   unsigned int rawbuf[RAWBUF]; // raw data
  48.   uint8_t rawlen;         // counter of entries in rawbuf
  49. }
  50. irparams_t;
  51.  
  52. // Defined in IRremote.cpp
  53. extern volatile irparams_t irparams;
  54.  
  55. // IR detector output is active low
  56. #define MARK  0
  57. #define SPACE 1
  58.  
  59. #define TOPBIT 0x80000000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement