rotary encoder class
More...
#include <NoiascaEncoder.h>
◆ Encoder() [1/2]
Encoder::Encoder |
( |
byte |
pinA, |
|
|
byte |
pinB |
|
) |
| |
|
inline |
constructor for encoder
This constructor is used for a simple rotary encoder connected to two pins.
- Parameters
-
pinA | the first GPIO |
pinB | the second GPIO |
◆ Encoder() [2/2]
Encoder::Encoder |
( |
byte |
pinA, |
|
|
byte |
pinB, |
|
|
CallBack |
funcUpPtr, |
|
|
CallBack |
funcDownPtr |
|
) |
| |
|
inline |
constructor for encoder
This constructor is used for a simple rotary encoder connected to two pins and to define two callback functions fired when the encoder is moved.
- Parameters
-
pinA | the first GPIO |
pinB | the second GPIO |
funcUpPtr | a callback function to be called when the rotary encoder is moved to the right/increase |
funcDownPtr | a callback function to be called when the rotary encoder is moved to the left/decrease |
◆ begin()
start hardware
call this function in your setup(). It is necessary to set the pins accordingly.
◆ encode()
function to be called in the background
This is the run method of the class. For usual this function is called internally. Call encode() in loop if you are only using the callback functions.
◆ getDirection()
int8_t Encoder::getDirection |
( |
| ) |
|
|
inline |
get current direction
Returns 1 (clockwise) or -1 (counter clockwise) depending on the rotary usage.
- Returns
- the current direction: 1 (clockwise) or -1 (counter clockwise)
◆ getCounter()
int32_t Encoder::getCounter |
( |
| ) |
|
|
inline |
get internal counter value
Returns the internal counter - a signed 32 bit variable.
- Returns
- the internal counter
◆ read()
int32_t Encoder::read |
( |
| ) |
|
|
inline |
get actual counter value.
alias function of getCounter for compatibily with Paul Stoffregen encoder library.
- See also
- getCounter
◆ setCounter()
void Encoder::setCounter |
( |
int32_t |
newValue | ) |
|
|
inline |
set actual countnr value.
- Parameters
-
newValue | the new value for the internal counter |
◆ write()
void Encoder::write |
( |
int32_t |
newValue | ) |
|
|
inline |
set actual coutner value.
alias function for setCounter for compatibily with Paul Stoffregen encoder library.
- Parameters
-
newValue | the new value for the internal counter |
- See also
- setCounter
◆ upClick()
bool Encoder::upClick |
( |
| ) |
|
|
inline |
gets true if rotary encoder is moved to the right
- Returns
- true when moved to right / clockwise
◆ downClick()
bool Encoder::downClick |
( |
| ) |
|
|
inline |
gets true if rotary encoder is moved to the left
- Returns
- true when moved to left / counter clockwise