Go to the documentation of this file.
32 #ifndef _IR_SAMSUNG_HPP
33 #define _IR_SAMSUNG_HPP
35 #if defined(DEBUG) && !defined(LOCAL_DEBUG)
83 #define SAMSUNG_ADDRESS_BITS 16
84 #define SAMSUNG_COMMAND16_BITS 16
85 #define SAMSUNG_COMMAND32_BITS 32
86 #define SAMSUNG_BITS (SAMSUNG_ADDRESS_BITS + SAMSUNG_COMMAND16_BITS)
87 #define SAMSUNG48_BITS (SAMSUNG_ADDRESS_BITS + SAMSUNG_COMMAND32_BITS)
90 #define SAMSUNG_UNIT 560 // 21.28 periods of 38 kHz, 11.2 ticks TICKS_LOW = 8.358 TICKS_HIGH = 15.0
91 #define SAMSUNG_HEADER_MARK (8 * SAMSUNG_UNIT) // 4500 | 180 periods
92 #define SAMSUNG_HEADER_SPACE (8 * SAMSUNG_UNIT) // 4500
93 #define SAMSUNG_BIT_MARK SAMSUNG_UNIT
94 #define SAMSUNG_ONE_SPACE (3 * SAMSUNG_UNIT) // 1690 | 33.8 TICKS_LOW = 25.07 TICKS_HIGH = 45.0
95 #define SAMSUNG_ZERO_SPACE SAMSUNG_UNIT
97 #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
98 #define SAMSUNG_REPEAT_DURATION (SAMSUNG_HEADER_MARK + SAMSUNG_HEADER_SPACE + SAMSUNG_BIT_MARK + SAMSUNG_ZERO_SPACE + SAMSUNG_BIT_MARK)
99 #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.
100 #define SAMSUNG_MAXIMUM_REPEAT_DISTANCE (SAMSUNG_REPEAT_PERIOD + (SAMSUNG_REPEAT_PERIOD / 4)) // 137000 - Just a guess
170 if (aAddress < 0x100) {
174 tSendValue.
UBytes[1] = aAddress;
175 tSendValue.
UBytes[0] = aAddress;
177 tSendValue.
UWords[0] = aAddress;
202 tSendValue.
UWords[0] = aAddress;
216 #if __INT_WIDTH__ < 32
217 uint32_t tRawSamsungData[2];
220 tSendValue.
UWords[0] = aAddress;
223 uint8_t tUpper8BitsOfCommand =
aCommand >> 8;
224 tRawSamsungData[1] = tUpper8BitsOfCommand | (~tUpper8BitsOfCommand) << 8;
225 tRawSamsungData[0] = tSendValue.
ULong;
230 tSendValue.
UWords[0] = aAddress;
234 uint8_t tUpper8BitsOfCommand =
aCommand >> 8;
235 tSendValue.
UBytes[4] = tUpper8BitsOfCommand;
236 tSendValue.
UBytes[5] = ~tUpper8BitsOfCommand;
273 #if defined(LOCAL_DEBUG)
274 Serial.print(F(
"Samsung: "));
275 Serial.println(F(
"Decode failed"));
290 #if defined(LOCAL_DEBUG)
291 Serial.print(F(
"Samsung: "));
292 Serial.println(F(
"Decode failed"));
302 #if __INT_WIDTH__ >= 32
344 unsigned int offset = 1;
356 aResults->
value = 0xFFFFFFFF;
399 #if defined(LOCAL_DEBUG)
402 #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!!!
#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.
uint_fast8_t rawlen
counter of entries in rawbuf
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 and enables receiver again.
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.
bool decodePulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, uint_fast8_t aNumberOfBits, uint_fast8_t aStartOffset=3)
Decode pulse distance protocols for PulseDistanceWidthProtocolConstants.
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)
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.
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
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 data The output always ends with a space Each additional call costs 16 bytes prog...
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.