-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbutton.ino
74 lines (71 loc) · 2.02 KB
/
button.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
void readEncoder() {
encoder.service();
enc_val += encoder.getValue(); //read encoder
if (enc_val == last_val)
return;
backlightON();
if (currentMenu == 0) { // if main screen return
last_val = enc_val; //reset encoder values
return;
}
if ((max(enc_val, last_val) - min(enc_val, last_val)) >= 2) { //if difference more than 2 -> one turn
if (last_val > enc_val) {
PRINTLNF("enc ++");
if (currentMenu ==4 ) { // set home temp
temp_set[0]++;
}
else if (currentMenu ==5 ) { // set heater temp
temp_set[1]++;
}
else if (currentMenu ==6 ) { // set home temp hysteresis
temp_set_hysteresis[0]++;
}
else if (currentMenu ==7 ) { // set set heater temp hysteresis
temp_set_hysteresis[1]++;
}
else if (!menu_system.switch_focus()) { // end of menu lines
menu_system++;
menu_system.switch_focus();
}
}
else {
PRINTLNF("enc --");
if (currentMenu ==4 ) { // set home temp
temp_set[0]--;
}
else if (currentMenu ==5 ) { // set heater temp
temp_set[1]--;
}
else if (currentMenu ==6 ) { // set home temp hysteresis
temp_set_hysteresis[0]--;
}
else if (currentMenu ==7 ) { // set set heater temp hysteresis
temp_set_hysteresis[1]--;
}
else if (!menu_system.switch_focus(false)) { // end of menu lines
menu_system--;
menu_system.switch_focus(false);
}
}
last_val = enc_val;
PRINTLNF("_"); // ^_^
}
}
void readButton() {
encoder.service();
button = encoder.getButton();
if (button != ClickEncoder::Open) {
PRINTLNF("button click");
backlightON();
if (currentMenu == 0) { //homepagego to main menu
menu_system.change_menu(main_menu);
menu_system.change_screen(1);
menu_system.switch_focus();
updateMainScreenFlag = false;
currentMenu = 1; //change to main menu
}
else { // go to attached to menu function
menu_system.call_function(1);
}
}
}