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.h@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 | #ifndef ENCODER_H |
| rpatelpj | 11:531208aca075 | 2 | #define ENCODER_H |
| rpatelpj | 11:531208aca075 | 3 | |
| rpatelpj | 11:531208aca075 | 4 | #include "globals.h" |
| rpatelpj | 11:531208aca075 | 5 | |
| rpatelpj | 11:531208aca075 | 6 | /** |
| rpatelpj | 11:531208aca075 | 7 | * Hall Effect Encoder (ROB-12629) bare-metal I/O driver class. |
| rpatelpj | 11:531208aca075 | 8 | * For more details, visit https://www.sparkfun.com/products/12629 |
| rpatelpj | 11:531208aca075 | 9 | * Fork of https://os.mbed.com/users/electromotivated/code/HALLFX_ENCODER/ |
| rpatelpj | 11:531208aca075 | 10 | */ |
| rpatelpj | 11:531208aca075 | 11 | class Encoder{ |
| rpatelpj | 11:531208aca075 | 12 | public: |
| rpatelpj | 11:531208aca075 | 13 | /** |
| rpatelpj | 11:531208aca075 | 14 | * Encoder constructor. Connect to 3.3 V. |
| rpatelpj | 11:531208aca075 | 15 | * @param trig mbed pin receiving encoder trigger |
| rpatelpj | 11:531208aca075 | 16 | */ |
| rpatelpj | 11:531208aca075 | 17 | Encoder(PinName trig); |
| rpatelpj | 11:531208aca075 | 18 | |
| rpatelpj | 11:531208aca075 | 19 | /** |
| rpatelpj | 11:531208aca075 | 20 | * Encoder destructor. |
| rpatelpj | 11:531208aca075 | 21 | */ |
| rpatelpj | 11:531208aca075 | 22 | ~Encoder(); |
| rpatelpj | 11:531208aca075 | 23 | |
| rpatelpj | 11:531208aca075 | 24 | /** |
| rpatelpj | 11:531208aca075 | 25 | * Read encoder count. |
| rpatelpj | 11:531208aca075 | 26 | * @return encoder count |
| rpatelpj | 11:531208aca075 | 27 | */ |
| rpatelpj | 11:531208aca075 | 28 | int read(); |
| rpatelpj | 11:531208aca075 | 29 | |
| rpatelpj | 11:531208aca075 | 30 | /** |
| rpatelpj | 11:531208aca075 | 31 | * Reset encoder count. |
| rpatelpj | 11:531208aca075 | 32 | */ |
| rpatelpj | 11:531208aca075 | 33 | void reset(); |
| rpatelpj | 11:531208aca075 | 34 | |
| rpatelpj | 11:531208aca075 | 35 | private: |
| rpatelpj | 11:531208aca075 | 36 | int count; |
| rpatelpj | 11:531208aca075 | 37 | InterruptIn _trig; |
| rpatelpj | 11:531208aca075 | 38 | void increment(); |
| rpatelpj | 11:531208aca075 | 39 | }; |
| rpatelpj | 11:531208aca075 | 40 | |
| rpatelpj | 11:531208aca075 | 41 | #endif /* ENCODER_H */ |
