mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2025-05-18 00:04:56 +02:00
PCF8574 output pin initialization parameter
This commit is contained in:
parent
54f8aaf116
commit
efe1b48c8a
13
IO_PCF8574.h
13
IO_PCF8574.h
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* © 2025 Herb Morton
|
||||
* © 2022 Paul M Antoine
|
||||
* © 2021, Neil McKechnie. All rights reserved.
|
||||
*
|
||||
@ -43,15 +44,21 @@
|
||||
|
||||
class PCF8574 : public GPIOBase<uint8_t> {
|
||||
public:
|
||||
static void create(VPIN firstVpin, uint8_t nPins, I2CAddress i2cAddress, int interruptPin=-1) {
|
||||
if (checkNoOverlap(firstVpin, nPins, i2cAddress)) new PCF8574(firstVpin, nPins, i2cAddress, interruptPin);
|
||||
static void create(VPIN firstVpin, uint8_t nPins, I2CAddress i2cAddress, int interruptPin=-1, int initPortState=-1) {
|
||||
if (checkNoOverlap(firstVpin, nPins, i2cAddress)) new PCF8574(firstVpin, nPins, i2cAddress, interruptPin, initPortState);
|
||||
}
|
||||
|
||||
private:
|
||||
PCF8574(VPIN firstVpin, uint8_t nPins, I2CAddress i2cAddress, int interruptPin=-1)
|
||||
PCF8574(VPIN firstVpin, uint8_t nPins, I2CAddress i2cAddress, int interruptPin=-1, int initPortState=-1)
|
||||
: GPIOBase<uint8_t>((FSH *)F("PCF8574"), firstVpin, nPins, i2cAddress, interruptPin)
|
||||
{
|
||||
requestBlock.setReadParams(_I2CAddress, inputBuffer, 1);
|
||||
if (initPortState>=0) {
|
||||
_portMode = 255; // set all pins to output mode
|
||||
_portInUse = 255; // 8 ports in use
|
||||
_portOutputState = initPortState; // initialize pins low-high 0-255
|
||||
I2CManager.write(_I2CAddress, 1, initPortState);
|
||||
}
|
||||
}
|
||||
|
||||
// The PCF8574 handles inputs by applying a weak pull-up when output is driven to '1'.
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "StringFormatter.h"
|
||||
|
||||
#define VERSION "5.5.25"
|
||||
// - PCF8574 output pin initialization parameter
|
||||
// 5.2.25 - IO_Bitmap and assicated Exrail macros
|
||||
// 5.5.24 - SensorCAM in I2C scan and automatically setClock
|
||||
// 5.5.23 - Reminder loop Idle packet optimization
|
||||
|
Loading…
x
Reference in New Issue
Block a user