File: ir_hasher.hpp

package info (click to toggle)
pigpio 1.78-1.1
  • links: PTS
  • area: main
  • in suites: sid, trixie
  • size: 7,088 kB
  • sloc: ansic: 17,891; python: 4,232; sh: 741; cpp: 281; makefile: 135
file content (44 lines) | stat: -rw-r--r-- 1,099 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef IR_RX_HASHER_HPP
#define IR_RX_HASHER_HPP

#include <stdint.h>

typedef void (*HasherCB_t)(uint32_t);

class Hasher
{

   /*
   This class forms a hash over the IR pulses generated by an
   IR remote.

   The remote key press is not converted into a code in the manner of
   the lirc module.  No attempt is made to decode the type of protocol
   used by the remote.  The hash is likely to be unique for different
   keys and different remotes but this is not guaranteed.

   This hashing process works for some remotes/protocols but not for
   others.  The only way to find out if it works for one or more of
   your remotes is to try it and see.
   */

   int mygpio, mytimeout;
   HasherCB_t mycallback;
   int in_code;
   uint32_t hash_val;
   int edges;
   uint32_t t1, t2, t3, t4;

   void _hash(int old_val, int new_val);
   void _callback(int gpio, int level, uint32_t tick);

   /* Need a static callback to link with C. */
   static void _callbackExt(int gpio, int level, uint32_t tick, void *user);

   public:

   Hasher(int gpio, HasherCB_t callback, int timeout=5);
};

#endif