BrickUp API Service for Docker version.

IRremote.h 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. //******************************************************************************
  2. // IRremote
  3. // Version 2.0.1 June, 2015
  4. // Copyright 2009 Ken Shirriff
  5. // For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html
  6. // Edited by Mitra to add new controller SANYO
  7. //
  8. // Interrupt code based on NECIRrcv by Joe Knapp
  9. // http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210243556
  10. // Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/
  11. //
  12. // JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
  13. // LG added by Darryl Smith (based on the JVC protocol)
  14. // Whynter A/C ARC-110WD added by Francesco Meschia
  15. //******************************************************************************
  16. #ifndef IRremote_h
  17. #define IRremote_h
  18. //------------------------------------------------------------------------------
  19. // The ISR header contains several useful macros the user may wish to use
  20. //
  21. #include "IRremoteInt.h"
  22. //------------------------------------------------------------------------------
  23. // Supported IR protocols
  24. // Each protocol you include costs memory and, during decode, costs time
  25. // Disable (set to 0) all the protocols you do not need/want!
  26. //
  27. #define DECODE_RC5 1
  28. #define SEND_RC5 1
  29. #define DECODE_RC6 1
  30. #define SEND_RC6 1
  31. #define DECODE_NEC 1
  32. #define SEND_NEC 1
  33. #define DECODE_SONY 1
  34. #define SEND_SONY 1
  35. #define DECODE_PANASONIC 1
  36. #define SEND_PANASONIC 1
  37. #define DECODE_JVC 1
  38. #define SEND_JVC 1
  39. #define DECODE_SAMSUNG 1
  40. #define SEND_SAMSUNG 1
  41. #define DECODE_WHYNTER 1
  42. #define SEND_WHYNTER 1
  43. #define DECODE_AIWA_RC_T501 1
  44. #define SEND_AIWA_RC_T501 1
  45. #define DECODE_LG 1
  46. #define SEND_LG 1
  47. #define DECODE_SANYO 1
  48. #define SEND_SANYO 0 // NOT WRITTEN
  49. #define DECODE_MITSUBISHI 1
  50. #define SEND_MITSUBISHI 0 // NOT WRITTEN
  51. #define DECODE_DISH 0 // NOT WRITTEN
  52. #define SEND_DISH 1
  53. #define DECODE_SHARP 0 // NOT WRITTEN
  54. #define SEND_SHARP 1
  55. #define DECODE_DENON 1
  56. #define SEND_DENON 1
  57. #define DECODE_PRONTO 0 // This function doe not logically make sense
  58. #define SEND_PRONTO 1
  59. //------------------------------------------------------------------------------
  60. // When sending a Pronto code we request to send either the "once" code
  61. // or the "repeat" code
  62. // If the code requested does not exist we can request to fallback on the
  63. // other code (the one we did not explicitly request)
  64. //
  65. // I would suggest that "fallback" will be the standard calling method
  66. // The last paragraph on this page discusses the rationale of this idea:
  67. // http://www.remotecentral.com/features/irdisp2.htm
  68. //
  69. #define PRONTO_ONCE false
  70. #define PRONTO_REPEAT true
  71. #define PRONTO_FALLBACK true
  72. #define PRONTO_NOFALLBACK false
  73. //------------------------------------------------------------------------------
  74. // An enumerated list of all supported formats
  75. // You do NOT need to remove entries from this list when disabling protocols!
  76. //
  77. typedef
  78. enum {
  79. UNKNOWN = -1,
  80. UNUSED = 0,
  81. RC5,
  82. RC6,
  83. NEC,
  84. SONY,
  85. PANASONIC,
  86. JVC,
  87. SAMSUNG,
  88. WHYNTER,
  89. AIWA_RC_T501,
  90. LG,
  91. SANYO,
  92. MITSUBISHI,
  93. DISH,
  94. SHARP,
  95. DENON,
  96. PRONTO,
  97. }
  98. decode_type_t;
  99. //------------------------------------------------------------------------------
  100. // Set DEBUG to 1 for lots of lovely debug output
  101. //
  102. #define DEBUG 0
  103. //------------------------------------------------------------------------------
  104. // Debug directives
  105. //
  106. #if DEBUG
  107. # define DBG_PRINT(...) Serial.print(__VA_ARGS__)
  108. # define DBG_PRINTLN(...) Serial.println(__VA_ARGS__)
  109. #else
  110. # define DBG_PRINT(...)
  111. # define DBG_PRINTLN(...)
  112. #endif
  113. //------------------------------------------------------------------------------
  114. // Mark & Space matching functions
  115. //
  116. int MATCH (int measured, int desired) ;
  117. int MATCH_MARK (int measured_ticks, int desired_us) ;
  118. int MATCH_SPACE (int measured_ticks, int desired_us) ;
  119. //------------------------------------------------------------------------------
  120. // Results returned from the decoder
  121. //
  122. class decode_results
  123. {
  124. public:
  125. decode_type_t decode_type; // UNKNOWN, NEC, SONY, RC5, ...
  126. unsigned int address; // Used by Panasonic & Sharp [16-bits]
  127. unsigned long value; // Decoded value [max 32-bits]
  128. int bits; // Number of bits in decoded value
  129. volatile unsigned int *rawbuf; // Raw intervals in 50uS ticks
  130. int rawlen; // Number of records in rawbuf
  131. int overflow; // true iff IR raw code too long
  132. };
  133. //------------------------------------------------------------------------------
  134. // Decoded value for NEC when a repeat code is received
  135. //
  136. #define REPEAT 0xFFFFFFFF
  137. //------------------------------------------------------------------------------
  138. // Main class for receiving IR
  139. //
  140. class IRrecv
  141. {
  142. public:
  143. IRrecv (int recvpin) ;
  144. IRrecv (int recvpin, int blinkpin);
  145. void blink13 (int blinkflag) ;
  146. int decode (decode_results *results) ;
  147. void enableIRIn ( ) ;
  148. bool isIdle ( ) ;
  149. void resume ( ) ;
  150. private:
  151. long decodeHash (decode_results *results) ;
  152. int compare (unsigned int oldval, unsigned int newval) ;
  153. //......................................................................
  154. # if (DECODE_RC5 || DECODE_RC6)
  155. // This helper function is shared by RC5 and RC6
  156. int getRClevel (decode_results *results, int *offset, int *used, int t1) ;
  157. # endif
  158. # if DECODE_RC5
  159. bool decodeRC5 (decode_results *results) ;
  160. # endif
  161. # if DECODE_RC6
  162. bool decodeRC6 (decode_results *results) ;
  163. # endif
  164. //......................................................................
  165. # if DECODE_NEC
  166. bool decodeNEC (decode_results *results) ;
  167. # endif
  168. //......................................................................
  169. # if DECODE_SONY
  170. bool decodeSony (decode_results *results) ;
  171. # endif
  172. //......................................................................
  173. # if DECODE_PANASONIC
  174. bool decodePanasonic (decode_results *results) ;
  175. # endif
  176. //......................................................................
  177. # if DECODE_JVC
  178. bool decodeJVC (decode_results *results) ;
  179. # endif
  180. //......................................................................
  181. # if DECODE_SAMSUNG
  182. bool decodeSAMSUNG (decode_results *results) ;
  183. # endif
  184. //......................................................................
  185. # if DECODE_WHYNTER
  186. bool decodeWhynter (decode_results *results) ;
  187. # endif
  188. //......................................................................
  189. # if DECODE_AIWA_RC_T501
  190. bool decodeAiwaRCT501 (decode_results *results) ;
  191. # endif
  192. //......................................................................
  193. # if DECODE_LG
  194. bool decodeLG (decode_results *results) ;
  195. # endif
  196. //......................................................................
  197. # if DECODE_SANYO
  198. bool decodeSanyo (decode_results *results) ;
  199. # endif
  200. //......................................................................
  201. # if DECODE_MITSUBISHI
  202. bool decodeMitsubishi (decode_results *results) ;
  203. # endif
  204. //......................................................................
  205. # if DECODE_DISH
  206. bool decodeDish (decode_results *results) ; // NOT WRITTEN
  207. # endif
  208. //......................................................................
  209. # if DECODE_SHARP
  210. bool decodeSharp (decode_results *results) ; // NOT WRITTEN
  211. # endif
  212. //......................................................................
  213. # if DECODE_DENON
  214. bool decodeDenon (decode_results *results) ;
  215. # endif
  216. } ;
  217. //------------------------------------------------------------------------------
  218. // Main class for sending IR
  219. //
  220. class IRsend
  221. {
  222. public:
  223. IRsend () { }
  224. void custom_delay_usec (unsigned long uSecs);
  225. void enableIROut (int khz) ;
  226. void mark (unsigned int usec) ;
  227. void space (unsigned int usec) ;
  228. void sendRaw (const unsigned int buf[], unsigned int len, unsigned int hz) ;
  229. //......................................................................
  230. # if SEND_RC5
  231. void sendRC5 (unsigned long data, int nbits) ;
  232. # endif
  233. # if SEND_RC6
  234. void sendRC6 (unsigned long data, int nbits) ;
  235. # endif
  236. //......................................................................
  237. # if SEND_NEC
  238. void sendNEC (unsigned long data, int nbits) ;
  239. # endif
  240. //......................................................................
  241. # if SEND_SONY
  242. void sendSony (unsigned long data, int nbits) ;
  243. # endif
  244. //......................................................................
  245. # if SEND_PANASONIC
  246. void sendPanasonic (unsigned int address, unsigned long data) ;
  247. # endif
  248. //......................................................................
  249. # if SEND_JVC
  250. // JVC does NOT repeat by sending a separate code (like NEC does).
  251. // The JVC protocol repeats by skipping the header.
  252. // To send a JVC repeat signal, send the original code value
  253. // and set 'repeat' to true
  254. void sendJVC (unsigned long data, int nbits, bool repeat) ;
  255. # endif
  256. //......................................................................
  257. # if SEND_SAMSUNG
  258. void sendSAMSUNG (unsigned long data, int nbits) ;
  259. # endif
  260. //......................................................................
  261. # if SEND_WHYNTER
  262. void sendWhynter (unsigned long data, int nbits) ;
  263. # endif
  264. //......................................................................
  265. # if SEND_AIWA_RC_T501
  266. void sendAiwaRCT501 (int code) ;
  267. # endif
  268. //......................................................................
  269. # if SEND_LG
  270. void sendLG (unsigned long data, int nbits) ;
  271. # endif
  272. //......................................................................
  273. # if SEND_SANYO
  274. void sendSanyo ( ) ; // NOT WRITTEN
  275. # endif
  276. //......................................................................
  277. # if SEND_MISUBISHI
  278. void sendMitsubishi ( ) ; // NOT WRITTEN
  279. # endif
  280. //......................................................................
  281. # if SEND_DISH
  282. void sendDISH (unsigned long data, int nbits) ;
  283. # endif
  284. //......................................................................
  285. # if SEND_SHARP
  286. void sendSharpRaw (unsigned long data, int nbits) ;
  287. void sendSharp (unsigned int address, unsigned int command) ;
  288. # endif
  289. //......................................................................
  290. # if SEND_DENON
  291. void sendDenon (unsigned long data, int nbits) ;
  292. # endif
  293. //......................................................................
  294. # if SEND_PRONTO
  295. void sendPronto (char* code, bool repeat, bool fallback) ;
  296. # endif
  297. } ;
  298. #endif