Skip to content

Commit

Permalink
Improve the HelloSIRC example and others
Browse files Browse the repository at this point in the history
HelloSIRC was not showing ext data;
Other examples needed some changes in the comments.
  • Loading branch information
LuisMiCa committed Jan 10, 2022
1 parent 0139b08 commit 95ec292
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions examples/HelloNEC/HelloNEC.ino
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/

#define IR_SMALLD_NEC //1st: define which protocol to use and then,
//#define IR_SMALLD_NECx
#include <IRsmallDecoder.h> //2nd: include the library;
IRsmallDecoder irDecoder(2); //3rd: create one decoder object with the correct digital pin;
irSmallD_t irData; //4th: declare one decoder data structure;
Expand Down
18 changes: 12 additions & 6 deletions examples/HelloSIRC/HelloSIRC.ino
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
/* A simple example, using the IRsmallDecoder library,
* for testing remote controls that use the Sony SIRC protocol.
*
* Note: this example uses an advanced implementation of the SIRC decoder which
*
* This example uses an advanced implementation of the SIRC decoder which
* takes advantage of the fact that most SIRC remotes will send three signal frames
* every time one key is pressed. That allows the decoder to:
* - identify the number of bits of the protocol;
* - identify the number of bits of the protocol (12, 15 or 20);
* - ignore the two additional repetitions;
* - use the repetitions to check for errors;
* - determine if a key is being held.
*
* If the decoder detects 12 or 15 bits, the ext data member is set to 0.
* If it detects a 20-bit code, it will save the extended data in the ext member.
*
* In this example it's assumed that the IR sensor is connected to digital pin 2 and
* the pin is usable for external interrupts.
*
Expand All @@ -25,15 +29,17 @@ irSmallD_t irData; //4th: declare one decoder data structure;
void setup() {
Serial.begin(250000);
Serial.println("Waiting for a SIRC remote control IR signal...");
Serial.println("held\t addr\t cmd");
Serial.println("held\taddr\tcmd \tExt");
}

void loop() {
if (irDecoder.dataAvailable(irData)) { //5th: if the decoder has some new data available,
Serial.print(irData.keyHeld, HEX); //6th: do something with the data.
Serial.print("\t ");
Serial.print(" \t");
Serial.print(irData.addr, HEX);
Serial.print("\t ");
Serial.println(irData.cmd, HEX);
Serial.print(" \t");
Serial.print(irData.cmd, HEX);
Serial.print(" \t");
Serial.println(irData.ext, HEX);
}
}
4 changes: 2 additions & 2 deletions examples/SingleHold/SingleHold.ino
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
* - Hold the selected keys to turn on/off the built-in LED.
* If you keep holding, it won't do anything else.
*
* In this example it's assumed that the IR sensor is connected to digital pin 2 and
* the pin is usable for external interrupts.
* In this example it's assumed that the board has a builtin LED and the IR sensor is
* connected to digital pin 2, which must be usable for external interrupts.
*
* For more information on the boards' usable pins, see the library documentation at:
* https://github.com/LuisMiCa/IRsmallDecoder
Expand Down

0 comments on commit 95ec292

Please sign in to comment.