Humidistat
Arduino firmware for a humidistat (humidity controller)
Loading...
Searching...
No Matches
ButtonReader Class Reference

Read button state from a voltage ladder-style keypad. More...

#include <ButtonReader.h>

Public Member Functions

 ButtonReader (uint8_t pin_btn, const VoltLadder *voltLadder)
 Constructor.
 
void sample ()
 Sample the button signal. Call this in the main loop.
 
Buttons isPressed () const
 Get the button state.
 
uint32_t getPressedFor () const
 Get the duration the key has been pressed. This can be used for debouncing using a stable interval.
 

Private Attributes

const VoltLadder & voltLadder
 Reference to a voltLadder instance.
 
uint8_t pin_btn
 Pin corresponding to the keypad.
 
Buttons lastState = Buttons::NONE
 Last sampled state of the keypad.
 
unsigned long pressedSince = 0
 Time of the start of the keypress (in micros)
 

Detailed Description

Read button state from a voltage ladder-style keypad.

Definition at line 10 of file ButtonReader.h.

Constructor & Destructor Documentation

◆ ButtonReader()

ButtonReader::ButtonReader ( uint8_t pin_btn,
const VoltLadder * voltLadder )
explicit

Constructor.

Parameters
pin_btnPin corresponding to the keypad
voltLadderPointer to VoltLadder instance

Definition at line 4 of file ButtonReader.cpp.

Member Function Documentation

◆ getPressedFor()

uint32_t ButtonReader::getPressedFor ( ) const

Get the duration the key has been pressed. This can be used for debouncing using a stable interval.

Returns
keypress duration (in micros)

Definition at line 18 of file ButtonReader.cpp.

Here is the caller graph for this function:

◆ isPressed()

Buttons ButtonReader::isPressed ( ) const

Get the button state.

Returns
instance of Buttons corresponding to the currently pressed button

Definition at line 14 of file ButtonReader.cpp.

Here is the caller graph for this function:

◆ sample()

void ButtonReader::sample ( )

Sample the button signal. Call this in the main loop.

Definition at line 6 of file ButtonReader.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ lastState

Buttons ButtonReader::lastState = Buttons::NONE
private

Last sampled state of the keypad.

Definition at line 15 of file ButtonReader.h.

◆ pin_btn

uint8_t ButtonReader::pin_btn
private

Pin corresponding to the keypad.

Definition at line 13 of file ButtonReader.h.

◆ pressedSince

unsigned long ButtonReader::pressedSince = 0
private

Time of the start of the keypress (in micros)

Definition at line 16 of file ButtonReader.h.

◆ voltLadder

const VoltLadder& ButtonReader::voltLadder
private

Reference to a voltLadder instance.

Definition at line 12 of file ButtonReader.h.


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