12 #ifndef _IOABSTRACTION_IOABSTRACTIONWIRE_H_
13 #define _IOABSTRACTION_IOABSTRACTIONWIRE_H_
18 #define LED_CURRENT_OUTPUT 0x99
19 #define AW9523_LED_OUTPUT LED_CURRENT_OUTPUT
21 #include "PlatformDeterminationWire.h"
33 enum { NEEDS_WRITE_FLAG, PINS_CONFIGURED_READ_FLAG, PCF8575_16BIT_FLAG, INVERTED_LOGIC };
50 PCF8574IoAbstraction(uint8_t addr, uint8_t interruptPin, WireType wireInstance =
nullptr,
bool mode16bit =
false,
bool invertedLogic =
false);
65 void writeValue(pinid_t pin, uint8_t value)
override;
75 void writePort(pinid_t pin, uint8_t port)
override;
80 uint8_t
readPort(pinid_t pin)
override;
87 void attachInterrupt(pinid_t pin, RawIntHandler intHandler, uint8_t mode)
override;
100 virtual void initDevice()=0;
105 void writeValue(pinid_t pin, uint8_t value)
override;
107 void writePort(pinid_t pin, uint8_t port)
override;
108 uint8_t
readPort(pinid_t pin)
override;
109 void clearChangeFlags();
110 void setReadPort(
int port);
111 bool isReadPortSet(
int port)
const;
112 bool isWritePortSet(
int port)
const;
113 bool isInitNeeded()
const;
114 void markInitialised();
122 NOT_ENABLED = 0, ACTIVE_HIGH_OPEN = 0b110, ACTIVE_LOW_OPEN = 0b100, ACTIVE_HIGH = 0b010, ACTIVE_LOW = 0b000
171 void attachInterrupt(pinid_t pin, RawIntHandler intHandler, uint8_t mode)
override;
199 void initDevice()
override;
212 pinid_t interruptPin;
214 enum AW9523CurrentControl: uint8_t { FULL_CURRENT = 0, CURRENT_THREE_QUARTER = 1, CURRENT_HALF = 2, CURRENT_QUARTER = 3 };
225 explicit AW9523IoAbstraction(uint8_t addr, pinid_t intPin = IO_PIN_NOT_DEFINED, WireType wirePtr =
nullptr);
248 void attachInterrupt(pinid_t pin, RawIntHandler intHandler, uint8_t mode)
override;
270 void writeGlobalControl(
bool pushPullP0, AW9523CurrentControl maxCurrentMode = FULL_CURRENT);
277 void initDevice()
override;
299 float getCurrentFloat(pinid_t pin)
override {
return NAN; }
312 #define MPR121_FIRST_GPIO 4
313 #define MPR121_TOTAL_PINS 13
314 #define MPR121_PROXIMITY_PIN 12
316 #define MPR121_TOUCH_STATUS_16 0x00
317 #define MPR121_OOR_STATUS_16 0x02
318 #define MPR121_ELECTRODE_DATA_2ND 0x04
319 #define MPR121_BASELINE_DATA_3RD 0x1E
320 #define MPR121_MHD_RISING 0x2B
321 #define MPR121_NHD_RISING 0x2C
322 #define MPR121_NCL_RISING 0x2D
323 #define MPR121_FDL_RISING 0x2E
324 #define MPR121_MHD_FALLING 0x2F
325 #define MPR121_NHD_FALLING 0x30
326 #define MPR121_NCL_FALLING 0x31
327 #define MPR121_FDL_FALLING 0x32
328 #define MPR121_NHD_TOUCHED 0x33
329 #define MPR121_NCL_TOUCHED 0x34
330 #define MPR121_FDL_TOUCHED 0x35
331 #define MPR121_TCH_REL_THRESHOLD 0x41
332 #define MPR121_DEBOUNCE_REG 0x5B
333 #define MPR121_AFE_CONFIG_1 0x5C
334 #define MPR121_AFE_CONFIG_2 0x5D
335 #define MPR121_ELECTRODE_CONFIG 0x5E
336 #define MPR121_ELECTRODE_CURRENT_0 0x5F
337 #define MPR121_CHARGE_TIME_0 0x6C
338 #define MPR121_GPIO_CONTROL_0 0x73
339 #define MPR121_GPIO_CONTROL_1 0x74
340 #define MPR121_GPIO_DATA 0x75
341 #define MPR121_GPIO_DIRECTION_0 0x76
342 #define MPR121_GPIO_ENABLE 0x77
343 #define MPR121_GPIO_DATA_SET 0x78
344 #define MPR121_GPIO_DATA_CLEAR 0x79
345 #define MPR121_GPIO_DATA_TOGGLE 0x7A
346 #define MPR121_AUTO_CONFIG_0 0x7B
347 #define MPR121_AUTO_CONFIG_1 0x7C
348 #define MPR121_UPPER_LIMIT 0x7D
349 #define MPR121_LOWER_LIMIT 0x7E
350 #define MPR121_TARGET_LIMIT 0x7F
351 #define MPR121_SOFT_RESET 0x80
352 #define MPR121_SOFT_RESET_VALUE 0x63
353 #define MPR121_LED_PWM_0 0x81
354 #define MPR121_LED_PWM_1 0x82
355 #define MPR121_LED_PWM_2 0x83
356 #define MPR121_LED_PWM_3 0x84
377 pinid_t interruptPin;
378 pinid_t maximumTouchPin = 0;
389 explicit MPR121IoAbstraction(uint8_t addr, pinid_t intPin = IO_PIN_NOT_DEFINED, WireType wirePtr =
nullptr);
402 void begin(
int maxTouchPin,
MPR121ConfigType configType, uint8_t configReg1 = 0x10, uint8_t configReg2 = 0x20);
417 void attachInterrupt(pinid_t pin, RawIntHandler intHandler, uint8_t mode)
override;
435 void electrodeSettingsForPin(pinid_t pin, uint8_t touchThreshold, uint8_t releaseThreshold, uint8_t current=0, uint8_t chargeTime=0);
471 void initDevice()
override { }
473 void writeReg8(uint8_t reg, uint8_t data);
474 void writeReg16(uint8_t reg, uint16_t data);
475 uint8_t readReg8(uint8_t reg);
476 uint16_t readReg16(uint8_t reg);
478 void enableTouchSupportOnPin(pinid_t pin);
500 float getCurrentFloat(pinid_t pin)
override {
return theAbstraction.
read2ndFilteredData(pin) / 1024.0F; }
508 #define ioFrom8754 ioFrom8575
575 return ioFrom8574(addr, interruptPin, defaultWireTypePtr, invertedLogic);
579 return ioFrom8575(addr, interruptPin, defaultWireTypePtr, invertedLogic);
587 return ioFrom23017(addr, intMode, interruptPin, defaultWireTypePtr);
Contains a series of helper classes for dealing with analog devices, these are compatible across a wi...
AnalogDirection
Definition: AnalogDeviceAbstraction.h:22
Using basic IoFacilities allows one to abstract away the use of IoExpanders, such that the switching ...
IoAbstractionRef ioFrom8574(uint8_t addr, pinid_t interruptPin, WireType wireImpl, bool invertedLogic=false)
Definition: IoAbstractionWire.cpp:88
MPR121ConfigType
Definition: IoAbstractionWire.h:361
IoAbstractionRef ioFrom23017IntPerPort(pinid_t addr, Mcp23xInterruptMode intMode, pinid_t interruptPinA, pinid_t interruptPinB, WireType wireImpl)
Definition: IoAbstractionWire.cpp:245
Mcp23xInterruptMode
Definition: IoAbstractionWire.h:121
IoAbstractionRef ioFrom23017(pinid_t addr, WireType wireImpl)
Definition: IoAbstractionWire.cpp:237
IoAbstractionRef ioFrom8575(uint8_t addr, pinid_t interruptPin, WireType wireImpl, bool invertedLogic=false)
Definition: IoAbstractionWire.cpp:92
Definition: IoAbstractionWire.h:285
int getBitDepth(AnalogDirection direction, pinid_t pin) override
Definition: IoAbstractionWire.h:293
void setCurrentFloat(pinid_t pin, float newValue) override
Definition: IoAbstractionWire.h:303
int getMaximumRange(AnalogDirection direction, pinid_t pin) override
Definition: IoAbstractionWire.h:291
unsigned int getCurrentValue(pinid_t pin) override
Definition: IoAbstractionWire.h:297
void setCurrentValue(pinid_t pin, unsigned int newValue) override
Definition: IoAbstractionWire.h:301
void initPin(pinid_t pin, AnalogDirection direction) override
Definition: IoAbstractionWire.cpp:448
Definition: IoAbstractionWire.h:208
void setPinLedCurrent(pinid_t pin, uint8_t pwr)
Definition: IoAbstractionWire.cpp:426
void writeGlobalControl(bool pushPullP0, AW9523CurrentControl maxCurrentMode=FULL_CURRENT)
Definition: IoAbstractionWire.cpp:442
AW9523IoAbstraction(uint8_t addr, pinid_t intPin=IO_PIN_NOT_DEFINED, WireType wirePtr=nullptr)
Definition: IoAbstractionWire.cpp:342
void attachInterrupt(pinid_t pin, RawIntHandler intHandler, uint8_t mode) override
Definition: IoAbstractionWire.cpp:363
void softwareReset()
Definition: IoAbstractionWire.cpp:434
void pinDirection(pinid_t pin, uint8_t mode) override
Definition: IoAbstractionWire.cpp:380
bool runLoop() override
Definition: IoAbstractionWire.cpp:399
uint8_t deviceId()
Definition: IoAbstractionWire.cpp:438
Definition: AnalogDeviceAbstraction.h:31
Definition: BasicIoAbstraction.h:38
Definition: IoAbstractionWire.h:130
void attachInterrupt(pinid_t pin, RawIntHandler intHandler, uint8_t mode) override
Definition: IoAbstractionWire.cpp:203
MCP23017IoAbstraction(uint8_t address, Mcp23xInterruptMode intMode, pinid_t intPinA, pinid_t intPinB, WireType wireImpl=nullptr)
Definition: IoAbstractionWire.cpp:121
void setInvertInputPin(pinid_t pin, bool shouldInvert)
Definition: IoAbstractionWire.cpp:226
void pinDirection(pinid_t pin, uint8_t mode) override
Definition: IoAbstractionWire.cpp:166
void resetDevice(int resetPin)
Definition: IoAbstractionWire.cpp:230
bool runLoop() override
Definition: IoAbstractionWire.cpp:175
Definition: IoAbstractionWire.h:486
unsigned int getCurrentValue(pinid_t pin) override
Definition: IoAbstractionWire.h:498
int getMaximumRange(AnalogDirection direction, pinid_t pin) override
Definition: IoAbstractionWire.h:492
void setCurrentFloat(pinid_t pin, float newValue) override
Definition: IoAbstractionWire.h:504
void setCurrentValue(pinid_t pin, unsigned int newValue) override
Definition: IoAbstractionWire.h:502
int getBitDepth(AnalogDirection direction, pinid_t pin) override
Definition: IoAbstractionWire.h:494
void initPin(pinid_t pin, AnalogDirection direction) override
Definition: IoAbstractionWire.cpp:606
Definition: IoAbstractionWire.h:373
uint16_t getOutOfRangeRegister()
Definition: IoAbstractionWire.cpp:512
void configureDebounce(uint8_t debounceTouch, uint8_t debounceRelease)
Definition: IoAbstractionWire.cpp:493
bool runLoop() override
Definition: IoAbstractionWire.cpp:576
void pinDirection(pinid_t pin, uint8_t mode) override
Definition: IoAbstractionWire.cpp:516
void begin(int maxTouchPin, MPR121ConfigType configType, uint8_t configReg1=0x10, uint8_t configReg2=0x20)
Definition: IoAbstractionWire.cpp:537
void softwareReset()
Definition: IoAbstractionWire.cpp:461
MPR121IoAbstraction(uint8_t addr, pinid_t intPin=IO_PIN_NOT_DEFINED, WireType wirePtr=nullptr)
Definition: IoAbstractionWire.cpp:456
uint16_t read2ndFilteredData(uint8_t pin)
Definition: IoAbstractionWire.cpp:508
void attachInterrupt(pinid_t pin, RawIntHandler intHandler, uint8_t mode) override
Definition: IoAbstractionWire.cpp:598
void electrodeSettingsForPin(pinid_t pin, uint8_t touchThreshold, uint8_t releaseThreshold, uint8_t current=0, uint8_t chargeTime=0)
Definition: IoAbstractionWire.cpp:498
void setPinLedCurrent(pinid_t pin, uint8_t pwr)
Definition: IoAbstractionWire.cpp:467
Definition: IoAbstractionWire.h:31
void attachInterrupt(pinid_t pin, RawIntHandler intHandler, uint8_t mode) override
Definition: IoAbstractionWire.cpp:79
uint8_t readValue(pinid_t pin) override
Definition: IoAbstractionWire.cpp:36
uint8_t readPort(pinid_t pin) override
Definition: IoAbstractionWire.cpp:41
void pinDirection(pinid_t pin, uint8_t mode) override
Definition: IoAbstractionWire.cpp:19
void overrideReadFlag()
Definition: IoAbstractionWire.h:54
bool runLoop() override
Definition: IoAbstractionWire.cpp:52
void writeValue(pinid_t pin, uint8_t value) override
Definition: IoAbstractionWire.cpp:30
PCF8574IoAbstraction(uint8_t addr, uint8_t interruptPin, WireType wireInstance=nullptr, bool mode16bit=false, bool invertedLogic=false)
Definition: IoAbstractionWire.cpp:9
void writePort(pinid_t pin, uint8_t port) override
Definition: IoAbstractionWire.cpp:46
Definition: IoAbstractionWire.h:95
uint8_t readValue(pinid_t pin) override
Definition: IoAbstractionWire.cpp:269
void writePort(pinid_t pin, uint8_t port) override
Definition: IoAbstractionWire.cpp:285
void writeValue(pinid_t pin, uint8_t value) override
Definition: IoAbstractionWire.cpp:273
uint8_t readPort(pinid_t pin) override
Definition: IoAbstractionWire.cpp:281