forked from dennisMe2/CarbOnBal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
menuActions.cpp
211 lines (178 loc) · 6.02 KB
/
menuActions.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
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
// This software, known as CarbOnBal is
// Copyright, 2017 L.L.M. (Dennis) Meulensteen. dennis@meulensteen.nl
//
// This file is part of CarbOnBal. A combination of software and hardware.
// I hope it may be of some help to you in balancing your carburetors and throttle bodies.
// Always be careful when working on a vehicle or electronic project like this.
// Your life and health are your sole responsibility, use wisely.
//
// CarbOnBal hardware is covered by the Cern Open Hardware License v1.2
// a copy of the text is incuded with the source code.
//
// CarbOnBal is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// CarbOnBal is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with CarbOnBal. If not, see <http://www.gnu.org/licenses/>.
#include "menuActions.h"
#include LANGUAGE
#include "lang_generic.h"
#include "menu.h"
#include "lcdWrapper.h"
#include "utils.h"
extern settings_t settings;
extern bool quitMenu;
void doConfirmation() {
lcd_clear();
lcd_setCursor(7, 1);
lcd_print(txtDone);
waitForAnyKey();
}
void actionBrightness() {
settings.brightness = doSettingChanger(txtBrightness, 0, 255,
settings.brightness, 10, &doBrightness);
actionSaveSettings();
lcd_clear();
}
void doEmaFactor(int value) {
settings.damping = value / 6;
}
void actionContrast() {
settings.contrast = doSettingChanger(txtContrast, 0, 127, settings.contrast,
1, &doContrast);
actionSaveSettings();
lcd_clear();
}
void actionSilent() {
const char *actions[] = { txtEnabled, txtDisabled };
settings.silent = (bool) doSettingChooser(txtShowDetails, actions, 2,
(int) settings.silent);
actionSaveSettings();
}
void doSplashScreen() {
const char *actions[] = { txtDisabled, txtEnabled };
settings.splashScreen = (bool) doSettingChooser(txtSplashScreen, actions, 2,
(int) settings.splashScreen);
actionSaveSettings();
}
void doAdvanced() {
bool oldAdvanced = settings.advanced;
const char *actions[] = { txtDisabled, txtEnabled };
settings.advanced = (bool) doSettingChooser(txtAdvancedMenu, actions, 2,
(int) settings.advanced);
actionSaveSettings();
if (oldAdvanced != settings.advanced) {
quitMenu = true;
}
}
void actionGraphing() {
const char *actions[] =
{ txtAbsoluteGraph, txtCenteredGraph, txtDiagnostic };
settings.graphType = doSettingChooser(txtSelectGraphType, actions, 3,
settings.graphType);
actionSaveSettings();
}
void actionReset() {
const char *actions[] = { txtKeepSettings, txtResetSettings };
bool reset = doSettingChooser(txtFactoryReset, actions, 2, 0);
if (reset) {
fetchFactoryDefaultSettings();
actionSaveSettings(); //store the data
asm volatile (" jmp 0");
//soft reset by jumping into the arduino boot loader directly
}
}
void actionEmaDamping() {
settings.damping = doBasicSettingChanger(txtDampingPerc, 0, 16,
settings.damping, 1);
actionSaveSettings();
}
void actionRpmEmaDamping() {
settings.rpmDamping = doBasicSettingChanger(txtRpmDampingPerc, 0, 16,
settings.rpmDamping, 1);
actionSaveSettings();
}
void actionCylinders() {
settings.cylinders = (uint8_t) doBasicSettingChanger(txtCylinderCount, 2, 4,
settings.cylinders, 1);
fixMaster();
actionSaveSettings();
}
void actionMaster() {
settings.master = (uint8_t) doBasicSettingChanger(txtMasterCylinder, 1, 4,
settings.master, 1);
fixMaster();
actionSaveSettings();
}
void fixMaster() {
if (settings.cylinders < settings.master) {
settings.master = settings.cylinders;
}
}
void actionBrightnessButton() {
const char *actions[] = { txtBrightness, txtRpmDisplay, txtRpmDamping };
settings.button2 = doSettingChooser(txtBrightnessButton, actions, 3,
(int) settings.button2);
//if(settings.button2 == 2) settings.button1 = 2;
actionSaveSettings();
}
void actionContrastButton() {
const char *actions[] = { txtContrast, txtResetMeasurements, txtDamping };
settings.button1 = doSettingChooser(txtContrastButton, actions, 3,
(int) settings.button1);
//if(settings.button1 == 2) settings.button2 = 2;
actionSaveSettings();
}
void actionCancelButton() {
const char *actions[] = { txtFreezeDisplay, txtResetMeasurements,
txtRpmDisplay };
settings.button3 = doSettingChooser(txtCancelButton, actions, 3,
(int) settings.button3);
actionSaveSettings();
}
void doUnits() {
const char *actions[] = { txtRawValues, txtRawDescending, txtMillibarHpa,
txtMillibarHpaDesc, txtCmMercury, txtCmMercuryDesc, txtInchMercury,
txtInchMercuryDesc };
settings.units = doSettingChooser(txtDisplayUnits, actions, 8,
(int) settings.units);
actionSaveSettings();
}
void actionCalibrationMax() {
settings.calibrationMax = doBasicSettingChanger(txtMaxCalibration, 16, 127,
settings.calibrationMax, 16);
actionSaveSettings();
}
void doMaxZoom() {
static uint8_t count = 5;
if ((0 == settings.units) || (1 == settings.units)) {
const char *actions[] = { txt100Max, txt200, txt300, txt600,
txt1024NoZoom };
settings.zoom = doSettingChooser(txtZoomUnits, actions, count,
(int) settings.zoom);
}
if ((2 == settings.units) || (3 == settings.units)) {
const char *actions[] =
{ txt84Max, txt169, txt254, txt509, txt870NoZoom };
settings.zoom = doSettingChooser(txtZoomMillibar, actions, count,
(int) settings.zoom);
}
if ((4 == settings.units) || (5 == settings.units)) {
const char *actions[] = { txt6Max, txt9, txt19, txt32, txt65NoZoom };
settings.zoom = doSettingChooser(txtZoomCmMercury, actions, count,
(int) settings.zoom);
}
if ((6 == settings.units) || (7 == settings.units)) {
const char *actions[] = { txt2Max, txt5, txt7, txt15, txt25NoZoom };
settings.zoom = doSettingChooser(txtZoomInMercury, actions, count,
(int) settings.zoom);
}
actionSaveSettings();
}