InputEvents v1.4.0
An easy to use but comprehensive Event Library for Buttons, Encoders, Encoder Buttons, Analog Inputs, Joysticks and Switches.
Public Member Functions | List of all members
GpioPinAdapter Class Reference

Description

This is the default PinAdapter for regular GPIO pins.

#include <GpioPinAdapter.h>

Inheritance diagram for GpioPinAdapter:
Inheritance graph
[legend]

Public Member Functions

 GpioPinAdapter (byte pin, uint8_t mode=INPUT_PULLUP)
 Construct a new Gpio Pin Adapter. More...
 
void begin ()
 Initialise the pin adapter. Must be safe for repeated calls (Idempotent) More...
 
bool read ()
 Read the current state of the pin. More...
 
virtual void begin ()=0
 Initialise the pin adapter. Must be safe for repeated calls (Idempotent) More...
 
virtual bool read ()=0
 Read the current state of the pin. More...
 

Constructor & Destructor Documentation

◆ GpioPinAdapter()

GpioPinAdapter::GpioPinAdapter ( byte  pin,
uint8_t  mode = INPUT_PULLUP 
)
inline

Construct a new Gpio Pin Adapter.

By default this PinAdapter will set the pinMode to INPUT_PULLUP

If you pass mode value as HIGH, you must also set EventButton::setPressedState(), EventEncoderButton::setPressedState() or EventSwitch::setOnState() to HIGH

If your board does not support INPUT_PULLDOWN, pass INPUT and use an external resistor.

Parameters
pinThe regular GPIO pin number
pinModeDefaults to INPUT_PULLUP.

Member Function Documentation

◆ begin()

void GpioPinAdapter::begin ( )
inlinevirtual

Initialise the pin adapter. Must be safe for repeated calls (Idempotent)

Implements PinAdapter.

◆ read()

bool GpioPinAdapter::read ( )
inlinevirtual

Read the current state of the pin.

Returns
true/HIGH
false/LOW

Implements PinAdapter.


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