IRremote
ir_Whynter.cpp
Go to the documentation of this file.
1 #include "IRremote.h"
2 
3 //==============================================================================
4 // W W H H Y Y N N TTTTT EEEEE RRRRR
5 // W W H H Y Y NN N T E R R
6 // W W W HHHHH Y N N N T EEE RRRR
7 // W W W H H Y N NN T E R R
8 // WWW H H Y N N T EEEEE R R
9 //==============================================================================
10 
11 #define WHYNTER_BITS 32
12 #define WHYNTER_HDR_MARK 2850
13 #define WHYNTER_HDR_SPACE 2850
14 #define WHYNTER_BIT_MARK 750
15 #define WHYNTER_ONE_MARK 750
16 #define WHYNTER_ONE_SPACE 2150
17 #define WHYNTER_ZERO_MARK 750
18 #define WHYNTER_ZERO_SPACE 750
19 
20 //+=============================================================================
21 #if SEND_WHYNTER
22 void IRsend::sendWhynter(unsigned long data, int nbits) {
23  // Set IR carrier frequency
24  enableIROut(38);
25 
26  // Start
29 
30  // Header
33 
34  // Data
35  for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) {
36  if (data & mask) {
39  } else {
42  }
43  }
44 
45  // Footer
47  space(WHYNTER_ZERO_SPACE); // Always end with the LED off
48 }
49 #endif
50 
51 //+=============================================================================
52 #if DECODE_WHYNTER
53 bool IRrecv::decodeWhynter(decode_results *results) {
54  long data = 0;
55  int offset = 1; // skip initial space
56 
57  // Check we have the right amount of data
58  if (irparams.rawlen < (2 * WHYNTER_BITS) + 6) {
59  return false;
60  }
61 
62  // Sequence begins with a bit mark and a zero space
63  if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_BIT_MARK)) {
64  return false;
65  }
66  offset++;
67 
68  if (!MATCH_SPACE(results->rawbuf[offset], WHYNTER_ZERO_SPACE)) {
69  return false;
70  }
71  offset++;
72 
73  // header mark and space
74  if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_HDR_MARK)) {
75  return false;
76  }
77  offset++;
78 
79  if (!MATCH_SPACE(results->rawbuf[offset], WHYNTER_HDR_SPACE)) {
80  return false;
81  }
82  offset++;
83 
84  // data bits
85  for (int i = 0; i < WHYNTER_BITS; i++) {
86  if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_BIT_MARK)) {
87  return false;
88  }
89  offset++;
90 
91  if (MATCH_SPACE(results->rawbuf[offset], WHYNTER_ONE_SPACE)) {
92  data = (data << 1) | 1;
93  } else if (MATCH_SPACE(results->rawbuf[offset], WHYNTER_ZERO_SPACE)) {
94  data = (data << 1) | 0;
95  } else {
96  return false;
97  }
98  offset++;
99  }
100 
101  // trailing mark
102  if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_BIT_MARK)) {
103  return false;
104  }
105 
106  // Success
107  results->bits = WHYNTER_BITS;
108  results->value = data;
109  results->decode_type = WHYNTER;
110  return true;
111 }
112 #endif
113 
WHYNTER_HDR_SPACE
#define WHYNTER_HDR_SPACE
Definition: ir_Whynter.cpp:13
decode_results
Results returned from the decoder.
Definition: IRremote.h:174
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
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
WHYNTER_ONE_SPACE
#define WHYNTER_ONE_SPACE
Definition: ir_Whynter.cpp:16
MATCH_SPACE
int MATCH_SPACE(int measured_ticks, int desired_us)
Definition: IRremote.cpp:89
WHYNTER_ZERO_MARK
#define WHYNTER_ZERO_MARK
Definition: ir_Whynter.cpp:17
irparams
volatile irparams_t irparams
Allow all parts of the code access to the ISR data NB.
WHYNTER_ONE_MARK
#define WHYNTER_ONE_MARK
Definition: ir_Whynter.cpp:15
WHYNTER
@ WHYNTER
Definition: IRremote.h:122
WHYNTER_BITS
#define WHYNTER_BITS
Definition: ir_Whynter.cpp:11
IRremote.h
Public API to the library.
IRsend::space
void space(unsigned int usec)
Definition: irSend.cpp:103
IRsend::sendWhynter
void sendWhynter(unsigned long data, int nbits)
Definition: ir_Whynter.cpp:22
WHYNTER_ZERO_SPACE
#define WHYNTER_ZERO_SPACE
Definition: ir_Whynter.cpp:18
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
WHYNTER_BIT_MARK
#define WHYNTER_BIT_MARK
Definition: ir_Whynter.cpp:14
irparams_t::rawlen
unsigned int rawlen
counter of entries in rawbuf
Definition: IRremoteInt.h:45
WHYNTER_HDR_MARK
#define WHYNTER_HDR_MARK
Definition: ir_Whynter.cpp:12