OpenSourceSimWheelESP32
Open-source wireless steering wheel/button box for ESP32 boards
Loading...
Searching...
No Matches
RotaryEncoderInput Class Reference

Relative Rotary Encoder. More...

#include <InputHardware.hpp>

Public Member Functions

 RotaryEncoderInput (InputGPIO clkPin, InputGPIO dtPin, InputNumber cwButtonNumber, InputNumber ccwButtonNumber, bool useAlternateEncoding=false)
 Construct a new Rotary Encoder Input object.
 
virtual uint64_t read (uint64_t lastState) override
 Read the current state of the inputs (pressed or released)
 
- Public Member Functions inherited from DigitalInput

Static Public Member Functions

static bool setPulseMultiplier (uint8_t multiplier)
 Set a time multiplier for "pulse" events.
 

Static Public Attributes

static uint8_t pulseMultiplier = 1
 Pulse multiplier for rotary encoders.
 

Additional Inherited Members

- Public Attributes inherited from DigitalInput
uint64_t mask = ~0ULL
 Input mask. For read-only.
 
- Protected Member Functions inherited from DigitalInput
void addToMask (uint64_t bitmap)
 Add an input bitmap to the current mask.
 

Detailed Description

Relative Rotary Encoder.

Definition at line 103 of file InputHardware.hpp.

Constructor & Destructor Documentation

◆ RotaryEncoderInput()

RotaryEncoderInput::RotaryEncoderInput ( InputGPIO clkPin,
InputGPIO dtPin,
InputNumber cwButtonNumber,
InputNumber ccwButtonNumber,
bool useAlternateEncoding = false )

Construct a new Rotary Encoder Input object.

Parameters
[in]clkPinGPIO pin attached to the "CLK" (or "A") pin of the encoder.
[in]dtPinGPIO pin attached to the "DT" (or "B") pin of the encoder.
[in]cwButtonNumberA number for the "virtual button" of a clockwise rotation event.
[in]ccwButtonNumberA number for the "virtual button" of a counter-clockwise rotation event. If not given, cwButtonNumber+1 is used.
[in]useAlternateEncodingSet to true in order to use the signal encoding of ALPS RKJX series of rotary encoders, and the alike.
Note
Internal pullup resistors will be enabled when available.

Member Function Documentation

◆ read()

virtual uint64_t RotaryEncoderInput::read ( uint64_t lastState)
overridevirtual

Read the current state of the inputs (pressed or released)

Warning
This function must not set any bit outside of the input bitmask in the return value.
Parameters
lastStateState of the same inputs as recorded in the previous iteration. Whether the current state is unknown, lastState must be returned (properly masked). Must be set to zero at first call.
Returns
uint64_t Current state of the inputs (a bit set to 1 means a pressed button).

Implements DigitalInput.

◆ setPulseMultiplier()

static bool RotaryEncoderInput::setPulseMultiplier ( uint8_t multiplier)
inlinestatic

Set a time multiplier for "pulse" events.

Parameters
multiplierA time multiplier between 1 and 6. Invalid values are ignored.
Returns
true if the multiplier has changed.
false otherwise.

Definition at line 159 of file InputHardware.hpp.

Member Data Documentation

◆ pulseMultiplier

uint8_t RotaryEncoderInput::pulseMultiplier = 1
inlinestatic

Pulse multiplier for rotary encoders.

Note
For read only. Do not overwrite. Always greater than zero.

Definition at line 130 of file InputHardware.hpp.


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