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.
Dependencies: mbed mbed-rtos Motor LSM9DS1_Library_cal X_NUCLEO_53L0A1
Encoder.cpp@11:531208aca075, 2019-04-23 (annotated)
- Committer:
- rpatelpj
- Date:
- Tue Apr 23 19:56:39 2019 +0000
- Revision:
- 11:531208aca075
Remove HALLFX_ENCODER lib, create and implement Encoder class, include Imu lib, implement RobotController angular position tracking and destructor
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| rpatelpj | 11:531208aca075 | 1 | #include "Encoder.h" |
| rpatelpj | 11:531208aca075 | 2 | |
| rpatelpj | 11:531208aca075 | 3 | Encoder::Encoder(PinName trig): _trig(trig) { |
| rpatelpj | 11:531208aca075 | 4 | _trig.mode(PullUp); |
| rpatelpj | 11:531208aca075 | 5 | _trig.rise(this, &Encoder::increment); |
| rpatelpj | 11:531208aca075 | 6 | count = 0; |
| rpatelpj | 11:531208aca075 | 7 | } |
| rpatelpj | 11:531208aca075 | 8 | |
| rpatelpj | 11:531208aca075 | 9 | Encoder::~Encoder() { |
| rpatelpj | 11:531208aca075 | 10 | delete &_trig; |
| rpatelpj | 11:531208aca075 | 11 | } |
| rpatelpj | 11:531208aca075 | 12 | |
| rpatelpj | 11:531208aca075 | 13 | int Encoder::read() { |
| rpatelpj | 11:531208aca075 | 14 | return count; |
| rpatelpj | 11:531208aca075 | 15 | } |
| rpatelpj | 11:531208aca075 | 16 | |
| rpatelpj | 11:531208aca075 | 17 | void Encoder::reset() { |
| rpatelpj | 11:531208aca075 | 18 | count = 0; |
| rpatelpj | 11:531208aca075 | 19 | } |
| rpatelpj | 11:531208aca075 | 20 | |
| rpatelpj | 11:531208aca075 | 21 | void Encoder::increment() { |
| rpatelpj | 11:531208aca075 | 22 | count = count + 1; |
| rpatelpj | 11:531208aca075 | 23 | } |
