forked from Arduino-IRremote/Arduino-IRremote
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ir_Sanyo.cpp
76 lines (63 loc) · 2.63 KB
/
ir_Sanyo.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "IRremote.h"
#include "IRremoteInt.h"
//==============================================================================
// SSSS AAA N N Y Y OOO
// S A A NN N Y Y O O
// SSS AAAAA N N N Y O O
// S A A N NN Y O O
// SSSS A A N N Y OOO
//==============================================================================
// I think this is a Sanyo decoder: Serial = SA 8650B
// Looks like Sony except for timings, 48 chars of data and time/space different
#define SANYO_BITS 12
#define SANYO_HDR_MARK 3500 // seen range 3500
#define SANYO_HDR_SPACE 950 // seen 950
#define SANYO_ONE_MARK 2400 // seen 2400
#define SANYO_ZERO_MARK 700 // seen 700
#define SANYO_DOUBLE_SPACE_USECS 800 // usually ssee 713 - not using ticks as get number wrapround
#define SANYO_RPT_LENGTH 45000
//+=============================================================================
#if DECODE_SANYO
bool IRrecv::decodeSanyo (decode_results *results)
{
long data = 0;
int offset = 0; // Skip first space <-- CHECK THIS!
if (irparams.rawlen < (2 * SANYO_BITS) + 2) return false ;
#if 0
// 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
Serial.print("IR Gap: ");
Serial.println( results->rawbuf[offset]);
Serial.println( "test against:");
Serial.println(results->rawbuf[offset]);
#endif
// Initial space
if (results->rawbuf[offset] < SANYO_DOUBLE_SPACE_USECS) {
//Serial.print("IR Gap found: ");
results->bits = 0;
results->value = REPEAT;
results->decode_type = SANYO;
return true;
}
offset++;
// Initial mark
if (!MATCH_MARK(results->rawbuf[offset++], SANYO_HDR_MARK)) return false ;
// Skip Second Mark
if (!MATCH_MARK(results->rawbuf[offset++], SANYO_HDR_MARK)) return false ;
while (offset + 1 < irparams.rawlen) {
if (!MATCH_SPACE(results->rawbuf[offset++], SANYO_HDR_SPACE)) break ;
if (MATCH_MARK(results->rawbuf[offset], SANYO_ONE_MARK)) data = (data << 1) | 1 ;
else if (MATCH_MARK(results->rawbuf[offset], SANYO_ZERO_MARK)) data = (data << 1) | 0 ;
else return false ;
offset++;
}
// Success
results->bits = (offset - 1) / 2;
if (results->bits < 12) {
results->bits = 0;
return false;
}
results->value = data;
results->decode_type = SANYO;
return true;
}
#endif