|
upm
1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
|
API for the DFRobot Wheel Encoder. More...
This sensor was developed for the DFRobot Wheel Encoder, though it could be used for any counting time-based task.
When you instantiate a class of this type, the gpio pin specified is connected to an interrupt. Whenever a low to high transition occurs on the gpio pin, the internal counter is incremented by one.
This class also includes a millisecond counter, so that you can correlate the number of counts to a time period for calculating an RPM or other value as needed.
Public Member Functions | |
| WheelEncoder (int pin) | |
| ~WheelEncoder () | |
| uint32_t | getMillis () |
| void | initClock () |
| void | clearCounter () |
| void | startCounter () |
| void | stopCounter () |
| uint32_t | counter () |
Static Protected Member Functions | |
| static void | wheelISR (void *ctx) |
Protected Attributes | |
| mraa::Gpio | m_gpio |
| WheelEncoder | ( | int | pin | ) |
DFRobot Wheel Encoder sensor constructor
| pin | Digital pin to use |

| ~WheelEncoder | ( | ) |
| uint32_t getMillis | ( | ) |
Returns the number of milliseconds elapsed since initClock() was last called.
| void initClock | ( | ) |
Resets the clock

|
inline |
Resets the counter to 0. The counter should be stopped via stopCounter() prior to calling this function.

| void startCounter | ( | ) |
Starts the counter. This function will also clear the current count and reset the clock.


| void stopCounter | ( | ) |
Stops the counter

|
inline |
Gets the current counter value
1.8.11