source: trunk/Arduino/libraries/Adafruit_Circuit_Playground/utility/IRLib_P07_NECx.h

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

Setup project structure

File size: 2.9 KB
Line 
1/* IRLib_P07_NECx.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/*
6 * NECx is a variation of NEC protocol. The only difference is in the timing of the
7 * header.  There are two variations NECx1 and NECx2. They differ only in the way in
8 * which they handle repeat codes.  If you hold a button using NECx1 it does not repeat
9 * the same sequence. Rather it sends a special sequence consisting of the usual header
10 * followed by a normal mark, a "1" bit, and then a long space with a 108ms extent. Note
11 * this so-called "ditto" repeat code is slightly different than the one for regular NEC.
12 * When IRLib receives one of these special repeat sequences, it returns the
13 * value REPEAT_CODE which is defined in IRLibProtocols.h as the value 0xffffffff. If you
14 * send REPEAT_CODE, the send routine will create a special sequence for you.
15 * Whether it is a normal code or a repeat code the entire frame has a 108ms extent.
16 * The IRP notation for these protocols are:
17 * NECx1: {38k,564}<1,-1|1,-3>(8,-8,D:8,S:8,F:8,~F:8,1,^108,(8,-8,D:1,1,^108m)*)
18 * NECx2: {38k,564}<1,-1|1,-3>(8,-8,D:8,S:8,F:8,~F:8,1,^108)+
19 */
20
21#ifndef IRLIB_PROTOCOL_07_H
22#define IRLIB_PROTOCOL_07_H
23#define IR_SEND_PROTOCOL_07             case 07: IRsendNECx::send(data); break;
24#define IR_DECODE_PROTOCOL_07   if(IRdecodeNECx::decode()) return true;
25#ifdef IRLIB_HAVE_COMBO
26        #define PV_IR_DECODE_PROTOCOL_07 ,public virtual IRdecodeNECx
27        #define PV_IR_SEND_PROTOCOL_07   ,public virtual IRsendNECx
28#else
29        #define PV_IR_DECODE_PROTOCOL_07  public virtual IRdecodeNECx
30        #define PV_IR_SEND_PROTOCOL_07    public virtual IRsendNECx
31#endif
32
33#ifdef IRLIBSENDBASE_H
34class IRsendNECx: public virtual IRsendBase {
35  public:
36    void send(uint32_t data) {
37      if (data==REPEAT_CODE) {
38        enableIROut(38);
39        mark(564*8); space(564*8); mark(564);space(564);
40        mark(564);  space(412);delay(98);//actually 98412us
41      }
42      else {
43        sendGeneric(data,32, 564*8, 564*8, 564, 564, 564*3, 564, 38, true);
44      }
45    };
46};
47#endif  //IRLIBSENDBASE_H
48
49#ifdef IRLIBDECODEBASE_H
50class IRdecodeNECx: public virtual IRdecodeBase {
51  public:
52    virtual bool decode(void) {
53      IRLIB_ATTEMPT_MESSAGE(F("NECx"));
54      resetDecoder();//This used to be in the receiver getResults.
55      // Check for repeat
56      if (recvGlobal.decodeLength == 6 && MATCH(recvGlobal.decodeBuffer[1], 564*8)  && MATCH(recvGlobal.decodeBuffer[2],564*8)
57        && MATCH(recvGlobal.decodeBuffer[3],564) && MATCH(recvGlobal.decodeBuffer[5],564)
58        ) {
59        bits = 0;
60        value = REPEAT_CODE;
61        protocolNum = NECX;
62        return true;
63      }
64      if(!decodeGeneric(68, 564*8, 564*8, 564, 564*3, 564)) return false;
65      protocolNum = NECX;
66      return true;
67    }
68};
69#endif //IRLIBDECODEBASE_H
70
71#define IRLIB_HAVE_COMBO
72
73#endif //IRLIB_PROTOCOL_07_H
Note: See TracBrowser for help on using the repository browser.