98 RotaryEncoder(
unsigned int clkPinNumber,
unsigned int dtPinNumber,
unsigned int swPinNumber);
123 virtual void TurnOn()
override;
135 virtual void TurnOff()
override;
162 virtual std::string
ToString()
const override;
Abstract base class for every component (sensor, actuator, etc.) the library manages.
Definition: BaseComponent.h:60
A standard rotary encoder.
Definition: RotaryEncoder.h:19
void SetLastDTStatus(char lastDTStatus)
Sets the DT pin's previous reading.
Definition: RotaryEncoder.cpp:365
unsigned int myDTPinNumber
The DT (data) pin.
Definition: RotaryEncoder.h:32
virtual ~RotaryEncoder()
Destroys the encoder, stopping and joining its listener thread first.
Definition: RotaryEncoder.cpp:67
unsigned int myCLKPinNumber
The CLK (clock) pin.
Definition: RotaryEncoder.h:29
virtual void TurnOff() override
Turns the encoder off: signals the listener thread to stop and waits for it to finish.
Definition: RotaryEncoder.cpp:111
unsigned int GetSWPinNumber() const
Gets the SW (switch / push-button) pin number.
Definition: RotaryEncoder.cpp:259
std::atomic< int > myValue
The running value, incremented or decremented as the knob turns.
Definition: RotaryEncoder.h:44
virtual std::string ToString() const override
Serializes the encoder's pins, value, and pressed state to a string.
Definition: RotaryEncoder.cpp:399
RotaryEncoder(unsigned int clkPinNumber, unsigned int dtPinNumber, unsigned int swPinNumber)
Builds a rotary encoder on the given CLK/DT/SW pins, sets them as inputs, registers this as the activ...
Definition: RotaryEncoder.cpp:25
std::atomic< bool > myHasBeenPressed
Whether the push button has been pressed since the last read (set by the interrupt callback,...
Definition: RotaryEncoder.h:47
static void OnButtonPressedInterrupt()
Interrupt callback for the push-button pin.
Definition: RotaryEncoder.cpp:151
std::atomic< unsigned char > myCurrentDTStatus
The DT pin's current reading (used to detect rotation direction).
Definition: RotaryEncoder.h:38
std::thread myListenerThread
The background thread that watches the encoder pins and updates the value.
Definition: RotaryEncoder.h:23
unsigned char GetLastDTStatus() const
Gets the DT pin's previous reading.
Definition: RotaryEncoder.cpp:293
virtual void TurnOn() override
Turns the encoder on: starts the background listener thread that watches the pins and updates the val...
Definition: RotaryEncoder.cpp:89
int GetValue() const
Gets the encoder's running value (increases/decreases as the knob turns).
Definition: RotaryEncoder.cpp:310
void Update()
The listener-thread loop: watches the CLK/DT pins and increments or decrements the value based on the...
Definition: RotaryEncoder.cpp:176
void SetCurrentDTStatus(char currentDTStatus)
Sets the DT pin's current reading.
Definition: RotaryEncoder.cpp:348
unsigned int GetDTPinNumber() const
Gets the DT (data) pin number.
Definition: RotaryEncoder.cpp:242
std::atomic< unsigned char > myLastDTStatus
The DT pin's previous reading (used to detect rotation direction).
Definition: RotaryEncoder.h:41
unsigned int mySWPinNumber
The SW (switch / push-button) pin.
Definition: RotaryEncoder.h:35
static std::atomic< RotaryEncoder * > theActiveEncoderForISR
The most recently constructed encoder, so the static interrupt callback (wiringPiISR carries no user ...
Definition: RotaryEncoder.h:51
std::atomic< bool > myIsRunning
Whether the listener thread should keep running.
Definition: RotaryEncoder.h:26
unsigned char GetCurrentDTStatus() const
Gets the DT pin's current reading.
Definition: RotaryEncoder.cpp:276
virtual void ProcessRawValues() override
Processes the encoder's raw values.
Definition: RotaryEncoder.cpp:134
void SetValue(int val)
Sets the encoder's running value.
Definition: RotaryEncoder.cpp:382
unsigned int GetCLKPinNumber() const
Gets the CLK (clock) pin number.
Definition: RotaryEncoder.cpp:225
bool ConsumePressed()
Gets whether the push button has been pressed since the last call, then clears the pressed state so e...
Definition: RotaryEncoder.cpp:331
RumPi is the library's top-level facade.
Definition: AlertManager.h:6