-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfig.ino
More file actions
96 lines (85 loc) · 2.69 KB
/
Copy pathConfig.ino
File metadata and controls
96 lines (85 loc) · 2.69 KB
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
// Setup menu
// Called from the main loop
// Allows the user to configure the outputs and maximum temperature
// Called when in setup mode
// Return false to exit this mode
boolean Config() {
static int setupPhase = 0;
static int output = 4; // Start with output D4
static int type = TYPE_TOP_ELEMENT;
static boolean drawMenu = true;
static int maxTemperature;
boolean continueWithSetup = true;
switch (setupPhase) {
case 0: // Set up the output types
if (drawMenu) {
drawMenu = false;
lcdPrintLine(0, "Dx is");
lcd.setCursor(1, 0);
lcd.print(output);
type = getSetting(SETTING_D4_TYPE - 4 + output);
lcdPrintLine(1, outputDescription[type]);
}
// Was a button pressed?
switch (getButton()) {
case CONTROLEO_BUTTON_TOP:
// Move to the next type
type = (type+1) % NO_OF_TYPES;
lcdPrintLine(1, outputDescription[type]);
break;
case CONTROLEO_BUTTON_BOTTOM:
// Save the type for this output
setSetting(SETTING_D4_TYPE - 4 + output, type);
// Go to the next output
output++;
if (output != 8) {
lcd.setCursor(1, 0);
lcd.print(output);
type = getSetting(SETTING_D4_TYPE - 4 + output);
lcdPrintLine(1, outputDescription[type]);
break;
}
// Go to the next phase. Reset variables used in this phase
setupPhase++;
drawMenu = true;
output = 4;
break;
}
break;
case 1: // Get the maximum temperature
if (drawMenu) {
drawMenu = false;
lcdPrintLine(0, "Max temperature");
lcdPrintLine(1, "xxx\1C");
maxTemperature = getSetting(SETTING_MAX_TEMPERATURE);
displayMaxTemperature(maxTemperature);
}
// Was a button pressed?
switch (getButton()) {
case CONTROLEO_BUTTON_TOP:
// Increase the temperature
maxTemperature++;
if (maxTemperature > 280)
maxTemperature = 175;
displayMaxTemperature(maxTemperature);
break;
case CONTROLEO_BUTTON_BOTTOM:
// Save the temperature
setSetting(SETTING_MAX_TEMPERATURE, maxTemperature);
// Go to the next phase. Reset variables used in this phase
setupPhase++;
drawMenu = true;
// Done with setup
continueWithSetup = false;
}
break;
}
// Is setup complete?
if (!continueWithSetup)
setupPhase = 0;
return continueWithSetup;
}
void displayMaxTemperature(int maxTemperature) {
lcd.setCursor(0, 1);
lcd.print(maxTemperature);
}