Skip to content

Commit

Permalink
Added SIRCS decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
ArminJo committed Dec 16, 2022
1 parent 610a6bf commit e8fd732
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 34 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/LibraryBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
- arduino-boards-fqbn: ATTinyCore:avr:attinyx7micr:LTO=enable,sketchclock=16external,pinmapping=new,millis=enabled
platform-url: http://drazzy.com/package_drazzy.com_index.json
required-libraries: ATtinySerialOut
sketches-exclude: ReceiveAndSendDynamicPins # No Serial.available() function in ATtinySerialOut
sketches-exclude: AllProtocols,ReceiveAndSendDynamicPins # No Serial.available() function in ATtinySerialOut

- arduino-boards-fqbn: TinyCore:avr:tiny32
platform-url: https://raw.githubusercontent.com/xukangmin/TinyCore/master/avr/package/package_tinycore_index.json
Expand Down Expand Up @@ -141,7 +141,7 @@ jobs:
sketches-exclude: MinimalReceiver

# Do not cancel all jobs / architectures if one job fails
# fail-fast: false
fail-fast: false

steps:
- name: Checkout
Expand Down
48 changes: 24 additions & 24 deletions examples/AllProtocols/AllProtocols.ino
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ IRMP_DATA irmp_data;
#endif

#if defined(USE_SERIAL_LCD)
LiquidCrystal_I2C myLCD(0x27, LCD_COLUMNS, LCD_ROWS); // set the LCD address to 0x27 for a 20 chars and 2 line display
LiquidCrystal_I2C myLCD(0x27, LCD_COLUMNS, LCD_ROWS); // set the LCD address to 0x27 for a 16 chars and 2 line display
#endif
#if defined(USE_PARALLEL_LCD)
//LiquidCrystal myLCD(4, 5, 6, 7, 8, 9);
Expand All @@ -106,6 +106,7 @@ uint32_t volatile sMillisOfLastVoltagePrint;

void handleReceivedIRData();
void printIRResultOnLCD();
size_t printHex(uint16_t aHexByteValue);

bool volatile sIRMPDataAvailable = false;

Expand Down Expand Up @@ -144,6 +145,7 @@ void setup()
#endif

#if defined(USE_LCD)
myLCD.setCursor(0, 0);
myLCD.print(F("IRMP all v" VERSION_IRMP));
myLCD.setCursor(0, 1);
myLCD.print(F(__DATE__));
Expand Down Expand Up @@ -183,11 +185,10 @@ void loop()
sMillisOfLastVoltagePrint = millis();
uint16_t tVCC = getVCCVoltageMillivoltSimple();

myLCD.setCursor(10, 0);
myLCD.print(' ');
myLCD.print(tVCC / 1000);
myLCD.print('.');
myLCD.print(((tVCC + 5) / 10) % 100);
char tVoltageString[5];
dtostrf(tVCC / 1000.0, 4, 2, tVoltageString);
myLCD.setCursor(11, 0);
myLCD.print(tVoltageString);
myLCD.print('V');
}
#endif
Expand Down Expand Up @@ -277,15 +278,15 @@ void printIRResultOnLCD()
* Show address
*/
myLCD.setCursor(0, tStartRow + 1);
myLCD.print(F("A=0x"));
myLCD.print(irmp_data.address, HEX);
myLCD.print(F("A="));
printHex(irmp_data.address);

# if (LCD_COLUMNS > 16)
/*
* Print prefix of command here, since it is constant string
*/
myLCD.setCursor(9, tStartRow + 1);
myLCD.print(F("C=0x"));
myLCD.print(F("C="));
# endif
}
else
Expand Down Expand Up @@ -319,23 +320,18 @@ void printIRResultOnLCD()
if (tDisplayWasCleared || (sLastCommand > 0x100 && tCommand < 0x100) || (sLastCommand < 0x100 && tCommand > 0x100))
{
sLastCommand = tCommand;
/*
* Print prefix of command
*/
myLCD.setCursor(9, tStartRow + 1);

/*
* Print prefix for 8/16 bit commands
*/
if (tCommand >= 0x100)
{
myLCD.print(F("0x"));
sLastCommandPrintPosition = 11;
sLastCommandPrintPosition = 9;
}
else
{
myLCD.print(F("C=0x"));
sLastCommandPrintPosition = 13;
myLCD.setCursor(9, tStartRow + 1);
myLCD.print(F("C="));
sLastCommandPrintPosition = 11;
}
}
# endif
Expand All @@ -344,13 +340,17 @@ void printIRResultOnLCD()
* Command data
*/
myLCD.setCursor(sLastCommandPrintPosition, tStartRow + 1);
if (irmp_data.command < 0x10)
{
// leading 0
myLCD.print('0');
}
myLCD.print(tCommand, HEX);
printHex(tCommand);

#endif // defined(USE_LCD)
}

size_t printHex(uint16_t aHexByteValue) {
myLCD.print(F("0x"));
size_t tPrintSize = 2;
if (aHexByteValue < 0x10 || (aHexByteValue > 0x100 && aHexByteValue < 0x1000)) {
myLCD.print('0'); // leading 0
tPrintSize++;
}
return myLCD.print(aHexByteValue, HEX) + tPrintSize;
}
1 change: 1 addition & 0 deletions examples/SimpleReceiver/SimpleReceiver.ino
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@

//#include <irmpSelectMain15Protocols.h> // This enables 15 main protocols
#define IRMP_SUPPORT_NEC_PROTOCOL 1 // this enables only one protocol
//#define IRMP_SUPPORT_SIRCS_PROTOCOL 1 // this enables only one protocol

