Sound Byte Libs 0.5.1-340-gab5b79a
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
sbl::control::input::Encoder Class Reference

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

Detailed Description

Quadrature encoder with Gray code state machine and position tracking.

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

Definition at line 30 of file encoder.hpp.

#include <encoder.hpp>

Public Member Functions

 Encoder ()
 Construct at position 0 with both phases low.
 
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.
 

Constructor & Destructor Documentation

◆ Encoder()

sbl::control::input::Encoder::Encoder ( )
inline

Construct at position 0 with both phases low.

Definition at line 33 of file encoder.hpp.

Member Function Documentation

◆ update()

void sbl::control::input::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.

◆ delta()

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

Steps since last delta() call.

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

Definition at line 88 of file encoder.hpp.

◆ position()

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

Cumulative position (does not reset)

Definition at line 95 of file encoder.hpp.

◆ reset()

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

Reset all state.

Definition at line 98 of file encoder.hpp.


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