-
Notifications
You must be signed in to change notification settings - Fork 0
/
set_up.ino
164 lines (143 loc) · 4.63 KB
/
set_up.ino
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
int set_up(void) {
if (digitalRead(buttonPinDown) == 1 and digitalRead(buttonPinUp) == 1) {
int casee = 0;
int buttonPinDown = 17;
display.clearDisplay();
display.display();
display.clearDisplay();
display.setTextColor(BLACK, WHITE);
display.display();
display.setTextSize(1);
display.setCursor(0, 0);
Serial.println("Temperature limit");
display.println("Orio thermokrasias");
display.setTextColor(WHITE);
Serial.println("Phone number");
display.println("Arithmos kinitou");
Serial.println("Change time");
display.println("Allagi oras");
next_back_menu();
int i = 1;
while (1) {
buttonStateDown = digitalRead(buttonPinDown);
if (buttonStateDown != lastButtonStateDown) {
// if the state has changed, increment the counter
if (buttonStateDown == HIGH) {
if (i <= 2) {
i = i + 1;
}
if (i == 2) {
display.clearDisplay();
display.display();
display.setCursor(0, 0);
display.setTextColor(WHITE);
Serial.println("Temperature limit");
display.println("Orio thermokrasias");
display.setTextColor(BLACK, WHITE);
Serial.println("Phone number");
display.println("Arithmos kinitou");
display.setTextColor(WHITE);
Serial.println("Allagi oras");
display.println("Allagi oras");
next_back_menu();
}
if (i == 3) {
display.clearDisplay();
display.display();
display.setCursor(0, 0);
display.setTextColor(WHITE);
Serial.println("Temperature limit");
display.println("Orio thermokrasias");
Serial.println("Phone number");
display.println("Arithmos kinitou");
display.setTextColor(BLACK, WHITE);
Serial.println("Change time");
display.println("Allagi oras");
display.setTextColor(WHITE);
next_back_menu();
}
}
// Delay a little bit to avoid bouncing
delay(50);
}
lastButtonStateDown = buttonStateDown;
buttonStateUp = digitalRead(buttonPinUp);
if (buttonStateUp != lastButtonStateUp) {
// if the state has changed, increment the counter
if (buttonStateUp == HIGH) {
if (i > 1)
i = i - 1;
}
if (i == 1) {
display.clearDisplay();
display.setTextColor(BLACK, WHITE);
display.display();
display.setTextSize(1);
display.setCursor(0, 0);
Serial.println("Temperature limit");
display.println("Orio thermokrasias");
display.setTextColor(WHITE);
Serial.println("Phone number");
display.println("Arithmos kinitou");
Serial.println("Change time");
display.println("Allagi oras");
next_back_menu();
}
if (i == 2) {
display.clearDisplay();
display.setTextColor(WHITE);
display.display();
display.setTextSize(1);
display.setCursor(0, 0);
Serial.println("Temperature limit");
display.println("Orio thermokrasias");
display.setTextColor(BLACK, WHITE);
Serial.println("Phone number");
display.println("Arithmos kinitou");
display.setTextColor(WHITE);
Serial.println("Change time");
display.println("Allagi oras");
next_back_menu();
}
// Delay a little bit to avoid bouncing
delay(50);
}
lastButtonStateUp = buttonStateUp;
buttonStateEnter = digitalRead(buttonPinEnter);
if (buttonStateEnter != lastButtonStateEnter) {
// if the state has changed, increment the counter
if (buttonStateEnter == HIGH) {
Serial.println(i);
if (i == 1) {
delay(1000);
set_up_limits();
break;
}
if (i == 2) {
delay(500);
set_number_to_call();
break;
}
if (i == 3) {
delay(500);
set_year();
break;
}
}
// Delay a little bit to avoid bouncing
delay(50);
}
lastButtonStateEnter = buttonStateEnter;
buttonStateBack = digitalRead(buttonPinBack);
if (buttonStateBack != lastButtonStateBack) {
// if the state has changed, increment the counter
if (buttonStateBack == HIGH) {
return 1;
}
// Delay a little bit to avoid bouncing
delay(50);
}
lastButtonStateBack = buttonStateBack;
}
}
}