Infrared remote library for Arduino: send and receive infrared signals with multiple protocols Port from Arduino-IRremote https://github.com/z3t0/Arduino-IRremote
ir_Sanyo.cpp@0:70c8e56bac45, 2016-01-23 (annotated)
- Committer:
- yuhki50
- Date:
- Sat Jan 23 06:16:48 2016 +0000
- Revision:
- 0:70c8e56bac45
- Child:
- 5:a4dfe2bb80b9
import https://github.com/z3t0/Arduino-IRremote e3ec11d
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yuhki50 | 0:70c8e56bac45 | 1 | #include "IRremote.h" |
yuhki50 | 0:70c8e56bac45 | 2 | #include "IRremoteInt.h" |
yuhki50 | 0:70c8e56bac45 | 3 | |
yuhki50 | 0:70c8e56bac45 | 4 | //============================================================================== |
yuhki50 | 0:70c8e56bac45 | 5 | // SSSS AAA N N Y Y OOO |
yuhki50 | 0:70c8e56bac45 | 6 | // S A A NN N Y Y O O |
yuhki50 | 0:70c8e56bac45 | 7 | // SSS AAAAA N N N Y O O |
yuhki50 | 0:70c8e56bac45 | 8 | // S A A N NN Y O O |
yuhki50 | 0:70c8e56bac45 | 9 | // SSSS A A N N Y OOO |
yuhki50 | 0:70c8e56bac45 | 10 | //============================================================================== |
yuhki50 | 0:70c8e56bac45 | 11 | |
yuhki50 | 0:70c8e56bac45 | 12 | // I think this is a Sanyo decoder: Serial = SA 8650B |
yuhki50 | 0:70c8e56bac45 | 13 | // Looks like Sony except for timings, 48 chars of data and time/space different |
yuhki50 | 0:70c8e56bac45 | 14 | |
yuhki50 | 0:70c8e56bac45 | 15 | #define SANYO_BITS 12 |
yuhki50 | 0:70c8e56bac45 | 16 | #define SANYO_HDR_MARK 3500 // seen range 3500 |
yuhki50 | 0:70c8e56bac45 | 17 | #define SANYO_HDR_SPACE 950 // seen 950 |
yuhki50 | 0:70c8e56bac45 | 18 | #define SANYO_ONE_MARK 2400 // seen 2400 |
yuhki50 | 0:70c8e56bac45 | 19 | #define SANYO_ZERO_MARK 700 // seen 700 |
yuhki50 | 0:70c8e56bac45 | 20 | #define SANYO_DOUBLE_SPACE_USECS 800 // usually ssee 713 - not using ticks as get number wrapround |
yuhki50 | 0:70c8e56bac45 | 21 | #define SANYO_RPT_LENGTH 45000 |
yuhki50 | 0:70c8e56bac45 | 22 | |
yuhki50 | 0:70c8e56bac45 | 23 | //+============================================================================= |
yuhki50 | 0:70c8e56bac45 | 24 | #if DECODE_SANYO |
yuhki50 | 0:70c8e56bac45 | 25 | bool IRrecv::decodeSanyo (decode_results *results) |
yuhki50 | 0:70c8e56bac45 | 26 | { |
yuhki50 | 0:70c8e56bac45 | 27 | long data = 0; |
yuhki50 | 0:70c8e56bac45 | 28 | int offset = 0; // Skip first space <-- CHECK THIS! |
yuhki50 | 0:70c8e56bac45 | 29 | |
yuhki50 | 0:70c8e56bac45 | 30 | if (irparams.rawlen < (2 * SANYO_BITS) + 2) return false ; |
yuhki50 | 0:70c8e56bac45 | 31 | |
yuhki50 | 0:70c8e56bac45 | 32 | #if 0 |
yuhki50 | 0:70c8e56bac45 | 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 |
yuhki50 | 0:70c8e56bac45 | 34 | Serial.print("IR Gap: "); |
yuhki50 | 0:70c8e56bac45 | 35 | Serial.println( results->rawbuf[offset]); |
yuhki50 | 0:70c8e56bac45 | 36 | Serial.println( "test against:"); |
yuhki50 | 0:70c8e56bac45 | 37 | Serial.println(results->rawbuf[offset]); |
yuhki50 | 0:70c8e56bac45 | 38 | #endif |
yuhki50 | 0:70c8e56bac45 | 39 | |
yuhki50 | 0:70c8e56bac45 | 40 | // Initial space |
yuhki50 | 0:70c8e56bac45 | 41 | if (results->rawbuf[offset] < SANYO_DOUBLE_SPACE_USECS) { |
yuhki50 | 0:70c8e56bac45 | 42 | //Serial.print("IR Gap found: "); |
yuhki50 | 0:70c8e56bac45 | 43 | results->bits = 0; |
yuhki50 | 0:70c8e56bac45 | 44 | results->value = REPEAT; |
yuhki50 | 0:70c8e56bac45 | 45 | results->decode_type = SANYO; |
yuhki50 | 0:70c8e56bac45 | 46 | return true; |
yuhki50 | 0:70c8e56bac45 | 47 | } |
yuhki50 | 0:70c8e56bac45 | 48 | offset++; |
yuhki50 | 0:70c8e56bac45 | 49 | |
yuhki50 | 0:70c8e56bac45 | 50 | // Initial mark |
yuhki50 | 0:70c8e56bac45 | 51 | if (!MATCH_MARK(results->rawbuf[offset++], SANYO_HDR_MARK)) return false ; |
yuhki50 | 0:70c8e56bac45 | 52 | |
yuhki50 | 0:70c8e56bac45 | 53 | // Skip Second Mark |
yuhki50 | 0:70c8e56bac45 | 54 | if (!MATCH_MARK(results->rawbuf[offset++], SANYO_HDR_MARK)) return false ; |
yuhki50 | 0:70c8e56bac45 | 55 | |
yuhki50 | 0:70c8e56bac45 | 56 | while (offset + 1 < irparams.rawlen) { |
yuhki50 | 0:70c8e56bac45 | 57 | if (!MATCH_SPACE(results->rawbuf[offset++], SANYO_HDR_SPACE)) break ; |
yuhki50 | 0:70c8e56bac45 | 58 | |
yuhki50 | 0:70c8e56bac45 | 59 | if (MATCH_MARK(results->rawbuf[offset], SANYO_ONE_MARK)) data = (data << 1) | 1 ; |
yuhki50 | 0:70c8e56bac45 | 60 | else if (MATCH_MARK(results->rawbuf[offset], SANYO_ZERO_MARK)) data = (data << 1) | 0 ; |
yuhki50 | 0:70c8e56bac45 | 61 | else return false ; |
yuhki50 | 0:70c8e56bac45 | 62 | offset++; |
yuhki50 | 0:70c8e56bac45 | 63 | } |
yuhki50 | 0:70c8e56bac45 | 64 | |
yuhki50 | 0:70c8e56bac45 | 65 | // Success |
yuhki50 | 0:70c8e56bac45 | 66 | results->bits = (offset - 1) / 2; |
yuhki50 | 0:70c8e56bac45 | 67 | if (results->bits < 12) { |
yuhki50 | 0:70c8e56bac45 | 68 | results->bits = 0; |
yuhki50 | 0:70c8e56bac45 | 69 | return false; |
yuhki50 | 0:70c8e56bac45 | 70 | } |
yuhki50 | 0:70c8e56bac45 | 71 | |
yuhki50 | 0:70c8e56bac45 | 72 | results->value = data; |
yuhki50 | 0:70c8e56bac45 | 73 | results->decode_type = SANYO; |
yuhki50 | 0:70c8e56bac45 | 74 | return true; |
yuhki50 | 0:70c8e56bac45 | 75 | } |
yuhki50 | 0:70c8e56bac45 | 76 | #endif |