This library reads Wiegand, saving it into a buffer, calling a callback function after it is full or a timeout is reached.

Dependents:   mbed-os-wiegand-example

This library reads Wiegand, saving it into a buffer, calling a callback function after it is full or a timeout is reached. Data can be extracted as :

  • Raw
  • Base 10 Integer
  • Base 10 String
  • Base 16 String

Always call reset after saving Wiegand data.

It automatically calibrates the timeout during the first reading unless specified.

Timeout can be set using setTimout, units are in milliseconds (first call stopCalibrating()).

EventQueue is required for deferring from ISR, it is possible to dispatch the EventQueue from the mainQueue or any other thread.

Revision:
3:ea5e0ab156b5
Parent:
2:2c72a6b13593
--- a/wiegand.h	Wed May 08 18:08:18 2019 +0000
+++ b/wiegand.h	Thu May 16 22:12:19 2019 +0000
@@ -69,7 +69,7 @@
     void _shift_left(volatile unsigned char *ar, int size, int shift);
 
 public:
-    Wiegand(PinName d0, PinName d1, EventQueue* eventQueue, unsigned char bits, unsigned char i=0);
+    Wiegand(PinName d0, PinName d1, EventQueue* eventQueue, unsigned char i=0);
     ~Wiegand();
 
     void            attach(Callback<void(Wiegand *WiegandObj)> wiegandCallback);
@@ -84,6 +84,7 @@
     unsigned int    getTimeout(void);
     void            reset(void);
     void            setTimeout(unsigned int time);
+    void            setBits(unsigned char bits);
     void            startCalibrating(void);
     void            stopCalibrating(void);
 };