Infrared remote library for Arduino: send and receive infrared signals with multiple protocols Port from Arduino-IRremote https://github.com/z3t0/Arduino-IRremote
Dependents: Lilnija_29012017 NucleoF042K6_IRReceiver
IRremoteInt.h@3:17440cf7ab90, 2016-01-23 (annotated)
- Committer:
- yuhki50
- Date:
- Sat Jan 23 15:09:34 2016 +0000
- Revision:
- 3:17440cf7ab90
- Parent:
- 0:70c8e56bac45
- Child:
- 7:c82a0d54a024
porting
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yuhki50 | 0:70c8e56bac45 | 1 | //****************************************************************************** |
yuhki50 | 0:70c8e56bac45 | 2 | // IRremote |
yuhki50 | 0:70c8e56bac45 | 3 | // Version 2.0.1 June, 2015 |
yuhki50 | 0:70c8e56bac45 | 4 | // Copyright 2009 Ken Shirriff |
yuhki50 | 0:70c8e56bac45 | 5 | // For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html |
yuhki50 | 0:70c8e56bac45 | 6 | // |
yuhki50 | 0:70c8e56bac45 | 7 | // Modified by Paul Stoffregen <paul@pjrc.com> to support other boards and timers |
yuhki50 | 0:70c8e56bac45 | 8 | // |
yuhki50 | 0:70c8e56bac45 | 9 | // Interrupt code based on NECIRrcv by Joe Knapp |
yuhki50 | 0:70c8e56bac45 | 10 | // http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210243556 |
yuhki50 | 0:70c8e56bac45 | 11 | // Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/ |
yuhki50 | 0:70c8e56bac45 | 12 | // |
yuhki50 | 0:70c8e56bac45 | 13 | // JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post) |
yuhki50 | 0:70c8e56bac45 | 14 | // Whynter A/C ARC-110WD added by Francesco Meschia |
yuhki50 | 0:70c8e56bac45 | 15 | //****************************************************************************** |
yuhki50 | 0:70c8e56bac45 | 16 | |
yuhki50 | 0:70c8e56bac45 | 17 | #ifndef IRremoteint_h |
yuhki50 | 0:70c8e56bac45 | 18 | #define IRremoteint_h |
yuhki50 | 0:70c8e56bac45 | 19 | |
yuhki50 | 0:70c8e56bac45 | 20 | //------------------------------------------------------------------------------ |
yuhki50 | 3:17440cf7ab90 | 21 | // Include the right mbed header |
yuhki50 | 0:70c8e56bac45 | 22 | // |
yuhki50 | 3:17440cf7ab90 | 23 | #include "mbed.h" |
yuhki50 | 0:70c8e56bac45 | 24 | |
yuhki50 | 0:70c8e56bac45 | 25 | //------------------------------------------------------------------------------ |
yuhki50 | 0:70c8e56bac45 | 26 | // Information for the Interrupt Service Routine |
yuhki50 | 0:70c8e56bac45 | 27 | // |
yuhki50 | 0:70c8e56bac45 | 28 | #define RAWBUF 101 // Maximum length of raw duration buffer |
yuhki50 | 0:70c8e56bac45 | 29 | |
yuhki50 | 0:70c8e56bac45 | 30 | typedef |
yuhki50 | 0:70c8e56bac45 | 31 | struct { |
yuhki50 | 0:70c8e56bac45 | 32 | // The fields are ordered to reduce memory over caused by struct-padding |
yuhki50 | 0:70c8e56bac45 | 33 | uint8_t rcvstate; // State Machine state |
yuhki50 | 0:70c8e56bac45 | 34 | uint8_t rawlen; // counter of entries in rawbuf |
yuhki50 | 0:70c8e56bac45 | 35 | unsigned int timer; // State timer, counts 50uS ticks. |
yuhki50 | 0:70c8e56bac45 | 36 | unsigned int rawbuf[RAWBUF]; // raw data |
yuhki50 | 0:70c8e56bac45 | 37 | uint8_t overflow; // Raw buffer overflow occurred |
yuhki50 | 0:70c8e56bac45 | 38 | } |
yuhki50 | 0:70c8e56bac45 | 39 | irparams_t; |
yuhki50 | 0:70c8e56bac45 | 40 | |
yuhki50 | 0:70c8e56bac45 | 41 | // ISR State-Machine : Receiver States |
yuhki50 | 0:70c8e56bac45 | 42 | #define STATE_IDLE 2 |
yuhki50 | 0:70c8e56bac45 | 43 | #define STATE_MARK 3 |
yuhki50 | 0:70c8e56bac45 | 44 | #define STATE_SPACE 4 |
yuhki50 | 0:70c8e56bac45 | 45 | #define STATE_STOP 5 |
yuhki50 | 0:70c8e56bac45 | 46 | #define STATE_OVERFLOW 6 |
yuhki50 | 0:70c8e56bac45 | 47 | |
yuhki50 | 0:70c8e56bac45 | 48 | //------------------------------------------------------------------------------ |
yuhki50 | 0:70c8e56bac45 | 49 | // Pulse parms are ((X*50)-100) for the Mark and ((X*50)+100) for the Space. |
yuhki50 | 0:70c8e56bac45 | 50 | // First MARK is the one after the long gap |
yuhki50 | 0:70c8e56bac45 | 51 | // Pulse parameters in uSec |
yuhki50 | 0:70c8e56bac45 | 52 | // |
yuhki50 | 0:70c8e56bac45 | 53 | |
yuhki50 | 0:70c8e56bac45 | 54 | // Due to sensor lag, when received, Marks tend to be 100us too long and |
yuhki50 | 0:70c8e56bac45 | 55 | // Spaces tend to be 100us too short |
yuhki50 | 0:70c8e56bac45 | 56 | #define MARK_EXCESS 100 |
yuhki50 | 0:70c8e56bac45 | 57 | |
yuhki50 | 0:70c8e56bac45 | 58 | // microseconds per clock interrupt tick |
yuhki50 | 0:70c8e56bac45 | 59 | #define USECPERTICK 50 |
yuhki50 | 0:70c8e56bac45 | 60 | |
yuhki50 | 0:70c8e56bac45 | 61 | // Upper and Lower percentage tolerances in measurements |
yuhki50 | 0:70c8e56bac45 | 62 | #define TOLERANCE 25 |
yuhki50 | 0:70c8e56bac45 | 63 | #define LTOL (1.0 - (TOLERANCE/100.)) |
yuhki50 | 0:70c8e56bac45 | 64 | #define UTOL (1.0 + (TOLERANCE/100.)) |
yuhki50 | 0:70c8e56bac45 | 65 | |
yuhki50 | 0:70c8e56bac45 | 66 | // Minimum gap between IR transmissions |
yuhki50 | 0:70c8e56bac45 | 67 | #define _GAP 5000 |
yuhki50 | 0:70c8e56bac45 | 68 | #define GAP_TICKS (_GAP/USECPERTICK) |
yuhki50 | 0:70c8e56bac45 | 69 | |
yuhki50 | 0:70c8e56bac45 | 70 | #define TICKS_LOW(us) ((int)(((us)*LTOL/USECPERTICK))) |
yuhki50 | 0:70c8e56bac45 | 71 | #define TICKS_HIGH(us) ((int)(((us)*UTOL/USECPERTICK + 1))) |
yuhki50 | 0:70c8e56bac45 | 72 | |
yuhki50 | 0:70c8e56bac45 | 73 | //------------------------------------------------------------------------------ |
yuhki50 | 0:70c8e56bac45 | 74 | // IR detector output is active low |
yuhki50 | 0:70c8e56bac45 | 75 | // |
yuhki50 | 0:70c8e56bac45 | 76 | #define MARK 0 |
yuhki50 | 0:70c8e56bac45 | 77 | #define SPACE 1 |
yuhki50 | 0:70c8e56bac45 | 78 | |
yuhki50 | 0:70c8e56bac45 | 79 | #endif |