25 for (
int i = 0; i < N_CGNDI; i++) {
28 pinMode(first + i, INPUT_PULLUP);
29 cur[i] = digitalRead(first + i) ?
false :
true;
33 pinMode(relay + i, OUTPUT);
34 digitalWrite(relay + i, cur[i] ? HIGH : LOW);
50 past = millis() - last;
53 for (
int i = 0; i < n; i++) {
61 cur[i] = digitalRead(first + i) ?
false :
true;
63 if (cur[i] != pre[i]) {
66 digitalWrite(relay + i, cur[i] ? HIGH : LOW);
94 return cur[i] && !pre[i];
102 return !cur[i] && pre[i];
110 return cur[i] != pre[i];
118 return cur[i] == pre[i];
void update()
Updates DI buffer by current pin voltages.
bool turnoff(byte=0)
Checks whether i-th DI pin was turned off in current loop.
bool on(byte=0)
Checks whether i-th DI pin is on (active).
bool change(byte=0)
Checks whether i-th DI pin was changed from previous loop.
bool turnon(byte=0)
Checks whether i-th DI pin was turned on in current loop.
bool off(byte=0)
Checks whether i-th DI pin is off (inactive).
bool keep(byte=0)
Checks whether i-th DI pin kept unchanged from previous loop.
CgnDI(byte, byte=1, byte=NULL, byte=2)
Constructor.