IRremote
ir_Aiwa.cpp
Go to the documentation of this file.
1 #include "IRremote.h"
2 
3 //==============================================================================
4 // AAA IIIII W W AAA
5 // A A I W W A A
6 // AAAAA I W W W AAAAA
7 // A A I W W W A A
8 // A A IIIII WWW A A
9 //==============================================================================
10 
11 // Based off the RC-T501 RCU
12 // Lirc file http://lirc.sourceforge.net/remotes/aiwa/RC-T501
13 
14 #define AIWA_RC_T501_HZ 38
15 #define AIWA_RC_T501_BITS 15
16 #define AIWA_RC_T501_PRE_BITS 26
17 #define AIWA_RC_T501_POST_BITS 1
18 #define AIWA_RC_T501_SUM_BITS (AIWA_RC_T501_PRE_BITS + AIWA_RC_T501_BITS + AIWA_RC_T501_POST_BITS)
19 #define AIWA_RC_T501_HDR_MARK 8800
20 #define AIWA_RC_T501_HDR_SPACE 4500
21 #define AIWA_RC_T501_BIT_MARK 500
22 #define AIWA_RC_T501_ONE_SPACE 600
23 #define AIWA_RC_T501_ZERO_SPACE 1700
24 
25 //+=============================================================================
26 #if SEND_AIWA_RC_T501
27 void IRsend::sendAiwaRCT501(int code) {
28  unsigned long pre = 0x0227EEC0; // 26-bits
29 
30  // Set IR carrier frequency
32 
33  // Header
36 
37  // Send "pre" data
38  for (unsigned long mask = 1UL << (26 - 1); mask; mask >>= 1) {
40  if (pre & mask)
42  else
44  }
45 
46 //-v- THIS CODE LOOKS LIKE IT MIGHT BE WRONG - CHECK!
47 // it only send 15bits and ignores the top bit
48 // then uses TOPBIT which is 0x80000000 to check the bit code
49 // I suspect TOPBIT should be changed to 0x00008000
50 
51  // Skip first code bit
52  code <<= 1;
53  // Send code
54  for (int i = 0; i < 15; i++) {
56  if (code & 0x80000000)
58  else
60  code <<= 1;
61  }
62 
63 //-^- THIS CODE LOOKS LIKE IT MIGHT BE WRONG - CHECK!
64 
65  // POST-DATA, 1 bit, 0x0
68 
70  space(0);
71 }
72 #endif
73 
74 //+=============================================================================
75 #if DECODE_AIWA_RC_T501
76 bool IRrecv::decodeAiwaRCT501(decode_results *results) {
77  int data = 0;
78  unsigned int offset = 1;
79 
80  // Check SIZE
81  if (irparams.rawlen < 2 * (AIWA_RC_T501_SUM_BITS) + 4) {
82  return false;
83  }
84 
85  // Check HDR Mark/Space
86  if (!MATCH_MARK(results->rawbuf[offset], AIWA_RC_T501_HDR_MARK)) {
87  return false;
88  }
89  offset++;
90 
91  if (!MATCH_SPACE(results->rawbuf[offset], AIWA_RC_T501_HDR_SPACE)) {
92  return false;
93  }
94  offset++;
95 
96  offset += 26; // skip pre-data - optional
97  while (offset < irparams.rawlen - 4) {
98  if (MATCH_MARK(results->rawbuf[offset], AIWA_RC_T501_BIT_MARK)) {
99  offset++;
100  } else {
101  return false;
102  }
103 
104  // ONE & ZERO
105  if (MATCH_SPACE(results->rawbuf[offset], AIWA_RC_T501_ONE_SPACE)) {
106  data = (data << 1) | 1;
107  } else if (MATCH_SPACE(results->rawbuf[offset], AIWA_RC_T501_ZERO_SPACE)) {
108  data = (data << 1) | 0;
109  } else {
110  break; // End of one & zero detected
111  }
112  offset++;
113  }
114 
115  results->bits = (offset - 1) / 2;
116  if (results->bits < 42) {
117  return false;
118  }
119 
120  results->value = data;
121  results->decode_type = AIWA_RC_T501;
122  return true;
123 }
124 #endif
AIWA_RC_T501
@ AIWA_RC_T501
Definition: IRremote.h:123
decode_results
Results returned from the decoder.
Definition: IRremote.h:174
AIWA_RC_T501_ZERO_SPACE
#define AIWA_RC_T501_ZERO_SPACE
Definition: ir_Aiwa.cpp:23
AIWA_RC_T501_HDR_MARK
#define AIWA_RC_T501_HDR_MARK
Definition: ir_Aiwa.cpp:19
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
AIWA_RC_T501_BIT_MARK
#define AIWA_RC_T501_BIT_MARK
Definition: ir_Aiwa.cpp:21
decode_results::decode_type
decode_type_t decode_type
UNKNOWN, NEC, SONY, RC5, ...
Definition: IRremote.h:176
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.
AIWA_RC_T501_ONE_SPACE
#define AIWA_RC_T501_ONE_SPACE
Definition: ir_Aiwa.cpp:22
AIWA_RC_T501_HZ
#define AIWA_RC_T501_HZ
Definition: ir_Aiwa.cpp:14
AIWA_RC_T501_SUM_BITS
#define AIWA_RC_T501_SUM_BITS
Definition: ir_Aiwa.cpp:18
IRremote.h
Public API to the library.
IRsend::space
void space(unsigned int usec)
Definition: irSend.cpp:103
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
AIWA_RC_T501_HDR_SPACE
#define AIWA_RC_T501_HDR_SPACE
Definition: ir_Aiwa.cpp:20
IRsend::sendAiwaRCT501
void sendAiwaRCT501(int code)
Definition: ir_Aiwa.cpp:27
irparams_t::rawlen
unsigned int rawlen
counter of entries in rawbuf
Definition: IRremoteInt.h:45