IR-PC-HID-Remote.ino 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906
  1. //------------------------------------------------------------------------------
  2. // Include the IRremote library header
  3. //
  4. #include <IRremote.h>
  5. #include <HID-Project.h> // HID-Project 2.8.2
  6. // switch on/off debug mode at once
  7. bool isDebugBuild = false;
  8. // enable HID Keyboard output
  9. bool sendHID = true;
  10. bool enableVolumeButtons = false; // if set to false Vol+, Vol- and Mute commands will not be sent via USB to PC so that they can be used with a different IR-receiver i.E. to control to an AVR
  11. // ATTENTION - set ALL debug and useSerial to false in normal usage
  12. // as sending over Serial blocks the Arduino Leonardo unless a terminal application is connected!
  13. bool debug = false;
  14. bool debug2 = false;
  15. bool useSerial = false;
  16. // global conf vars
  17. unsigned int holdButton_releaseTimeout = 120; // global default, will be overwritten depending on RC code used
  18. #define BTN_UNKNOWN 0
  19. #define BTN_1 1
  20. #define BTN_2 2
  21. #define BTN_3 3
  22. #define BTN_4 4
  23. #define BTN_5 5
  24. #define BTN_6 6
  25. #define BTN_7 7
  26. #define BTN_8 8
  27. #define BTN_9 9
  28. #define BTN_0 10
  29. #define BTN_PLAY 11
  30. #define BTN_PAUSE 12
  31. #define BTN_STOP 13
  32. #define BTN_REC 14
  33. #define BTN_REWD 15
  34. #define BTN_FFWD 16
  35. #define BTN_PREV 17
  36. #define BTN_NEXT 18
  37. #define BTN_LEFT 20
  38. #define BTN_RIGHT 21
  39. #define BTN_UP 22
  40. #define BTN_DOWN 23
  41. #define BTN_OK_ENTER 24
  42. #define BTN_BACK 25
  43. #define BTN_MENU 26
  44. #define BTN_HOME 27
  45. #define BTN_RED 30
  46. #define BTN_GREEN 31
  47. #define BTN_YELLOW 32
  48. #define BTN_BLUE 33
  49. #define BTN_STATUS 34
  50. #define BTN_RETURN 35
  51. #define BTN_SETUP 36
  52. #define BTN_GUIDE 37
  53. #define BTN_RADIO 38
  54. #define BTN_PREVCH 39
  55. #define BTN_CH_DOWN 40
  56. #define BTN_CH_UP 41
  57. #define BTN_VOL_DOWN 42
  58. #define BTN_VOL_UP 43
  59. #define BTN_MUTE 44
  60. #define BTN_TV 46
  61. #define BTN_VIDEOS 47
  62. #define BTN_MUSIC 48
  63. #define BTN_PICTURES 49
  64. #define BTN_STAR 50
  65. #define BTN_HASH 51
  66. #define BTN_PAGE_UP 60
  67. #define BTN_PAGE_DOWN 61
  68. #define BTN_CONTEXT 62
  69. #define BTN_INFO 63
  70. #define BTN_POWER 100
  71. #define BTN_TASKSWITCH 101
  72. #define BTN_SLEEP 102
  73. #define BTN_REPETITION 255
  74. // Button Modes
  75. #define BUTTONMODE_LAST 0
  76. #define BUTTONMODE_ONCE 1
  77. #define BUTTONMODE_HOLD 2
  78. #define BUTTONMODE_REPEAT 3
  79. #define BUTTONMODE_EXTENDED_REPEAT 4
  80. // Remote Types
  81. #define REMOTETYPE_RC5 0
  82. #define REMOTETYPE_RC6 1
  83. // global vars
  84. unsigned long lastNECcode;
  85. unsigned long lastReceivedMillis;
  86. unsigned long holdButton_lastTriggeredMillis = 0;
  87. //------------------------------------------------------------------------------
  88. // Tell IRremote which Arduino pin is connected to the IR Receiver (TSOP4838)
  89. //
  90. int recvPin = 2;
  91. IRrecv irrecv(recvPin);
  92. //+=============================================================================
  93. // Configure the Arduino
  94. //
  95. void setup ( )
  96. {
  97. if (isDebugBuild) {
  98. useSerial = true;
  99. debug = true;
  100. debug2 = true;
  101. }
  102. if (useSerial || debug || debug2) Serial.begin(115200);
  103. BootKeyboard.begin();
  104. Consumer.begin();
  105. System.begin();
  106. irrecv.enableIRIn(); // Start the receiver
  107. }
  108. //+=============================================================================
  109. // Dump out the decode_results structure.
  110. //
  111. void dumpInfo (decode_results *results)
  112. {
  113. // Check if the buffer overflowed
  114. // if (results->overflow) {
  115. // Serial.println("IR code too long. Edit IRremoteInt.h and increase RAWLEN");
  116. // return;
  117. // }
  118. if (debug) {
  119. if ((results->decode_type != UNKNOWN && results->bits > 0) && debug2) {
  120. if (useSerial) {
  121. Serial.println();
  122. Serial.println();
  123. Serial.print(F("RECEIVED: "));
  124. encoding(results);
  125. Serial.print(";0x");
  126. ircode(results);
  127. Serial.print(";");
  128. Serial.print(results->bits, DEC);
  129. Serial.println();
  130. }
  131. }
  132. }
  133. // RC5 CODES
  134. if (results->decode_type == RC5 && results->bits == 12) {
  135. // RC5 code
  136. // 3 bytes, start byte for this device is 0xF or 0x7 depending on toggle bit
  137. uint8_t _currRC5Code = results->value ^ 0xF00;
  138. uint8_t _currRC5Pref = ( _currRC5Code ^ results->value ) >> 8;
  139. if (debug) {
  140. Serial.print(F(" _currRC5Code=0x"));
  141. Serial.print(_currRC5Code, HEX);
  142. Serial.print(F(" _currRC5Pref=0x"));
  143. Serial.println(_currRC5Pref, HEX);
  144. }
  145. // Hauppauge Remote
  146. if (_currRC5Code == 0xBD) { // POWER (upper right key)
  147. //handleButton_RCx(BTN_POWER, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
  148. //handlePowerButton();
  149. handleButton_RCx(BTN_POWER, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
  150. }
  151. else if (_currRC5Code == 0xBB) { // HOME/GO (upper left key)
  152. //handleButton_RCx(BTN_HOME, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  153. //handleTaskSwitchButton();
  154. handleButton_RCx(BTN_TASKSWITCH, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
  155. }
  156. // media player controls
  157. else if (_currRC5Code == 0xB7) { // REC
  158. handleButton_RCx(BTN_REC, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  159. }
  160. else if (_currRC5Code == 0xB6) { // STOP
  161. handleButton_RCx(BTN_STOP, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  162. }
  163. else if (_currRC5Code == 0xB5) { // PLAY
  164. handleButton_RCx(BTN_PLAY, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  165. }
  166. else if (_currRC5Code == 0xB0) { // PAUSE
  167. handleButton_RCx(BTN_PAUSE, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  168. }
  169. else if (_currRC5Code == 0xA4) { // PREV
  170. handleButton_RCx(BTN_PREV, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  171. }
  172. else if (_currRC5Code == 0x9E) { // NEXT
  173. handleButton_RCx(BTN_NEXT, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  174. }
  175. else if (_currRC5Code == 0xB2) { // REWIND
  176. //handleButton_RCx(BTN_REWD, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
  177. //handleButton_RCx(BTN_REWD, BUTTONMODE_HOLD, _currRC5Pref, REMOTETYPE_RC5);
  178. handleButton_RCx(BTN_REWD, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  179. }
  180. else if (_currRC5Code == 0xB4) { // FAST_FORWARD
  181. //handleButton_RCx(BTN_FFWD, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
  182. //handleButton_RCx(BTN_FFWD, BUTTONMODE_HOLD, _currRC5Pref, REMOTETYPE_RC5);
  183. handleButton_RCx(BTN_FFWD, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  184. }
  185. // above control pad
  186. else if (_currRC5Code == 0x9B) { // GUIDE -> left above control pad
  187. //handleButton_RCx(BTN_GUIDE, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  188. handleButton_RCx(BTN_TASKSWITCH, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
  189. }
  190. else if (_currRC5Code == 0x8C) { // RADIO -> right above control pad
  191. //handleButton_RCx(BTN_RADIO, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  192. handleButton_RCx(BTN_CONTEXT, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  193. }
  194. // control pad
  195. else if (_currRC5Code == 0xA5) { // OK
  196. //handleButton_RCx(BTN_OK_ENTER, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  197. handleButton_RCx(BTN_OK_ENTER, BUTTONMODE_HOLD, _currRC5Pref, REMOTETYPE_RC5);
  198. }
  199. else if (_currRC5Code == 0x94) { // ARROW UP
  200. //handleButton_RCx(BTN_UP, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
  201. //handleButton_RCx(BTN_UP, BUTTONMODE_HOLD, _currRC5Pref, REMOTETYPE_RC5);
  202. handleButton_RCx(BTN_UP, BUTTONMODE_EXTENDED_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
  203. }
  204. else if (_currRC5Code == 0x95) { // ARROW DOWN
  205. //handleButton_RCx(BTN_DOWN, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
  206. //handleButton_RCx(BTN_DOWN, BUTTONMODE_HOLD, _currRC5Pref, REMOTETYPE_RC5);
  207. handleButton_RCx(BTN_DOWN, BUTTONMODE_EXTENDED_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
  208. }
  209. else if (_currRC5Code == 0x96) { // ARROW LEFT
  210. //handleButton_RCx(BTN_LEFT, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
  211. //handleButton_RCx(BTN_LEFT, BUTTONMODE_HOLD, _currRC5Pref, REMOTETYPE_RC5);
  212. handleButton_RCx(BTN_LEFT, BUTTONMODE_EXTENDED_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
  213. }
  214. else if (_currRC5Code == 0x97) { // ARROW RIGHT
  215. //handleButton_RCx(BTN_RIGHT, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
  216. //handleButton_RCx(BTN_RIGHT, BUTTONMODE_HOLD, _currRC5Pref, REMOTETYPE_RC5);
  217. handleButton_RCx(BTN_RIGHT, BUTTONMODE_EXTENDED_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
  218. }
  219. else if (_currRC5Code == 0xA5) { // OK
  220. //handleButton_RCx(BTN_OK_ENTER, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  221. handleButton_RCx(BTN_OK_ENTER, BUTTONMODE_EXTENDED_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
  222. }
  223. // below control pad
  224. else if (_currRC5Code == 0x9F) { // BACK/EXIT -> -> swapped and used as on the other remotes as MENU
  225. handleButton_RCx(BTN_MENU, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  226. }
  227. else if (_currRC5Code == 0x8D) { // i/MENU -> swapped and used as on the other remotes as BACK/EXIT
  228. handleButton_RCx(BTN_BACK, BUTTONMODE_HOLD, _currRC5Pref, REMOTETYPE_RC5);
  229. }
  230. // volume controls
  231. else if (_currRC5Code == 0x90) { // VOL+
  232. handleButton_RCx(BTN_VOL_UP, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
  233. }
  234. else if (_currRC5Code == 0x91) { // VOL-
  235. handleButton_RCx(BTN_VOL_DOWN, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
  236. }
  237. else if (_currRC5Code == 0x8F) { // MUTE
  238. handleButton_RCx(BTN_MUTE, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  239. }
  240. // channel controls
  241. else if (_currRC5Code == 0xA1) { // CH- used as page down
  242. handleButton_RCx(BTN_CH_DOWN, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  243. }
  244. else if (_currRC5Code == 0xA0) { // CH+ used as page up
  245. handleButton_RCx(BTN_CH_UP, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  246. }
  247. else if (_currRC5Code == 0x92) { // PREV.CH
  248. handleButton_RCx(BTN_CONTEXT, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  249. }
  250. // sources
  251. else if (_currRC5Code == 0x9C) { // TV
  252. handleButton_RCx(BTN_TV, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  253. }
  254. else if (_currRC5Code == 0x98) { // VIDEOS
  255. handleButton_RCx(BTN_VIDEOS, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  256. }
  257. else if (_currRC5Code == 0x99) { // MUSIC
  258. handleButton_RCx(BTN_MUSIC, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  259. }
  260. else if (_currRC5Code == 0x9A) { // PICTURES
  261. handleButton_RCx(BTN_PICTURES, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  262. }
  263. // number keys
  264. else if (_currRC5Code == 0x81) { // 1
  265. handleButton_RCx(BTN_1, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  266. }
  267. else if (_currRC5Code == 0x82) { // 2
  268. handleButton_RCx(BTN_2, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  269. }
  270. else if (_currRC5Code == 0x83) { // 3
  271. handleButton_RCx(BTN_3, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  272. }
  273. else if (_currRC5Code == 0x84) { // 4
  274. handleButton_RCx(BTN_4, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  275. }
  276. else if (_currRC5Code == 0x85) { // 5
  277. handleButton_RCx(BTN_5, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  278. }
  279. else if (_currRC5Code == 0x86) { // 6
  280. handleButton_RCx(BTN_6, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  281. }
  282. else if (_currRC5Code == 0x87) { // 7
  283. handleButton_RCx(BTN_7, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  284. }
  285. else if (_currRC5Code == 0x88) { // 8
  286. handleButton_RCx(BTN_8, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  287. }
  288. else if (_currRC5Code == 0x89) { // 9
  289. handleButton_RCx(BTN_9, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  290. }
  291. else if (_currRC5Code == 0x80) { // 0
  292. handleButton_RCx(BTN_0, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  293. }
  294. else if (_currRC5Code == 0x8A) { // *
  295. handleButton_RCx(BTN_STAR, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  296. }
  297. else if (_currRC5Code == 0x8E) { // #
  298. handleButton_RCx(BTN_HASH, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  299. }
  300. // color keys
  301. else if (_currRC5Code == 0x8B) { // RED
  302. handleButton_RCx(BTN_RED, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  303. }
  304. else if (_currRC5Code == 0xAE) { // GREEN
  305. handleButton_RCx(BTN_GREEN, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  306. }
  307. else if (_currRC5Code == 0xB8) { // YELLOW
  308. handleButton_RCx(BTN_YELLOW, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  309. }
  310. else if (_currRC5Code == 0xA9) { // BLUE
  311. handleButton_RCx(BTN_BLUE, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
  312. }
  313. } // END RC5 CODES
  314. // SONY CODES
  315. else if (results->decode_type == SONY && results->bits == 12) {
  316. // DENON RC-1014 REMOTE, Mode AUDIO/CD, MEDIA KEYS (set to SONY CD Player)
  317. if (results->value == 0x9D1) { // PAUSE
  318. handleButton(BTN_PAUSE, false);
  319. }
  320. else if (results->value == 0xCD1) { // REWD
  321. handleButton(BTN_REWD, true);
  322. }
  323. else if (results->value == 0x2D1) { // FFWD
  324. handleButton(BTN_FFWD, true);
  325. }
  326. else if (results->value == 0xD1) { // PREV
  327. handleButton(BTN_PREV, false);
  328. }
  329. else if (results->value == 0x8D1) { // NEXT
  330. handleButton(BTN_NEXT, false);
  331. }
  332. else if (results->value == 0x4D1) { // PLAY
  333. handleButton(BTN_PLAY, false);
  334. }
  335. else if (results->value == 0x1D1) { // STOP
  336. handleButton(BTN_STOP, false);
  337. }
  338. } // END SONY CODES
  339. // RC6 CODES
  340. else if (results->decode_type == RC6 && results->bits == 20) {
  341. unsigned int _currRC6Code = results->value ^ 0xF0000;
  342. uint8_t _currRC6Pref = ( _currRC6Code ^ results->value ) >> 16;
  343. if (debug) {
  344. Serial.print(F(" _currRC6Code=0x"));
  345. Serial.print(_currRC6Code, HEX);
  346. Serial.print(F(" _currRC6Pref=0x"));
  347. Serial.println(_currRC6Pref, HEX);
  348. }
  349. // Pioneer Remote in BD mode, configured code preset to Sat-PVR/Philips 6139 (RC6 code)
  350. // with the most important buttons available.
  351. // Missing buttons configured using learning function, which does not work well with RCx format due to the toggle bit,
  352. // so i used an old unused IR remote with NEC code for these, which will be OK for non-repeating buttons.
  353. // power
  354. if (_currRC6Code == 0x270C) { // POWER (of SOURCE)
  355. //handleButton_RCx(BTN_POWER, BUTTONMODE_REPEAT, _currRC6Pref, REMOTETYPE_RC6);
  356. //handlePowerButton();
  357. handleButton_RCx(BTN_POWER, BUTTONMODE_REPEAT, _currRC6Pref, REMOTETYPE_RC6);
  358. }
  359. // above control pad
  360. else if (_currRC6Code == 0x2743) { // X - AUDIO PARAMETER - left above control pad
  361. //handleButton_RCx(BTN_HOME, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
  362. //handleTaskSwitchButton();
  363. handleButton_RCx(BTN_TASKSWITCH, BUTTONMODE_REPEAT, _currRC6Pref, REMOTETYPE_RC6);
  364. }
  365. else if (_currRC6Code == 0x2754) { // VIDEO PARAMETER - right above control pad
  366. //handleButton_RCx(BTN_MENU, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
  367. handleButton_RCx(BTN_CONTEXT, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
  368. }
  369. // control pad
  370. else if (_currRC6Code == 0x275C) { // OK/ENTER
  371. //handleButton_RCx(BTN_OK_ENTER, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
  372. handleButton_RCx(BTN_OK_ENTER, BUTTONMODE_HOLD, _currRC6Pref, REMOTETYPE_RC6);
  373. }
  374. else if (_currRC6Code == 0x275A) { // LEFT
  375. //handleButton_RCx(BTN_LEFT, BUTTONMODE_REPEAT, _currRC6Pref, REMOTETYPE_RC6);
  376. //handleButton_RCx(BTN_LEFT, BUTTONMODE_HOLD, _currRC6Pref, REMOTETYPE_RC6);
  377. handleButton_RCx(BTN_LEFT, BUTTONMODE_EXTENDED_REPEAT, _currRC6Pref, REMOTETYPE_RC6);
  378. }
  379. else if (_currRC6Code == 0x275B) { // RIGHT
  380. //handleButton_RCx(BTN_RIGHT, BUTTONMODE_REPEAT, _currRC6Pref, REMOTETYPE_RC6);
  381. //handleButton_RCx(BTN_RIGHT, BUTTONMODE_HOLD, _currRC6Pref, REMOTETYPE_RC6);
  382. handleButton_RCx(BTN_RIGHT, BUTTONMODE_EXTENDED_REPEAT, _currRC6Pref, REMOTETYPE_RC6);
  383. }
  384. else if (_currRC6Code == 0x2758) { // UP
  385. //handleButton_RCx(BTN_UP, BUTTONMODE_REPEAT, _currRC6Pref, REMOTETYPE_RC6);
  386. //handleButton_RCx(BTN_UP, BUTTONMODE_HOLD, _currRC6Pref, REMOTETYPE_RC6);
  387. handleButton_RCx(BTN_UP, BUTTONMODE_EXTENDED_REPEAT, _currRC6Pref, REMOTETYPE_RC6);
  388. }
  389. else if (_currRC6Code == 0x2759) { // DOWN
  390. //handleButton_RCx(BTN_DOWN, BUTTONMODE_REPEAT, _currRC6Pref, REMOTETYPE_RC6);
  391. //handleButton_RCx(BTN_DOWN, BUTTONMODE_HOLD, _currRC6Pref, REMOTETYPE_RC6);
  392. handleButton_RCx(BTN_DOWN, BUTTONMODE_EXTENDED_REPEAT, _currRC6Pref, REMOTETYPE_RC6);
  393. }
  394. // below control pad
  395. else if (_currRC6Code == 0x27CC) { // HOME MENU - left below control pad
  396. handleButton_RCx(BTN_MENU, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
  397. }
  398. else if (_currRC6Code == 0x2783) { // RETURN/BACK - right below control pad
  399. //handleButton_RCx(BTN_BACK, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
  400. handleButton_RCx(BTN_BACK, BUTTONMODE_HOLD, _currRC6Pref, REMOTETYPE_RC6);
  401. }
  402. // media player controls
  403. else if (_currRC6Code == 0x2771) { // PLAY
  404. handleButton_RCx(BTN_PLAY, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
  405. }
  406. else if (_currRC6Code == 0x276F) { // PAUSE
  407. handleButton_RCx(BTN_PAUSE, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
  408. }
  409. else if (_currRC6Code == 0x276E) { // STOP
  410. handleButton_RCx(BTN_STOP, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
  411. }
  412. else if (_currRC6Code == 0x276D) { // PREVIOUS
  413. handleButton_RCx(BTN_PREV, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
  414. }
  415. else if (_currRC6Code == 0x2770) { // NEXT
  416. handleButton_RCx(BTN_NEXT, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
  417. }
  418. // number keys
  419. else if (_currRC6Code == 0x2701) { // 1
  420. handleButton_RCx(BTN_1, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
  421. }
  422. else if (_currRC6Code == 0x2702) { // 2
  423. handleButton_RCx(BTN_2, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
  424. }
  425. else if (_currRC6Code == 0x2703) { // 3
  426. handleButton_RCx(BTN_3, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
  427. }
  428. else if (_currRC6Code == 0x2704) { // 4
  429. handleButton_RCx(BTN_4, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
  430. }
  431. else if (_currRC6Code == 0x2705) { // 5
  432. handleButton_RCx(BTN_5, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
  433. }
  434. else if (_currRC6Code == 0x2706) { // 6
  435. handleButton_RCx(BTN_6, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
  436. }
  437. else if (_currRC6Code == 0x2707) { // 7
  438. handleButton_RCx(BTN_7, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
  439. }
  440. else if (_currRC6Code == 0x2708) { // 8
  441. handleButton_RCx(BTN_8, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
  442. }
  443. else if (_currRC6Code == 0x2709) { // 9
  444. handleButton_RCx(BTN_9, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
  445. }
  446. else if (_currRC6Code == 0x2700) { // 0
  447. handleButton_RCx(BTN_0, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
  448. }
  449. // channel up/down
  450. else if (_currRC6Code == 0x2720) { // CH+
  451. handleButton_RCx(BTN_CH_UP, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
  452. }
  453. else if (_currRC6Code == 0x2721) { // CH-
  454. handleButton_RCx(BTN_CH_DOWN, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
  455. }
  456. // Buttons in NEC CODE due to limitations of this RC:
  457. // RED
  458. // GREEN
  459. // YELLOW
  460. // BLUE
  461. // REWIND
  462. // FAST FORWARD
  463. // ./CLR
  464. // CLASS/ENTER
  465. // AUDIO
  466. // INFO/DISP
  467. } // END RC6 CODES
  468. // NEC CODES - used also for Pioneer remote codes here (Pioneer code consists of 2 NEC codes and is not directly supported by Arduino IRRemote.h)
  469. else if (results->decode_type == NEC && results->bits == 32) {
  470. // Pioneer Remote in BD mode, configured code preset to Sat-PVR/Philips 6139 (RC6 code)
  471. // -> missing/unused buttons "learned" with codes in NEC format
  472. if (results->value == 0x4FF18E7) { // RED
  473. handleButton_NEC(BTN_RED, BUTTONMODE_ONCE);
  474. }
  475. else if (results->value == 0x4FF02FD) { // GREEN
  476. handleButton_NEC(BTN_GREEN, BUTTONMODE_ONCE);
  477. }
  478. else if (results->value == 0x4FF827D) { // YELLOW
  479. handleButton_NEC(BTN_YELLOW, BUTTONMODE_ONCE);
  480. }
  481. else if (results->value == 0x4FF38C7) { // BLUE
  482. handleButton_NEC(BTN_BLUE, BUTTONMODE_ONCE);
  483. }
  484. else if (results->value == 0x4FFB847) { // REWIND
  485. handleButton_NEC(BTN_REWD, BUTTONMODE_ONCE);
  486. }
  487. else if (results->value == 0x4FF08F7) { // FAST FORWARD
  488. handleButton_NEC(BTN_FFWD, BUTTONMODE_ONCE);
  489. }
  490. else if (results->value == 0x4FF6897) { // ./CLR
  491. //handleButton_NEC(BTN_, BUTTONMODE_ONCE);
  492. }
  493. else if (results->value == 0x4FF9867) { // CLASS/ENTER
  494. handleButton_NEC(BTN_OK_ENTER, BUTTONMODE_ONCE);
  495. }
  496. else if (results->value == 0x4FFF807) { // AUDIO
  497. //handleButton_NEC(BTN_, BUTTONMODE_ONCE);
  498. }
  499. else if (results->value == 0x4FF7887) { // DISPLAY/INFO
  500. handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
  501. }
  502. // TOSHIBA SE-R0319
  503. // NEC 32bit codes
  504. else if (results->value == 0x2FD48B7) { // POWER
  505. handleButton_NEC(BTN_POWER, BUTTONMODE_REPEAT);
  506. }
  507. else if (results->value == 0x2FDA857) { // SLEEP
  508. handleButton_NEC(BTN_SLEEP, BUTTONMODE_ONCE);
  509. }
  510. // above control pad
  511. else if (results->value == 0x2FDCA35) { // left above control pad -> TASKSWITCH
  512. handleButton_NEC(BTN_TASKSWITCH, BUTTONMODE_REPEAT);
  513. }
  514. else if (results->value == 0xA25D9E61) { // right above control pad -> CONTEXT
  515. handleButton_NEC(BTN_CONTEXT, BUTTONMODE_ONCE);
  516. }
  517. // control pad
  518. else if (results->value == 0x2FDBC43) { // ENTER
  519. handleButton_NEC(BTN_OK_ENTER, BUTTONMODE_HOLD);
  520. }
  521. else if (results->value == 0x22DD8A75) { // LEFT
  522. //handleButton_NEC(BTN_LEFT, BUTTONMODE_HOLD);
  523. handleButton_NEC(BTN_LEFT, BUTTONMODE_EXTENDED_REPEAT);
  524. }
  525. else if (results->value == 0x22DDB24D) { // RIGHT
  526. //handleButton_NEC(BTN_RIGHT, BUTTONMODE_HOLD);
  527. handleButton_NEC(BTN_RIGHT, BUTTONMODE_EXTENDED_REPEAT);
  528. }
  529. else if (results->value == 0x2FD7C83) { // UP
  530. //handleButton_NEC(BTN_UP, BUTTONMODE_HOLD);
  531. handleButton_NEC(BTN_UP, BUTTONMODE_EXTENDED_REPEAT);
  532. }
  533. else if (results->value == 0x2FDFC03) { // DOWN
  534. //handleButton_NEC(BTN_DOWN, BUTTONMODE_HOLD);
  535. handleButton_NEC(BTN_DOWN, BUTTONMODE_EXTENDED_REPEAT);
  536. }
  537. // below control pad
  538. else if (results->value == 0x2FD708F) { // left below control pad -> MENU
  539. handleButton_NEC(BTN_MENU, BUTTONMODE_ONCE);
  540. }
  541. else if (results->value == 0x22DDF708) { // left below control pad -> BACK
  542. handleButton_NEC(BTN_BACK, BUTTONMODE_ONCE);
  543. }
  544. // volume control
  545. else if (results->value == 0x2FD58A7) { // VOL+
  546. handleButton_NEC(BTN_VOL_UP, BUTTONMODE_REPEAT);
  547. }
  548. else if (results->value == 0x2FD7887) { // VOL-
  549. handleButton_NEC(BTN_VOL_DOWN, BUTTONMODE_REPEAT);
  550. }
  551. else if (results->value == 0x2FD08F7) { // MUTE
  552. handleButton_NEC(BTN_MUTE, BUTTONMODE_ONCE);
  553. }
  554. // media player controls
  555. else if (results->value == 0x22DDA857) { // PLAY
  556. handleButton_NEC(BTN_PLAY, BUTTONMODE_ONCE);
  557. }
  558. // else if (results->value == 0xA25DA857) { // PAUSE - combined with GREEN - unused as PLAY/PAUSE is 1 key anyway
  559. // handleButton_NEC(BTN_PAUSE, BUTTONMODE_ONCE);
  560. // }
  561. else if (results->value == 0x22DD28D7) { // STOP
  562. handleButton_NEC(BTN_STOP, BUTTONMODE_ONCE);
  563. }
  564. else if (results->value == 0xA25DC43B) { // PREV
  565. handleButton_NEC(BTN_PREV, BUTTONMODE_ONCE);
  566. }
  567. else if (results->value == 0xA25D24DB) { // NEXT
  568. handleButton_NEC(BTN_NEXT, BUTTONMODE_ONCE);
  569. }
  570. else if (results->value == 0xA25D9867) { // REWD
  571. handleButton_NEC(BTN_REWD, BUTTONMODE_ONCE);
  572. }
  573. else if (results->value == 0xA25DC837) { // FFWD
  574. handleButton_NEC(BTN_FFWD, BUTTONMODE_ONCE);
  575. }
  576. // number keys
  577. else if (results->value == 0x2FD807F) { // 1
  578. handleButton_NEC(BTN_1, BUTTONMODE_ONCE);
  579. }
  580. else if (results->value == 0x2FD40BF) { // 2
  581. handleButton_NEC(BTN_2, BUTTONMODE_ONCE);
  582. }
  583. else if (results->value == 0x2FDC03F) { // 3
  584. handleButton_NEC(BTN_3, BUTTONMODE_ONCE);
  585. }
  586. else if (results->value == 0x2FD20DF) { // 4
  587. handleButton_NEC(BTN_4, BUTTONMODE_ONCE);
  588. }
  589. else if (results->value == 0x2FDA05F) { // 5
  590. handleButton_NEC(BTN_5, BUTTONMODE_ONCE);
  591. }
  592. else if (results->value == 0x2FD609F) { // 6
  593. handleButton_NEC(BTN_6, BUTTONMODE_ONCE);
  594. }
  595. else if (results->value == 0x2FDE01F) { // 7
  596. handleButton_NEC(BTN_7, BUTTONMODE_ONCE);
  597. }
  598. else if (results->value == 0x2FD10EF) { // 8
  599. handleButton_NEC(BTN_8, BUTTONMODE_ONCE);
  600. }
  601. else if (results->value == 0x2FD906F) { // 9
  602. handleButton_NEC(BTN_9, BUTTONMODE_ONCE);
  603. }
  604. else if (results->value == 0x2FD00FF) { // 0
  605. handleButton_NEC(BTN_0, BUTTONMODE_ONCE);
  606. }
  607. // color keys
  608. else if (results->value == 0xA25D708F) { // RED (also SLOW REWD)
  609. handleButton_NEC(BTN_RED, BUTTONMODE_ONCE);
  610. }
  611. else if (results->value == 0xA25DA857) { // GREEN (also PAUSE)
  612. handleButton_NEC(BTN_GREEN, BUTTONMODE_ONCE);
  613. }
  614. else if (results->value == 0xA25D07F8) { // YELLOW (also PLAY MODE)
  615. handleButton_NEC(BTN_YELLOW, BUTTONMODE_ONCE);
  616. }
  617. else if (results->value == 0xA25DB04F) { // BLUE (also SLOW FWD)
  618. handleButton_NEC(BTN_BLUE, BUTTONMODE_ONCE);
  619. }
  620. // other
  621. else if (results->value == 0x2FD38C7) { // DISPLAY
  622. handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
  623. }
  624. // else if (results->value == 0xA23DCD32) { // TV/DVD
  625. // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
  626. // }
  627. // else if (results->value == 0xA25DAF50) { // EJECT
  628. // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
  629. // }
  630. // else if (results->value == 0x22DDE11E) { // SUBTITLE
  631. // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
  632. // }
  633. // else if (results->value == 0x2FDF00F) { // INPUT
  634. // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
  635. // }
  636. // else if (results->value == 0x2FD9867) { // MENU/DVD
  637. // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
  638. // }
  639. // else if (results->value == 0x22DDFB04) { // MENU/TOP
  640. // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
  641. // }
  642. // else if (results->value == 0x22DDCA35) { // AUDIO SELECT
  643. // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
  644. // }
  645. // else if (results->value == 0xA25D02FD) { // CH.RTN/ZOOM
  646. // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
  647. // }
  648. // else if (results->value == 0x22DDBA45) { // RETURN (next to PLAY)
  649. // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
  650. // }
  651. // else if (results->value == 0xA25D37C8) { // MARKER
  652. // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
  653. // }
  654. // else if (results->value == 0x22DD6996) { // ANGLE
  655. // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
  656. // }
  657. // else if (results->value == 0x22DD3AC5) { // REPEAT A+B
  658. // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
  659. // }
  660. // else if (results->value == 0x22DDD926) { // JUMP
  661. // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
  662. // }
  663. // else if (results->value == 0x2FD9A65) { // PIC SIZE
  664. // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
  665. // }
  666. // Pioneer Codes - here we have to take 2 received codes into account, so we check against the last received that we stored in a global variable then ;-)
  667. // // Pioneer 2238 code for BD ---- NOT UNUSED ANY MORE
  668. // if (lastNECcode == 0xD52A34CB && results->value == 0xF50AC639) { // LEFT
  669. // handleButton(BTN_LEFT, true);
  670. // }
  671. // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A26D9) { // RIGHT
  672. // handleButton(BTN_RIGHT, true);
  673. // }
  674. // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A4FB0) { // UP
  675. // handleButton(BTN_UP, true);
  676. // }
  677. // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50ACF30) { // DOWN
  678. // handleButton(BTN_DOWN, true);
  679. // }
  680. // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50AF708) { // ENTER + CLASS ENTER
  681. // handleButton(BTN_OK_ENTER, false);
  682. // }
  683. // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A3DC2) { // POWER
  684. // //handleButton(BTN_POWER, false);
  685. // handlePowerButton();
  686. // }
  687. // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A2DD2) { // AUDIO PARAMETER - top left at control pad
  688. // //handleButton(BTN_, false);
  689. // }
  690. // else if (lastNECcode == 0xD52A54AB && results->value == 0xF50A3CC3) { // VIDEO PARAMETER - top right at control pad
  691. // //handleButton(BTN_, false);
  692. // }
  693. // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A0DF2) { // HOME MENU - bottom left at control pad
  694. // handleButton(BTN_MENU, false);
  695. // }
  696. // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A2FD0) { // RETURN - bottom right at control pad
  697. // handleButton(BTN_BACK, false);
  698. // }
  699. // else if (lastNECcode == 0xD52A54AB && results->value == 0xF50A26D9) { // RED
  700. // handleButton(BTN_RED, false);
  701. // }
  702. // else if (lastNECcode == 0xD52A54AB && results->value == 0xF50AA659) { // GREEN
  703. // handleButton(BTN_GREEN, false);
  704. // }
  705. // else if (lastNECcode == 0xD52A54AB && results->value == 0xF50A1FE0) { // YELLOW
  706. // handleButton(BTN_YELLOW, false);
  707. // }
  708. // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A9D62) { // BLUE
  709. // handleButton(BTN_BLUE, false);
  710. // }
  711. // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A57A8) { // REWIND
  712. // handleButton(BTN_REWD, true);
  713. // }
  714. // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A9768) { // FFWD
  715. // handleButton(BTN_FFWD, true);
  716. // }
  717. // else if (lastNECcode == 0xD52A44BB && results->value == 0xD52A44BB) { // PLAY
  718. // handleButton(BTN_PLAY, false);
  719. // }
  720. // else if (lastNECcode == 0xD52AE41B && results->value == 0xD52AE41B) { // PREVIOUS
  721. // handleButton(BTN_PREV, false);
  722. // }
  723. // else if (lastNECcode == 0xD52AC43B && results->value == 0xD52AC43B) { // PAUSE
  724. // handleButton(BTN_PAUSE, false);
  725. // }
  726. // else if (lastNECcode == 0xD52A04FB && results->value == 0xD52A04FB) { // STOP
  727. // handleButton(BTN_STOP, false);
  728. // }
  729. // else if (lastNECcode == 0xD52A649B && results->value == 0xD52A649B) { // NEXT TRACK
  730. // handleButton(BTN_NEXT, false);
  731. // }
  732. // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A05FA) { // 0
  733. // handleButton(BTN_0, false);
  734. // }
  735. // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A857A) { // 1
  736. // handleButton(BTN_1, false);
  737. // }
  738. // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A45BA) { // 2
  739. // handleButton(BTN_2, false);
  740. // }
  741. // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50AC53A) { // 3
  742. // handleButton(BTN_3, false);
  743. // }
  744. // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A25DA) { // 4
  745. // handleButton(BTN_4, false);
  746. // }
  747. // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50AA55A) { // 5
  748. // handleButton(BTN_5, false);
  749. // }
  750. // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A659A) { // 6
  751. // handleButton(BTN_6, false);
  752. // }
  753. // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50AE51A) { // 7
  754. // handleButton(BTN_7, false);
  755. // }
  756. // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A15EA) { // 8
  757. // handleButton(BTN_8, false);
  758. // }
  759. // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A956A) { // 9
  760. // handleButton(BTN_9, false);
  761. // }
  762. // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A7D82) { // AUDIO
  763. // //handleButton(BTN_POWER, false);
  764. // }
  765. // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50AC738) { // DISP/INFO
  766. // //handleButton(BTN_POWER, false);
  767. // }
  768. // else if (lastNECcode == 0xD52A54AB && results->value == 0xF50A7689) { // CH_UP
  769. // handleButton(BTN_CH_UP, false);
  770. // }
  771. // else if (lastNECcode == 0xD52A54AB && results->value == 0xF50AF609) { // CH_DOWN
  772. // handleButton(BTN_CH_DOWN, false);
  773. // }
  774. // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50AA758) { // ./CLR/D.ACCESS
  775. // //handleButton(BTN_POWER, false);
  776. // }
  777. // remember last NEC code - for PIONEER remotes sending 2 NEC codes as one PIONEER code
  778. //lastNECcode = results->value;
  779. else {
  780. // unknown / not implemented NEC code -> must reset last key or a repeat of this unknown key will trigger the last one
  781. handleButton_NEC(BTN_UNKNOWN, BUTTONMODE_REPEAT);
  782. }
  783. } // END NEC CODES
  784. // NEC repetitions (0 bits)
  785. // RC using NEC code send a 0 bit NEC code as repetition after the actual key press
  786. else if (results->decode_type == NEC && results->bits == 0) {
  787. if (debug) Serial.println(F("NEC REPETITION"));
  788. handleButton_NEC(BTN_REPETITION, BUTTONMODE_LAST);
  789. }
  790. }
  791. //+=============================================================================
  792. // The repeating section of the code
  793. //
  794. void loop ( )
  795. {
  796. decode_results results; // Somewhere to store the results
  797. if (irrecv.decode(&results)) { // Grab an IR code
  798. dumpInfo(&results); // Output the results (if not in ignore time window)
  799. irrecv.resume(); // Prepare for the next value
  800. }
  801. handlePowerButton_loop();
  802. handleTaskSwitchButton_loop();
  803. handleHoldButtons_loop(); // release all keys after timeout
  804. }