Basic Encoder Library for Sparkfun's Hall- Effect Encoder Kit Part# ROB-12629

Fork of HALLFX_ENCODER by Bryce Williams

Files at this revision

API Documentation at this revision

Comitter:
PeaceBearer
Date:
Sat May 05 15:26:01 2018 +0000
Parent:
1:f28b876f1fe1
Commit message:
code;

Changed in this revision

Encodeur.cpp Show annotated file Show diff for this revision Revisions of this file
Encodeur.h Show annotated file Show diff for this revision Revisions of this file
diff -r f28b876f1fe1 -r 818c44a8d4ad Encodeur.cpp
--- a/Encodeur.cpp	Wed Apr 11 14:35:54 2018 +0000
+++ b/Encodeur.cpp	Sat May 05 15:26:01 2018 +0000
@@ -14,23 +14,26 @@
 
 void Encodeur::zero(){
     _compteur = 0;
-    _tour = 0;
+    _tour = 0.0;
 }
 
 void Encodeur::incrementer(){
     _compteur++;   
-    _tour += 1/8;
+    _tour = _tour  + 0.125;
 }
-
-long Encodeur::lire_compteur(){
+int Encodeur::lire_compteur(){
     return _compteur;
 }
 
-float Encodeur::lire_tour(){
+double Encodeur::lire_tour(){
     return _tour;
 }
 
 void Encodeur::afficher() const {
-    cout << "compteur = " << _compteur << ", tour = " << _tour << endl;
+    cout << "compteur = " << _compteur << ", tour = " << _tour << ", distance = " << (_tour*3.14*63) << endl;
 }
 
+double Encodeur::distance() {
+    return (_tour*3.14*63);
+}
+
diff -r f28b876f1fe1 -r 818c44a8d4ad Encodeur.h
--- a/Encodeur.h	Wed Apr 11 14:35:54 2018 +0000
+++ b/Encodeur.h	Sat May 05 15:26:01 2018 +0000
@@ -8,13 +8,14 @@
 public:
         Encodeur(PinName encIn);
         void zero();
-        long lire_compteur();
-        float lire_tour();
+        int lire_compteur();
+        double lire_tour();
         void afficher() const;
+        double distance();
         
 protected:
-        long _compteur;         
-        float _tour;
+        int _compteur;         
+        double _tour;
         InterruptIn _enc_in;
         void incrementer();
 };