Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of HALLFX_ENCODER by
Encodeur.cpp
00001 #include "Encodeur.h" 00002 #include <iostream> 00003 00004 using namespace std; 00005 00006 Encodeur::Encodeur(PinName enc_in): _enc_in(enc_in){ 00007 00008 _enc_in.mode(PullUp); 00009 00010 // Invoke interrupt on both falling and rising edges 00011 _enc_in.fall(callback(this, &Encodeur::incrementer)); 00012 _enc_in.rise(callback(this, &Encodeur::incrementer)); 00013 } 00014 00015 void Encodeur::zero(){ 00016 _compteur = 0; 00017 _tour = 0.0; 00018 } 00019 00020 void Encodeur::incrementer(){ 00021 _compteur++; 00022 _tour = _tour + 0.125; 00023 } 00024 int Encodeur::lire_compteur(){ 00025 return _compteur; 00026 } 00027 00028 double Encodeur::lire_tour(){ 00029 return _tour; 00030 } 00031 00032 void Encodeur::afficher() const { 00033 cout << "compteur = " << _compteur << ", tour = " << _tour << ", distance = " << (_tour*3.14*63) << endl; 00034 } 00035 00036 double Encodeur::distance() { 00037 return (_tour*3.14*63); 00038 } 00039
Generated on Thu Jul 14 2022 17:37:30 by
1.7.2
