Skip to content

Commit

Permalink
Improved printIRSendUsage()
Browse files Browse the repository at this point in the history
  • Loading branch information
Armin committed Feb 15, 2024
1 parent 2c2be06 commit ef69840
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ Send with: IrSender.sendLG(0x2, 0x3434, <numberOfRepeats>);
You will discover that **the address is a constant** and the commands sometimes are sensibly grouped.<br/>
If you are uncertain about the numbers of repeats to use for sending, **3** is a good starting point. If this works, you can check lower values afterwards.

If you have enabled `DECODE_DISTANCE_WIDTH`, the code printed by `printIRSendUsage()` **differs between 8 and 32 bit platforms**, so it is best to run the receiving program on the same platform as the sending program.

The codes found in the [irdb database](https://github.com/probonopd/irdb/tree/master/codes) specify a **device**, a **subdevice** and a **function**. Most of the times, *device* and *subdevice* can be taken as upper and lower byte of the **address parameter** and *function* is the **command parameter** for the **new structured functions** with address, command and repeat-count parameters like e.g. `IrSender.sendNEC((device << 8) | subdevice, 0x19, 2)`.<br/>
An **exact mapping** can be found in the [IRP definition files for IR protocols](https://github.com/probonopd/MakeHex/tree/master/protocols). "D" and "S" denotes device and subdevice and "F" denotes the function.

Expand Down
9 changes: 8 additions & 1 deletion src/IRReceive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1243,22 +1243,24 @@ uint32_t IRrecv::getTotalDurationOfRawData() {
/**
* Function to print values and flags of IrReceiver.decodedIRData in one line.
* Ends with println().
* !!!Attention: The result differs on a 8 bit or 32 bit platform!!!
*
* @param aSerial The Print object on which to write, for Arduino you can use &Serial.
*/
void IRrecv::printIRSendUsage(Print *aSerial) {
if (decodedIRData.protocol != UNKNOWN
&& (decodedIRData.flags & (IRDATA_FLAGS_IS_AUTO_REPEAT | IRDATA_FLAGS_IS_REPEAT)) == 0x00) {
#if defined(DECODE_DISTANCE_WIDTH)
aSerial->print(F("Send with:"));
uint_fast8_t tNumberOfArrayData = 0;
if (decodedIRData.protocol == PULSE_DISTANCE || decodedIRData.protocol == PULSE_WIDTH) {
# if __INT_WIDTH__ < 32
aSerial->print(F("Send on a 8 bit platform with:"));
tNumberOfArrayData = ((decodedIRData.numberOfBits - 1) / 32) + 1;
if(tNumberOfArrayData > 1) {
aSerial->println();
aSerial->print(F(" uint32_t tRawData[]={0x"));
# else
aSerial->print(F("Send on a 32 bit platform with:"));
tNumberOfArrayData = ((decodedIRData.numberOfBits - 1) / 64) + 1;
if(tNumberOfArrayData > 1) {
aSerial->println();
Expand Down Expand Up @@ -1358,6 +1360,11 @@ void IRrecv::printIRSendUsage(Print *aSerial) {
aSerial->print(F(");"));
aSerial->println();
}
#if defined(DECODE_DISTANCE_WIDTH)
else {
aSerial->print(F("Send with:"));
}
#endif
}

/**
Expand Down

0 comments on commit ef69840

Please sign in to comment.