uses attachInterrupt() platform: esp32, teensy (could be used with standard avr arduinos but only with pins that support attachInterrupt())
More...
#include <JEncoderSingleAttachInterrupt.h>
|
| JEncoderSingleAttachInterrupt (byte _encoderPin, float _distPerCountFactor=1.0, bool _reverse=false, unsigned long _slowestIntervalMicros=100000UL, unsigned long _switchBounceIntervalMicros=0, byte _interruptType=CHANGE) |
| constructor, sets pins and settings
|
|
void | setUpInterrupts (void(*_isrPointer)(void)) |
|
void | turnOffInterrupts () |
| disable interrupts and stop monitoring encoder
|
|
bool | getRev () |
| get whether the encoder is told it's going backwards currently
|
|
void | setRev (bool _rev) |
| set which direction the encoder is moving (if you have external information about direction (like motor power) and want getVel and getDist to go the right direction even with this directionless encoder)
|
|
long | zeroCounter () |
| reset the counter of how far the encoder has turned
|
|
float | getVel () |
| calculates velocity in distance per second where distance was set by setdistPerCountFactor()
|
|
long | getCounter () |
| returns how far the encoder has turned from the zero position
|
|
float | getPos () |
| returns how far the encoder has turned from the zero position converted to distance
|
|
float | getDistPerCountFactor () |
| returns a conversion factor between encoder ticks and distance that can be set for the encoder
|
|
void | setDistPerCountFactor (float _factor) |
| set the conversion factor between encoder ticks and distance
|
|
void | setReverse (bool _reverse) |
| reverse readings of encoder
|
|
bool | hasDirection () |
| can this encoder measure direction or just speed
|
|
bool | isVelNew () |
| could be useful for only recalculating a control loop if there's new velocity data
|
|
void | run () |
| if an encoder needs to have some code called each loop (like absolute encoder polling encoder and calculating amount turned)
|
|
void | encoderISR (void) |
|
|
| JEncoderSingle (byte _encoderPin, float _distPerCountFactor, bool _reverse, unsigned long _slowestIntervalMicros, unsigned long _switchBounceIntervalMicros, byte _interruptType) |
| constructor, sets pins and settings
|
|
unsigned char | encoderPin |
|
byte | interruptType |
|
uses attachInterrupt() platform: esp32, teensy (could be used with standard avr arduinos but only with pins that support attachInterrupt())
- Note
- make sure to call setUpInterrupts() when your code starts
◆ JEncoderSingleAttachInterrupt()
JEncoderSingleAttachInterrupt::JEncoderSingleAttachInterrupt |
( |
byte |
_encoderPin, |
|
|
float |
_distPerCountFactor = 1.0 , |
|
|
bool |
_reverse = false , |
|
|
unsigned long |
_slowestIntervalMicros = 100000UL , |
|
|
unsigned long |
_switchBounceIntervalMicros = 0 , |
|
|
byte |
_interruptType = CHANGE |
|
) |
| |
|
inline |
constructor, sets pins and settings
- Parameters
-
_encoderPin | encoder input pin, or, if they are different, interrupt number |
_distPerCountFactor | conversion factor for getting distance in an actual unit |
_reverse | false(default) |
_slowestIntervalMicros | after this many microseconds without an encoder tick velocity is set to zero. |
_switchBounceIntervalMicros | ignore additional pulses for this many microseconds after each pulse |
_interruptType | counts on RISING, FALLING, or CHANGE interrupt |
◆ setUpInterrupts()
void JEncoderSingleAttachInterrupt::setUpInterrupts |
( |
void(*)(void) |
_isrPointer | ) |
|
|
inlinevirtual |
- Note
- interrupt created by jENCODER_SINGLE_MAKE_ISR_MACRO(name of encoder) will be of the form <name of encoder instance>_jENCODER_ISR
Reimplemented from JEncoderSingle.
◆ turnOffInterrupts()
void JEncoderSingleAttachInterrupt::turnOffInterrupts |
( |
| ) |
|
|
inlinevirtual |
disable interrupts and stop monitoring encoder
- Note
- use setUpInterrupts to start encoder again
Reimplemented from JEncoderSingle.
The documentation for this class was generated from the following file: