//------------------------------------------------------------------------------ // Include the IRremote library header // #include #include // HID-Project 2.8.2 // switch on/off debug mode at once bool isDebugBuild = false; // enable HID Keyboard output bool sendHID = true; 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 // ATTENTION - set ALL debug and useSerial to false in normal usage // as sending over Serial blocks the Arduino Leonardo unless a terminal application is connected! bool debug = false; bool debug2 = false; bool useSerial = false; // global conf vars unsigned int holdButton_releaseTimeout = 120; // global default, will be overwritten depending on RC code used #define BTN_UNKNOWN 0 #define BTN_1 1 #define BTN_2 2 #define BTN_3 3 #define BTN_4 4 #define BTN_5 5 #define BTN_6 6 #define BTN_7 7 #define BTN_8 8 #define BTN_9 9 #define BTN_0 10 #define BTN_PLAY 11 #define BTN_PAUSE 12 #define BTN_STOP 13 #define BTN_REC 14 #define BTN_REWD 15 #define BTN_FFWD 16 #define BTN_PREV 17 #define BTN_NEXT 18 #define BTN_LEFT 20 #define BTN_RIGHT 21 #define BTN_UP 22 #define BTN_DOWN 23 #define BTN_OK_ENTER 24 #define BTN_BACK 25 #define BTN_MENU 26 #define BTN_HOME 27 #define BTN_RED 30 #define BTN_GREEN 31 #define BTN_YELLOW 32 #define BTN_BLUE 33 #define BTN_STATUS 34 #define BTN_RETURN 35 #define BTN_SETUP 36 #define BTN_GUIDE 37 #define BTN_RADIO 38 #define BTN_PREVCH 39 #define BTN_CH_DOWN 40 #define BTN_CH_UP 41 #define BTN_VOL_DOWN 42 #define BTN_VOL_UP 43 #define BTN_MUTE 44 #define BTN_TV 46 #define BTN_VIDEOS 47 #define BTN_MUSIC 48 #define BTN_PICTURES 49 #define BTN_STAR 50 #define BTN_HASH 51 #define BTN_PAGE_UP 60 #define BTN_PAGE_DOWN 61 #define BTN_CONTEXT 62 #define BTN_INFO 63 #define BTN_POWER 100 #define BTN_TASKSWITCH 101 #define BTN_SLEEP 102 #define BTN_REPETITION 255 // Button Modes #define BUTTONMODE_LAST 0 #define BUTTONMODE_ONCE 1 #define BUTTONMODE_HOLD 2 #define BUTTONMODE_REPEAT 3 #define BUTTONMODE_EXTENDED_REPEAT 4 // Remote Types #define REMOTETYPE_RC5 0 #define REMOTETYPE_RC6 1 // global vars unsigned long lastNECcode; unsigned long lastReceivedMillis; unsigned long holdButton_lastTriggeredMillis = 0; //------------------------------------------------------------------------------ // Tell IRremote which Arduino pin is connected to the IR Receiver (TSOP4838) // int recvPin = 2; IRrecv irrecv(recvPin); //+============================================================================= // Configure the Arduino // void setup ( ) { if (isDebugBuild) { useSerial = true; debug = true; debug2 = true; } if (useSerial || debug || debug2) Serial.begin(115200); BootKeyboard.begin(); Consumer.begin(); System.begin(); irrecv.enableIRIn(); // Start the receiver } //+============================================================================= // Dump out the decode_results structure. // void dumpInfo (decode_results *results) { // Check if the buffer overflowed // if (results->overflow) { // Serial.println("IR code too long. Edit IRremoteInt.h and increase RAWLEN"); // return; // } if (debug) { if ((results->decode_type != UNKNOWN && results->bits > 0) && debug2) { if (useSerial) { Serial.println(); Serial.println(); Serial.print(F("RECEIVED: ")); encoding(results); Serial.print(";0x"); ircode(results); Serial.print(";"); Serial.print(results->bits, DEC); Serial.println(); } } } // RC5 CODES if (results->decode_type == RC5 && results->bits == 12) { // RC5 code // 3 bytes, start byte for this device is 0xF or 0x7 depending on toggle bit uint8_t _currRC5Code = results->value ^ 0xF00; uint8_t _currRC5Pref = ( _currRC5Code ^ results->value ) >> 8; if (debug) { Serial.print(F(" _currRC5Code=0x")); Serial.print(_currRC5Code, HEX); Serial.print(F(" _currRC5Pref=0x")); Serial.println(_currRC5Pref, HEX); } // Hauppauge Remote if (_currRC5Code == 0xBD) { // POWER (upper right key) //handleButton_RCx(BTN_POWER, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5); //handlePowerButton(); handleButton_RCx(BTN_POWER, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0xBB) { // HOME/GO (upper left key) //handleButton_RCx(BTN_HOME, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); //handleTaskSwitchButton(); handleButton_RCx(BTN_TASKSWITCH, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5); } // media player controls else if (_currRC5Code == 0xB7) { // REC handleButton_RCx(BTN_REC, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0xB6) { // STOP handleButton_RCx(BTN_STOP, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0xB5) { // PLAY handleButton_RCx(BTN_PLAY, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0xB0) { // PAUSE handleButton_RCx(BTN_PAUSE, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0xA4) { // PREV handleButton_RCx(BTN_PREV, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0x9E) { // NEXT handleButton_RCx(BTN_NEXT, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0xB2) { // REWIND //handleButton_RCx(BTN_REWD, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5); //handleButton_RCx(BTN_REWD, BUTTONMODE_HOLD, _currRC5Pref, REMOTETYPE_RC5); handleButton_RCx(BTN_REWD, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0xB4) { // FAST_FORWARD //handleButton_RCx(BTN_FFWD, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5); //handleButton_RCx(BTN_FFWD, BUTTONMODE_HOLD, _currRC5Pref, REMOTETYPE_RC5); handleButton_RCx(BTN_FFWD, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } // above control pad else if (_currRC5Code == 0x9B) { // GUIDE -> left above control pad //handleButton_RCx(BTN_GUIDE, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); handleButton_RCx(BTN_TASKSWITCH, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0x8C) { // RADIO -> right above control pad //handleButton_RCx(BTN_RADIO, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); handleButton_RCx(BTN_CONTEXT, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } // control pad else if (_currRC5Code == 0xA5) { // OK //handleButton_RCx(BTN_OK_ENTER, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); handleButton_RCx(BTN_OK_ENTER, BUTTONMODE_HOLD, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0x94) { // ARROW UP //handleButton_RCx(BTN_UP, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5); //handleButton_RCx(BTN_UP, BUTTONMODE_HOLD, _currRC5Pref, REMOTETYPE_RC5); handleButton_RCx(BTN_UP, BUTTONMODE_EXTENDED_REPEAT, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0x95) { // ARROW DOWN //handleButton_RCx(BTN_DOWN, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5); //handleButton_RCx(BTN_DOWN, BUTTONMODE_HOLD, _currRC5Pref, REMOTETYPE_RC5); handleButton_RCx(BTN_DOWN, BUTTONMODE_EXTENDED_REPEAT, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0x96) { // ARROW LEFT //handleButton_RCx(BTN_LEFT, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5); //handleButton_RCx(BTN_LEFT, BUTTONMODE_HOLD, _currRC5Pref, REMOTETYPE_RC5); handleButton_RCx(BTN_LEFT, BUTTONMODE_EXTENDED_REPEAT, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0x97) { // ARROW RIGHT //handleButton_RCx(BTN_RIGHT, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5); //handleButton_RCx(BTN_RIGHT, BUTTONMODE_HOLD, _currRC5Pref, REMOTETYPE_RC5); handleButton_RCx(BTN_RIGHT, BUTTONMODE_EXTENDED_REPEAT, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0xA5) { // OK //handleButton_RCx(BTN_OK_ENTER, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); handleButton_RCx(BTN_OK_ENTER, BUTTONMODE_EXTENDED_REPEAT, _currRC5Pref, REMOTETYPE_RC5); } // below control pad else if (_currRC5Code == 0x9F) { // BACK/EXIT -> -> swapped and used as on the other remotes as MENU handleButton_RCx(BTN_MENU, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0x8D) { // i/MENU -> swapped and used as on the other remotes as BACK/EXIT handleButton_RCx(BTN_BACK, BUTTONMODE_HOLD, _currRC5Pref, REMOTETYPE_RC5); } // volume controls else if (_currRC5Code == 0x90) { // VOL+ handleButton_RCx(BTN_VOL_UP, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0x91) { // VOL- handleButton_RCx(BTN_VOL_DOWN, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0x8F) { // MUTE handleButton_RCx(BTN_MUTE, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } // channel controls else if (_currRC5Code == 0xA1) { // CH- used as page down handleButton_RCx(BTN_CH_DOWN, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0xA0) { // CH+ used as page up handleButton_RCx(BTN_CH_UP, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0x92) { // PREV.CH handleButton_RCx(BTN_CONTEXT, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } // sources else if (_currRC5Code == 0x9C) { // TV handleButton_RCx(BTN_TV, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0x98) { // VIDEOS handleButton_RCx(BTN_VIDEOS, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0x99) { // MUSIC handleButton_RCx(BTN_MUSIC, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0x9A) { // PICTURES handleButton_RCx(BTN_PICTURES, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } // number keys else if (_currRC5Code == 0x81) { // 1 handleButton_RCx(BTN_1, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0x82) { // 2 handleButton_RCx(BTN_2, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0x83) { // 3 handleButton_RCx(BTN_3, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0x84) { // 4 handleButton_RCx(BTN_4, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0x85) { // 5 handleButton_RCx(BTN_5, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0x86) { // 6 handleButton_RCx(BTN_6, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0x87) { // 7 handleButton_RCx(BTN_7, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0x88) { // 8 handleButton_RCx(BTN_8, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0x89) { // 9 handleButton_RCx(BTN_9, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0x80) { // 0 handleButton_RCx(BTN_0, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0x8A) { // * handleButton_RCx(BTN_STAR, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0x8E) { // # handleButton_RCx(BTN_HASH, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } // color keys else if (_currRC5Code == 0x8B) { // RED handleButton_RCx(BTN_RED, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0xAE) { // GREEN handleButton_RCx(BTN_GREEN, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0xB8) { // YELLOW handleButton_RCx(BTN_YELLOW, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } else if (_currRC5Code == 0xA9) { // BLUE handleButton_RCx(BTN_BLUE, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5); } } // END RC5 CODES // SONY CODES else if (results->decode_type == SONY && results->bits == 12) { // DENON RC-1014 REMOTE, Mode AUDIO/CD, MEDIA KEYS (set to SONY CD Player) if (results->value == 0x9D1) { // PAUSE handleButton(BTN_PAUSE, false); } else if (results->value == 0xCD1) { // REWD handleButton(BTN_REWD, true); } else if (results->value == 0x2D1) { // FFWD handleButton(BTN_FFWD, true); } else if (results->value == 0xD1) { // PREV handleButton(BTN_PREV, false); } else if (results->value == 0x8D1) { // NEXT handleButton(BTN_NEXT, false); } else if (results->value == 0x4D1) { // PLAY handleButton(BTN_PLAY, false); } else if (results->value == 0x1D1) { // STOP handleButton(BTN_STOP, false); } } // END SONY CODES // RC6 CODES else if (results->decode_type == RC6 && results->bits == 20) { unsigned int _currRC6Code = results->value ^ 0xF0000; uint8_t _currRC6Pref = ( _currRC6Code ^ results->value ) >> 16; if (debug) { Serial.print(F(" _currRC6Code=0x")); Serial.print(_currRC6Code, HEX); Serial.print(F(" _currRC6Pref=0x")); Serial.println(_currRC6Pref, HEX); } // Pioneer Remote in BD mode, configured code preset to Sat-PVR/Philips 6139 (RC6 code) // with the most important buttons available. // Missing buttons configured using learning function, which does not work well with RCx format due to the toggle bit, // so i used an old unused IR remote with NEC code for these, which will be OK for non-repeating buttons. // power if (_currRC6Code == 0x270C) { // POWER (of SOURCE) //handleButton_RCx(BTN_POWER, BUTTONMODE_REPEAT, _currRC6Pref, REMOTETYPE_RC6); //handlePowerButton(); handleButton_RCx(BTN_POWER, BUTTONMODE_REPEAT, _currRC6Pref, REMOTETYPE_RC6); } // above control pad else if (_currRC6Code == 0x2743) { // X - AUDIO PARAMETER - left above control pad //handleButton_RCx(BTN_HOME, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6); //handleTaskSwitchButton(); handleButton_RCx(BTN_TASKSWITCH, BUTTONMODE_REPEAT, _currRC6Pref, REMOTETYPE_RC6); } else if (_currRC6Code == 0x2754) { // VIDEO PARAMETER - right above control pad //handleButton_RCx(BTN_MENU, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6); handleButton_RCx(BTN_CONTEXT, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6); } // control pad else if (_currRC6Code == 0x275C) { // OK/ENTER //handleButton_RCx(BTN_OK_ENTER, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6); handleButton_RCx(BTN_OK_ENTER, BUTTONMODE_HOLD, _currRC6Pref, REMOTETYPE_RC6); } else if (_currRC6Code == 0x275A) { // LEFT //handleButton_RCx(BTN_LEFT, BUTTONMODE_REPEAT, _currRC6Pref, REMOTETYPE_RC6); //handleButton_RCx(BTN_LEFT, BUTTONMODE_HOLD, _currRC6Pref, REMOTETYPE_RC6); handleButton_RCx(BTN_LEFT, BUTTONMODE_EXTENDED_REPEAT, _currRC6Pref, REMOTETYPE_RC6); } else if (_currRC6Code == 0x275B) { // RIGHT //handleButton_RCx(BTN_RIGHT, BUTTONMODE_REPEAT, _currRC6Pref, REMOTETYPE_RC6); //handleButton_RCx(BTN_RIGHT, BUTTONMODE_HOLD, _currRC6Pref, REMOTETYPE_RC6); handleButton_RCx(BTN_RIGHT, BUTTONMODE_EXTENDED_REPEAT, _currRC6Pref, REMOTETYPE_RC6); } else if (_currRC6Code == 0x2758) { // UP //handleButton_RCx(BTN_UP, BUTTONMODE_REPEAT, _currRC6Pref, REMOTETYPE_RC6); //handleButton_RCx(BTN_UP, BUTTONMODE_HOLD, _currRC6Pref, REMOTETYPE_RC6); handleButton_RCx(BTN_UP, BUTTONMODE_EXTENDED_REPEAT, _currRC6Pref, REMOTETYPE_RC6); } else if (_currRC6Code == 0x2759) { // DOWN //handleButton_RCx(BTN_DOWN, BUTTONMODE_REPEAT, _currRC6Pref, REMOTETYPE_RC6); //handleButton_RCx(BTN_DOWN, BUTTONMODE_HOLD, _currRC6Pref, REMOTETYPE_RC6); handleButton_RCx(BTN_DOWN, BUTTONMODE_EXTENDED_REPEAT, _currRC6Pref, REMOTETYPE_RC6); } // below control pad else if (_currRC6Code == 0x27CC) { // HOME MENU - left below control pad handleButton_RCx(BTN_MENU, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6); } else if (_currRC6Code == 0x2783) { // RETURN/BACK - right below control pad //handleButton_RCx(BTN_BACK, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6); handleButton_RCx(BTN_BACK, BUTTONMODE_HOLD, _currRC6Pref, REMOTETYPE_RC6); } // media player controls else if (_currRC6Code == 0x2771) { // PLAY handleButton_RCx(BTN_PLAY, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6); } else if (_currRC6Code == 0x276F) { // PAUSE handleButton_RCx(BTN_PAUSE, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6); } else if (_currRC6Code == 0x276E) { // STOP handleButton_RCx(BTN_STOP, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6); } else if (_currRC6Code == 0x276D) { // PREVIOUS handleButton_RCx(BTN_PREV, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6); } else if (_currRC6Code == 0x2770) { // NEXT handleButton_RCx(BTN_NEXT, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6); } // number keys else if (_currRC6Code == 0x2701) { // 1 handleButton_RCx(BTN_1, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6); } else if (_currRC6Code == 0x2702) { // 2 handleButton_RCx(BTN_2, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6); } else if (_currRC6Code == 0x2703) { // 3 handleButton_RCx(BTN_3, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6); } else if (_currRC6Code == 0x2704) { // 4 handleButton_RCx(BTN_4, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6); } else if (_currRC6Code == 0x2705) { // 5 handleButton_RCx(BTN_5, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6); } else if (_currRC6Code == 0x2706) { // 6 handleButton_RCx(BTN_6, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6); } else if (_currRC6Code == 0x2707) { // 7 handleButton_RCx(BTN_7, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6); } else if (_currRC6Code == 0x2708) { // 8 handleButton_RCx(BTN_8, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6); } else if (_currRC6Code == 0x2709) { // 9 handleButton_RCx(BTN_9, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6); } else if (_currRC6Code == 0x2700) { // 0 handleButton_RCx(BTN_0, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6); } // channel up/down else if (_currRC6Code == 0x2720) { // CH+ handleButton_RCx(BTN_CH_UP, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6); } else if (_currRC6Code == 0x2721) { // CH- handleButton_RCx(BTN_CH_DOWN, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6); } // Buttons in NEC CODE due to limitations of this RC: // RED // GREEN // YELLOW // BLUE // REWIND // FAST FORWARD // ./CLR // CLASS/ENTER // AUDIO // INFO/DISP } // END RC6 CODES // 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) else if (results->decode_type == NEC && results->bits == 32) { // Pioneer Remote in BD mode, configured code preset to Sat-PVR/Philips 6139 (RC6 code) // -> missing/unused buttons "learned" with codes in NEC format if (results->value == 0x4FF18E7) { // RED handleButton_NEC(BTN_RED, BUTTONMODE_ONCE); } else if (results->value == 0x4FF02FD) { // GREEN handleButton_NEC(BTN_GREEN, BUTTONMODE_ONCE); } else if (results->value == 0x4FF827D) { // YELLOW handleButton_NEC(BTN_YELLOW, BUTTONMODE_ONCE); } else if (results->value == 0x4FF38C7) { // BLUE handleButton_NEC(BTN_BLUE, BUTTONMODE_ONCE); } else if (results->value == 0x4FFB847) { // REWIND handleButton_NEC(BTN_REWD, BUTTONMODE_ONCE); } else if (results->value == 0x4FF08F7) { // FAST FORWARD handleButton_NEC(BTN_FFWD, BUTTONMODE_ONCE); } else if (results->value == 0x4FF6897) { // ./CLR //handleButton_NEC(BTN_, BUTTONMODE_ONCE); } else if (results->value == 0x4FF9867) { // CLASS/ENTER handleButton_NEC(BTN_OK_ENTER, BUTTONMODE_ONCE); } else if (results->value == 0x4FFF807) { // AUDIO //handleButton_NEC(BTN_, BUTTONMODE_ONCE); } else if (results->value == 0x4FF7887) { // DISPLAY/INFO handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE); } // TOSHIBA SE-R0319 // NEC 32bit codes else if (results->value == 0x2FD48B7) { // POWER handleButton_NEC(BTN_POWER, BUTTONMODE_REPEAT); } else if (results->value == 0x2FDA857) { // SLEEP handleButton_NEC(BTN_SLEEP, BUTTONMODE_ONCE); } // above control pad else if (results->value == 0x2FDCA35) { // left above control pad -> TASKSWITCH handleButton_NEC(BTN_TASKSWITCH, BUTTONMODE_REPEAT); } else if (results->value == 0xA25D9E61) { // right above control pad -> CONTEXT handleButton_NEC(BTN_CONTEXT, BUTTONMODE_ONCE); } // control pad else if (results->value == 0x2FDBC43) { // ENTER handleButton_NEC(BTN_OK_ENTER, BUTTONMODE_HOLD); } else if (results->value == 0x22DD8A75) { // LEFT //handleButton_NEC(BTN_LEFT, BUTTONMODE_HOLD); handleButton_NEC(BTN_LEFT, BUTTONMODE_EXTENDED_REPEAT); } else if (results->value == 0x22DDB24D) { // RIGHT //handleButton_NEC(BTN_RIGHT, BUTTONMODE_HOLD); handleButton_NEC(BTN_RIGHT, BUTTONMODE_EXTENDED_REPEAT); } else if (results->value == 0x2FD7C83) { // UP //handleButton_NEC(BTN_UP, BUTTONMODE_HOLD); handleButton_NEC(BTN_UP, BUTTONMODE_EXTENDED_REPEAT); } else if (results->value == 0x2FDFC03) { // DOWN //handleButton_NEC(BTN_DOWN, BUTTONMODE_HOLD); handleButton_NEC(BTN_DOWN, BUTTONMODE_EXTENDED_REPEAT); } // below control pad else if (results->value == 0x2FD708F) { // left below control pad -> MENU handleButton_NEC(BTN_MENU, BUTTONMODE_ONCE); } else if (results->value == 0x22DDF708) { // left below control pad -> BACK handleButton_NEC(BTN_BACK, BUTTONMODE_ONCE); } // volume control else if (results->value == 0x2FD58A7) { // VOL+ handleButton_NEC(BTN_VOL_UP, BUTTONMODE_REPEAT); } else if (results->value == 0x2FD7887) { // VOL- handleButton_NEC(BTN_VOL_DOWN, BUTTONMODE_REPEAT); } else if (results->value == 0x2FD08F7) { // MUTE handleButton_NEC(BTN_MUTE, BUTTONMODE_ONCE); } // media player controls else if (results->value == 0x22DDA857) { // PLAY handleButton_NEC(BTN_PLAY, BUTTONMODE_ONCE); } // else if (results->value == 0xA25DA857) { // PAUSE - combined with GREEN - unused as PLAY/PAUSE is 1 key anyway // handleButton_NEC(BTN_PAUSE, BUTTONMODE_ONCE); // } else if (results->value == 0x22DD28D7) { // STOP handleButton_NEC(BTN_STOP, BUTTONMODE_ONCE); } else if (results->value == 0xA25DC43B) { // PREV handleButton_NEC(BTN_PREV, BUTTONMODE_ONCE); } else if (results->value == 0xA25D24DB) { // NEXT handleButton_NEC(BTN_NEXT, BUTTONMODE_ONCE); } else if (results->value == 0xA25D9867) { // REWD handleButton_NEC(BTN_REWD, BUTTONMODE_ONCE); } else if (results->value == 0xA25DC837) { // FFWD handleButton_NEC(BTN_FFWD, BUTTONMODE_ONCE); } // number keys else if (results->value == 0x2FD807F) { // 1 handleButton_NEC(BTN_1, BUTTONMODE_ONCE); } else if (results->value == 0x2FD40BF) { // 2 handleButton_NEC(BTN_2, BUTTONMODE_ONCE); } else if (results->value == 0x2FDC03F) { // 3 handleButton_NEC(BTN_3, BUTTONMODE_ONCE); } else if (results->value == 0x2FD20DF) { // 4 handleButton_NEC(BTN_4, BUTTONMODE_ONCE); } else if (results->value == 0x2FDA05F) { // 5 handleButton_NEC(BTN_5, BUTTONMODE_ONCE); } else if (results->value == 0x2FD609F) { // 6 handleButton_NEC(BTN_6, BUTTONMODE_ONCE); } else if (results->value == 0x2FDE01F) { // 7 handleButton_NEC(BTN_7, BUTTONMODE_ONCE); } else if (results->value == 0x2FD10EF) { // 8 handleButton_NEC(BTN_8, BUTTONMODE_ONCE); } else if (results->value == 0x2FD906F) { // 9 handleButton_NEC(BTN_9, BUTTONMODE_ONCE); } else if (results->value == 0x2FD00FF) { // 0 handleButton_NEC(BTN_0, BUTTONMODE_ONCE); } // color keys else if (results->value == 0xA25D708F) { // RED (also SLOW REWD) handleButton_NEC(BTN_RED, BUTTONMODE_ONCE); } else if (results->value == 0xA25DA857) { // GREEN (also PAUSE) handleButton_NEC(BTN_GREEN, BUTTONMODE_ONCE); } else if (results->value == 0xA25D07F8) { // YELLOW (also PLAY MODE) handleButton_NEC(BTN_YELLOW, BUTTONMODE_ONCE); } else if (results->value == 0xA25DB04F) { // BLUE (also SLOW FWD) handleButton_NEC(BTN_BLUE, BUTTONMODE_ONCE); } // other else if (results->value == 0x2FD38C7) { // DISPLAY handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE); } // else if (results->value == 0xA23DCD32) { // TV/DVD // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE); // } // else if (results->value == 0xA25DAF50) { // EJECT // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE); // } // else if (results->value == 0x22DDE11E) { // SUBTITLE // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE); // } // else if (results->value == 0x2FDF00F) { // INPUT // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE); // } // else if (results->value == 0x2FD9867) { // MENU/DVD // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE); // } // else if (results->value == 0x22DDFB04) { // MENU/TOP // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE); // } // else if (results->value == 0x22DDCA35) { // AUDIO SELECT // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE); // } // else if (results->value == 0xA25D02FD) { // CH.RTN/ZOOM // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE); // } // else if (results->value == 0x22DDBA45) { // RETURN (next to PLAY) // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE); // } // else if (results->value == 0xA25D37C8) { // MARKER // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE); // } // else if (results->value == 0x22DD6996) { // ANGLE // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE); // } // else if (results->value == 0x22DD3AC5) { // REPEAT A+B // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE); // } // else if (results->value == 0x22DDD926) { // JUMP // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE); // } // else if (results->value == 0x2FD9A65) { // PIC SIZE // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE); // } // 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 ;-) // // Pioneer 2238 code for BD ---- NOT UNUSED ANY MORE // if (lastNECcode == 0xD52A34CB && results->value == 0xF50AC639) { // LEFT // handleButton(BTN_LEFT, true); // } // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A26D9) { // RIGHT // handleButton(BTN_RIGHT, true); // } // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A4FB0) { // UP // handleButton(BTN_UP, true); // } // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50ACF30) { // DOWN // handleButton(BTN_DOWN, true); // } // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50AF708) { // ENTER + CLASS ENTER // handleButton(BTN_OK_ENTER, false); // } // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A3DC2) { // POWER // //handleButton(BTN_POWER, false); // handlePowerButton(); // } // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A2DD2) { // AUDIO PARAMETER - top left at control pad // //handleButton(BTN_, false); // } // else if (lastNECcode == 0xD52A54AB && results->value == 0xF50A3CC3) { // VIDEO PARAMETER - top right at control pad // //handleButton(BTN_, false); // } // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A0DF2) { // HOME MENU - bottom left at control pad // handleButton(BTN_MENU, false); // } // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A2FD0) { // RETURN - bottom right at control pad // handleButton(BTN_BACK, false); // } // else if (lastNECcode == 0xD52A54AB && results->value == 0xF50A26D9) { // RED // handleButton(BTN_RED, false); // } // else if (lastNECcode == 0xD52A54AB && results->value == 0xF50AA659) { // GREEN // handleButton(BTN_GREEN, false); // } // else if (lastNECcode == 0xD52A54AB && results->value == 0xF50A1FE0) { // YELLOW // handleButton(BTN_YELLOW, false); // } // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A9D62) { // BLUE // handleButton(BTN_BLUE, false); // } // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A57A8) { // REWIND // handleButton(BTN_REWD, true); // } // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A9768) { // FFWD // handleButton(BTN_FFWD, true); // } // else if (lastNECcode == 0xD52A44BB && results->value == 0xD52A44BB) { // PLAY // handleButton(BTN_PLAY, false); // } // else if (lastNECcode == 0xD52AE41B && results->value == 0xD52AE41B) { // PREVIOUS // handleButton(BTN_PREV, false); // } // else if (lastNECcode == 0xD52AC43B && results->value == 0xD52AC43B) { // PAUSE // handleButton(BTN_PAUSE, false); // } // else if (lastNECcode == 0xD52A04FB && results->value == 0xD52A04FB) { // STOP // handleButton(BTN_STOP, false); // } // else if (lastNECcode == 0xD52A649B && results->value == 0xD52A649B) { // NEXT TRACK // handleButton(BTN_NEXT, false); // } // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A05FA) { // 0 // handleButton(BTN_0, false); // } // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A857A) { // 1 // handleButton(BTN_1, false); // } // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A45BA) { // 2 // handleButton(BTN_2, false); // } // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50AC53A) { // 3 // handleButton(BTN_3, false); // } // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A25DA) { // 4 // handleButton(BTN_4, false); // } // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50AA55A) { // 5 // handleButton(BTN_5, false); // } // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A659A) { // 6 // handleButton(BTN_6, false); // } // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50AE51A) { // 7 // handleButton(BTN_7, false); // } // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A15EA) { // 8 // handleButton(BTN_8, false); // } // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A956A) { // 9 // handleButton(BTN_9, false); // } // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A7D82) { // AUDIO // //handleButton(BTN_POWER, false); // } // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50AC738) { // DISP/INFO // //handleButton(BTN_POWER, false); // } // else if (lastNECcode == 0xD52A54AB && results->value == 0xF50A7689) { // CH_UP // handleButton(BTN_CH_UP, false); // } // else if (lastNECcode == 0xD52A54AB && results->value == 0xF50AF609) { // CH_DOWN // handleButton(BTN_CH_DOWN, false); // } // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50AA758) { // ./CLR/D.ACCESS // //handleButton(BTN_POWER, false); // } // remember last NEC code - for PIONEER remotes sending 2 NEC codes as one PIONEER code //lastNECcode = results->value; else { // unknown / not implemented NEC code -> must reset last key or a repeat of this unknown key will trigger the last one handleButton_NEC(BTN_UNKNOWN, BUTTONMODE_REPEAT); } } // END NEC CODES // NEC repetitions (0 bits) // RC using NEC code send a 0 bit NEC code as repetition after the actual key press else if (results->decode_type == NEC && results->bits == 0) { if (debug) Serial.println(F("NEC REPETITION")); handleButton_NEC(BTN_REPETITION, BUTTONMODE_LAST); } } //+============================================================================= // The repeating section of the code // void loop ( ) { decode_results results; // Somewhere to store the results if (irrecv.decode(&results)) { // Grab an IR code dumpInfo(&results); // Output the results (if not in ignore time window) irrecv.resume(); // Prepare for the next value } handlePowerButton_loop(); handleTaskSwitchButton_loop(); handleHoldButtons_loop(); // release all keys after timeout }