Skip to content

daisy::Encoder

Module: LIBDAISY / HUMAN_INTERFACE / CONTROLS

Generic Class for handling Quadrature Encoders Inspired/influenced by Mutable Instruments (pichenettes) Encoder classes. More...

#include <encoder.h>

Public Functions

Name
Encoder()
~Encoder()
void Init(dsy_gpio_pin a, dsy_gpio_pin b, dsy_gpio_pin click, float update_rate =0.f)
void Debounce()
int32_t Increment() const
bool RisingEdge() const
bool FallingEdge() const
bool Pressed() const
float TimeHeldMs() const
void SetUpdateRate(float update_rate)

Detailed Description

class daisy::Encoder;

Generic Class for handling Quadrature Encoders Inspired/influenced by Mutable Instruments (pichenettes) Encoder classes.

Author: Stephen Hensley

Date: December 2019

Public Functions Documentation

function Encoder

inline Encoder()

function ~Encoder

inline ~Encoder()

function Init

void Init(
    dsy_gpio_pin a,
    dsy_gpio_pin b,
    dsy_gpio_pin click,
    float update_rate =0.f
)

Initializes the encoder with the specified hardware pins. Update rate is to be deprecated in a future release


function Debounce

void Debounce()

Called at update_rate to debounce and handle timing for the switch. In order for events not to be missed, its important that the Edge/Pressed checks be made at the same rate as the debounce function is being called.


function Increment

inline int32_t Increment() const

Returns +1 if the encoder was turned clockwise, -1 if it was turned counter-clockwise, or 0 if it was not just turned.


function RisingEdge

inline bool RisingEdge() const

Returns true if the encoder was just pressed.


function FallingEdge

inline bool FallingEdge() const

Returns true if the encoder was just released.


function Pressed

inline bool Pressed() const

Returns true while the encoder is held down.


function TimeHeldMs

inline float TimeHeldMs() const

Returns the time in milliseconds that the encoder has been held down.


function SetUpdateRate

inline void SetUpdateRate(
    float update_rate
)

Parameters:

  • update_rate Does nothing

To be removed in breaking update

---

Updated on 2024-01-03 at 19:41:01 +0000