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.
Diff: shared/QEI/QEI.cpp
- Revision:
- 0:ee7e9405e1c7
diff -r 000000000000 -r ee7e9405e1c7 shared/QEI/QEI.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/shared/QEI/QEI.cpp Wed Apr 14 07:26:19 2021 +0000
@@ -0,0 +1,29 @@
+#include "QEI.h"
+
+QEI::QEI(int edge_per_revolution)
+ :_edge_per_revolution(edge_per_revolution)
+{}
+
+int QEI::read()
+{
+ return _read();
+}
+
+void QEI::write(int32_t count)
+{
+ _write(count);
+}
+
+void QEI::reset()
+{
+ _write(0);
+}
+
+double QEI::get_ang()
+{
+ return ((double)read() / (double)_edge_per_revolution) * (2 * M_PI); //[rad]
+}
+
+double QEI::get_ang_vel(){
+ return (_get_pps() / (double)_edge_per_revolution) * (2 * M_PI); //[rad/s]
+}
\ No newline at end of file