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

Class for buttons attached to a PCF8574 GPIO expander. More...

#include <InputHardware.hpp>

Public Member Functions

 PCF8574ButtonsInput (const PCF8574Expander &inputNumbers, uint8_t address7Bits, I2CBus bus=I2CBus::PRIMARY)
 Construct a new PCF8574ButtonsInput object.
 
virtual uint64_t read (uint64_t lastState) override
 Read the current state of the inputs (pressed or released)
 
- Public Member Functions inherited from I2CInput
 I2CInput (uint8_t address7Bits, I2CBus bus=I2CBus::PRIMARY, uint8_t max_speed_mult=1)
 Construct a new I2CButtonsInput object.
 
- Public Member Functions inherited from DigitalInput

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.
 
- Protected Attributes inherited from I2CInput
void * device = nullptr
 Slave device in the I2C API (must be type-casted)
 

Detailed Description

Class for buttons attached to a PCF8574 GPIO expander.

Definition at line 342 of file InputHardware.hpp.

Constructor & Destructor Documentation

◆ PCF8574ButtonsInput()

PCF8574ButtonsInput::PCF8574ButtonsInput ( const PCF8574Expander & inputNumbers,
uint8_t address7Bits,
I2CBus bus = I2CBus::PRIMARY )

Construct a new PCF8574ButtonsInput object.

Parameters
inputNumbersSpecification of inputs
address7BitsI2C address in 7 bits format
busBus where the chip is attached to

Member Function Documentation

◆ read()

virtual uint64_t PCF8574ButtonsInput::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.


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