File: wiegand.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 (43 lines) | stat: -rw-r--r-- 893 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
#ifndef WIEGAND_HPP
#define WIEGAND_HPP

#include <stdint.h>

typedef void (*WiegandCB_t)(int, uint32_t);

class Wiegand
{
   int mygpio_0, mygpio_1, mytimeout, in_code, bits;

   WiegandCB_t mycallback;

   uint32_t num;

   uint32_t code_timeout;

   void _cb(int gpio, int level, uint32_t tick);

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

   public:

   Wiegand(int gpio_0, int gpio_1, WiegandCB_t callback, int timeout=5);
   /*
      This function establishes a Wiegand decoder on gpio_0 and gpio_1.

      A gap of timeout milliseconds without a new bit indicates
      the end of a code.

      When the code is ended the callback function is called with the code
      bit length and value.
   */

   void cancel(void);
   /*
      This function releases the resources used by the decoder.
   */
};

#endif