pcf.ino
984 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "pcf.h"
void updateButton(struct button *buttonX) {
int read = 0; //!pcf8574.digitalRead(buttonX->pin);
buttonX->pressed = ( buttonX->holding == 0 && read == 1 ) ? (1) : (0);
buttonX->released = ( buttonX->holding == 1 && read == 0 ) ? (1) : (0);
buttonX->holding = read;
}
void setup_pcf () {
pcf8591.begin(sda,scl);
for (int pin = 0; pin < 8; pin ++) {
pcf8574.pinMode(pin, OUTPUT);
}
pcf8574.begin();
for (int pin = 0; pin < 8; pin ++) {
pcf8574.digitalWrite(pin,1);
}
/* button1->pin = 1; */
/* button1->holding = 0; */
/* button1->pressed = 0; */
/* button1->released = 0; */
/* button2->pin = 2; */
/* button2->holding = 0; */
/* button2->pressed = 0; */
/* button2->released = 0; */
/* button3->pin = 3; */
/* button3->holding = 0; */
/* button3->pressed = 0; */
/* button3->released = 0; */
}
void loop_pcf () {
/* updateButton(button1); */
/* updateButton(button2); */
/* updateButton(button3); */
}