-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathoption_handler.cpp
92 lines (85 loc) · 2.18 KB
/
option_handler.cpp
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
#include "DB_CG_scale-master.h"
void changeValue(int button,float *value, float adj)
{
switch (button)
{
case BUTTON2:
*value += adj;
break;
case BUTTON3:
*value -= adj;
break;
}
}
int OptionHandler::handle(int button, I2C_LCD *lcd, HX711 *frontCell, HX711 *rearCell, EepromValues *eepromValues) {
static int step = 0;
if (status == WAITING)
{
status = WORKING;
step = 0;
}
switch (step) {
case 0:
lcd->printrow(0, "Change options?");
lcd->printrow(1, "Btn 1 = Yes");
if ((button == BUTTON2) || (button == BUTTON3)) {
status = WAITING;
return MAIN_ID;
}
break;
case 1:
lcd->printrow(0, "Span Dist. 1's");
lcd->printrow(1, String(eepromValues->spanDistance,1));
changeValue(button, &eepromValues->spanDistance, 1.0);
break;
case 2:
lcd->printrow(0, "Span Dist. .1's");
lcd->printrow(1, String(eepromValues->spanDistance,1));
changeValue(button, &eepromValues->spanDistance, 0.1);
break;
case 3:
lcd->printrow(0, "Peg Dist. 1's");
lcd->printrow(1, String(eepromValues->pegDistance,1));
changeValue(button, &eepromValues->pegDistance, 1.0);
break;
case 4:
lcd->printrow(0, "Peg Dist. .1's");
lcd->printrow(1, String(eepromValues->pegDistance,1));
changeValue(button, &eepromValues->pegDistance, 0.1);
break;
// set units of measure
case 5:
lcd->printrow(0, "Btn 1 g Btn 2 oz");
lcd->printrow(1, "Btn 3 = both");
switch (button)
{
case BUTTON1:
eepromValues->gramsOuncesOption = 0;
step++;
break;
case BUTTON2:
eepromValues->gramsOuncesOption = 1;
step++;
break;
case BUTTON3:
eepromValues->gramsOuncesOption = 2;
step++;
break;
}
break;
default:
lcd->printrow(0, "Saving values ...");
lcd->printrow(1, "");
Eeprom::putValues(*eepromValues);
delay(500);
status = WAITING;
return MAIN_ID;
break;
}
switch (button) {
case BUTTON1:
step++;
break;
}
return OPTION_ID;
}