AbleButtons V0.4.0
Lightweight button library for Arduino.
 
Loading...
Searching...
No Matches
able::Pin Class Reference

Pin base class reading direct from the pin (without debouncing). More...

#include <Pins.h>

+ Inheritance diagram for able::Pin:

Protected Member Functions

 Pin (uint8_t pin, uint8_t initState)
 Protected constructor used by sub-classes. More...
 
void readPin ()
 Read the pin directly. More...
 
int clicks (uint8_t pressed, uint8_t released)
 Return the number of clicks. More...
 

Static Protected Member Functions

static uint8_t nextId ()
 Return the next auto-assigned button identifier. More...
 

Protected Attributes

uint8_t pin_
 The Arduino pin connected to the button. More...
 
uint8_t currState_
 The reading of the pin. More...
 

Static Protected Attributes

static uint8_t autoId_ = 0
 Auto-assigned button identifier. More...
 

Detailed Description

Pin base class reading direct from the pin (without debouncing).

Other pins inherit directly/indirectly from this base class. This class cannot be instantiated directly. Instantiation comes through Button sub-classes.

Definition at line 17 of file Pins.h.

Constructor & Destructor Documentation

◆ Pin()

able::Pin::Pin ( uint8_t  pin,
uint8_t  initState 
)
inlineprotected

Protected constructor used by sub-classes.

Use a Button sub-class instead of this class directly.

Parameters
pinThe pin to read from.
initStateThe initial (un-pushed) state of the button.

Definition at line 45 of file Pins.h.

Member Function Documentation

◆ clicks()

int able::Pin::clicks ( uint8_t  pressed,
uint8_t  released 
)
inlineprotected

Return the number of clicks.

Parameters
pressedThe pressed state of a button.
releasedThe released state of a button.
Returns
Always no clicks (0) as clicks not supported by default.

Definition at line 83 of file Pins.h.

◆ nextId()

static uint8_t able::Pin::nextId ( )
inlinestaticprotected

Return the next auto-assigned button identifier.

Returns
The next auto-assigned button identifier. Each call increases the auto-assigned identifier.

Definition at line 29 of file Pins.h.

◆ readPin()

void able::Pin::readPin ( )
inlineprotected

Read the pin directly.

In order to save memory, virtual functions are not used (which can consume almost 1K of memory to deal with). Runtime polymorphism is not required, so avoiding virtual functions saves memory.

Definition at line 66 of file Pins.h.

Member Data Documentation

◆ autoId_

uint8_t able::Pin::autoId_ = 0
staticprotected

Auto-assigned button identifier.

Definition at line 91 of file Pins.h.

◆ currState_

uint8_t able::Pin::currState_
protected

The reading of the pin.

Definition at line 94 of file Pins.h.

◆ pin_

uint8_t able::Pin::pin_
protected

The Arduino pin connected to the button.

Definition at line 93 of file Pins.h.


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