IoAbstraction
Loading...
Searching...
No Matches
StateMachineEncoder.h File Reference

The statemachine encoder class provides an interrupt or timer based rotary encoder. Fulfills the regular rotary encoder interface in IoAbstraction with an interrupt based rotary encoder. In an ideal world the encoder should have debounce capacitors near the encoder end, but this class should be fairly resistant to noise within reason. NOTE that unlike previous implementations, this does require either both pins are interrupt driven, a separate interrupt pin that is effectively A or B, or a timer interrupt. It is not possible to use this version without an interrupt or timer or over I2C. For this see the other rotary encoder implementations. More...

Go to the source code of this file.

Classes

class  StateRotaryEncoderBuilder

Enumerations

enum class  EncoderInterruptMode { SINGLE_PIN , ALL_PINS , TIMER , NONE }

Functions

ISR_ATTR void encoderInterruptHandler ()
bool setupStateMachineRotaryEncoder (const StateRotaryEncoderBuilder &builder)

Detailed Description

The statemachine encoder class provides an interrupt or timer based rotary encoder. Fulfills the regular rotary encoder interface in IoAbstraction with an interrupt based rotary encoder. In an ideal world the encoder should have debounce capacitors near the encoder end, but this class should be fairly resistant to noise within reason. NOTE that unlike previous implementations, this does require either both pins are interrupt driven, a separate interrupt pin that is effectively A or B, or a timer interrupt. It is not possible to use this version without an interrupt or timer or over I2C. For this see the other rotary encoder implementations.

Enumeration Type Documentation

◆ EncoderInterruptMode

enum class EncoderInterruptMode
strong

The supported interrupt modes, note that NONE is not supported and a form of interrupt must be provided.

Enumerator
SINGLE_PIN 

The interrupt will be registered on a single pin that is effectively A or B.

ALL_PINS 

An interrupt will be registered on both A and B pin

TIMER 

You are responsible for configuring the timer interrupt (or regular interrupts on pins A and B)

NONE 

This is just the initial case, it is a not valid marker

Function Documentation

◆ encoderInterruptHandler()

ISR_ATTR void encoderInterruptHandler ( )

When in timer mode, IE you're responsible for configuring the timer interrupt (or regular interrupts on pins A and B) then you must call this method from your timer interrupt handler.

◆ setupStateMachineRotaryEncoder()

bool setupStateMachineRotaryEncoder ( const StateRotaryEncoderBuilder & builder)
inline

Configures a state machine rotary encoder that must either be configured to run through a timer or an interrupt. See the StateRotaryEncoderBuilder for more information about options and configuration.

See also
StateRotaryEncoderBuilder
Parameters
buildera description of how to build the encoder
Returns
true if the encoder was successfully built, false otherwise