Go to the documentation of this file.
32 #ifndef _IR_SAMSUNG_HPP
33 #define _IR_SAMSUNG_HPP
35 #if defined(DEBUG) && !defined(LOCAL_DEBUG)
85 #define SAMSUNG_ADDRESS_BITS 16
86 #define SAMSUNG_COMMAND16_BITS 16
87 #define SAMSUNG_COMMAND32_BITS 32
88 #define SAMSUNG_BITS (SAMSUNG_ADDRESS_BITS + SAMSUNG_COMMAND16_BITS)
89 #define SAMSUNG48_BITS (SAMSUNG_ADDRESS_BITS + SAMSUNG_COMMAND32_BITS)
92 #define SAMSUNG_UNIT 560 // 21.28 periods of 38 kHz, 11.2 ticks TICKS_LOW = 8.358 TICKS_HIGH = 15.0
93 #define SAMSUNG_HEADER_MARK (8 * SAMSUNG_UNIT) // 4500 | 180 periods
94 #define SAMSUNG_HEADER_SPACE (8 * SAMSUNG_UNIT) // 4500
95 #define SAMSUNG_BIT_MARK SAMSUNG_UNIT
96 #define SAMSUNG_ONE_SPACE (3 * SAMSUNG_UNIT) // 1690 | 33.8 TICKS_LOW = 25.07 TICKS_HIGH = 45.0
97 #define SAMSUNG_ZERO_SPACE SAMSUNG_UNIT
99 #define SAMSUNG_AVERAGE_DURATION 55000 // SAMSUNG_HEADER_MARK + SAMSUNG_HEADER_SPACE + 32 * 2,5 * SAMSUNG_UNIT + SAMSUNG_UNIT // 2.5 because we assume more zeros than ones
100 #define SAMSUNG_REPEAT_DURATION (SAMSUNG_HEADER_MARK + SAMSUNG_HEADER_SPACE + SAMSUNG_BIT_MARK + SAMSUNG_ZERO_SPACE + SAMSUNG_BIT_MARK)
101 #define SAMSUNG_REPEAT_PERIOD 110000 // Commands are repeated every 110 ms (measured from start to start) for as long as the key on the remote control is held down.
102 #define SAMSUNG_MAXIMUM_REPEAT_DISTANCE (SAMSUNG_REPEAT_PERIOD + (SAMSUNG_REPEAT_PERIOD / 4)) // 137000 - Just a guess
174 if (aAddress < 0x100) {
178 tSendValue.
UBytes[1] = aAddress;
179 tSendValue.
UBytes[0] = aAddress;
181 tSendValue.
UWords[0] = aAddress;
206 tSendValue.
UWords[0] = aAddress;
223 tSendValue.
UWords[0] = aAddress;
236 #if __INT_WIDTH__ < 32
237 uint32_t tRawSamsungData[2];
240 tSendValue.
UWords[0] = aAddress;
243 uint8_t tUpper8BitsOfCommand =
aCommand >> 8;
244 tRawSamsungData[1] = tUpper8BitsOfCommand | (~tUpper8BitsOfCommand) << 8;
245 tRawSamsungData[0] = tSendValue.
ULong;
250 tSendValue.
UWords[0] = aAddress;
254 uint8_t tUpper8BitsOfCommand =
aCommand >> 8;
255 tSendValue.
UBytes[4] = tUpper8BitsOfCommand;
256 tSendValue.
UBytes[5] = ~tUpper8BitsOfCommand;
298 #if defined(LOCAL_DEBUG)
299 Serial.print(F(
"Samsung: "));
300 Serial.println(F(
"Decode failed"));
315 #if defined(LOCAL_DEBUG)
316 Serial.print(F(
"Samsung: "));
317 Serial.println(F(
"Decode failed"));
327 #if __INT_WIDTH__ >= 32
369 unsigned int offset = 1;
381 aResults->
value = 0xFFFFFFFF;
426 #if defined(LOCAL_DEBUG)
429 #endif // _IR_SAMSUNG_HPP
uint16_t address
Decoded address, Distance protocol (tMarkTicksLong (if tMarkTicksLong == 0, then tMarkTicksShort) << ...
#define MICROS_PER_TICK
microseconds per clock interrupt tick
Union to specify parts / manifestations of a 32 bit Long without casts and shifts.
#define SAMSUNG_HEADER_SPACE
Results returned from old decoders !!!deprecated!!!
void sendSamsungMSB(unsigned long data, int nbits)
#define PROTOCOL_IS_MSB_FIRST
uint16_t numberOfBits
Number of bits received for data (address + command + parity) - to determine protocol length if diffe...
void int_fast8_t aNumberOfRepeats
#define MICROS_IN_ONE_MILLI
struct LongUnion::@4 UByte
struct PulseDistanceWidthProtocolConstants SamsungProtocolConstants
void mark(uint16_t aMarkMicros)
Sends an IR mark for the specified number of microseconds.
void sendSamsungLGRepeat()
Send repeat Repeat commands should be sent in a 110 ms raster.
void sendSamsung48(uint16_t aAddress, uint32_t aCommand, int_fast8_t aNumberOfRepeats)
Here we send Samsung48 We send 2 x (8 bit command and then ~command)
#define IRDATA_FLAGS_IS_REPEAT
The gap between the preceding frame is as smaller than the maximum gap expected for a repeat....
void sendPulseDistanceWidth(PulseDistanceWidthProtocolConstants *aProtocolConstants, IRRawDataType aData, uint_fast8_t aNumberOfBits, int_fast8_t aNumberOfRepeats)
Sends PulseDistance frames and repeats.
decode_type_t decode_type
IRRawDataType decodedRawData
Up to 32/64 bit decoded raw data, to be used for send functions.
void checkForRepeatSpaceTicksAndSetFlag(uint16_t aMaximumRepeatSpaceTicks)
#define IR_DEBUG_PRINT(...)
If DEBUG, print the arguments, otherwise do nothing.
bool matchSpace(uint16_t aMeasuredTicks, uint16_t aMatchValueMicros)
Compensate for spaces shortened by demodulator hardware.
Union to specify parts / manifestations of a 64 bit LongLong without casts and shifts.
void sendSamsung(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats)
Here we send Samsung32 If we get a command < 0x100, we send command and then ~command If we get an ad...
#define IRDATA_FLAGS_PARITY_FAILED
The current (autorepeat) frame violated parity check.
bool decodeSAMSUNG(decode_results *aResults)
void sendSamsung16BitAddressAndCommand(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats)
Maybe no one needs it in the wild...
uint8_t flags
IRDATA_FLAGS_IS_REPEAT, IRDATA_FLAGS_WAS_OVERFLOW etc. See IRDATA_FLAGS_* definitions above.
void sendSamsungLG(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats)
#define PROTOCOL_IS_LSB_FIRST
#define IRDATA_FLAGS_IS_PROTOCOL_WITH_DIFFERENT_REPEAT
Here we have a repeat of type NEC2 or SamsungLG.
void sendSamsungLGSpecialRepeat()
Like above, but implemented as a static function Used for sending special repeat frame.
bool checkHeader(PulseDistanceWidthProtocolConstants *aProtocolConstants)
bool decodePulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, uint_fast8_t aNumberOfBits, IRRawlenType aStartOffset=3)
Decode pulse distance protocols for PulseDistanceWidthProtocolConstants.
uint16_t command
Decoded command, Distance protocol (tMarkTicksShort << 8) | tSpaceTicksShort.
#define SAMSUNG_MAXIMUM_REPEAT_DISTANCE
#define SAMSUNG_COMMAND16_BITS
#define SAMSUNG_ZERO_SPACE
bool matchMark(uint16_t aMeasuredTicks, uint16_t aMatchValueMicros)
Compensate for marks exceeded by demodulator hardware.
void sendSamsung16BitAddressAnd8BitCommand(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats)
Maybe no one needs it in the wild...
uint32_t lastDecodedCommand
#define IRDATA_FLAGS_IS_LSB_FIRST
#define SAMSUNG_REPEAT_PERIOD
#define SAMSUNG_HEADER_MARK
static void space(uint16_t aSpaceMicros)
Sends an IR space for the specified number of microseconds.
#define SAMSUNG_COMMAND32_BITS
#define SAMSUNG_ONE_SPACE
IRRawlenType rawlen
counter of entries in rawbuf of last received frame.
void sendSAMSUNG(unsigned long data, int nbits)
struct LongUnion::@6 UWord
void sendPulseDistanceWidthFromArray(uint_fast8_t aFrequencyKHz, uint16_t aHeaderMarkMicros, uint16_t aHeaderSpaceMicros, uint16_t aOneMarkMicros, uint16_t aOneSpaceMicros, uint16_t aZeroMarkMicros, uint16_t aZeroSpaceMicros, IRRawDataType *aDecodedRawDataArray, uint16_t aNumberOfBits, uint8_t aFlags, uint16_t aRepeatPeriodMillis, int_fast8_t aNumberOfRepeats)
struct PulseDistanceWidthProtocolConstants SamsungLGProtocolConstants
void sendPulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, IRRawDataType aData, uint_fast8_t aNumberOfBits)
Sends PulseDistance from data contained in parameter using ProtocolConstants structure for timing etc...
uint32_t lastDecodedAddress
#define IR_DEBUG_PRINTLN(...)
If DEBUG, print the arguments as a line, otherwise do nothing.
decode_type_t protocol
UNKNOWN, NEC, SONY, RC5, PULSE_DISTANCE, ...
void enableIROut(uint_fast8_t aFrequencyKHz)
Enables IR output.