Improved printIRSendUsage()

This commit is contained in:
Armin 2024-02-15 18:50:02 +01:00
parent 2c2be06431
commit ef69840a5f
2 changed files with 10 additions and 1 deletions

View File

@ -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.

View File

@ -1243,6 +1243,7 @@ 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.
*/
@ -1250,15 +1251,16 @@ 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();
@ -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
}
/**