diff --git a/BITsIRReciver.h b/BITsIRReciver.h index 923f4cac042e415650828b32246be7e89af13020..d840c44ef911d5d024cb130ca66ce97d07f70b1f 100644 --- a/BITsIRReciver.h +++ b/BITsIRReciver.h @@ -1,67 +1,59 @@ -#ifndef BITSIIRRECIVER_H -#define BITSIIRRECIVER_H +#ifndef BITSIRRECIVER_H +#define BITSIRRECIVER_H + +/* ****************************************** * + * IR Remote * + * * + * Button | Signal Kodierung * + * ------------------------------------------ * + * Power Button | 69 * + * VOL+ Button | 70 * + * Func Button | 71 * + * Rewind Button | 68 * + * Play/Pause Button | 64 * + * Forward Button | 67 * + * Down Button | 7 * + * VOL- Button | 21 * + * UP Button | 9 * + * 0 Button | 22 * + * EQ Button | 25 * + * ST/REPT Button | 13 * + * 1 Button | 12 * + * 2 Button | 24 * + * 3 Button | 94 * + * 4 Button | 8 * + * 5 Button | 28 * + * 6 Button | 90 * + * 7 Button | 66 * + * 8 Button | 82 * + * 9 Button | 74 * + * ****************************************** */ -/* ***************************************************** * - * IR Remote * - * * - * Button | Signal Kodierung | Index * - * ----------------------------------------------------- * - * Power Button | 69 | 0 * - * VOL+ Button | 70 | 1 * - * Func Button | 71 | 2 * - * Rewind Button | 68 | 3 * - * Play/Pause Button | 64 | 4 * - * Forward Button | 67 | 5 * - * Down Button | 7 | 6 * - * VOL- Button | 21 | 7 * - * UP Button | 9 | 8 * - * 0 Button | 22 | 9 * - * EQ Button | 25 | 10 * - * ST/REPT Button | 13 | 11 * - * 1 Button | 12 | 12 * - * 2 Button | 24 | 13 * - * 3 Button | 94 | 14 * - * 4 Button | 8 | 15 * - * 5 Button | 28 | 16 * - * 6 Button | 90 | 17 * - * 7 Button | 66 | 18 * - * 8 Button | 82 | 19 * - * 9 Button | 74 | 20 * - * ***************************************************** */ #include <IRremote.h> -// #define IR_USE_AVR_TIMER3 -const int irReceiverPin = 46; -IRrecv irrecv(irReceiverPin); +const int IR_PIN = 46; +IRrecv ir_reciver(IR_PIN); decode_results results; -// Liste von oben nach unten sortiert -int commandlist[22] = {0, 69, 70, 71, 68, 64, 67, 7, 21, 9, 22, 25, 13, 12, 24, 94, 8, 28, 90, 66, 82, 74}; +class BitsIrReciver +{ +public: + void begin() + { + ir_reciver.enableIRIn(); + }; -class BITsIRReciver{ - public: - void init(){ - irrecv.enableIRIn(); - }; + int recieve_command() + { + if (ir_reciver.decode()) + { + ir_command = ir_reciver.decodedIRData.command; + ir_reciver.resume(); + return ir_command; + } + }; - int ir_recv(){ - //if the ir receiver module receiver data - if (irrecv.decode()) - { - ir_command = irrecv.decodedIRData.command; - // Receive the next value - irrecv.resume(); - for (int i=0; i<22; i++) { - if (ir_command == commandlist[i]) { - ir_command_pos = i; - break; - } - } - return ir_command_pos; - } - }; - private: - int ir_command; - int ir_command_pos; +private: + int ir_command; }; #endif \ No newline at end of file diff --git a/README.md b/README.md index 7d6b72fc446699dfdf903c46746f075f8dd2344a..b1c9db9ce08725b261c2c3874fc76d17ecdc6e3e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,46 @@ # **BITs IR Empfänger** +Mit dieser Klasse werden die Empfangenen Befehle von einer Infrarot Fernbedienung zurück gegeben. +Sie dient als erleichterte Bedienung der IRRemote.h Bibliothek. + +|**Button** | **Signal Kodierung** | |**Button** | **Signal Kodierung** | +|:---|:---:|:---|:---:|:---:| +|Power Button | 69 | | 0 Button | 22 | +|VOL+ Button | 70 | |1 Button | 12 | +|Func Button | 71 | |2 Button | 24 | +|Rewind Button | 68 | |3 Button | 94 | +|Play/Pause Button | 64 | |4 Button | 8 | +|Forward Button | 67 | |5 Button | 28 | +|Down Button | 7 | |6 Button | 90 | +|VOL- Button | 21 | |7 Button | 66 | +|UP Button | 9 | |8 Button | 82 | +|EQ Button | 25 | |9 Button | 74 | +|ST/REPT Button | 13 | | | | + +## **Voraussetzung** + +- Die angepasste IRRemote Bibliothek in der **customized_library.zip** muss in das Libraries-Verzeichnis der Arduino-IDE kopiert werden. + +## ** Installation** + +- Um diese Klasse verwenden zu können, muss dieses Repository geklont und in das Libraries-Verzeichnis der Arduino-IDE kopiert werden. + +## **Anwendung** + +Zur Verwendung siehe zunächst das Beispiel `IRReciver.ino` + +**Einbinden der Bibliothek:** + +`#include <BITsIRReciver.h>` + +**Instanziieren:** + +`BitsIrReciver ir_sensor;` + +**Aufruden der Methoden:** +- Um den IR-Empfänger zu initialisieren wird folgende Methode im `void setup()` ausgeführt: `ir_sensor.begin()` +- Für das Empfangen der Signale wird folgende Methode verwendet: `ir_sensor.recieve_command()` + + diff --git a/customized_library.zip b/customized_library.zip new file mode 100644 index 0000000000000000000000000000000000000000..4e4f6c71a0e4a8935ddd63360db5e609b68473a6 Binary files /dev/null and b/customized_library.zip differ diff --git a/examples/IRReciver/IRReciver.ino b/examples/IRReciver/IRReciver.ino index 95994cefbf3f36536b091601ee7f1d18f842861b..9a2a80efad2e8f8842199e497ef744736efe6f19 100644 --- a/examples/IRReciver/IRReciver.ino +++ b/examples/IRReciver/IRReciver.ino @@ -1,16 +1,16 @@ #include "BITsIRReciver.h" -BITsIRReciver bIRrec; -int command_index; +BitsIrReciver ir_sensor; +int command; void setup(){ Serial.begin(115200); - bIRrec.init(); + ir_sensor.begin(); } void loop(){ - command_index = bIRrec.ir_recv(); - Serial.println(command_index); + command = ir_sensor.recieve_command(); + Serial.println(command); }