IRremote
ir_Samsung.cpp
Go to the documentation of this file.
1 #include "IRremote.h"
2 
3 //==============================================================================
4 // SSSS AAA MMM SSSS U U N N GGGG
5 // S A A M M M S U U NN N G
6 // SSS AAAAA M M M SSS U U N N N G GG
7 // S A A M M S U U N NN G G
8 // SSSS A A M M SSSS UUU N N GGG
9 //==============================================================================
10 
11 #define SAMSUNG_BITS 32
12 #define SAMSUNG_HDR_MARK 5000
13 #define SAMSUNG_HDR_SPACE 5000
14 #define SAMSUNG_BIT_MARK 560
15 #define SAMSUNG_ONE_SPACE 1600
16 #define SAMSUNG_ZERO_SPACE 560
17 #define SAMSUNG_RPT_SPACE 2250
18 
19 //+=============================================================================
20 #if SEND_SAMSUNG
21 void IRsend::sendSAMSUNG(unsigned long data, int nbits) {
22  // Set IR carrier frequency
23  enableIROut(38);
24 
25  // Header
28 
29  // Data
30  for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) {
31  if (data & mask) {
34  } else {
37  }
38  }
39 
40  // Footer
42  space(0); // Always end with the LED off
43 }
44 #endif
45 
46 //+=============================================================================
47 // SAMSUNGs have a repeat only 4 items long
48 //
49 #if DECODE_SAMSUNG
50 bool IRrecv::decodeSAMSUNG(decode_results *results) {
51  long data = 0;
52  int offset = 1; // Skip first space
53 
54  // Initial mark
55  if (!MATCH_MARK(results->rawbuf[offset], SAMSUNG_HDR_MARK)) {
56  return false;
57  }
58  offset++;
59 
60 // Check for repeat
61  if ((irparams.rawlen == 4) && MATCH_SPACE(results->rawbuf[offset], SAMSUNG_RPT_SPACE)
62  && MATCH_MARK(results->rawbuf[offset + 1], SAMSUNG_BIT_MARK)) {
63  results->bits = 0;
64  results->value = REPEAT;
65  results->decode_type = SAMSUNG;
66  return true;
67  }
68  if (irparams.rawlen < (2 * SAMSUNG_BITS) + 4) {
69  return false;
70  }
71 
72 // Initial space
73  if (!MATCH_SPACE(results->rawbuf[offset], SAMSUNG_HDR_SPACE)) {
74  return false;
75  }
76  offset++;
77 
78  for (int i = 0; i < SAMSUNG_BITS; i++) {
79  if (!MATCH_MARK(results->rawbuf[offset], SAMSUNG_BIT_MARK)) {
80  return false;
81  }
82  offset++;
83 
84  if (MATCH_SPACE(results->rawbuf[offset], SAMSUNG_ONE_SPACE)) {
85  data = (data << 1) | 1;
86  } else if (MATCH_SPACE(results->rawbuf[offset], SAMSUNG_ZERO_SPACE)) {
87  data = (data << 1) | 0;
88  } else {
89  return false;
90  }
91  offset++;
92  }
93 
94 // Success
95  results->bits = SAMSUNG_BITS;
96  results->value = data;
97  results->decode_type = SAMSUNG;
98  return true;
99 }
100 #endif
101 
SAMSUNG_RPT_SPACE
#define SAMSUNG_RPT_SPACE
Definition: ir_Samsung.cpp:17
SAMSUNG_BITS
#define SAMSUNG_BITS
Definition: ir_Samsung.cpp:11
SAMSUNG_ZERO_SPACE
#define SAMSUNG_ZERO_SPACE
Definition: ir_Samsung.cpp:16
decode_results
Results returned from the decoder.
Definition: IRremote.h:174
SAMSUNG_HDR_MARK
#define SAMSUNG_HDR_MARK
Definition: ir_Samsung.cpp:12
decode_results::bits
int bits
Number of bits in decoded value.
Definition: IRremote.h:179
decode_results::rawbuf
volatile unsigned int * rawbuf
Raw intervals in 50uS ticks.
Definition: IRremote.h:180
SAMSUNG_HDR_SPACE
#define SAMSUNG_HDR_SPACE
Definition: ir_Samsung.cpp:13
IRsend::mark
void mark(unsigned int usec)
Definition: irSend.cpp:69
IRsend::enableIROut
void enableIROut(int khz)
Definition: irSend.cpp:127
decode_results::decode_type
decode_type_t decode_type
UNKNOWN, NEC, SONY, RC5, ...
Definition: IRremote.h:176
SAMSUNG
@ SAMSUNG
Definition: IRremote.h:121
MATCH_SPACE
int MATCH_SPACE(int measured_ticks, int desired_us)
Definition: IRremote.cpp:89
irparams
volatile irparams_t irparams
Allow all parts of the code access to the ISR data NB.
IRremote.h
Public API to the library.
IRsend::space
void space(unsigned int usec)
Definition: irSend.cpp:103
REPEAT
#define REPEAT
Decoded value for NEC when a repeat code is received.
Definition: IRremote.h:188
SAMSUNG_ONE_SPACE
#define SAMSUNG_ONE_SPACE
Definition: ir_Samsung.cpp:15
decode_results::value
unsigned long value
Decoded value [max 32-bits].
Definition: IRremote.h:178
MATCH_MARK
int MATCH_MARK(int measured_ticks, int desired_us)
Definition: IRremote.cpp:63
IRsend::sendSAMSUNG
void sendSAMSUNG(unsigned long data, int nbits)
Definition: ir_Samsung.cpp:21
irparams_t::rawlen
unsigned int rawlen
counter of entries in rawbuf
Definition: IRremoteInt.h:45
SAMSUNG_BIT_MARK
#define SAMSUNG_BIT_MARK
Definition: ir_Samsung.cpp:14