Sound Byte Libs 29c5ff3
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
Public Member Functions | List of all members
sbl::components::control::Encoder Class Reference

Quadrature encoder with Gray code state machine and position tracking. More...

#include <encoder.hpp>

Collaboration diagram for sbl::components::control::Encoder:

Public Member Functions

 Encoder ()
 
void update (bool a, bool b)
 Feed quadrature signals.
 
int32_t delta ()
 Steps since last delta() call.
 
int32_t position () const
 Cumulative position (does not reset)
 
void reset ()
 Reset all state.
 

Detailed Description

Quadrature encoder with Gray code state machine and position tracking.

Note
All public methods are ISR-safe — pure state machine with no hardware I/O.

Definition at line 31 of file encoder.hpp.

Constructor & Destructor Documentation

◆ Encoder()

sbl::components::control::Encoder::Encoder ( )
inline

Definition at line 33 of file encoder.hpp.

Member Function Documentation

◆ delta()

int32_t sbl::components::control::Encoder::delta ( )
inline

Steps since last delta() call.

Positive = CW, negative = CCW. Resets on read.

Definition at line 76 of file encoder.hpp.

◆ position()

int32_t sbl::components::control::Encoder::position ( ) const
inline

Cumulative position (does not reset)

Definition at line 83 of file encoder.hpp.

◆ reset()

void sbl::components::control::Encoder::reset ( )
inline

Reset all state.

Definition at line 86 of file encoder.hpp.

◆ update()

void sbl::components::control::Encoder::update ( bool  a,
bool  b 
)
inline

Feed quadrature signals.

Call once per update cycle with current A and B readings. The state machine detects CW/CCW transitions and accumulates delta.

Parameters
aChannel A reading
bChannel B reading

Definition at line 44 of file encoder.hpp.

Referenced by sbl::encoder::read().

Here is the caller graph for this function:

The documentation for this class was generated from the following file: