Deluge Firmware 1.3.0
Build date: 2026.10.14
Loading...
Searching...
No Matches
deluge::hid::encoders::DetentedEncoder Class Reference

#include <encoders.h>

Public Member Functions

 DetentedEncoder (const DetentedEncoder &)=delete
DetentedEncoder & operator= (const DetentedEncoder &)=delete
void apply_edges (int8_t edges)
bool pending () const
 True if any detent steps are waiting to be consumed.
int32_t take ()
 Returns the accumulated signed detent count and resets pos to 0.
void restore (int32_t val)

Private Member Functions

int32_t positiveThreshold () const
int32_t negativeThreshold () const

Private Attributes

int8_t last_direction_ = 0
 Direction of the last reported detent, not the last electrical edge.
int32_t edge_accumulator = 0
 Accumulates quadrature edges until we have a full detent click.
std::atomic_int32_t pos = 0
 Written by the IRQ (apply_edges), drained by the encoder task.

Detailed Description

Black function encoders (SCROLL_X/Y, TEMPO, SELECT) are detented. Four quadrature edges = one detent click. The decoder confirms each edge one edge late, so the first click needs three confirmed edges, continuing needs four, and a reversal needs two (the pending edge is retraced before reverse edges confirm). Partial reverse travel cancels on returning to the detent, without undoing the reported click or discarding forward progress.

Member Function Documentation

◆ restore()

void deluge::hid::encoders::DetentedEncoder::restore ( int32_t val)
inline

Puts a value back (used by the SD card-routine retry path). fetch_add rather than store so a detent that arrived from the IRQ since take() isn't clobbered.


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