/*
* We use LED_BUILTIN as feedback for commands 0x40 and 0x48 and cannot use it as feedback LED for receiving
Expand Down
64 changes: 56 additions & 8 deletions src/LongUnion.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
*/

#if !defined(_WORD_UNION_H) || !defined(_LONG_UNION_H)
#if !defined(_WORD_UNION_H) || !defined(_LONG_UNION_H) || !defined(_LONG_LONG_UNION_H)

#include <stdint.h>

Expand Down Expand Up @@ -67,11 +67,17 @@ union LongUnion {
int8_t MidHighByte;
int8_t HighByte;
} Byte;
/* Does not work for STM32
struct {
uint8_t LowByte;
WordUnion MidWord;
uint16_t MidWord;
uint8_t HighByte;
} ByteWord;
} UByteWord;
*/
struct {
uint16_t LowWord;
uint16_t HighWord;
} UWord;
struct {
int16_t LowWord;
int16_t HighWord;
Expand All @@ -80,10 +86,6 @@ union LongUnion {
WordUnion LowWord;
WordUnion HighWord;
} WordUnion;
struct {
uint16_t LowWord;
uint16_t HighWord;
} UWord;
uint8_t UBytes[4]; // seems to have the same code size as using struct UByte
int8_t Bytes[4]; // Bytes[0] is LowByte
uint16_t UWords[2];
Expand All @@ -93,4 +95,50 @@ union LongUnion {
};
#endif // _LONG_UNION_H

#endif // !defined(_WORD_UNION_H) || !defined(_LONG_UNION_H)
#ifndef _LONG_LONG_UNION_H
#define _LONG_LONG_UNION_H
/**
* Union to specify parts / manifestations of a 64 bit LongLong without casts and shifts.
* It also supports the compiler generating small code.
*/
union LongLongUnion {
struct {
uint16_t LowWord;
uint16_t MidLowWord;
uint16_t MidHighWord;
uint16_t HighWord;
} UWord;
struct {
int16_t LowWord;
int16_t MidLowWord;
int16_t MidHighWord;
int16_t HighWord;
} Word;
struct {
WordUnion LowWord;
WordUnion MidLowWord;
WordUnion MidHighWord;
WordUnion HighWord;
} WordUnion;
struct {
uint32_t LowLong;
uint32_t HighLong;
} ULong;
struct {
int32_t LowLong;
int32_t HighLong;
} Long;
struct {
LongUnion LowLong;
LongUnion HighLong;
} LongUnion;
uint8_t UBytes[8]; // seems to have the same code size as using struct UByte
int8_t Bytes[8];
uint16_t UWords[4];
int16_t Words[4];
uint64_t ULongLong;
int64_t LongLong;
};
#endif // _LONG_LONG_UNION_H

#endif // !defined(_WORD_UNION_H) || !defined(_LONG_UNION_H) || !defined(_LONG_LONG_UNION_H)
6 changes: 6 additions & 0 deletions src/digitalWriteFast.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@
#define __digitalPinToPINReg(P) ((P) <= 5 ? &VPORTB.IN : ((P) <= 9 ? &VPORTC.IN : ((P) <= 16 ? &VPORTA.IN : ((P) <= 18 ? &VPORTB.IN : &VPORTC.IN))))
#define __digitalPinToBit(P) ( (P) <= 3 ? (3 - P) : ((P) <= 5 ? (P) : ((P) <= 9 ? (P - 6) : ((P) <= 16 ? ((P) - 9) : ((P) <= 18 ? ((P) - 11) : ((P) - 15))))) )

#elif defined(__AVR_ATtiny1614__)
#define __digitalPinToPortReg(P) ((P) <= 3 ? &VPORTA.OUT : ((P) <= 7 ? &VPORTB.OUT : &VPORTA.OUT))
#define __digitalPinToDDRReg(P) ((P) <= 3 ? &VPORTA.DIR : ((P) <= 7 ? &VPORTB.DIR : &VPORTA.DIR))
#define __digitalPinToPINReg(P) ((P) <= 3 ? &VPORTA.IN : ((P) <= 7 ? &VPORTB.IN : &VPORTA.IN))
#define __digitalPinToBit(P) ( (P) <= 3 ? (P + 4) : ((P) <= 7 ? (7 - P) : ((P) <= 10 ? (P - 7) : (P) - 11)) )

#elif defined(__AVR_ATtiny816__)
// https://github.com/Arduino-IRremote/Arduino-IRremote/discussions/1029
#define __digitalPinToPortReg(P) ((P) <= 3 ? &VPORTA.OUT : ((P) <= 9 ? &VPORTB.OUT : ((P) <= 13 ? &VPORTC.OUT : ((P) <= 17 ? &VPORTA.OUT : &VPORTC.OUT))))
Expand Down
16 changes: 16 additions & 0 deletions src/irmp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2499,6 +2499,22 @@ irmp_get_data (IRMP_DATA * irmp_data_p)
# endif
#endif

#if IRMP_SUPPORT_SIRCS_PROTOCOL == 1
case IRMP_SIRCS_PROTOCOL:
// Concatenate high byte of command and low byte of address
irmp_address <<= 7;
irmp_address = irmp_address | irmp_command >> 8;
// Command is 7 bytes, so add the 8.th bit of command to address
irmp_address <<= 1;
if ((irmp_command & 0x80))
{
irmp_address++;
}
irmp_command &= 0x7F;
tReturnCode = TRUE;
break;
#endif

#if IRMP_SUPPORT_NEC_PROTOCOL == 1
case IRMP_NEC_PROTOCOL:
if ((irmp_command >> 8) == (~irmp_command & 0x00FF))
Expand Down

0 comments on commit e8fd732

Please sign in to comment.