Good day to you all,
I hoop my request is a simple one.
I like to use the pcf8574 family (about 4 of them needed, in the current state of the house)
for inputs using the intPin. Don't want to waste energie and or processor resources on polling al the time,
Is it possible to have;
A Puls/Held --> Release switch - So a interrupt is detected, a small wait (20ms) if not held output a PULS - if held output HELD and after release a output RELEASE
I have read the hole library and all examples but could not find it and surely can't write it myself.
#include<IoAbstraction.h>
#include<IoAbstractionWire.h>
const int c1_btn01 = 0;
const int c1_btn02 = 1;
const int c2_btn01 = 2;
const int c2_btn02 = 3;
void c1_btn02Clicked(uint8_t pin, bool heldDown) {
Serial.print(c1_btn02);
Serial.println(heldDown ? " MQTT send presed" : "");
}
void c1_btn02Released(uint8_t pin, bool heldDown) {
Serial.print(c1_btn02);
Serial.println(heldDown ? " MQTT send Released" : " MQTT send Puls");
}
void setup() {
// Before doing anything else, we must initialise the wire and serial libraries, as we are using both.
Serial.begin(9600);
Wire.begin();
// First we set up the switches library, giving it the task manager and tell it where the pins are located
// We could also of chosen IO through an i2c device that supports interrupts.
// the second parameter is a flag to use pull up switching, (true is pull up).
// switches.initialiseInterrupt(ioFrom8574(0x20, 2), true);
switches.initialiseInterrupt(ioFrom8574(0x38, 2), true);
// now we add the switches, we dont want the spinwheel button to repeat, so leave off the last parameter
// which is the repeat interval (millis / 20 basically) Repeat button does repeat as we can see.
switches.addSwitch(c1_btn02, c1_btn02Clicked);
switches.onRelease(c1_btn02, c1_btn02Released);
}
void loop() {
taskManager.runLoop(); }
Last couple of days, I have bin surfing the net to find the code to make it work, on a RPI3 or arduino,
this library is getting so close to the code i am after, it will detect a second puls while a other pin is HELD perfect.
The output is now;
1
1 MQTT send Puls
1
1 MQTT send presed
1 MQTT send Released
1
1 MQTT send presed
1 MQTT send Released
1
1 MQTT send Puls
I like to daisy chain 3 or 4 pcf8574, and hope a for loop will do the rest, darn i wish i was a coder
I truly hope it's possible,
Kind regards
Spend a hour on it again after a relaxing sauna so new code up