Skip to content

Commit 447105d

Browse files
add MultiPlexer_PCF8574
1 parent 91e9edc commit 447105d

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
/*
3+
MultiPlexer_PCF8574.cpp
4+
*/
5+
6+
#include <MultiPlexer_PCF8574.h>
7+
8+
// Function interrupt
9+
bool keyPressed = false;
10+
11+
void keyPressedOnPCF8574(){
12+
Serial.println("keyPressedOnPCF8574");
13+
keyPressed = true;
14+
}
15+
16+
17+
MultiPlexer_PCF8574::MultiPlexer_PCF8574(uint8_t address, uint8_t interrupt_pin) {
18+
_expander = new PCF8574(address, interrupt_pin, keyPressedOnPCF8574);
19+
}
20+
21+
void MultiPlexer_PCF8574::begin() {
22+
/*pinMode(ESP8266_INTERRUPTED_PIN, INPUT_PULLUP);
23+
attachInterrupt(digitalPinToInterrupt(ESP8266_INTERRUPTED_PIN), keyPressedOnPCF8574, FALLING);*/
24+
25+
for (int i=0; i<8; i++) {
26+
_expander->pinMode(i, INPUT);
27+
}
28+
29+
if (_expander->begin()) {
30+
Serial.println("OK");
31+
} else{
32+
Serial.println("KO");
33+
}
34+
}
35+
36+
void MultiPlexer_PCF8574::loop() {
37+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
MultiPlexer_PCF8574.h
3+
*/
4+
#ifndef MultiPlexer_PCF8574_h
5+
#define MultiPlexer_PCF8574_h
6+
7+
#include <Arduino.h>
8+
#include <Method.h>
9+
#include <PCF8574.h>
10+
11+
#define ESP8266_INTERRUPTED_PIN 16
12+
13+
class MultiPlexer_PCF8574
14+
{
15+
public:
16+
MultiPlexer_PCF8574(uint8_t address, uint8_t interrupt_pin);
17+
void begin();
18+
void loop();
19+
20+
private:
21+
PCF8574* _expander;
22+
};
23+
24+
#endif

0 commit comments

Comments
 (0)