Rotary encoder library. Uses interrupts for reading rotation,

Fork of RPG by Christopher Anderson

Revision:
2:94d27805abda
Parent:
1:0b389c2c21b5
Child:
3:e041653b7338
--- a/RPG.h	Fri Oct 12 14:04:17 2012 +0000
+++ b/RPG.h	Sun May 21 09:59:35 2017 +0000
@@ -1,8 +1,9 @@
 /**
  * =============================================================================
- * Rotary Pulse Generator class (Version 0.0.1)
+ * Rotary Pulse Generator class (Version 1.0.0)
  * =============================================================================
  * Copyright (c) 2012 Christopher Anderson
+ * Copyright (c) 2017 Dmitry Makarenko
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -33,22 +34,32 @@
  * Constructor(Channel A input pin, Channel B input pin, Pushbutton input pin)
  */
 class RPG{
+    
 public:
     RPG(PinName pA, PinName pB, PinName pPB);
     
-    //Destructor
-    ~RPG();
-    
     //Get Direction 
     int dir();
+    
     //Check Push Button
     bool pb();
 
     
 private:
-    BusInOut chRPG;
+    
+    // Channel A
+    InterruptIn IA;
+    
+    // Channel B
+    DigitalIn B;
+    
+    //Push button
     DigitalIn PB;
-    int RPGO;
-    int RPGN;
+    
+    // Rotation counter (positive value - cw rotation, negative - ccw)
+    int m_dir;
+    
+    // Interrupt handler for channel A, IH for CB is not required
+    void onA();
 };
 #endif
\ No newline at end of file