Infrared remote library for Arduino: send and receive infrared signals with multiple protocols Port from Arduino-IRremote https://github.com/z3t0/Arduino-IRremote

Dependents:   mbed-os-example-FinalReal mbed-os-example-FinalReal

Committer:
eunmango
Date:
Sun Jun 16 04:36:58 2019 +0000
Revision:
8:0650578366fd
Parent:
3:17440cf7ab90
dd

Who changed what in which revision?

UserRevisionLine numberNew 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 H H AAA RRRR PPPP
yuhki50 0:70c8e56bac45 6 // S H H A A R R P P
yuhki50 0:70c8e56bac45 7 // SSS HHHHH AAAAA RRRR PPPP
yuhki50 0:70c8e56bac45 8 // S H H A A R R P
yuhki50 0:70c8e56bac45 9 // SSSS H H A A R R P
yuhki50 0:70c8e56bac45 10 //==============================================================================
yuhki50 0:70c8e56bac45 11
yuhki50 0:70c8e56bac45 12 // Sharp and DISH support by Todd Treece: http://unionbridge.org/design/ircommand
yuhki50 0:70c8e56bac45 13 //
yuhki50 0:70c8e56bac45 14 // The send function has the necessary repeat built in because of the need to
yuhki50 0:70c8e56bac45 15 // invert the signal.
yuhki50 0:70c8e56bac45 16 //
yuhki50 0:70c8e56bac45 17 // Sharp protocol documentation:
yuhki50 0:70c8e56bac45 18 // http://www.sbprojects.com/knowledge/ir/sharp.htm
yuhki50 0:70c8e56bac45 19 //
yuhki50 0:70c8e56bac45 20 // Here is the LIRC file I found that seems to match the remote codes from the
yuhki50 0:70c8e56bac45 21 // oscilloscope:
yuhki50 0:70c8e56bac45 22 // Sharp LCD TV:
yuhki50 0:70c8e56bac45 23 // http://lirc.sourceforge.net/remotes/sharp/GA538WJSA
yuhki50 0:70c8e56bac45 24
yuhki50 0:70c8e56bac45 25 #define SHARP_BITS 15
yuhki50 0:70c8e56bac45 26 #define SHARP_BIT_MARK 245
yuhki50 0:70c8e56bac45 27 #define SHARP_ONE_SPACE 1805
yuhki50 0:70c8e56bac45 28 #define SHARP_ZERO_SPACE 795
yuhki50 0:70c8e56bac45 29 #define SHARP_GAP 600000
yuhki50 0:70c8e56bac45 30 #define SHARP_RPT_SPACE 3000
yuhki50 0:70c8e56bac45 31
yuhki50 0:70c8e56bac45 32 #define SHARP_TOGGLE_MASK 0x3FF
yuhki50 0:70c8e56bac45 33
yuhki50 0:70c8e56bac45 34 //+=============================================================================
yuhki50 0:70c8e56bac45 35 #if SEND_SHARP
yuhki50 0:70c8e56bac45 36 void IRsend::sendSharpRaw (unsigned long data, int nbits)
yuhki50 0:70c8e56bac45 37 {
yuhki50 0:70c8e56bac45 38 enableIROut(38);
yuhki50 0:70c8e56bac45 39
yuhki50 0:70c8e56bac45 40 // Sending codes in bursts of 3 (normal, inverted, normal) makes transmission
yuhki50 0:70c8e56bac45 41 // much more reliable. That's the exact behaviour of CD-S6470 remote control.
yuhki50 0:70c8e56bac45 42 for (int n = 0; n < 3; n++) {
yuhki50 0:70c8e56bac45 43 for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) {
yuhki50 0:70c8e56bac45 44 if (data & mask) {
yuhki50 0:70c8e56bac45 45 mark(SHARP_BIT_MARK);
yuhki50 0:70c8e56bac45 46 space(SHARP_ONE_SPACE);
yuhki50 0:70c8e56bac45 47 } else {
yuhki50 0:70c8e56bac45 48 mark(SHARP_BIT_MARK);
yuhki50 0:70c8e56bac45 49 space(SHARP_ZERO_SPACE);
yuhki50 0:70c8e56bac45 50 }
yuhki50 0:70c8e56bac45 51 }
yuhki50 0:70c8e56bac45 52
yuhki50 0:70c8e56bac45 53 mark(SHARP_BIT_MARK);
yuhki50 0:70c8e56bac45 54 space(SHARP_ZERO_SPACE);
yuhki50 3:17440cf7ab90 55 wait_ms(40);
yuhki50 0:70c8e56bac45 56
yuhki50 0:70c8e56bac45 57 data = data ^ SHARP_TOGGLE_MASK;
yuhki50 0:70c8e56bac45 58 }
yuhki50 0:70c8e56bac45 59 }
yuhki50 0:70c8e56bac45 60 #endif
yuhki50 0:70c8e56bac45 61
yuhki50 0:70c8e56bac45 62 //+=============================================================================
yuhki50 0:70c8e56bac45 63 // Sharp send compatible with data obtained through decodeSharp()
yuhki50 0:70c8e56bac45 64 // ^^^^^^^^^^^^^ FUNCTION MISSING!
yuhki50 0:70c8e56bac45 65 //
yuhki50 0:70c8e56bac45 66 #if SEND_SHARP
yuhki50 0:70c8e56bac45 67 void IRsend::sendSharp (unsigned int address, unsigned int command)
yuhki50 0:70c8e56bac45 68 {
yuhki50 0:70c8e56bac45 69 sendSharpRaw((address << 10) | (command << 2) | 2, SHARP_BITS);
yuhki50 0:70c8e56bac45 70 }
yuhki50 0:70c8e56bac45 71 #endif