source: trunk/Arduino/libraries/Adafruit_Circuit_Playground/utility/IRLibRecvBase.h @ 23

Last change on this file since 23 was 3, checked in by markus, 7 years ago

Setup project structure

File size: 4.0 KB
Line 
1/* IRLibRecvBase.h
2 * Part of IRLib Library for Arduino receiving, decoding, and sending
3 * infrared signals. See COPYRIGHT.txt and LICENSE.txt for more information.
4 *
5 * This module contains the base class classes for receiving IR signals. You will not create
6 * instances of this class, rather it is used as a base class for the 3 different
7 * receiver classes. These are the original IRrecv which uses a 50us timer interrupt.
8 * The IRrecvPCI version that uses pin change interrupts and IRrecvLoop which uses no timers
9 * or interrupts. Each of these has its own .h and .cpp file.
10 *
11 * The IRrecvLoop files are in this folder.  However the other two receivers in their own
12 * separate libraries. That is because their interrupt service routines can conflict
13 * with other ISRs. The ISRs conflict would occur even if you did not create an instance
14 * of their receiver classes. Similarly the frequency detection receiver which also uses
15 * interrupts is also in a separate folder IRLibFreq.
16 */
17
18#ifndef IRLibRecvBase_h
19#define IRLibRecvBase_h
20#include "IRLibGlobals.h"
21
22/* Below are default values for initializing various receiver parameters.
23 * Each of these can be set using methods or variables in the base class
24 * however these are the defaults if you do not specifically set them.
25 */
26#define DEFAULT_BLINK_PIN LED_BUILTIN  //NOTE: LED_BUILTIN is an Arduino constant
27#define DEFAULT_BLINK_ENABLED false
28#define DEFAULT_MARK_EXCESS 50
29#define DEFAULT_FRAME_TIMEOUT 7800 //maximum length of SPACE Sbefore we assume frame ended
30//DEFAULT_TIMEOUT should be 1.25*the_largest_space_any_valid_IR_protocol_might_have.
31//In IRremote library ir_Dish.cpp space they use DISH_RPT_SPACE 6200 while referenced says
32//about 6000. If we take 6200*1.25= 7750 rounded up we will use 7800. Previous IRLib
33//value was 10000 was probably too large. Thanks to Gabriel Staples for this note.
34
35
36/* Base receiver class. Do not create instance. Only used as base for other
37 * receiver classes. See documentation for description of each method or variable.
38 */
39class IRrecvBase {
40public:
41  IRrecvBase(void) {};
42  IRrecvBase(uint8_t recvPin);
43  bool getResults(const uint16_t timePerTicks=1);
44  virtual void enableIRIn(void);
45  virtual void disableIRIn(void);
46  void enableAutoResume(uint16_t *P); 
47  void setFrameTimeout(uint16_t frameTimeout);
48  void blink13(bool enableBlinkLED);
49        uint16_t markExcess;
50protected:
51  void init(void);
52};
53
54/* The global functions below are not methods of any class because they either
55 * do not directly relate to the classes or they must be global functions
56 * so that they can appear inside and ISR. You cannot pass variables to ISR's
57 * or you could not pass any object or methods to it. These functions have been
58 * renamed to emphasize the fact that they are part of this library.
59 */
60 
61/* This function does the actual blinking of an indicator LED. Must be global
62 * so it can be used by ISRs
63 */
64void IRLib_doBlink(void);
65
66/* Some users create custom boards for input and output of IR signals and those boards are
67 * connected to their Arduino even in the case when the sketch only does input. It is
68 * theoretically possible that when running an “input only” sketch that the output pin
69 * could initialize high and your output LED would be on all the time. LED driver circuits
70 * are sometimes designed to overdrive the LED because it is used only intermittently. If
71 * it were to be accidentally left on continuously, it could burn out your circuit. If you
72 * want to ensure that this does not happen you can call the function below.
73 * NOTE: This used to be a method of the base receiver class but it really doesn't have
74 *  anything to do with receiving so we renamed it and made it a standalone function.
75 */
76void IRLib_NoOutput(void);
77
78/* This function is called by both the 50us and PCI ISR in one of two circumstances:
79 * 1) The SPACE was long enough that we are sure the frame is over and ready to process.
80 * 2) The buffer overflowed we have to quit. The parameter is for debugging purposes only.
81 */
82void IRLib_IRrecvComplete(uint8_t Reason);
83
84#endif //IRLibRecvBase_h
Note: See TracBrowser for help on using the repository browser.