-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathatm_bell.cpp
More file actions
41 lines (37 loc) · 1020 Bytes
/
atm_bell.cpp
File metadata and controls
41 lines (37 loc) · 1020 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
#include "atm_bell.h"
Atm_bell & Atm_bell::begin(int attached_pin) {
const static state_t state_table[] PROGMEM = {
/*|- STATES --|- ACTIONS ------------------------|- EVENTS --------------------|
/* ON_ENTER, ON_LOOP, ON_EXIT, EVT_TIMER, EVT_HISCORE, ELSE */
/* IDLE */ -1, -1, -1, -1, PING_PING, -1,
/* PING_PING */ ENT_PING_ON, -1, EX_PING_ON, IDLE, -1, -1
};
Machine::begin(state_table, ELSE);
pin = attached_pin;
timer.set(250);
pinMode(pin, OUTPUT);
return *this;
}
int Atm_bell::event(int id) {
switch(id) {
case EVT_TIMER:
return timer.expired(this);
}
return 0;
}
void Atm_bell::action(int id) {
switch(id) {
case ENT_PING_ON:
digitalWrite(pin, HIGH);
delay(10);
digitalWrite(pin, LOW);
delay(100);
return;
case EX_PING_ON:
digitalWrite(pin, HIGH);
delay(10);
digitalWrite(pin, LOW);
delay(100);
return;
}
}