IRremote
ir_Sanyo.cpp
Go to the documentation of this file.
1 #include "IRremote.h"
2 
3 //==============================================================================
4 // SSSS AAA N N Y Y OOO
5 // S A A NN N Y Y O O
6 // SSS AAAAA N N N Y O O
7 // S A A N NN Y O O
8 // SSSS A A N N Y OOO
9 //==============================================================================
10 
11 // I think this is a Sanyo decoder: Serial = SA 8650B
12 // Looks like Sony except for timings, 48 chars of data and time/space different
13 
14 #define SANYO_BITS 12
15 #define SANYO_HDR_MARK 3500 // seen range 3500
16 #define SANYO_HDR_SPACE 950 // seen 950
17 #define SANYO_ONE_MARK 2400 // seen 2400
18 #define SANYO_ZERO_MARK 700 // seen 700
19 #define SANYO_DOUBLE_SPACE_USECS 800 // usually see 713 - not using ticks as get number wrap around
20 #define SANYO_RPT_LENGTH 45000
21 
22 //+=============================================================================
23 #if DECODE_SANYO
24 bool IRrecv::decodeSanyo(decode_results *results) {
25  long data = 0;
26  unsigned int offset = 0; // Skip first space <-- CHECK THIS!
27 
28  if (irparams.rawlen < (2 * SANYO_BITS) + 2) {
29  return false;
30  }
31 
32 #if 0
33  // Put this back in for debugging - note can't use #DEBUG as if Debug on we don't see the repeat cos of the delay
34  Serial.print("IR Gap: ");
35  Serial.println( results->rawbuf[offset] * USECPERTICK);
36  Serial.println( "test against:");
37  Serial.println(SANYO_DOUBLE_SPACE_USECS);
38 #endif
39 
40 // Initial space
41  if ((results->rawbuf[offset] * USECPERTICK) < SANYO_DOUBLE_SPACE_USECS) {
42  //Serial.print("IR Gap found: ");
43  results->bits = 0;
44  results->value = REPEAT;
45  results->decode_type = SANYO;
46  return true;
47  }
48  offset++;
49 
50  // Initial mark
51  if (!MATCH_MARK(results->rawbuf[offset], SANYO_HDR_MARK)) {
52  return false;
53  }
54  offset++;
55 
56  // Skip Second Mark
57  if (!MATCH_MARK(results->rawbuf[offset], SANYO_HDR_MARK)) {
58  return false;
59  }
60  offset++;
61 
62  while (offset + 1 < irparams.rawlen) {
63  if (!MATCH_SPACE(results->rawbuf[offset], SANYO_HDR_SPACE)) {
64  break;
65  }
66  offset++;
67 
68  if (MATCH_MARK(results->rawbuf[offset], SANYO_ONE_MARK)) {
69  data = (data << 1) | 1;
70  } else if (MATCH_MARK(results->rawbuf[offset], SANYO_ZERO_MARK)) {
71  data = (data << 1) | 0;
72  } else {
73  return false;
74  }
75  offset++;
76  }
77 
78  // Success
79  results->bits = (offset - 1) / 2;
80  if (results->bits < 12) {
81  results->bits = 0;
82  return false;
83  }
84 
85  results->value = data;
86  results->decode_type = SANYO;
87  return true;
88 }
89 #endif
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
SANYO_HDR_MARK
#define SANYO_HDR_MARK
Definition: ir_Sanyo.cpp:15
SANYO_ZERO_MARK
#define SANYO_ZERO_MARK
Definition: ir_Sanyo.cpp:18
decode_results::rawbuf
volatile unsigned int * rawbuf
Raw intervals in 50uS ticks.
Definition: IRremote.h:180
decode_results::decode_type
decode_type_t decode_type
UNKNOWN, NEC, SONY, RC5, ...
Definition: IRremote.h:176
SANYO_BITS
#define SANYO_BITS
Definition: ir_Sanyo.cpp:14
MATCH_SPACE
int MATCH_SPACE(int measured_ticks, int desired_us)
Definition: IRremote.cpp:89
SANYO_HDR_SPACE
#define SANYO_HDR_SPACE
Definition: ir_Sanyo.cpp:16
irparams
volatile irparams_t irparams
Allow all parts of the code access to the ISR data NB.
USECPERTICK
#define USECPERTICK
Definition: IRremoteBoardDefs.h:166
SANYO
@ SANYO
Definition: IRremote.h:125
SANYO_DOUBLE_SPACE_USECS
#define SANYO_DOUBLE_SPACE_USECS
Definition: ir_Sanyo.cpp:19
IRremote.h
Public API to the library.
REPEAT
#define REPEAT
Decoded value for NEC when a repeat code is received.
Definition: IRremote.h:188
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
irparams_t::rawlen
unsigned int rawlen
counter of entries in rawbuf
Definition: IRremoteInt.h:45
SANYO_ONE_MARK
#define SANYO_ONE_MARK
Definition: ir_Sanyo.cpp:17