Mercurial > public > ostc4
annotate Discovery/Src/settings.c @ 125:626191e1fed1 FlipDisplay
Change GPIO speed for SPI communication as recommended by STM32 Errata
author | Ideenmodellierer |
---|---|
date | Sun, 27 Jan 2019 22:21:01 +0100 |
parents | 3834b6272ee5 |
children | cc9c18075e00 |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/settings.c | |
5 /// \brief settingsHelperButtonSens_translate_hwOS_values_to_percentage. | |
6 /// \author Heinrichs Weikamp gmbh | |
7 /// \date 6-March-2017 | |
8 /// | |
9 /// \details | |
10 /// | |
11 /// $Id$ | |
12 /////////////////////////////////////////////////////////////////////////////// | |
13 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh | |
14 /// | |
15 /// This program is free software: you can redistribute it and/or modify | |
16 /// it under the terms of the GNU General Public License as published by | |
17 /// the Free Software Foundation, either version 3 of the License, or | |
18 /// (at your option) any later version. | |
19 /// | |
20 /// This program is distributed in the hope that it will be useful, | |
21 /// but WITHOUT ANY WARRANTY; without even the implied warranty of | |
22 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
23 /// GNU General Public License for more details. | |
24 /// | |
25 /// You should have received a copy of the GNU General Public License | |
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>. | |
27 ////////////////////////////////////////////////////////////////////////////// | |
28 | |
29 #include <string.h> | |
30 #include "settings.h" | |
31 #include "firmwareEraseProgram.h" // for HARDWAREDATA_ADDRESS | |
32 #include "externLogbookFlash.h" // for SAMPLESTART and SAMPLESTOP | |
33 #include "text_multilanguage.h" // for LANGUAGE_END | |
34 #include "tHome.h" // for CVIEW_END | |
35 | |
36 SSettings Settings; | |
37 | |
38 const uint8_t RTErequiredHigh = 1; | |
69 | 39 const uint8_t RTErequiredLow = 4; |
38 | 40 |
75 | 41 const uint8_t FONTrequiredHigh = 1; |
42 const uint8_t FONTrequiredLow = 0; | |
38 | 43 |
44 uint8_t RTEactualHigh = 0; | |
45 uint8_t RTEactualLow = 0; | |
46 | |
47 // =============================================================================== | |
48 // SFirmwareData FirmwareData | |
49 /// @brief internal counter is for changes after last release | |
50 /// use date and info as well for this purpose | |
51 /// | |
52 // =============================================================================== | |
53 | |
54 const SFirmwareData firmware_FirmwareData __attribute__( (section(".firmware_firmware_data")) ) = | |
55 { | |
56 .versionFirst = 1, | |
75 | 57 .versionSecond = 4, |
104 | 58 .versionThird = 4, |
102
4276d56eb37c
hPa instead of mbar, enabled Spanish language
heinrichsweikamp
parents:
100
diff
changeset
|
59 .versionBeta = 1, |
38 | 60 |
61 /* 4 bytes with trailing 0 */ | |
55
a7683f9765da
Italian activated (needs some fine tuning), special characters (?,?,?,?,? and others) currently not working...
heinrichsweikamp
parents:
48
diff
changeset
|
62 .signature = "mh", |
38 | 63 |
55
a7683f9765da
Italian activated (needs some fine tuning), special characters (?,?,?,?,? and others) currently not working...
heinrichsweikamp
parents:
48
diff
changeset
|
64 .release_year = 18, |
a7683f9765da
Italian activated (needs some fine tuning), special characters (?,?,?,?,? and others) currently not working...
heinrichsweikamp
parents:
48
diff
changeset
|
65 .release_month = 8, |
69 | 66 .release_day = 22, |
38 | 67 .release_sub = 0, |
68 | |
69 /* max 48 with trailing 0 */ | |
70 //release_info ="12345678901234567890123456789012345678901" | |
66 | 71 .release_info ="gcc_1st", |
38 | 72 |
73 /* for safety reasons and coming functions */ | |
74 .magic[0] = FIRMWARE_MAGIC_FIRST, | |
75 .magic[1] = FIRMWARE_MAGIC_SECOND, | |
76 .magic[2] = FIRMWARE_MAGIC_FIRMWARE, /* the magic byte */ | |
77 .magic[3] = FIRMWARE_MAGIC_END | |
78 }; | |
79 | |
80 | |
81 /* always adjust check_and_correct_settings() accordingly | |
82 * There might even be entries with fixed values that have no range | |
83 */ | |
84 const SSettings SettingsStandard = { | |
111
38785aa95837
Added new nvm parameter"FlipDisplay" indicating the screen orientation
Ideenmodellierer
parents:
75
diff
changeset
|
85 .header = 0xFFFF0018, |
38 | 86 .warning_blink_dsec = 8 * 2, |
87 .lastDiveLogId = 0, | |
88 .logFlashNextSampleStartAddress = 0, | |
89 | |
90 .gas[0].oxygen_percentage = 21, | |
91 .gas[1].oxygen_percentage = 21, | |
92 .gas[2].oxygen_percentage = 21, | |
93 .gas[3].oxygen_percentage = 21, | |
94 .gas[4].oxygen_percentage = 21, | |
95 .gas[5].oxygen_percentage = 21, | |
96 .gas[6].oxygen_percentage = 21, | |
97 .gas[7].oxygen_percentage = 21, | |
98 .gas[8].oxygen_percentage = 21, | |
99 .gas[9].oxygen_percentage = 21, | |
100 .gas[10].oxygen_percentage = 21, | |
101 .gas[0].helium_percentage = 0, | |
102 .gas[1].helium_percentage = 0, | |
103 .gas[2].helium_percentage = 0, | |
104 .gas[3].helium_percentage = 0, | |
105 .gas[4].helium_percentage = 0, | |
106 .gas[5].helium_percentage = 0, | |
107 .gas[6].helium_percentage = 0, | |
108 .gas[7].helium_percentage = 0, | |
109 .gas[8].helium_percentage = 0, | |
110 .gas[9].helium_percentage = 0, | |
111 .gas[10].helium_percentage = 0, | |
112 .gas[0].depth_meter = 0, | |
113 .gas[1].depth_meter = 0, | |
114 .gas[2].depth_meter = 0, | |
115 .gas[3].depth_meter = 0, | |
116 .gas[4].depth_meter = 0, | |
117 .gas[5].depth_meter = 0, | |
118 .gas[6].depth_meter = 0, | |
119 .gas[7].depth_meter = 0, | |
120 .gas[8].depth_meter = 0, | |
121 .gas[9].depth_meter = 0, | |
122 .gas[10].depth_meter = 0, | |
123 .gas[0].depth_meter_travel = 0, | |
124 .gas[1].depth_meter_travel = 0, | |
125 .gas[2].depth_meter_travel = 0, | |
126 .gas[3].depth_meter_travel = 0, | |
127 .gas[4].depth_meter_travel = 0, | |
128 .gas[5].depth_meter_travel = 0, | |
129 .gas[6].depth_meter_travel = 0, | |
130 .gas[7].depth_meter_travel = 0, | |
131 .gas[8].depth_meter_travel = 0, | |
132 .gas[9].depth_meter_travel = 0, | |
133 .gas[10].depth_meter_travel = 0, | |
134 .gas[0].note.uw = 0, | |
135 .gas[1].note.ub.first = 1, | |
136 .gas[1].note.ub.active = 1, | |
137 .gas[1].note.ub.deco = 0, | |
138 .gas[1].note.ub.travel = 0, | |
139 .gas[2].note.uw = 0, | |
140 .gas[3].note.uw = 0, | |
141 .gas[4].note.uw = 0, | |
142 .gas[5].note.uw = 0, | |
143 .gas[6].note.ub.first = 1, | |
144 .gas[6].note.ub.active = 1, | |
145 .gas[6].note.ub.deco = 0, | |
146 .gas[6].note.ub.travel = 0, | |
147 .gas[7].note.uw = 0, | |
148 .gas[8].note.uw = 0, | |
149 .gas[9].note.uw = 0, | |
150 .gas[10].note.uw = 0, | |
151 .gas[0].bottle_size_liter = 0, | |
152 .gas[1].bottle_size_liter = 0, | |
153 .gas[2].bottle_size_liter = 0, | |
154 .gas[3].bottle_size_liter = 0, | |
155 .gas[4].bottle_size_liter = 0, | |
156 .gas[5].bottle_size_liter = 0, | |
157 .gas[6].bottle_size_liter = 0, | |
158 .gas[7].bottle_size_liter = 0, | |
159 .gas[8].bottle_size_liter = 0, | |
160 .gas[9].bottle_size_liter = 0, | |
161 .gas[10].bottle_size_liter = 0, | |
162 /* | |
163 .gas[0].bottle_wireless_status = 0, | |
164 .gas[1].bottle_wireless_status = 0, | |
165 .gas[2].bottle_wireless_status = 0, | |
166 .gas[3].bottle_wireless_status = 0, | |
167 .gas[4].bottle_wireless_status = 0, | |
168 .gas[5].bottle_wireless_status = 0, | |
169 .gas[6].bottle_wireless_status = 0, | |
170 .gas[7].bottle_wireless_status = 0, | |
171 .gas[8].bottle_wireless_status = 0, | |
172 .gas[9].bottle_wireless_status = 0, | |
173 .gas[10].bottle_wireless_status = 0, | |
174 */ | |
175 .gas[0].bottle_wireless_id = 0, | |
176 .gas[1].bottle_wireless_id = 0, | |
177 .gas[2].bottle_wireless_id = 0, | |
178 .gas[3].bottle_wireless_id = 0, | |
179 .gas[4].bottle_wireless_id = 0, | |
180 .gas[5].bottle_wireless_id = 0, | |
181 .gas[6].bottle_wireless_id = 0, | |
182 .gas[7].bottle_wireless_id = 0, | |
183 .gas[8].bottle_wireless_id = 0, | |
184 .gas[9].bottle_wireless_id = 0, | |
185 .gas[10].bottle_wireless_id = 0, | |
186 .setpoint[0].setpoint_cbar = 100, | |
187 .setpoint[1].setpoint_cbar = 70, | |
188 .setpoint[2].setpoint_cbar = 90, | |
189 .setpoint[3].setpoint_cbar = 100, | |
190 .setpoint[4].setpoint_cbar = 120, | |
191 .setpoint[5].setpoint_cbar = 140, | |
192 .setpoint[0].depth_meter = 0, | |
193 .setpoint[1].depth_meter = 0, | |
194 .setpoint[2].depth_meter = 0, | |
195 .setpoint[3].depth_meter = 0, | |
196 .setpoint[4].depth_meter = 0, | |
197 .setpoint[5].depth_meter = 0, | |
198 .setpoint[0].note.uw = 0, | |
199 .setpoint[1].note.ub.active = 1, | |
200 .setpoint[1].note.ub.first = 1, | |
201 .setpoint[2].note.ub.active = 1, | |
202 .setpoint[2].note.ub.first = 0, | |
203 .setpoint[3].note.ub.active = 1, | |
204 .setpoint[3].note.ub.first = 0, | |
205 .setpoint[4].note.ub.active = 1, | |
206 .setpoint[4].note.ub.first = 0, | |
207 .setpoint[5].note.ub.active = 1, | |
208 .setpoint[5].note.ub.first = 0, | |
209 | |
210 .CCR_Mode = CCRMODE_Sensors, | |
211 .dive_mode = DIVEMODE_OC, | |
212 .deco_type.ub.standard = GF_MODE, | |
213 .deco_type.ub.alternative = GF_MODE, | |
214 .ppO2_max_deco = 160, | |
215 .ppO2_max_std = 140, | |
216 .ppO2_min = 15, | |
217 .CNS_max = 90, | |
218 .ascent_MeterPerMinute_max = 30, | |
219 .ascent_MeterPerMinute_showGraph = 7, | |
220 .future_TTS = 5, | |
221 .GF_high = 85, | |
222 .GF_low = 30, | |
223 .aGF_high = 95, | |
224 .aGF_low = 95, | |
225 .VPM_conservatism.ub.standard = 2, | |
226 .VPM_conservatism.ub.alternative = 0, | |
227 .safetystopDuration = 1, | |
228 .AtemMinutenVolumenLiter = 25, | |
229 .ReserveFractionDenominator = 4, | |
230 .salinity = 0, | |
231 .last_stop_depth_meter = 3, | |
232 .stop_increment_depth_meter = 3, | |
233 .brightness = 1, | |
234 .date_format = DDMMYY, | |
235 .selected_language = 0, /* 0 = LANGUAGE_English */ | |
236 .customtext = " <your name>\n" " <address>", | |
237 .timeoutSurfacemode = 120, | |
238 .timeoutMenuSurface = 120,//240, | |
239 .timeoutMenuDive = 120,//20, | |
240 .timeoutMenuEdit = 120,//40, | |
241 .timeoutInfo = 120,//60, | |
242 .timeoutInfoCompass = 60, | |
243 .design = 7, | |
244 .timeoutDiveReachedZeroDepth = 300, | |
245 .divetimeToCreateLogbook = 60, | |
246 .serialHigh = 0, | |
247 .serialLow = 2, | |
248 /* | |
249 .firmwareVersion16to32bit.ub.first = 0, | |
250 .firmwareVersion16to32bit.ub.second = 6, | |
251 .firmwareVersion16to32bit.ub.third = 0, | |
252 .firmwareVersion16to32bit.ub.betaFlag = 0, | |
253 */ | |
254 .backup_localtime_rtc_tr = 0, | |
255 .backup_localtime_rtc_dr = 0, | |
256 .totalDiveCounter = 0, | |
257 .personalDiveCount = 0, | |
258 .showDebugInfo = 0, | |
92
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
91
diff
changeset
|
259 .ButtonResponsiveness[0] = DEFAULT_BUTTONRESPONSIVENESS_GUI, // new hw 170306 |
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
91
diff
changeset
|
260 .ButtonResponsiveness[1] = DEFAULT_BUTTONRESPONSIVENESS_GUI, // new hw 170306 |
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
91
diff
changeset
|
261 .ButtonResponsiveness[2] = DEFAULT_BUTTONRESPONSIVENESS_GUI, // new hw 170306 |
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
91
diff
changeset
|
262 .ButtonResponsiveness[3] = DEFAULT_BUTTONRESPONSIVENESS_GUI, // new hw 170306 |
38 | 263 .nonMetricalSystem = 0, |
264 .fallbackToFixedSetpoint = 1, | |
265 .bluetoothActive = 0, | |
266 .safetystopDepth = 5, | |
267 .updateSettingsAllowedFromHeader = 0xFFFF0002, | |
268 .scooterControl = 0, | |
269 .scooterDrag = 2, | |
270 .scooterLoad = 2, | |
271 .scooterNumberOfBatteries = 1, | |
272 .scooterBattSize = 760, | |
273 .scooterSPARE1[0] = 0, | |
274 .scooterSPARE2[0] = 0, | |
275 .ppo2sensors_deactivated = 0, | |
276 .tX_colorscheme = 0, | |
277 .tX_userselectedLeftLowerCornerPrimary = 1, | |
278 .tX_userselectedLeftLowerCornerTimeout = 0, | |
279 .tX_customViewPrimary = 1, | |
280 .tX_customViewTimeout = 0, | |
281 .timeoutEnterButtonSelectDive = 10, | |
282 .logbookOffset = 0, | |
283 .alwaysShowPPO2 = 0, | |
284 .extraDisplay = EXTRADISPLAY_BIGFONT, | |
285 .display_toogle_desc = 200, | |
286 .offsetPressure_mbar = 0, | |
287 .offsetTemperature_centigrad = 0, | |
288 .gasConsumption_travel_l_min = 30, | |
289 .gasConsumption_bottom_l_min = 30, | |
290 .gasConsumption_deco_l_min = 20, | |
291 .debugModeOnStart = 0, | |
292 .compassBearing = 0, | |
293 .lastKnownBatteryPercentage = 0, | |
294 .buttonBalance[0] = 3, | |
295 .buttonBalance[1] = 3, | |
296 .buttonBalance[2] = 3, | |
297 .firmwareVersion[0] = 0,//FirmwareData.firmwareVersion16to32bit.ub.first, | |
298 .firmwareVersion[1] = 0,//FirmwareData.firmwareVersion16to32bit.ub.second, | |
299 .firmwareVersion[2] = 0,//FirmwareData.firmwareVersion16to32bit.ub.third, | |
300 .firmwareVersion[3] = 0,//FirmwareData.firmwareVersion16to32bit.ub.betaFlag, | |
301 .timeoutSurfacemodeWithSensors = 600, | |
302 .VPM_model = 0, | |
303 .GF_model = 0, | |
92
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
91
diff
changeset
|
304 .FactoryButtonBase = DEFAULT_BUTTONRESPONSIVENESS_GUI, |
38 | 305 .FactoryButtonBalance[0] = 3, |
306 .FactoryButtonBalance[1] = 3, | |
307 .FactoryButtonBalance[2] = 3, | |
111
38785aa95837
Added new nvm parameter"FlipDisplay" indicating the screen orientation
Ideenmodellierer
parents:
75
diff
changeset
|
308 .FlipDisplay = 0, |
38 | 309 }; |
310 | |
311 /* Private function prototypes -----------------------------------------------*/ | |
312 uint8_t checkValue(uint8_t value,uint8_t from, uint8_t to); | |
313 | |
314 /* Functions -----------------------------------------------------------------*/ | |
315 | |
316 | |
317 // =============================================================================== | |
318 // set_new_settings_missing_in_ext_flash | |
319 /// @brief Add all the new setting variables of this version | |
320 /// or/and change what has changed in the meantime | |
321 /// | |
322 /// Additionally update the serial number if written via bluetooth | |
323 /// | |
324 // =============================================================================== | |
325 void set_new_settings_missing_in_ext_flash(void) | |
326 { | |
327 // never delete this part setting the serial | |
328 if(hardwareDataGetPointer()->secondarySerial != 0xFFFF) | |
329 { | |
330 settingsGetPointer()->serialHigh = (hardwareDataGetPointer()->secondarySerial / 256); | |
331 settingsGetPointer()->serialLow = (hardwareDataGetPointer()->secondarySerial & 0xFF); | |
332 } | |
333 else | |
334 if(hardwareDataGetPointer()->primarySerial != 0xFFFF) | |
335 { | |
336 settingsGetPointer()->serialHigh = (hardwareDataGetPointer()->primarySerial / 256); | |
337 settingsGetPointer()->serialLow = (hardwareDataGetPointer()->primarySerial & 0xFF); | |
338 } | |
339 else | |
340 { | |
341 settingsGetPointer()->serialHigh = 0; | |
342 settingsGetPointer()->serialLow = 0; | |
343 } | |
344 | |
345 settingsGetPointer()->firmwareVersion[0] = firmware_FirmwareData.versionFirst; | |
346 settingsGetPointer()->firmwareVersion[1] = firmware_FirmwareData.versionSecond; | |
347 settingsGetPointer()->firmwareVersion[2] = firmware_FirmwareData.versionThird; | |
348 settingsGetPointer()->firmwareVersion[3] = firmware_FirmwareData.versionBeta; | |
349 | |
350 SSettings* pSettings = settingsGetPointer(); | |
351 const SSettings* pStandard = settingsGetPointerStandard(); | |
352 | |
353 pSettings->scooterControl = 0; | |
354 | |
355 switch(pSettings->header) | |
356 { | |
357 case 0xFFFF0000: | |
358 case 0xFFFF0001: | |
359 case 0xFFFF0002: | |
360 case 0xFFFF0003: | |
361 case 0xFFFF0004: | |
362 case 0xFFFF0005: | |
363 pSettings->ppo2sensors_deactivated = pStandard->ppo2sensors_deactivated; | |
364 pSettings->tX_colorscheme = pStandard->tX_colorscheme; | |
365 pSettings->tX_userselectedLeftLowerCornerPrimary = pStandard->tX_userselectedLeftLowerCornerPrimary; | |
366 pSettings->tX_userselectedLeftLowerCornerTimeout = pStandard->tX_userselectedLeftLowerCornerTimeout; | |
367 pSettings->tX_customViewPrimary = pStandard->tX_customViewPrimary; | |
368 pSettings->tX_customViewTimeout = pStandard->tX_customViewTimeout; | |
369 // no break | |
370 case 0xFFFF0006: | |
371 pSettings->timeoutEnterButtonSelectDive = pStandard->timeoutEnterButtonSelectDive; | |
372 pSettings->ButtonResponsiveness[0] = pStandard->ButtonResponsiveness[0]; | |
373 pSettings->ButtonResponsiveness[1] = pStandard->ButtonResponsiveness[1]; | |
374 pSettings->ButtonResponsiveness[2] = pStandard->ButtonResponsiveness[2]; | |
375 pSettings->ButtonResponsiveness[3] = pStandard->ButtonResponsiveness[3]; | |
376 pSettings->timeoutSurfacemode = pStandard->timeoutSurfacemode; | |
377 pSettings->timeoutMenuSurface = pStandard->timeoutMenuSurface; | |
378 pSettings->timeoutMenuDive = pStandard->timeoutMenuDive; | |
379 pSettings->timeoutMenuEdit = pStandard->timeoutMenuEdit; | |
380 pSettings->timeoutInfo = pStandard->timeoutInfo; | |
381 pSettings->timeoutInfoCompass = pStandard->timeoutInfoCompass; | |
382 pSettings->timeoutDiveReachedZeroDepth = pStandard->timeoutDiveReachedZeroDepth; | |
383 pSettings->divetimeToCreateLogbook = pStandard->divetimeToCreateLogbook; | |
384 pSettings->safetystopDuration = pStandard->safetystopDuration; // change from on/off to minutes | |
385 // no break | |
386 case 0xFFFF0007: | |
387 case 0xFFFF0008: | |
388 pSettings->alwaysShowPPO2 = pStandard->alwaysShowPPO2; | |
389 pSettings->logbookOffset = pStandard->logbookOffset; | |
390 // no break | |
391 case 0xFFFF0009: | |
392 pSettings->extraDisplay = pStandard->extraDisplay; | |
393 // no break | |
394 case 0xFFFF000A: | |
395 pSettings->display_toogle_desc = pStandard->display_toogle_desc; | |
396 // no break | |
397 case 0xFFFF000B: | |
398 pSettings->offsetPressure_mbar = pStandard->offsetPressure_mbar; | |
399 pSettings->offsetTemperature_centigrad = pStandard->offsetTemperature_centigrad; | |
400 pSettings->gasConsumption_travel_l_min = pStandard->gasConsumption_travel_l_min; | |
401 pSettings->gasConsumption_bottom_l_min = pStandard->gasConsumption_bottom_l_min; | |
402 pSettings->gasConsumption_deco_l_min = pStandard->gasConsumption_deco_l_min; | |
403 // no break | |
404 case 0xFFFF000C: | |
405 memcpy(pSettings->customtext, " hwOS 4\n\r" " welcome\n\r", 60); | |
406 // no break | |
407 case 0xFFFF000D: // nothing to do from 0xFFFF000D to 0xFFFF000E, just about header :-) | |
408 case 0xFFFF000E: | |
409 pSettings->debugModeOnStart = 0; | |
410 // no break | |
411 case 0xFFFF000F: | |
412 pSettings->compassBearing = 0; | |
413 // no break | |
414 case 0xFFFF0010: | |
415 pSettings->scooterDrag = 2; | |
416 pSettings->scooterLoad = 2; | |
417 pSettings->scooterSPARE1[0] = 0; | |
418 pSettings->scooterSPARE2[0] = 0; | |
419 // no break | |
420 case 0xFFFF0011: | |
421 pSettings->scooterNumberOfBatteries = 1; | |
422 pSettings->scooterBattSize = 760; | |
423 pSettings->lastKnownBatteryPercentage = 0; | |
424 // no break | |
425 case 0xFFFF0012: | |
426 pSettings->buttonBalance[0] = 3; | |
427 pSettings->buttonBalance[1] = 3; | |
428 pSettings->buttonBalance[2] = 3; | |
429 // no break | |
430 case 0xFFFF0013: | |
431 case 0xFFFF0014: | |
432 pSettings->timeoutSurfacemodeWithSensors = pStandard->timeoutSurfacemodeWithSensors; | |
433 // no break | |
434 case 0xFFFF0015: | |
435 pSettings->ButtonResponsiveness[3] = pStandard->ButtonResponsiveness[3]; | |
436 settingsHelperButtonSens_keepPercentageValues(settingsHelperButtonSens_translate_hwOS_values_to_percentage(pSettings->ButtonResponsiveness[3]), pSettings->ButtonResponsiveness); | |
437 pSettings->VPM_model = 0; | |
438 pSettings->GF_model = 0; | |
439 // no break | |
440 case 0xFFFF0016: | |
441 pSettings->FactoryButtonBase = pStandard->FactoryButtonBase; | |
442 pSettings->FactoryButtonBalance[0] = pStandard->FactoryButtonBalance[0]; | |
443 pSettings->FactoryButtonBalance[1] = pStandard->FactoryButtonBalance[1]; | |
444 pSettings->FactoryButtonBalance[2] = pStandard->FactoryButtonBalance[2]; | |
445 // no break | |
111
38785aa95837
Added new nvm parameter"FlipDisplay" indicating the screen orientation
Ideenmodellierer
parents:
75
diff
changeset
|
446 case 0xFFFF0017: |
38785aa95837
Added new nvm parameter"FlipDisplay" indicating the screen orientation
Ideenmodellierer
parents:
75
diff
changeset
|
447 pSettings->FlipDisplay = 0; |
38785aa95837
Added new nvm parameter"FlipDisplay" indicating the screen orientation
Ideenmodellierer
parents:
75
diff
changeset
|
448 // no break |
38 | 449 default: |
450 pSettings->header = pStandard->header; | |
451 break; // no break before!! | |
452 } | |
453 } | |
454 | |
455 | |
456 uint8_t newFirmwareVersionCheckViaSettings(void) | |
457 { | |
458 SSettings* pSettings = settingsGetPointer(); | |
459 | |
460 if(pSettings->header < 0xFFFF0014) // for the versions without firmwareVersion[] | |
461 return 1; | |
462 | |
463 if(pSettings->firmwareVersion[0] != firmware_FirmwareData.versionFirst) | |
464 return 1; | |
465 if(pSettings->firmwareVersion[1] != firmware_FirmwareData.versionSecond) | |
466 return 1; | |
467 if(pSettings->firmwareVersion[2] != firmware_FirmwareData.versionThird) | |
468 return 1; | |
469 if(pSettings->firmwareVersion[3] != firmware_FirmwareData.versionBeta) | |
470 return 1; | |
471 | |
472 return 0; | |
473 } | |
474 | |
475 | |
476 void set_settings_button_to_standard_with_individual_buttonBalance(void) | |
477 { | |
478 settingsHelperButtonSens_keepPercentageValues(SettingsStandard.ButtonResponsiveness[3], settingsGetPointer()->ButtonResponsiveness); | |
479 } | |
480 | |
481 | |
482 uint8_t check_and_correct_settings(void) | |
483 { | |
484 uint32_t corrections = 0; | |
485 uint8_t firstGasFoundOC = 0; | |
486 uint8_t firstGasFoundCCR = 0; | |
487 | |
488 /* uint32_t header; | |
489 */ | |
490 | |
491 /* uint8_t warning_blink_dsec; 1/10 seconds | |
492 */ | |
493 if((Settings.warning_blink_dsec < 1) || (Settings.warning_blink_dsec > 100)) | |
494 { | |
495 Settings.warning_blink_dsec = SettingsStandard.warning_blink_dsec; | |
496 corrections++; | |
497 } | |
498 | |
499 /* uint8_t lastDiveLogId; | |
500 */ | |
501 | |
502 /* uint32_t logFlashNextSampleStartAddress; | |
503 */ | |
504 if((Settings.logFlashNextSampleStartAddress < SAMPLESTART) || (Settings.logFlashNextSampleStartAddress > SAMPLESTOP)) | |
505 { | |
506 Settings.logFlashNextSampleStartAddress = SAMPLESTART; | |
507 corrections++; | |
508 } | |
509 | |
510 | |
511 /* uint8_t dive_mode; has to before the gases | |
512 */ | |
513 if( (Settings.dive_mode != DIVEMODE_OC) && | |
514 (Settings.dive_mode != DIVEMODE_CCR) && | |
515 (Settings.dive_mode != DIVEMODE_Gauge) && | |
516 (Settings.dive_mode != DIVEMODE_Apnea) ) | |
517 { | |
518 Settings.dive_mode = DIVEMODE_OC; | |
519 corrections++; | |
520 } | |
521 | |
522 | |
523 /* SGasLine gas[1 + (2*NUM_GASES)]; | |
524 */ | |
525 for(int i=1; i<=2*NUM_GASES;i++) | |
526 { | |
527 if(Settings.gas[i].oxygen_percentage < 4) | |
528 { | |
529 Settings.gas[i].oxygen_percentage = 4; | |
530 corrections++; | |
531 } | |
532 if(Settings.gas[i].oxygen_percentage > 100) | |
533 { | |
534 Settings.gas[i].oxygen_percentage = 100; | |
535 corrections++; | |
536 } | |
537 if((Settings.gas[i].oxygen_percentage + Settings.gas[i].helium_percentage) > 100) | |
538 { | |
539 Settings.gas[i].helium_percentage = 100 - Settings.gas[i].oxygen_percentage; | |
540 corrections++; | |
541 } | |
542 if(Settings.gas[i].note.ub.deco) | |
543 { | |
544 if(Settings.gas[i].note.ub.active != 1) | |
545 { | |
546 Settings.gas[i].note.ub.active = 1; | |
547 corrections++; | |
548 } | |
549 if(Settings.gas[i].note.ub.travel == 1) | |
550 { | |
551 Settings.gas[i].note.ub.travel = 0; | |
552 corrections++; | |
553 } | |
554 } | |
555 if(Settings.gas[i].note.ub.travel) | |
556 { | |
557 if(Settings.gas[i].note.ub.active != 1) | |
558 { | |
559 Settings.gas[i].note.ub.active = 1; | |
560 corrections++; | |
561 } | |
562 if(Settings.gas[i].note.ub.deco == 1) | |
563 { | |
564 Settings.gas[i].note.ub.deco = 0; | |
565 corrections++; | |
566 } | |
567 } | |
568 if(Settings.gas[i].note.ub.first) | |
569 { | |
570 if(Settings.setpoint[i].note.ub.active != 1) | |
571 { | |
572 Settings.setpoint[i].note.ub.active = 1; | |
573 corrections++; | |
574 } | |
575 if(Settings.gas[i].note.ub.travel == 1) | |
576 { | |
577 Settings.gas[i].note.ub.travel = 0; | |
578 corrections++; | |
579 } | |
580 if(Settings.gas[i].note.ub.deco == 1) | |
581 { | |
582 Settings.gas[i].note.ub.deco = 0; | |
583 corrections++; | |
584 } | |
585 if((i<=NUM_GASES) && (!firstGasFoundOC)) | |
586 firstGasFoundOC = 1; | |
587 else | |
588 if((i>NUM_GASES) && (!firstGasFoundCCR)) | |
589 firstGasFoundCCR = 1; | |
590 else | |
591 Settings.gas[i].note.ub.first = 0; | |
592 } | |
593 if(Settings.gas[i].bottle_size_liter > 40) | |
594 { | |
595 Settings.gas[i].bottle_size_liter = 40; | |
596 corrections++; | |
597 } | |
598 if(Settings.gas[i].depth_meter > 250) | |
599 { | |
600 Settings.gas[i].depth_meter = 250; | |
601 corrections++; | |
602 } | |
603 if(Settings.gas[i].depth_meter_travel > 250) | |
604 { | |
605 Settings.gas[i].depth_meter_travel = 250; | |
606 corrections++; | |
607 } | |
608 /*if(Settings.gas[i].note.ub.senderCode) | |
609 { | |
610 } | |
611 if(Settings.gas[i].bottle_wireless_id) | |
612 { | |
613 } | |
614 */ | |
615 } // for(int i=1; i<=2*NUM_GASES;i++) | |
616 | |
617 if(!firstGasFoundOC) | |
618 { | |
619 Settings.gas[1].note.ub.active = 1; | |
620 Settings.gas[1].note.ub.first = 1; | |
621 Settings.gas[1].note.ub.travel = 0; | |
622 Settings.gas[1].note.ub.deco = 0; | |
623 } | |
624 if(!firstGasFoundCCR) | |
625 { | |
626 Settings.gas[1 + NUM_GASES].note.ub.active = 1; | |
627 Settings.gas[1 + NUM_GASES].note.ub.first = 1; | |
628 Settings.gas[1 + NUM_GASES].note.ub.travel = 0; | |
629 Settings.gas[1 + NUM_GASES].note.ub.deco = 0; | |
630 } | |
631 /* SSetpointLine setpoint[1 + NUM_GASES]; | |
632 */ | |
633 for(int i=1; i<=NUM_GASES;i++) | |
634 { | |
635 if(Settings.setpoint[i].setpoint_cbar < 50) | |
636 { | |
637 Settings.setpoint[i].setpoint_cbar = 50; | |
638 corrections++; | |
639 } | |
640 if(Settings.setpoint[i].setpoint_cbar > 160) | |
641 { | |
642 Settings.setpoint[i].setpoint_cbar = 160; | |
643 corrections++; | |
644 } | |
645 if(Settings.setpoint[i].depth_meter > 250) | |
646 { | |
647 Settings.setpoint[i].depth_meter = 250; | |
648 corrections++; | |
649 } | |
650 if(Settings.setpoint[i].note.ub.deco) | |
651 { | |
652 if(Settings.setpoint[i].note.ub.active != 1) | |
653 { | |
654 Settings.setpoint[i].note.ub.active = 1; | |
655 corrections++; | |
656 } | |
657 if(Settings.setpoint[i].note.ub.travel == 1) | |
658 { | |
659 Settings.setpoint[i].note.ub.travel = 0; | |
660 corrections++; | |
661 } | |
662 } | |
663 if(Settings.setpoint[i].note.ub.travel) | |
664 { | |
665 if(Settings.setpoint[i].note.ub.active != 1) | |
666 { | |
667 Settings.setpoint[i].note.ub.active = 1; | |
668 corrections++; | |
669 } | |
670 if(Settings.setpoint[i].note.ub.deco == 1) | |
671 { | |
672 Settings.setpoint[i].note.ub.deco = 0; | |
673 corrections++; | |
674 } | |
675 } | |
676 if(Settings.setpoint[i].note.ub.first) | |
677 { | |
678 if(Settings.setpoint[i].note.ub.active != 1) | |
679 { | |
680 Settings.setpoint[i].note.ub.active = 1; | |
681 corrections++; | |
682 } | |
683 if(Settings.setpoint[i].note.ub.travel == 1) | |
684 { | |
685 Settings.setpoint[i].note.ub.travel = 0; | |
686 corrections++; | |
687 } | |
688 if(Settings.setpoint[i].note.ub.deco == 1) | |
689 { | |
690 Settings.setpoint[i].note.ub.deco = 0; | |
691 corrections++; | |
692 } | |
693 } | |
694 } // for(int i=1; i<=NUM_GASES;i++) | |
695 | |
696 /* uint8_t CCR_Mode; | |
697 */ | |
698 if( (Settings.CCR_Mode != CCRMODE_Sensors) && | |
699 (Settings.CCR_Mode != CCRMODE_FixedSetpoint)) | |
700 { | |
701 Settings.CCR_Mode = CCRMODE_FixedSetpoint; | |
702 corrections++; | |
703 } | |
704 | |
705 /* split2x4_Type deco_type; | |
706 */ | |
707 if( (Settings.deco_type.ub.standard != GF_MODE) && | |
708 (Settings.deco_type.ub.standard != VPM_MODE)) | |
709 { | |
710 Settings.deco_type.ub.standard = VPM_MODE; | |
711 corrections++; | |
712 } | |
713 if(Settings.deco_type.ub.alternative != GF_MODE) | |
714 { | |
715 Settings.deco_type.ub.alternative = GF_MODE; | |
716 corrections++; | |
717 } | |
718 | |
719 /* uint8_t ppO2_max_deco; | |
720 */ | |
721 if(Settings.ppO2_max_deco > 190) | |
722 { | |
723 Settings.ppO2_max_deco = 190; | |
724 corrections++; | |
725 } | |
726 if(Settings.ppO2_max_deco < 100) | |
727 { | |
728 Settings.ppO2_max_deco = 100; | |
729 corrections++; | |
730 } | |
731 | |
732 /* uint8_t ppO2_max_std; | |
733 */ | |
734 if(Settings.ppO2_max_std > 190) | |
735 { | |
736 Settings.ppO2_max_std = 190; | |
737 corrections++; | |
738 } | |
739 if(Settings.ppO2_max_std < 100) | |
740 { | |
741 Settings.ppO2_max_std = 100; | |
742 corrections++; | |
743 } | |
744 | |
745 /* uint8_t ppO2_min; | |
746 */ | |
747 if(Settings.ppO2_min != 15) | |
748 { | |
749 Settings.ppO2_min = 15; | |
750 corrections++; | |
751 } | |
752 | |
753 /* uint8_t CNS_max; | |
754 */ | |
755 if(Settings.CNS_max != 90) | |
756 { | |
757 Settings.CNS_max = 90; | |
758 corrections++; | |
759 } | |
760 | |
761 /* uint8_t ascent_MeterPerMinute_max; | |
762 */ | |
763 if(Settings.ascent_MeterPerMinute_max != 30) | |
764 { | |
765 Settings.ascent_MeterPerMinute_max = 30; | |
766 corrections++; | |
767 } | |
768 | |
769 /* uint8_t ascent_MeterPerMinute_showGraph; | |
770 */ | |
771 if(Settings.ascent_MeterPerMinute_showGraph != 30) | |
772 { | |
773 Settings.ascent_MeterPerMinute_showGraph = 30; | |
774 corrections++; | |
775 } | |
776 | |
777 /* uint8_t future_TTS; | |
778 */ | |
779 if(Settings.future_TTS > 15) | |
780 { | |
781 Settings.future_TTS = 15; | |
782 corrections++; | |
783 } | |
784 | |
785 /* uint8_t GF_high; | |
786 */ | |
787 if(Settings.GF_high > 99) | |
788 { | |
789 Settings.GF_high = 99; | |
790 corrections++; | |
791 } | |
792 if(Settings.GF_high < 45) | |
793 { | |
794 Settings.GF_high = 45; | |
795 corrections++; | |
796 } | |
797 | |
798 /* uint8_t GF_low; | |
799 */ | |
800 if(Settings.GF_low > 99) | |
801 { | |
802 Settings.GF_low = 99; | |
803 corrections++; | |
804 } | |
805 if(Settings.GF_low < 10) | |
806 { | |
807 Settings.GF_low = 10; | |
808 corrections++; | |
809 } | |
810 if(Settings.GF_low > Settings.GF_high) | |
811 { | |
812 Settings.GF_low = Settings.GF_high; | |
813 corrections++; | |
814 } | |
815 | |
816 /* uint8_t aGF_high; | |
817 */ | |
818 if(Settings.aGF_high > 99) | |
819 { | |
820 Settings.aGF_high = 99; | |
821 corrections++; | |
822 } | |
823 if(Settings.aGF_high < 45) | |
824 { | |
825 Settings.aGF_high = 45; | |
826 corrections++; | |
827 } | |
828 | |
829 /* uint8_t aGF_low; | |
830 */ | |
831 if(Settings.aGF_low > 99) | |
832 { | |
833 Settings.aGF_low = 99; | |
834 corrections++; | |
835 } | |
836 if(Settings.aGF_low < 10) | |
837 { | |
838 Settings.aGF_low = 10; | |
839 corrections++; | |
840 } | |
841 if(Settings.aGF_low > Settings.aGF_high) | |
842 { | |
843 Settings.aGF_low = Settings.aGF_high; | |
844 corrections++; | |
845 } | |
846 | |
847 /* split2x4_Type VPM_conservatism; | |
848 */ | |
849 if(Settings.VPM_conservatism.ub.standard > 5) | |
850 { | |
851 Settings.VPM_conservatism.ub.standard = 5; | |
852 corrections++; | |
853 } | |
854 if(Settings.VPM_conservatism.ub.alternative > 5) | |
855 { | |
856 Settings.VPM_conservatism.ub.alternative = 5; | |
857 corrections++; | |
858 } | |
859 | |
860 /* uint8_t safetystopDuration; | |
861 */ | |
862 if(Settings.safetystopDuration > 5) | |
863 { | |
864 Settings.safetystopDuration = 5; | |
865 corrections++; | |
866 } | |
867 | |
868 /* uint8_t AtemMinutenVolumenLiter; | |
869 */ | |
870 if(Settings.AtemMinutenVolumenLiter != 25) | |
871 { | |
872 Settings.AtemMinutenVolumenLiter = 25; | |
873 corrections++; | |
874 } | |
875 | |
876 /* uint8_t ReserveFractionDenominator; | |
877 */ | |
878 if(Settings.ReserveFractionDenominator != 4) | |
879 { | |
880 Settings.ReserveFractionDenominator = 4; | |
881 corrections++; | |
882 } | |
883 | |
884 /* uint8_t salinity; | |
885 */ | |
886 if(Settings.salinity > 4) | |
887 { | |
888 Settings.salinity = 4; | |
889 corrections++; | |
890 } | |
891 | |
892 /* uint8_t last_stop_depth_meter; | |
893 */ | |
894 if(Settings.last_stop_depth_meter > 9) | |
895 { | |
896 Settings.last_stop_depth_meter = 9; | |
897 corrections++; | |
898 } | |
899 if(Settings.last_stop_depth_meter < 3) | |
900 { | |
901 Settings.last_stop_depth_meter = 3; | |
902 corrections++; | |
903 } | |
904 | |
905 /* uint8_t stop_increment_depth_meter; | |
906 */ | |
907 if(Settings.stop_increment_depth_meter != 3) | |
908 { | |
909 Settings.stop_increment_depth_meter = 3; | |
910 corrections++; | |
911 } | |
912 | |
913 /* uint8_t brightness; | |
914 */ | |
915 if(Settings.brightness > 4) | |
916 { | |
917 Settings.brightness = 4; | |
918 corrections++; | |
919 } | |
920 | |
921 /* uint8_t date_format; | |
922 */ | |
923 if( (Settings.date_format != DDMMYY) && | |
924 (Settings.date_format != MMDDYY) && | |
925 (Settings.date_format != YYMMDD)) | |
926 { | |
927 Settings.date_format = DDMMYY; | |
928 corrections++; | |
929 } | |
930 | |
931 /* uint8_t selected_language; | |
932 */ | |
933 if(Settings.selected_language >= LANGUAGE_END) | |
934 { | |
935 Settings.selected_language = LANGUAGE_English; | |
936 corrections++; | |
937 } | |
938 | |
939 /* char customtext[60]; | |
940 */ | |
941 if(Settings.customtext[59] != 0) | |
942 { | |
943 Settings.customtext[59] = 0; | |
944 corrections++; | |
945 } | |
946 | |
947 /* uint16_t timeoutSurfacemode; | |
948 */ | |
949 if( (Settings.timeoutSurfacemode != 20) && // Quick Sleep Option | |
950 (Settings.timeoutSurfacemode != 120)) | |
951 { | |
952 Settings.timeoutSurfacemode = 120; | |
953 corrections++; | |
954 } | |
955 | |
956 /* uint8_t timeoutMenuSurface; | |
957 */ | |
958 if(Settings.timeoutMenuSurface != 120) | |
959 { | |
960 Settings.timeoutMenuSurface = 120; | |
961 corrections++; | |
962 } | |
963 | |
964 /* uint8_t timeoutMenuDive; | |
965 */ | |
966 if(Settings.timeoutMenuDive != 120) | |
967 { | |
968 Settings.timeoutMenuDive = 120; | |
969 corrections++; | |
970 } | |
971 | |
972 /* uint8_t timeoutMenuEdit; | |
973 */ | |
974 if(Settings.timeoutMenuEdit != 120) | |
975 { | |
976 Settings.timeoutMenuEdit = 120; | |
977 corrections++; | |
978 } | |
979 | |
980 /* uint8_t timeoutInfo; | |
981 */ | |
982 if(Settings.timeoutInfo != 120) | |
983 { | |
984 Settings.timeoutInfo = 120; | |
985 corrections++; | |
986 } | |
987 | |
988 /* uint8_t timeoutInfoCompass; | |
989 */ | |
990 if(Settings.timeoutInfoCompass != 60) | |
991 { | |
992 Settings.timeoutInfoCompass = 60; | |
993 corrections++; | |
994 } | |
995 | |
996 /* uint8_t design; | |
997 */ | |
998 if(Settings.design != 7) | |
999 { | |
1000 Settings.design = 7; | |
1001 corrections++; | |
1002 } | |
1003 | |
1004 /* uint16_t timeoutDiveReachedZeroDepth; | |
1005 */ | |
1006 if(Settings.timeoutDiveReachedZeroDepth != 300) | |
1007 { | |
1008 Settings.timeoutDiveReachedZeroDepth = 300; | |
1009 corrections++; | |
1010 } | |
1011 | |
1012 /* uint16_t divetimeToCreateLogbook; | |
1013 */ | |
1014 if(Settings.divetimeToCreateLogbook != 60) | |
1015 { | |
1016 Settings.divetimeToCreateLogbook = 60; | |
1017 corrections++; | |
1018 } | |
1019 | |
1020 /* uint8_t serialHigh; | |
1021 */ | |
1022 | |
1023 /* uint8_t serialLow; | |
1024 */ | |
1025 | |
1026 /* SUFirmware firmwareVersion16to32bit; | |
1027 */ | |
1028 | |
1029 /* uint32_t backup_localtime_rtc_tr; | |
1030 */ | |
1031 | |
1032 /* uint32_t backup_localtime_rtc_dr; | |
1033 */ | |
1034 | |
1035 /* uint16_t totalDiveCounter; | |
1036 */ | |
1037 | |
1038 /* uint16_t personalDiveCount; | |
1039 */ | |
1040 | |
1041 /* uint8_t showDebugInfo; | |
1042 */ | |
1043 if(Settings.showDebugInfo > 1) | |
1044 { | |
1045 Settings.showDebugInfo = 0; | |
1046 corrections++; | |
1047 } | |
1048 | |
1049 /* uint8_t ButtonResponsiveness[4]; | |
1050 */ | |
1051 // Base value, index 3 | |
93 | 1052 if(Settings.ButtonResponsiveness[3] < MIN_BUTTONRESPONSIVENESS_GUI) |
38 | 1053 { |
93 | 1054 Settings.ButtonResponsiveness[3] = MIN_BUTTONRESPONSIVENESS_GUI; |
38 | 1055 corrections++; |
1056 } | |
1057 else | |
93 | 1058 if(Settings.ButtonResponsiveness[3] > MIN_BUTTONRESPONSIVENESS_GUI) |
38 | 1059 { |
93 | 1060 Settings.ButtonResponsiveness[3] = MIN_BUTTONRESPONSIVENESS; |
38 | 1061 corrections++; |
1062 } | |
1063 // flex values 0, 1, 2 | |
1064 for(int i=0; i<3;i++) | |
1065 { | |
93 | 1066 if(Settings.ButtonResponsiveness[i] < MIN_BUTTONRESPONSIVENESS) // 50-10 //Fix for broken buttons. :) |
38 | 1067 { |
93 | 1068 Settings.ButtonResponsiveness[i] = MIN_BUTTONRESPONSIVENESS; |
38 | 1069 corrections++; |
1070 } | |
1071 else | |
93 | 1072 if(Settings.ButtonResponsiveness[i] > MAX_BUTTONRESPONSIVENESS) // 110+20 |
38 | 1073 { |
93 | 1074 Settings.ButtonResponsiveness[i] = MAX_BUTTONRESPONSIVENESS; |
38 | 1075 corrections++; |
1076 } | |
1077 } | |
1078 | |
1079 /* uint8_t buttonBalance[3]; | |
1080 */ | |
1081 for(int i=0; i<3;i++) | |
1082 { | |
1083 if(Settings.buttonBalance[i] < 2) // 2 = -10 | |
1084 { | |
1085 Settings.buttonBalance[i] = 2; | |
1086 corrections++; | |
1087 } | |
1088 else | |
1089 if(Settings.buttonBalance[i] > 5) // 3 = 0, 4 = +10, 5 = +20 | |
1090 { | |
1091 Settings.buttonBalance[i] = 5; | |
1092 corrections++; | |
1093 } | |
1094 } | |
1095 | |
1096 /* uint8_t nonMetricalSystem; | |
1097 */ | |
1098 if(Settings.nonMetricalSystem > 1) | |
1099 { | |
1100 Settings.nonMetricalSystem = 1; | |
1101 corrections++; | |
1102 } | |
1103 | |
1104 /* uint8_t fallbackToFixedSetpoint; | |
1105 */ | |
1106 if(Settings.fallbackToFixedSetpoint > 1) | |
1107 { | |
1108 Settings.fallbackToFixedSetpoint = 1; | |
1109 corrections++; | |
1110 } | |
1111 | |
1112 /* uint8_t bluetoothActive; | |
1113 */ | |
1114 if(Settings.bluetoothActive > 1) | |
1115 { | |
1116 Settings.bluetoothActive = 1; | |
1117 corrections++; | |
1118 } | |
1119 | |
1120 /* uint8_t safetystopDepth; | |
1121 */ | |
1122 if(Settings.safetystopDepth > 6) | |
1123 { | |
1124 Settings.safetystopDepth = 6; | |
1125 corrections++; | |
1126 } | |
1127 if(Settings.safetystopDepth < 3) | |
1128 { | |
1129 Settings.safetystopDepth = 3; | |
1130 corrections++; | |
1131 } | |
1132 | |
1133 /* uint32_t updateSettingsAllowedFromHeader; | |
1134 */ | |
1135 | |
1136 /* uint8_t scooterControl; | |
1137 */ | |
1138 if(Settings.scooterControl > 1) | |
1139 { | |
1140 Settings.scooterControl = 1; | |
1141 corrections++; | |
1142 } | |
1143 | |
1144 /* char scooterDeviceAddress[12]; | |
1145 */ | |
1146 | |
1147 /* char scooterDeviceName[19]; | |
1148 */ | |
1149 | |
1150 /* uint8_t ppo2sensors_deactivated; | |
1151 */ | |
1152 if(Settings.ppo2sensors_deactivated > (1+2+4)) | |
1153 { | |
1154 Settings.ppo2sensors_deactivated = 0; | |
1155 corrections++; | |
1156 } | |
1157 | |
1158 /* uint8_t tX_colorscheme; | |
1159 */ | |
1160 if(Settings.tX_colorscheme > 3) | |
1161 { | |
1162 Settings.tX_colorscheme = 0; | |
1163 corrections++; | |
1164 } | |
1165 | |
1166 /* uint8_t tX_userselectedLeftLowerCornerPrimary; | |
1167 */ | |
1168 if(Settings.tX_userselectedLeftLowerCornerPrimary > 7) | |
1169 { | |
1170 Settings.tX_userselectedLeftLowerCornerPrimary = 1; | |
1171 corrections++; | |
1172 } | |
1173 | |
1174 /* uint8_t tX_userselectedLeftLowerCornerTimeout; | |
1175 */ | |
1176 if(Settings.tX_userselectedLeftLowerCornerTimeout > 60) | |
1177 { | |
1178 Settings.tX_userselectedLeftLowerCornerTimeout = 0; | |
1179 corrections++; | |
1180 } | |
1181 | |
1182 /* uint8_t tX_customViewPrimary; | |
1183 */ | |
1184 if(Settings.tX_customViewPrimary >= CVIEW_END) | |
1185 { | |
1186 Settings.tX_customViewPrimary = 1; | |
1187 corrections++; | |
1188 } | |
1189 | |
1190 /* uint8_t tX_customViewTimeout; | |
1191 */ | |
1192 if(Settings.tX_customViewTimeout > 60) | |
1193 { | |
1194 Settings.tX_customViewTimeout = 0; | |
1195 corrections++; | |
1196 } | |
1197 | |
1198 /* uint8_t timeoutEnterButtonSelectDive; | |
1199 */ | |
1200 if(Settings.timeoutEnterButtonSelectDive != 10) | |
1201 { | |
1202 Settings.timeoutEnterButtonSelectDive = 10; | |
1203 corrections++; | |
1204 } | |
1205 | |
1206 /* uint8_t logbookOffset; | |
1207 */ | |
1208 if(Settings.logbookOffset > 9000) | |
1209 { | |
1210 Settings.logbookOffset = 0; | |
1211 corrections++; | |
1212 } | |
1213 | |
1214 /* uint8_t alwaysShowPPO2; | |
1215 */ | |
1216 if(Settings.alwaysShowPPO2 > 1) | |
1217 { | |
1218 Settings.alwaysShowPPO2 = 0; | |
1219 corrections++; | |
1220 } | |
1221 | |
1222 /* uint8_t extraDisplay; | |
1223 */ | |
1224 if(Settings.extraDisplay >= EXTRADISPLAY_END) | |
1225 { | |
1226 Settings.extraDisplay = EXTRADISPLAY_BIGFONT; | |
1227 corrections++; | |
1228 } | |
1229 | |
1230 /* int8_t offsetPressure_mbar; | |
1231 */ | |
1232 if((Settings.offsetPressure_mbar > 20) || | |
1233 (Settings.offsetPressure_mbar < -20)) | |
1234 { | |
1235 Settings.offsetPressure_mbar = 0; | |
1236 corrections++; | |
1237 } | |
1238 | |
1239 /* int8_t offsetTemperature_centigrad; | |
1240 */ | |
1241 if((Settings.offsetTemperature_centigrad > 20) || | |
1242 (Settings.offsetTemperature_centigrad < -20)) | |
1243 { | |
1244 Settings.offsetTemperature_centigrad = 0; | |
1245 corrections++; | |
1246 } | |
1247 | |
1248 /* uint8_t gasConsumption_travel_l_min; | |
1249 */ | |
1250 if((Settings.gasConsumption_travel_l_min < 5) || | |
1251 (Settings.gasConsumption_travel_l_min > 50)) | |
1252 { | |
1253 Settings.gasConsumption_travel_l_min = 20; | |
1254 corrections++; | |
1255 } | |
1256 | |
1257 /* uint8_t gasConsumption_bottom_l_min; | |
1258 */ | |
1259 if((Settings.gasConsumption_bottom_l_min < 5) || | |
1260 (Settings.gasConsumption_bottom_l_min > 50)) | |
1261 { | |
1262 Settings.gasConsumption_bottom_l_min = 20; | |
1263 corrections++; | |
1264 } | |
1265 | |
1266 /* uint8_t gasConsumption_deco_l_min; | |
1267 */ | |
1268 if((Settings.gasConsumption_deco_l_min < 5) || | |
1269 (Settings.gasConsumption_deco_l_min > 50)) | |
1270 { | |
1271 Settings.gasConsumption_deco_l_min = 20; | |
1272 corrections++; | |
1273 } | |
1274 | |
1275 /* uint8_t showDebugInfo; | |
1276 */ | |
1277 #ifdef BOOT16 | |
1278 Settings.showDebugInfo = 0; | |
1279 #else | |
1280 if(Settings.showDebugInfo > 1) | |
1281 Settings.showDebugInfo = 0; | |
1282 | |
1283 #endif | |
1284 | |
1285 /* uint8_t selected_language; | |
1286 */ | |
1287 #ifdef BOOT16 | |
1288 if(Settings.selected_language > 1) | |
1289 Settings.selected_language = 0; | |
1290 #else | |
1291 if(Settings.selected_language > 4) | |
1292 Settings.selected_language = 0; | |
1293 #endif | |
1294 | |
1295 | |
1296 /* uint8_t display_toogle_desc; 1/10 seconds | |
1297 */ | |
1298 if((Settings.display_toogle_desc < 20) || (Settings.display_toogle_desc > 600)) | |
1299 { | |
1300 Settings.display_toogle_desc = SettingsStandard.display_toogle_desc; | |
1301 corrections++; | |
1302 } | |
1303 | |
1304 /* uint8_t debugModeOnStart; | |
1305 */ | |
1306 if(Settings.debugModeOnStart > 1) | |
1307 { | |
1308 Settings.debugModeOnStart = 0; | |
1309 corrections++; | |
1310 } | |
1311 | |
1312 | |
1313 /* uint8_t IAmStolenPleaseKillMe; | |
1314 */ | |
1315 | |
1316 if(hardwareDataGetPointer()->primarySerial == 90) | |
1317 Settings.IAmStolenPleaseKillMe++; | |
1318 else | |
1319 Settings.IAmStolenPleaseKillMe = 0; | |
1320 | |
1321 | |
1322 /* uint8_t debugModeOnStart; | |
1323 */ | |
1324 if(Settings.compassBearing > 360) | |
1325 { | |
1326 Settings.compassBearing = 0; | |
1327 corrections++; | |
1328 } | |
1329 | |
1330 /* uint8_t scooterDrag; | |
1331 */ | |
1332 if(Settings.scooterDrag > 3) | |
1333 { | |
1334 Settings.scooterDrag = 3; | |
1335 corrections++; | |
1336 } | |
1337 | |
1338 /* uint8_t scooterLoad; | |
1339 */ | |
1340 if(Settings.scooterLoad > 4) | |
1341 { | |
1342 Settings.scooterLoad = 4; | |
1343 corrections++; | |
1344 } | |
1345 | |
1346 /* uint8_t scooterNumberOfBatteries; | |
1347 */ | |
1348 if(Settings.scooterNumberOfBatteries > 3) | |
1349 { | |
1350 Settings.scooterNumberOfBatteries = 3; | |
1351 corrections++; | |
1352 } | |
1353 | |
1354 /* uint16_t scooterBattSize; | |
1355 */ | |
1356 if((Settings.scooterBattSize < 300) || | |
1357 (Settings.scooterBattSize > 5000)) | |
1358 { | |
1359 Settings.scooterBattSize = 700; | |
1360 corrections++; | |
1361 } | |
1362 | |
1363 | |
1364 /* uint8_t lastKnownBatteryPercentage; | |
1365 */ | |
1366 if(Settings.lastKnownBatteryPercentage > 100) | |
1367 { | |
1368 Settings.lastKnownBatteryPercentage = 100; | |
1369 corrections++; | |
1370 } | |
1371 | |
1372 /* uint8_t VPM_model | |
1373 */ | |
1374 if((Settings.VPM_model != VPM_FROM_FORTRAN) && (Settings.VPM_model != VPM_BACHELORWORK)) | |
1375 { | |
1376 Settings.VPM_model = VPM_FROM_FORTRAN; | |
1377 corrections++; | |
1378 } | |
1379 | |
1380 /* uint8_t Buehlmann_model | |
1381 */ | |
1382 if((Settings.GF_model != BUEHLMANN_OSTC4) && (Settings.GF_model != BUEHLMANN_hwOS)) | |
1383 { | |
1384 Settings.GF_model = BUEHLMANN_OSTC4; | |
1385 corrections++; | |
1386 } | |
1387 | |
111
38785aa95837
Added new nvm parameter"FlipDisplay" indicating the screen orientation
Ideenmodellierer
parents:
75
diff
changeset
|
1388 if(Settings.FlipDisplay > 1) /* only boolean values allowed */ |
38785aa95837
Added new nvm parameter"FlipDisplay" indicating the screen orientation
Ideenmodellierer
parents:
75
diff
changeset
|
1389 { |
38785aa95837
Added new nvm parameter"FlipDisplay" indicating the screen orientation
Ideenmodellierer
parents:
75
diff
changeset
|
1390 Settings.FlipDisplay = 0; |
38785aa95837
Added new nvm parameter"FlipDisplay" indicating the screen orientation
Ideenmodellierer
parents:
75
diff
changeset
|
1391 corrections++; |
38785aa95837
Added new nvm parameter"FlipDisplay" indicating the screen orientation
Ideenmodellierer
parents:
75
diff
changeset
|
1392 } |
38 | 1393 |
1394 if(corrections > 255) | |
1395 return 255; | |
1396 else | |
1397 return (uint8_t)corrections; | |
1398 } | |
1399 | |
1400 | |
1401 /* always at 0x8080000, do not move -> bootloader access */ | |
1402 const SFirmwareData* firmwareDataGetPointer(void) | |
1403 { | |
1404 return &firmware_FirmwareData; | |
1405 } | |
1406 | |
1407 | |
1408 #ifndef SPECIALPROGRAMM | |
1409 const SHardwareData* hardwareDataGetPointer(void) | |
1410 { | |
1411 return (SHardwareData *)HARDWAREDATA_ADDRESS; | |
1412 } | |
1413 #endif | |
1414 | |
1415 const SSettings* settingsGetPointerStandard(void) | |
1416 { | |
1417 return &SettingsStandard; | |
1418 } | |
1419 | |
1420 | |
1421 void hardwareBatchCode(uint8_t *high, uint8_t *low) | |
1422 { | |
1423 if(high) | |
1424 { | |
1425 *high = (uint8_t)((hardwareDataGetPointer()->production_year - 16) * 16); | |
1426 *high += hardwareDataGetPointer()->production_month; | |
1427 if(low) | |
1428 { | |
1429 *low = (uint8_t)(hardwareDataGetPointer()->production_day * 8); | |
1430 } | |
1431 } | |
1432 } | |
1433 | |
1434 | |
1435 uint8_t firmwareVersion_16bit_high(void) | |
1436 { | |
1437 return ((firmware_FirmwareData.versionFirst & 0x1F) << 3) + ((firmware_FirmwareData.versionSecond & 0x1C) >> 5); | |
1438 } | |
1439 | |
1440 uint8_t firmwareVersion_16bit_low(void) | |
1441 { | |
1442 return ((firmware_FirmwareData.versionSecond & 0x03) << 6) + ((firmware_FirmwareData.versionThird & 0x1F) << 1) + (firmware_FirmwareData.versionBeta & 0x01); | |
1443 } | |
1444 | |
1445 SSettings* settingsGetPointer(void) | |
1446 { | |
1447 return &Settings; | |
1448 } | |
1449 | |
1450 | |
1451 // =============================================================================== | |
1452 // set_settings_to_Standard | |
1453 /// @brief This function overwrites the current settings of the system | |
1454 /// with the EXCEPTION of the personalDiveCount | |
1455 /// | |
1456 /// It additionally calls set_new_settings_missing_in_ext_flash() and | |
1457 /// check_and_correct_settings(), even so this shouldn't be necessary. | |
1458 /// It is called on every start and from Reset All. | |
1459 /// | |
1460 /// 160622 added lastDiveLogIdBackup | |
1461 /// | |
1462 // =============================================================================== | |
1463 void set_settings_to_Standard(void) | |
1464 { | |
1465 SSettings *pSettings; | |
1466 const SSettings *pSettingsStandard; | |
1467 uint16_t personalDiveCountBackup; | |
1468 uint8_t lastDiveLogIdBackup; | |
1469 pSettings = settingsGetPointer(); | |
1470 pSettingsStandard = settingsGetPointerStandard(); | |
1471 | |
1472 personalDiveCountBackup = pSettings->personalDiveCount; | |
1473 lastDiveLogIdBackup = pSettings->lastDiveLogId; | |
1474 memcpy(pSettings,pSettingsStandard,sizeof(*pSettings)); | |
1475 pSettings->personalDiveCount = personalDiveCountBackup; | |
1476 pSettings->lastDiveLogId = lastDiveLogIdBackup; | |
1477 | |
1478 pSettings->firmwareVersion[0] = firmware_FirmwareData.versionFirst; | |
1479 pSettings->firmwareVersion[1] = firmware_FirmwareData.versionSecond; | |
1480 pSettings->firmwareVersion[2] = firmware_FirmwareData.versionThird; | |
1481 pSettings->firmwareVersion[3] = firmware_FirmwareData.versionBeta; | |
1482 | |
1483 set_new_settings_missing_in_ext_flash(); | |
1484 check_and_correct_settings(); | |
1485 // has to be called too: createDiveSettings(); | |
1486 } | |
1487 | |
1488 | |
1489 // =============================================================================== | |
1490 // mod_settings_for_first_start_with_empty_ext_flash | |
1491 /// @brief This function overwrites some settings of the system | |
1492 /// It is called on every start. | |
1493 /// Those settings will be overwriten by ext_flash_read_settings() | |
1494 /// Will be kept if ext_flash_read_settings() is invalid because | |
1495 /// it is still empty. | |
1496 /// | |
1497 // =============================================================================== | |
1498 void mod_settings_for_first_start_with_empty_ext_flash(void) | |
1499 { | |
1500 settingsGetPointer()->debugModeOnStart = 1; // | |
1501 } | |
1502 | |
1503 | |
1504 | |
1505 // =============================================================================== | |
1506 // hwOS4_to_hwOS_GasType | |
1507 /// @brief Helper for get gas / diluent | |
1508 /// | |
1509 // =============================================================================== | |
1510 uint8_t hwOS4_to_hwOS_GasType(uint8_t inOSTC4style) | |
1511 { | |
1512 switch(inOSTC4style) | |
1513 { | |
1514 case (1+2): // first | |
1515 case (2): // first | |
1516 return 1; // hwOS style first | |
1517 case (1+4): // deco | |
1518 case (4): // deco | |
1519 return 3; // hwOS style deco | |
1520 case (1+8): // travel | |
1521 case (8): // travel | |
1522 return 2; // hwOS style travel | |
1523 default: | |
1524 return 0; // hwOS style Disabled | |
1525 } | |
1526 } | |
1527 | |
1528 | |
1529 // =============================================================================== | |
1530 // hwOS_to_hwOS4_GasType | |
1531 /// @brief Helper for set gas / diluent | |
1532 /// | |
1533 // =============================================================================== | |
1534 uint8_t hwOS_to_hwOS4_GasType(uint8_t inOSTC4style) | |
1535 { | |
1536 switch(inOSTC4style) | |
1537 { | |
1538 case (1): // first | |
1539 return 1+2; // hwOS4 style first | |
1540 case (2): // travel (normal for diluent) | |
1541 return 1+8; // hwOS4 style travel | |
1542 case (3): // deco | |
1543 return 1+4; // hwOS4 style deco | |
1544 default: | |
1545 return 0; // hwOS4 style inactive | |
1546 } | |
1547 } | |
1548 | |
1549 | |
1550 | |
1551 // =============================================================================== | |
1552 // setGas | |
1553 /// @brief This function overwrites one gas, including mode and deco depth, | |
1554 /// it returns 0x4D prompt which is not used by writeData() that calls it. | |
1555 /// | |
1556 /// @param i the gas id from 1 to 5 for OC and 6 to 10 for CCR, 0 is the extra gas | |
1557 /// @param *data 5 bytes with the first the command to call setGas and the four | |
1558 /// following bytes to define oxygen, helium, mode and deco depth | |
1559 /// | |
1560 /// @return 0x4D (prompt that is not used) | |
1561 // =============================================================================== | |
1562 uint8_t setGas(int i,uint8_t * data) | |
1563 { | |
1564 if(!checkValue(data[1],4,100)) | |
1565 return ERROR_; | |
1566 if(!checkValue(data[4],0,250)) | |
1567 return ERROR_; | |
1568 | |
1569 Settings.gas[i].oxygen_percentage = data[1]; | |
1570 Settings.gas[i].helium_percentage = data[2]; | |
1571 Settings.gas[i].note.uw = hwOS_to_hwOS4_GasType(data[3]); | |
1572 Settings.gas[i].depth_meter = data[4]; | |
1573 return 0x4d; | |
1574 } | |
1575 | |
1576 | |
1577 uint8_t getGas(int i,uint8_t * data) | |
1578 { | |
1579 data[0] = Settings.gas[i].oxygen_percentage; | |
1580 data[1] = Settings.gas[i].helium_percentage; | |
1581 data[2] = hwOS4_to_hwOS_GasType(Settings.gas[i].note.uw); | |
1582 data[3] = Settings.gas[i].depth_meter; | |
1583 return 0x4d; | |
1584 } | |
1585 | |
1586 uint8_t setDiluent(int i,uint8_t * data) | |
1587 { | |
1588 if(!checkValue(data[1],4,100)) | |
1589 return ERROR_; | |
1590 if(!checkValue(data[4],0,250)) | |
1591 return ERROR_; | |
1592 | |
1593 Settings.gas[NUM_OFFSET_DILUENT + i].oxygen_percentage = data[1]; | |
1594 Settings.gas[NUM_OFFSET_DILUENT + i].helium_percentage = data[2]; | |
1595 Settings.gas[NUM_OFFSET_DILUENT + i].note.uw = hwOS_to_hwOS4_GasType(data[3]); | |
1596 Settings.gas[NUM_OFFSET_DILUENT + i].depth_meter = data[4]; | |
1597 return 0x4d; | |
1598 } | |
1599 | |
1600 uint8_t getDiluent(int i,uint8_t * data) | |
1601 { | |
1602 data[0] = Settings.gas[NUM_OFFSET_DILUENT + i].oxygen_percentage; | |
1603 data[1] = Settings.gas[NUM_OFFSET_DILUENT + i].helium_percentage; | |
1604 data[2] = hwOS4_to_hwOS_GasType(Settings.gas[NUM_OFFSET_DILUENT + i].note.uw); | |
1605 data[3] = Settings.gas[NUM_OFFSET_DILUENT + i].depth_meter; | |
1606 return 0x4d; | |
1607 } | |
1608 | |
1609 uint8_t setSetpoint(int i,uint8_t * data) | |
1610 { | |
1611 if(!checkValue(data[1],50,160)) | |
1612 return ERROR_; | |
1613 if(!checkValue(data[2],0,250)) | |
1614 return ERROR_; | |
1615 | |
1616 Settings.setpoint[i].setpoint_cbar = data[1]; | |
1617 Settings.setpoint[i].depth_meter = data[2]; | |
1618 return 0x4d; | |
1619 } | |
1620 | |
1621 uint8_t getSetpoint(int i,uint8_t * data) | |
1622 { | |
1623 data[0] = Settings.setpoint[i].setpoint_cbar; | |
1624 data[1] = Settings.setpoint[i].depth_meter; | |
1625 return 0x4d; | |
1626 } | |
1627 | |
1628 uint8_t checkValue(uint8_t value,uint8_t from, uint8_t to) | |
1629 { | |
1630 if(value >= from && value <= to) | |
1631 return 1; | |
1632 return 0; | |
1633 } | |
1634 | |
1635 uint8_t writeData(uint8_t * data) | |
1636 { | |
1637 uint32_t newSensitivity; | |
1638 uint16_t newDuration, newOffset; | |
1639 uint8_t newStopDepth; | |
1640 | |
1641 switch(data[0]) | |
1642 { | |
1643 case 0x10: | |
1644 return setGas(1,data); | |
1645 case 0x11: | |
1646 return setGas(2,data); | |
1647 case 0x12: | |
1648 return setGas(3,data); | |
1649 case 0x13: | |
1650 return setGas(4,data); | |
1651 case 0x14: | |
1652 return setGas(5,data); | |
1653 case 0x15: | |
1654 return setDiluent(1,data); | |
1655 case 0x16: | |
1656 return setDiluent(2,data); | |
1657 case 0x17: | |
1658 return setDiluent(3,data); | |
1659 case 0x18: | |
1660 return setDiluent(4,data); | |
1661 case 0x19: | |
1662 return setDiluent(5,data); | |
1663 case 0x1A: | |
1664 return setSetpoint(1,data); | |
1665 case 0x1B: | |
1666 return setSetpoint(2,data); | |
1667 case 0x1C: | |
1668 return setSetpoint(3,data); | |
1669 case 0x1D: | |
1670 return setSetpoint(4,data); | |
1671 case 0x1E: | |
1672 return setSetpoint(5,data); | |
1673 case 0x1F: | |
1674 if(!checkValue(data[2],0,1)) | |
1675 return ERROR_; | |
1676 Settings.CCR_Mode = data[1]; | |
1677 break; | |
1678 case 0x20: | |
1679 if(!checkValue(data[1],0,3)) | |
1680 return ERROR_; | |
1681 Settings.dive_mode = data[1]; | |
1682 break; | |
1683 case 0x21: | |
1684 if(!checkValue(data[1],1,2)) | |
1685 return ERROR_; | |
1686 Settings.deco_type.ub.standard = data[1] & 0x0F; | |
1687 //Settings.deco_type.ub.alternative = (data[1] & 0xF0) >> 4; | |
1688 break; | |
1689 case 0x22: | |
1690 if(!checkValue(data[1],100,190)) | |
1691 return ERROR_; | |
1692 Settings.ppO2_max_std = data[1]; | |
1693 break; | |
1694 case 0x23: | |
1695 if(!checkValue(data[1],15,15)) | |
1696 return ERROR_; | |
1697 Settings.ppO2_min = data[1]; | |
1698 break; | |
1699 case 0x24: | |
1700 if(!checkValue(data[1],0,15)) | |
1701 return ERROR_; | |
1702 Settings.future_TTS = data[1]; | |
1703 break; | |
1704 case 0x25: | |
1705 if(!checkValue(data[1],10,99)) | |
1706 return ERROR_; | |
1707 Settings.GF_low = data[1]; | |
1708 break; | |
1709 case 0x26: | |
1710 if(!checkValue(data[1],45,99)) | |
1711 return ERROR_; | |
1712 Settings.GF_high = data[1]; | |
1713 break; | |
1714 case 0x27: | |
1715 if(!checkValue(data[1],10,99)) | |
1716 return ERROR_; | |
1717 Settings.aGF_low = data[1]; | |
1718 break; | |
1719 case 0x28: | |
1720 if(!checkValue(data[1],45,99)) | |
1721 return ERROR_; | |
1722 Settings.aGF_high = data[1]; | |
1723 break; | |
1724 case 0x29: | |
1725 if(!checkValue(data[1],0,5)) | |
1726 return ERROR_; | |
1727 Settings.VPM_conservatism.ub.standard = data[1]; | |
1728 break; | |
1729 case 0x2A: | |
1730 case 0x2B: | |
1731 return ERROR_; | |
1732 case 0x2C: | |
1733 if(!checkValue(data[1],3,9)) | |
1734 return ERROR_; | |
1735 Settings.last_stop_depth_meter = data[1]; | |
1736 break; | |
1737 case 0x2D: | |
1738 if(!checkValue(data[1],0,4)) | |
1739 return ERROR_; | |
1740 Settings.brightness = data[1]; | |
1741 break; | |
1742 case 0x2E: | |
1743 if(!checkValue(data[1],0,1)) | |
1744 return ERROR_; | |
1745 Settings.nonMetricalSystem = data[1]; | |
1746 break; | |
1747 case 0x2F: | |
1748 return ERROR_; | |
1749 case 0x30: | |
1750 if(!checkValue(data[1],0,4)) | |
1751 return ERROR_; | |
1752 Settings.salinity = data[1]; | |
1753 break; | |
1754 case 0x31: | |
1755 if(!checkValue(data[1],0,3)) | |
1756 return ERROR_; | |
1757 Settings.tX_colorscheme = data[1]; | |
1758 GFX_use_colorscheme(Settings.tX_colorscheme); | |
1759 break; | |
1760 case 0x32: | |
1761 if(!checkValue(data[1],0,4)) | |
1762 return ERROR_; | |
1763 Settings.selected_language = data[1]; | |
1764 break; | |
1765 case 0x33: | |
1766 if(!checkValue(data[1],0,2)) | |
1767 return ERROR_; | |
1768 Settings.date_format = data[1]; | |
1769 break; | |
1770 case 0x34: | |
1771 return ERROR_; | |
1772 case 0x35: | |
1773 if(data[1] & 0x80) | |
1774 { | |
1775 data[1] = ~(data[1]); | |
1776 if(!checkValue(data[1],0,20)) | |
1777 return ERROR_; | |
1778 Settings.offsetPressure_mbar = 0 - data[1]; | |
1779 } | |
1780 else | |
1781 { | |
1782 if(!checkValue(data[1],0,20)) | |
1783 return ERROR_; | |
1784 Settings.offsetPressure_mbar = data[1]; | |
1785 } | |
1786 break; | |
1787 case 0x36: | |
1788 if(!checkValue(data[1],0,1)) | |
1789 return ERROR_; | |
1790 if(data[1]) | |
1791 Settings.safetystopDuration = settingsGetPointerStandard()->safetystopDuration; | |
1792 else | |
1793 Settings.safetystopDuration = 0; | |
1794 break; | |
1795 case 0x37: | |
1796 return ERROR_; | |
1797 case 0x38: | |
1798 if(!checkValue(data[1],0,1)) | |
1799 return ERROR_; | |
1800 Settings.fallbackToFixedSetpoint = data[1]; | |
1801 break; | |
1802 case 0x39: | |
1803 return ERROR_; | |
1804 case 0x3A: | |
1805 if(!checkValue(data[1],70,110)) | |
1806 return ERROR_; | |
1807 newSensitivity = data[1]; | |
1808 settingsHelperButtonSens_keepPercentageValues(newSensitivity, settingsGetPointer()->ButtonResponsiveness); | |
1809 setButtonResponsiveness(Settings.ButtonResponsiveness); | |
1810 break; | |
1811 case 0x3B: | |
1812 // value between 0 and 127 | |
1813 if(buttonBalanceTranslatorHexToArray(data[1], settingsGetPointer()->buttonBalance)) | |
1814 { | |
1815 settingsHelperButtonSens_keepPercentageValues(settingsGetPointer()->ButtonResponsiveness[3], settingsGetPointer()->ButtonResponsiveness); | |
1816 } | |
1817 else // value >= 128 (bit 7 set) factory reset | |
1818 { | |
1819 getButtonFactorDefaults(&settingsGetPointer()->ButtonResponsiveness[3], settingsGetPointer()->buttonBalance); | |
1820 settingsHelperButtonSens_keepPercentageValues(settingsGetPointerStandard()->ButtonResponsiveness[3], settingsGetPointer()->ButtonResponsiveness); | |
1821 } | |
1822 // valid for both: | |
1823 setButtonResponsiveness(Settings.ButtonResponsiveness); | |
1824 break; | |
1825 case 0x3C: | |
1826 if(!checkValue(data[1],5,50)) | |
1827 return ERROR_; | |
1828 Settings.gasConsumption_bottom_l_min = data[1]; | |
1829 break; | |
1830 case 0x3D: | |
1831 if(!checkValue(data[1],5,50)) | |
1832 return ERROR_; | |
1833 Settings.gasConsumption_deco_l_min = data[1]; | |
1834 break; | |
1835 case 0x3E: | |
1836 if(!checkValue(data[1],5,50)) | |
1837 return ERROR_; | |
1838 Settings.gasConsumption_travel_l_min = data[1]; | |
1839 break; | |
1840 case 0x3F: | |
1841 case 0x40: | |
1842 return ERROR_; | |
1843 case 0x41: | |
1844 if(!checkValue(data[1],0,1)) | |
1845 return ERROR_; | |
1846 Settings.alwaysShowPPO2 = data[1]; | |
1847 break; | |
1848 case 0x42: | |
1849 if(data[1] & 0x80) | |
1850 { | |
1851 data[1] = ~(data[1]); | |
1852 if(!checkValue(data[1],0,20)) | |
1853 return ERROR_; | |
1854 Settings.offsetTemperature_centigrad = 0 - data[1]; | |
1855 } | |
1856 else | |
1857 { | |
1858 if(!checkValue(data[1],0,20)) | |
1859 return ERROR_; | |
1860 Settings.offsetTemperature_centigrad = data[1]; | |
1861 } | |
1862 break; | |
1863 case 0x43: | |
1864 if(!checkValue(data[1],60,255)) | |
1865 return ERROR_; | |
1866 newDuration = (uint16_t)data[1] + 59; | |
1867 newDuration /= 60; | |
1868 Settings.safetystopDuration = (uint8_t)newDuration; | |
1869 break; | |
1870 case 0x44: | |
1871 if(!checkValue(data[1],21,61)) | |
1872 return ERROR_; | |
1873 newStopDepth = data[1] + 9; | |
1874 if(newStopDepth > 60) | |
1875 newStopDepth = 60; | |
1876 newStopDepth /= 10; | |
1877 Settings.safetystopDepth = newStopDepth; | |
1878 break; | |
1879 case 0x45: | |
1880 case 0x46: | |
1881 return ERROR_; | |
1882 case 0x47: | |
1883 newOffset = data[2] * 256; | |
1884 newOffset += data[1]; | |
1885 if(newOffset > 9000) | |
1886 return ERROR_; | |
1887 Settings.logbookOffset = newOffset; | |
1888 break; | |
1889 case 0x70: | |
1890 if(!checkValue(data[1],0,1)) | |
1891 return ERROR_; | |
1892 Settings.showDebugInfo = data[1]; | |
1893 break; | |
1894 case 0x71: | |
1895 if(!checkValue(data[1],0,(EXTRADISPLAY_END - 1))) | |
1896 return ERROR_; | |
1897 Settings.extraDisplay = data[1]; | |
1898 break; | |
1899 case 0x72: | |
1900 if(!checkValue(data[1],0,8)) | |
1901 return ERROR_; | |
1902 Settings.tX_customViewPrimary = data[1]; | |
1903 break; | |
1904 case 0x73: | |
1905 if(!checkValue(data[1],0,20)) | |
1906 return ERROR_; | |
1907 Settings.tX_customViewTimeout = data[1]; | |
1908 break; | |
1909 case 0x74: | |
1910 if(!checkValue(data[1],1,7)) | |
1911 return ERROR_; | |
1912 Settings.tX_userselectedLeftLowerCornerPrimary = data[1]; | |
1913 break; | |
1914 case 0x75: | |
1915 if(!checkValue(data[1],0,20)) | |
1916 return ERROR_; | |
1917 Settings.tX_userselectedLeftLowerCornerTimeout = data[1]; | |
1918 break; | |
1919 } | |
1920 return 0; | |
1921 } | |
1922 | |
1923 | |
1924 uint8_t readDataLimits__8and16BitValues_4and7BytesOutput(uint8_t what, uint8_t * data) | |
1925 { | |
1926 enum JeanDoParameterType { | |
1927 PARAM_UNKNOWN = 0, | |
1928 PARAM_INT15 = 1, | |
1929 PARAM_INT8, | |
1930 PARAM_DECI, | |
1931 PARAM_CENTI, | |
1932 PARAM_MILI, | |
1933 PARAM_PERCENT, | |
1934 PARAM_SEC, | |
1935 PARAM_COLOR, | |
1936 PARAM_BOOL, | |
1937 PARAM_ENUM, | |
1938 PARAM_SIGNED = 128, | |
1939 PARAM_SDECI = PARAM_SIGNED|PARAM_DECI, | |
1940 PARAM_SSEC = PARAM_SIGNED|PARAM_SEC, | |
1941 PARAM_SINT = PARAM_SIGNED|PARAM_INT8 | |
1942 }; | |
1943 | |
1944 // uint32_t buttonSensitivity; | |
1945 uint16_t newDuration; | |
1946 | |
1947 uint8_t datacounter = 0; | |
1948 | |
1949 data[0] = 0; | |
1950 data[1] = 0; | |
1951 data[2] = 0; | |
1952 data[3] = 0; | |
1953 datacounter = 0; | |
1954 | |
1955 switch(what) | |
1956 { | |
1957 case 0x10: | |
1958 case 0x11: | |
1959 case 0x12: | |
1960 case 0x13: | |
1961 case 0x14: | |
1962 data[datacounter++] = PARAM_INT8; | |
1963 data[datacounter++] = 4; | |
1964 data[datacounter++] = settingsGetPointerStandard()->gas[1].oxygen_percentage; | |
1965 data[datacounter++] = 100; | |
1966 break; | |
1967 | |
1968 case 0x15: | |
1969 case 0x16: | |
1970 case 0x17: | |
1971 case 0x18: | |
1972 case 0x19: | |
1973 data[datacounter++] = PARAM_INT8; | |
1974 data[datacounter++] = 4; | |
1975 data[datacounter++] = settingsGetPointerStandard()->gas[1].oxygen_percentage; | |
1976 data[datacounter++] = 100; | |
1977 break; | |
1978 | |
1979 case 0x1A: | |
1980 case 0x1B: | |
1981 case 0x1C: | |
1982 case 0x1D: | |
1983 case 0x1E: | |
1984 data[datacounter++] = PARAM_CENTI; | |
1985 data[datacounter++] = 50; | |
1986 data[datacounter++] = settingsGetPointerStandard()->setpoint[1].setpoint_cbar; | |
1987 data[datacounter++] = 160; | |
1988 break; | |
1989 | |
1990 case 0x1F: | |
1991 data[datacounter++] = PARAM_ENUM; | |
1992 data[datacounter++] = 0; | |
1993 data[datacounter++] = settingsGetPointerStandard()->CCR_Mode; | |
1994 data[datacounter++] = 1; | |
1995 break; | |
1996 | |
1997 case 0x20: | |
1998 data[datacounter++] = PARAM_ENUM; | |
1999 data[datacounter++] = 0; | |
2000 data[datacounter++] = settingsGetPointerStandard()->dive_mode; | |
2001 data[datacounter++] = 3; | |
2002 break; | |
2003 | |
2004 case 0x21: | |
2005 data[datacounter++] = PARAM_ENUM; | |
2006 data[datacounter++] = 1; | |
2007 data[datacounter++] = settingsGetPointerStandard()->deco_type.ub.standard; | |
2008 data[datacounter++] = 2; | |
2009 break; | |
2010 | |
2011 case 0x22: | |
2012 data[datacounter++] = PARAM_CENTI; | |
2013 data[datacounter++] = 100; | |
2014 data[datacounter++] = settingsGetPointerStandard()->ppO2_max_std; | |
2015 data[datacounter++] = 190; | |
2016 break; | |
2017 | |
2018 case 0x23: | |
2019 data[datacounter++] = PARAM_CENTI; | |
2020 data[datacounter++] = 15; | |
2021 data[datacounter++] = settingsGetPointerStandard()->ppO2_min; | |
2022 data[datacounter++] = 15; | |
2023 break; | |
2024 | |
2025 case 0x24: | |
2026 data[datacounter++] = PARAM_INT8; // minutes | |
2027 data[datacounter++] = 0; | |
2028 data[datacounter++] = settingsGetPointerStandard()->future_TTS; | |
2029 data[datacounter++] = 15; | |
2030 break; | |
2031 | |
2032 case 0x25: | |
2033 data[datacounter++] = PARAM_PERCENT; | |
2034 data[datacounter++] = 10; | |
2035 data[datacounter++] = settingsGetPointerStandard()->GF_low; | |
2036 data[datacounter++] = 99; | |
2037 break; | |
2038 | |
2039 case 0x26: | |
2040 data[datacounter++] = PARAM_PERCENT; | |
2041 data[datacounter++] = 45; | |
2042 data[datacounter++] = settingsGetPointerStandard()->GF_high; | |
2043 data[datacounter++] = 99; | |
2044 break; | |
2045 | |
2046 case 0x27: | |
2047 data[datacounter++] = PARAM_PERCENT; | |
2048 data[datacounter++] = 10; | |
2049 data[datacounter++] = settingsGetPointerStandard()->aGF_low; | |
2050 data[datacounter++] = 99; | |
2051 break; | |
2052 | |
2053 case 0x28: | |
2054 data[datacounter++] = PARAM_PERCENT; | |
2055 data[datacounter++] = 45; | |
2056 data[datacounter++] = settingsGetPointerStandard()->aGF_high; | |
2057 data[datacounter++] = 99; | |
2058 break; | |
2059 | |
2060 case 0x29: | |
2061 data[datacounter++] = PARAM_INT8; // conservatism +0 .. +5 | |
2062 data[datacounter++] = 0; | |
2063 data[datacounter++] = settingsGetPointerStandard()->VPM_conservatism.ub.standard; | |
2064 data[datacounter++] = 5; | |
2065 break; | |
2066 | |
2067 case 0x2A: | |
2068 case 0x2B: | |
2069 data[datacounter++] = PARAM_PERCENT; | |
2070 data[datacounter++] = 100; | |
2071 data[datacounter++] = 100;// saturation, desaturation, settingsGetPointerStandard()->; | |
2072 data[datacounter++] = 100; | |
2073 break; | |
2074 | |
2075 case 0x2C: | |
2076 data[datacounter++] = PARAM_INT8; | |
2077 data[datacounter++] = 3; | |
2078 data[datacounter++] = settingsGetPointerStandard()->last_stop_depth_meter; | |
2079 data[datacounter++] = 9; | |
2080 break; | |
2081 | |
2082 case 0x2D: | |
2083 data[datacounter++] = PARAM_ENUM; | |
2084 data[datacounter++] = 0; | |
2085 data[datacounter++] = settingsGetPointerStandard()->brightness; | |
2086 data[datacounter++] = 4; | |
2087 break; | |
2088 | |
2089 case 0x2E: | |
2090 data[datacounter++] = PARAM_ENUM; | |
2091 data[datacounter++] = 0; | |
2092 data[datacounter++] = settingsGetPointerStandard()->nonMetricalSystem; | |
2093 data[datacounter++] = 1; | |
2094 break; | |
2095 | |
2096 case 0x2F: | |
2097 data[datacounter++] = PARAM_INT8; // Sampling rate logbook | |
2098 data[datacounter++] = 2; | |
2099 data[datacounter++] = 2; | |
2100 data[datacounter++] = 2; | |
2101 break; | |
2102 | |
2103 case 0x30: | |
2104 data[datacounter++] = PARAM_PERCENT; | |
2105 data[datacounter++] = 0; | |
2106 data[datacounter++] = settingsGetPointerStandard()->salinity; | |
2107 data[datacounter++] = 4; | |
2108 break; | |
2109 | |
2110 case 0x31: | |
2111 data[datacounter++] = PARAM_INT8; | |
2112 data[datacounter++] = 0; | |
2113 data[datacounter++] = settingsGetPointerStandard()->tX_colorscheme; | |
2114 data[datacounter++] = 3; | |
2115 break; | |
2116 | |
2117 case 0x32: | |
2118 data[datacounter++] = PARAM_ENUM; | |
2119 data[datacounter++] = 0; | |
2120 data[datacounter++] = settingsGetPointerStandard()->selected_language; | |
2121 data[datacounter++] = 1; | |
2122 break; | |
2123 | |
2124 case 0x33: | |
2125 data[datacounter++] = PARAM_ENUM; | |
2126 data[datacounter++] = 0; | |
2127 data[datacounter++] = settingsGetPointerStandard()->date_format; | |
2128 data[datacounter++] = 2; | |
2129 break; | |
2130 | |
2131 case 0x34: | |
2132 data[datacounter++] = PARAM_UNKNOWN ; | |
2133 data[datacounter++] = 0; | |
2134 data[datacounter++] = 0; // compass gain, is unknown,, settingsGetPointerStandard()->; | |
2135 data[datacounter++] = 0; | |
2136 break; | |
2137 | |
2138 case 0x35: | |
2139 data[datacounter++] = PARAM_SINT; | |
2140 data[datacounter++] = (uint8_t)(256 - 20); // == -20 | |
2141 if(settingsGetPointerStandard()->offsetPressure_mbar < 0) | |
2142 data[datacounter++] = (uint8_t)(127 - settingsGetPointerStandard()->offsetPressure_mbar); | |
2143 else | |
2144 data[datacounter++] = settingsGetPointerStandard()->offsetPressure_mbar; | |
2145 data[datacounter++] = 20; | |
2146 break; | |
2147 | |
2148 case 0x36: | |
2149 data[datacounter++] = PARAM_BOOL; | |
2150 data[datacounter++] = 0; | |
2151 if(settingsGetPointerStandard()->safetystopDuration) | |
2152 data[datacounter++] = 1; | |
2153 else | |
2154 data[datacounter++] = 0; | |
2155 data[datacounter++] = 1; | |
2156 break; | |
2157 | |
2158 case 0x37: | |
2159 data[datacounter++] = PARAM_UNKNOWN ; | |
2160 data[datacounter++] = 0; | |
2161 data[datacounter++] = 0; // Set calibration gas, not possible with optical | |
2162 data[datacounter++] = 0; | |
2163 break; | |
2164 | |
2165 case 0x38: | |
2166 data[datacounter++] = PARAM_BOOL; | |
2167 data[datacounter++] = 0; | |
2168 data[datacounter++] = settingsGetPointerStandard()->fallbackToFixedSetpoint; | |
2169 data[datacounter++] = 1; | |
2170 break; | |
2171 | |
2172 case 0x39: | |
2173 data[datacounter++] = PARAM_BOOL; | |
2174 data[datacounter++] = 0; | |
2175 data[datacounter++] = 0; // flipscreen, not yet :-) settingsGetPointerStandard()->; | |
2176 data[datacounter++] = 0; | |
2177 break; | |
2178 | |
2179 case 0x3A: | |
2180 data[datacounter++] = PARAM_PERCENT; | |
2181 data[datacounter++] = 70; | |
2182 data[datacounter++] = settingsGetPointerStandard()->ButtonResponsiveness[3]; | |
2183 data[datacounter++] = 110; | |
2184 break; | |
2185 | |
2186 case 0x3B: | |
2187 data[datacounter++] = PARAM_UNKNOWN; | |
2188 data[datacounter++] = 0; | |
2189 data[datacounter++] = buttonBalanceTranslateArrayOutHex(settingsGetPointerStandard()->buttonBalance); | |
2190 data[datacounter++] = 128; | |
2191 break; | |
2192 | |
2193 case 0x3C: | |
2194 data[datacounter++] = PARAM_INT8; | |
2195 data[datacounter++] = 5; | |
2196 data[datacounter++] = settingsGetPointerStandard()->gasConsumption_bottom_l_min; | |
2197 data[datacounter++] = 50; | |
2198 break; | |
2199 | |
2200 case 0x3D: | |
2201 data[datacounter++] = PARAM_INT8; | |
2202 data[datacounter++] = 5; | |
2203 data[datacounter++] = settingsGetPointerStandard()->gasConsumption_deco_l_min; | |
2204 data[datacounter++] = 50; | |
2205 break; | |
2206 | |
2207 case 0x3E: | |
2208 data[datacounter++] = PARAM_INT8; | |
2209 data[datacounter++] = 5; | |
2210 data[datacounter++] = settingsGetPointerStandard()->gasConsumption_travel_l_min; | |
2211 data[datacounter++] = 50; | |
2212 break; | |
2213 | |
2214 case 0x3F: | |
2215 data[datacounter++] = PARAM_UNKNOWN; | |
2216 data[datacounter++] = 0; | |
2217 data[datacounter++] = 0; // Dynamic ascend rate, not yet :-) settingsGetPointerStandard()->; | |
2218 data[datacounter++] = 0; | |
2219 break; | |
2220 | |
2221 case 0x40: | |
2222 data[datacounter++] = PARAM_BOOL; | |
2223 data[datacounter++] = 1; | |
2224 data[datacounter++] = 1; // Graphical speed indicator; | |
2225 data[datacounter++] = 1; | |
2226 break; | |
2227 | |
2228 case 0x41: | |
2229 data[datacounter++] = PARAM_BOOL; | |
2230 data[datacounter++] = 0; | |
2231 data[datacounter++] = settingsGetPointerStandard()->alwaysShowPPO2; | |
2232 data[datacounter++] = 1; | |
2233 break; | |
2234 | |
2235 case 0x42: | |
2236 data[datacounter++] = PARAM_SIGNED|PARAM_CENTI; | |
2237 data[datacounter++] = (uint8_t)(256 - 20); // == -20 | |
2238 if(settingsGetPointerStandard()->offsetTemperature_centigrad < 0) | |
2239 data[datacounter++] = (uint8_t)(127 - settingsGetPointerStandard()->offsetTemperature_centigrad); | |
2240 else | |
2241 data[datacounter++] = settingsGetPointerStandard()->offsetTemperature_centigrad; | |
2242 data[datacounter++] = 20; | |
2243 break; | |
2244 | |
2245 case 0x43: | |
2246 newDuration = settingsGetPointerStandard()->safetystopDuration; | |
2247 newDuration *= 60; | |
2248 if(newDuration > 255) | |
2249 newDuration = 255; | |
2250 data[datacounter++] = PARAM_INT8; | |
2251 data[datacounter++] = 60; // coud be 1 minute instead | |
2252 data[datacounter++] = (uint8_t)newDuration; | |
2253 data[datacounter++] = 255; // could be 5 minutes instead | |
2254 break; | |
2255 | |
2256 case 0x44: | |
2257 data[datacounter++] = PARAM_INT8; | |
2258 data[datacounter++] = 30; // coud be 3 meter instead | |
2259 data[datacounter++] = settingsGetPointerStandard()->safetystopDepth * 10; | |
2260 data[datacounter++] = 60; // could be 6 meter instead | |
2261 break; | |
2262 | |
2263 case 0x45: | |
2264 case 0x46: | |
2265 data[datacounter++] = PARAM_UNKNOWN; | |
2266 data[datacounter++] = 0; | |
2267 data[datacounter++] = 0; // SafetyStop End Depth and SafetyStop Reset Depth | |
2268 data[datacounter++] = 0; | |
2269 break; | |
2270 | |
2271 case 0x47: | |
2272 data[datacounter++] = PARAM_INT15; | |
2273 data[datacounter++] = 0; | |
2274 data[datacounter++] = 0; | |
2275 data[datacounter++] = settingsGetPointerStandard()->logbookOffset & 0xFF; | |
2276 data[datacounter++] = settingsGetPointerStandard()->logbookOffset / 0xFF; | |
2277 data[datacounter++] = 9000 & 0xFF; | |
2278 data[datacounter++] = 9000 / 0xFF; | |
2279 break; | |
2280 | |
2281 case 0x70: | |
2282 data[datacounter++] = PARAM_BOOL; | |
2283 data[datacounter++] = 0; | |
2284 data[datacounter++] = settingsGetPointerStandard()->showDebugInfo; | |
2285 data[datacounter++] = 1; | |
2286 break; | |
2287 | |
2288 case 0x71: | |
2289 data[datacounter++] = PARAM_ENUM; | |
2290 data[datacounter++] = 0; | |
2291 data[datacounter++] = settingsGetPointerStandard()->extraDisplay; | |
2292 data[datacounter++] = (EXTRADISPLAY_END - 1); | |
2293 break; | |
2294 | |
2295 case 0x72: | |
2296 data[datacounter++] = PARAM_ENUM; | |
2297 data[datacounter++] = 0; | |
2298 data[datacounter++] = settingsGetPointerStandard()->tX_customViewPrimary; | |
2299 data[datacounter++] = 8; | |
2300 break; | |
2301 | |
2302 case 0x73: | |
2303 data[datacounter++] = PARAM_INT8; | |
2304 data[datacounter++] = 0; | |
2305 data[datacounter++] = settingsGetPointerStandard()->tX_customViewTimeout; | |
2306 data[datacounter++] = 60; | |
2307 break; | |
2308 | |
2309 case 0x74: | |
2310 data[datacounter++] = PARAM_ENUM; | |
2311 data[datacounter++] = 1; | |
2312 data[datacounter++] = settingsGetPointerStandard()->tX_userselectedLeftLowerCornerPrimary; | |
2313 data[datacounter++] = 7; | |
2314 break; | |
2315 | |
2316 case 0x75: | |
2317 data[datacounter++] = PARAM_INT8; | |
2318 data[datacounter++] = 0; | |
2319 data[datacounter++] = settingsGetPointerStandard()->tX_userselectedLeftLowerCornerTimeout; | |
2320 data[datacounter++] = 60; | |
2321 break; | |
2322 } | |
2323 | |
2324 if(datacounter == 0) | |
2325 { | |
2326 data[datacounter++] = PARAM_UNKNOWN; | |
2327 data[datacounter++] = 0; | |
2328 data[datacounter++] = 0; // SafetyStop End Depth and SafetyStop Reset Depth | |
2329 data[datacounter++] = 0; | |
2330 } | |
2331 | |
2332 return datacounter; | |
2333 } | |
2334 | |
2335 | |
2336 uint8_t readData(uint8_t what, uint8_t * data) | |
2337 { | |
2338 data[0] = 0; | |
2339 data[1] = 0; | |
2340 data[2] = 0; | |
2341 data[3] = 0; | |
2342 switch(what) | |
2343 { | |
2344 case 0x10: | |
2345 return getGas(1,data); | |
2346 case 0x11: | |
2347 return getGas(2,data); | |
2348 case 0x12: | |
2349 return getGas(3,data); | |
2350 case 0x13: | |
2351 return getGas(4,data); | |
2352 case 0x14: | |
2353 return getGas(5,data); | |
2354 case 0x15: | |
2355 return getDiluent(1,data); | |
2356 case 0x16: | |
2357 return getDiluent(2,data); | |
2358 case 0x17: | |
2359 return getDiluent(3,data); | |
2360 case 0x18: | |
2361 return getDiluent(4,data); | |
2362 case 0x19: | |
2363 return getDiluent(5,data); | |
2364 case 0x1A: | |
2365 return getSetpoint(1,data); | |
2366 case 0x1B: | |
2367 return getSetpoint(2,data); | |
2368 case 0x1C: | |
2369 return getSetpoint(3,data); | |
2370 case 0x1D: | |
2371 return getSetpoint(4,data); | |
2372 case 0x1E: | |
2373 return getSetpoint(5,data); | |
2374 case 0x1F: | |
2375 data[0] = Settings.CCR_Mode; | |
2376 break; | |
2377 case 0x20: | |
2378 data[0] = Settings.dive_mode; | |
2379 break; | |
2380 case 0x21: | |
2381 data[0] = Settings.deco_type.ub.standard; | |
2382 break; | |
2383 case 0x22: | |
2384 data[0] = Settings.ppO2_max_std; | |
2385 break; | |
2386 case 0x23: | |
2387 data[0] = Settings.ppO2_min; | |
2388 break; | |
2389 case 0x24: | |
2390 data[0] = Settings.future_TTS; | |
2391 break; | |
2392 case 0x25: | |
2393 data[0] = Settings.GF_low; | |
2394 break; | |
2395 case 0x26: | |
2396 data[0] = Settings.GF_high; | |
2397 break; | |
2398 case 0x27: | |
2399 data[0] = Settings.aGF_low; | |
2400 break; | |
2401 case 0x28: | |
2402 data[0] = Settings.aGF_high; | |
2403 break; | |
2404 case 0x29: | |
2405 data[0] = Settings.VPM_conservatism.ub.standard; | |
2406 break; | |
2407 case 0x2A: | |
2408 case 0x2B: | |
2409 data[0] = 100; | |
2410 break; | |
2411 case 0x2C: | |
2412 data[0] = Settings.last_stop_depth_meter; | |
2413 break; | |
2414 case 0x2D: | |
2415 data[0] = Settings.brightness; | |
2416 break; | |
2417 case 0x2E: | |
2418 data[0] = Settings.nonMetricalSystem; | |
2419 break; | |
2420 case 0x2F: | |
2421 data[0] = 0; // 0 == 2 sec sampling rate | |
2422 break; | |
2423 case 0x30: | |
2424 data[0] = Settings.salinity; | |
2425 break; | |
2426 case 0x31: | |
2427 data[0] = Settings.tX_colorscheme; | |
2428 break; | |
2429 case 0x32: | |
2430 data[0] = Settings.selected_language; | |
2431 break; | |
2432 case 0x33: | |
2433 data[0] = Settings.date_format; | |
2434 break; | |
2435 case 0x34: | |
2436 data[0] = 7; // gain should be always 7 as far as I understand the code in RTE | |
2437 break; | |
2438 case 0x35: | |
2439 data[0] = Settings.offsetPressure_mbar; | |
2440 break; | |
2441 case 0x36: | |
2442 if(Settings.safetystopDepth) | |
2443 data[0] = 1; | |
2444 else | |
2445 data[0] = 0; | |
2446 break; | |
2447 case 0x37: | |
2448 data[0] = 0; // calibration gas %O2 -> 0 no gas :-) | |
2449 break; | |
2450 case 0x38: | |
2451 data[0] = Settings.fallbackToFixedSetpoint; | |
2452 break; | |
2453 case 0x39: | |
2454 data[0] = 0; // flip screen | |
2455 break; | |
2456 case 0x3A: | |
2457 data[0] = Settings.ButtonResponsiveness[3]; | |
2458 break; | |
2459 case 0x3B: | |
2460 data[0] = buttonBalanceTranslateArrayOutHex(settingsGetPointer()->buttonBalance); | |
2461 break; | |
2462 case 0x3C: | |
2463 data[0] = Settings.gasConsumption_bottom_l_min; | |
2464 break; | |
2465 case 0x3D: | |
2466 data[0] = Settings.gasConsumption_deco_l_min; | |
2467 break; | |
2468 case 0x3E: | |
2469 data[0] = Settings.gasConsumption_travel_l_min; | |
2470 break; | |
2471 case 0x3F: | |
2472 data[0] = 0; // fixed ascend rate 10 m/min | |
2473 break; | |
2474 case 0x40: | |
2475 data[0] = 1; // graphical speed indicator | |
2476 break; | |
2477 case 0x41: | |
2478 data[0] = Settings.alwaysShowPPO2; | |
2479 break; | |
2480 case 0x42: | |
2481 data[0] = Settings.offsetTemperature_centigrad; | |
2482 break; | |
2483 case 0x43: | |
2484 if(Settings.safetystopDuration > 4) | |
2485 data[0] = 255; // seconds | |
2486 else | |
2487 data[0] = 60 * Settings.safetystopDuration; | |
2488 break; | |
2489 case 0x44: | |
2490 data[0] = Settings.safetystopDepth * 10; // cbar instead of meter | |
2491 break; | |
2492 case 0x45: | |
2493 if(Settings.safetystopDepth == 3) | |
2494 data[0] = 20; // cbar | |
2495 else | |
2496 data[0] = 30; // cbar | |
2497 break; | |
2498 case 0x46: | |
2499 data[0] = 10; // reset at 10 meter as far as I understood | |
2500 break; | |
2501 case 0x47: | |
2502 data[0] = Settings.logbookOffset & 0xFF; | |
2503 data[1] = Settings.logbookOffset / 0xFF; | |
2504 break; | |
2505 case 0x70: | |
2506 data[0] = Settings.showDebugInfo; | |
2507 break; | |
2508 case 0x71: | |
2509 data[0] = Settings.extraDisplay; | |
2510 break; | |
2511 case 0x72: | |
2512 data[0] = Settings.tX_customViewPrimary; | |
2513 break; | |
2514 case 0x73: | |
2515 data[0] = Settings.tX_customViewTimeout; | |
2516 break; | |
2517 case 0x74: | |
2518 data[0] = Settings.tX_userselectedLeftLowerCornerPrimary; | |
2519 break; | |
2520 case 0x75: | |
2521 data[0] = Settings.tX_userselectedLeftLowerCornerTimeout; | |
2522 break; | |
2523 } | |
2524 return 0x4D; | |
2525 } | |
2526 | |
2527 | |
2528 uint8_t RTEminimum_required_high(void) | |
2529 { | |
2530 return RTErequiredHigh; | |
2531 } | |
2532 uint8_t RTEminimum_required_low(void) | |
2533 { | |
2534 return RTErequiredLow; | |
2535 } | |
2536 | |
2537 uint8_t FONTminimum_required_high(void) | |
2538 { | |
2539 return FONTrequiredHigh; | |
2540 } | |
2541 uint8_t FONTminimum_required_low(void) | |
2542 { | |
2543 return FONTrequiredLow; | |
2544 } | |
2545 | |
2546 | |
2547 void setActualRTEversion(uint8_t high, uint8_t low) | |
2548 { | |
2549 RTEactualHigh = high; | |
2550 RTEactualLow = low; | |
2551 } | |
2552 | |
2553 | |
2554 void getActualRTEandFONTversion(uint8_t *RTEhigh, uint8_t *RTElow, uint8_t *FONThigh, uint8_t *FONTlow) | |
2555 { | |
2556 if(RTEhigh && RTElow) | |
2557 { | |
2558 *RTEhigh = RTEactualHigh; | |
2559 *RTElow = RTEactualLow; | |
2560 } | |
2561 if(FONThigh && FONTlow) | |
2562 { | |
2563 *FONThigh = *(uint8_t *)0x08132000; | |
2564 *FONTlow = *(uint8_t *)0x08132001; | |
2565 } | |
2566 } | |
2567 | |
2568 | |
2569 uint8_t getLicence(void) | |
2570 { | |
2571 //return 0xFF; | |
2572 //return LICENCEBONEX; | |
2573 return hardwareDataGetPointer()->primaryLicence; | |
2574 } | |
2575 | |
2576 | |
2577 void firmwareGetDate(RTC_DateTypeDef *SdateOutput) | |
2578 { | |
2579 SdateOutput->Year = firmwareDataGetPointer()->release_year; | |
2580 SdateOutput->Month = firmwareDataGetPointer()->release_month; | |
2581 SdateOutput->Date = firmwareDataGetPointer()->release_day; | |
2582 } | |
2583 | |
2584 | |
2585 // this should use device specific values stored in OTPROG ROM soon | |
2586 void getButtonFactorDefaults(uint8_t* basePercentage, uint8_t* buttonBalanceArray) | |
2587 { | |
2588 *basePercentage = settingsGetPointerStandard()->ButtonResponsiveness[3]; | |
2589 | |
2590 for(int i=0;i<3;i++) | |
2591 { | |
2592 buttonBalanceArray[i] = settingsGetPointerStandard()->buttonBalance[i]; | |
2593 } | |
2594 } | |
2595 | |
2596 | |
2597 uint8_t buttonBalanceTranslatorHexToArray(uint8_t hexValue, uint8_t* outputArray) | |
2598 { | |
2599 if(hexValue > 127) | |
2600 return 0; | |
2601 // internal order: 0 = right, 1 = center, 2 = left | |
2602 // external order: Factory,left,center,right | |
2603 outputArray[0] = 2 + (hexValue & 0x03); | |
2604 hexValue /= 4; | |
2605 outputArray[1] = 2 + (hexValue & 0x03); | |
2606 hexValue /= 4; | |
2607 outputArray[2] = 2 + (hexValue & 0x03); | |
2608 | |
2609 return 1; | |
2610 } | |
2611 | |
2612 | |
2613 uint8_t buttonBalanceTranslateArrayOutHex(const uint8_t* inputArray) | |
2614 { | |
2615 uint8_t hexValue = 0; | |
2616 | |
2617 if(inputArray[2] > 2) | |
2618 { | |
2619 hexValue += inputArray[2] - 2; | |
2620 } | |
2621 hexValue *= 4; | |
2622 | |
2623 if(inputArray[1] > 2) | |
2624 { | |
2625 hexValue += inputArray[1] - 2; | |
2626 } | |
2627 hexValue *= 4; | |
2628 if(inputArray[0] > 2) | |
2629 { | |
2630 hexValue += inputArray[0] - 2; | |
2631 } | |
2632 return hexValue; | |
2633 } | |
2634 | |
2635 void settingsWriteFactoryDefaults(uint8_t inputValueRaw, uint8_t *inputBalanceArray) | |
2636 { | |
2637 if((inputValueRaw >= 70) && (inputValueRaw <= 110)) | |
2638 { | |
2639 Settings.FactoryButtonBase = inputValueRaw; | |
2640 } | |
2641 for(int i=0;i<3;i++) | |
2642 { | |
2643 if((inputBalanceArray[i] >= 2) && (inputBalanceArray[i] <= 5)) | |
2644 { | |
2645 Settings.FactoryButtonBalance[i] = inputBalanceArray[i]; | |
2646 } | |
2647 } | |
2648 } | |
2649 | |
2650 | |
2651 /** | |
2652 ****************************************************************************** | |
2653 * @brief settingsHelperButtonSens. / make 32 bit input to three buttons + storage value in [3] | |
2654 * @author heinrichs weikamp gmbh | |
2655 * @version V 01 | |
2656 * @date 19-Sept-2016 | |
2657 ****************************************************************************** | |
2658 * | |
2659 * @param inputValueRaw: | |
2660 * @param outArray4Values: [0] is right, [1] is center, [2] is left, [3] is original value with zero balance | |
2661 * @retval None | |
2662 */ | |
2663 void settingsHelperButtonSens_keepPercentageValues(uint32_t inputValueRaw, uint8_t *outArray4Values) | |
2664 { | |
2665 uint32_t newSensitivity; | |
2666 | |
92
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
91
diff
changeset
|
2667 if(inputValueRaw > MAX_BUTTONRESPONSIVENESS) |
38 | 2668 { |
92
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
91
diff
changeset
|
2669 inputValueRaw = MAX_BUTTONRESPONSIVENESS; |
38 | 2670 } |
2671 else | |
92
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
91
diff
changeset
|
2672 if(inputValueRaw < MIN_BUTTONRESPONSIVENESS) |
38 | 2673 { |
92
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
91
diff
changeset
|
2674 inputValueRaw = MIN_BUTTONRESPONSIVENESS; |
38 | 2675 } |
2676 | |
2677 // the unbalanced value | |
2678 outArray4Values[3] = inputValueRaw; | |
2679 | |
2680 // the balanced values | |
2681 for(int i=0;i<3;i++) | |
2682 { | |
2683 newSensitivity = inputValueRaw; | |
2684 switch(settingsGetPointer()->buttonBalance[i]) | |
2685 { | |
2686 case 1: // should not be an option hw 170508 | |
2687 newSensitivity -= 20; | |
2688 break; | |
2689 case 2: | |
2690 newSensitivity -= 10; | |
2691 break; | |
2692 default: | |
2693 break; | |
2694 case 4: | |
2695 newSensitivity += 10; | |
2696 break; | |
2697 case 5: | |
2698 newSensitivity += 20; | |
2699 break; | |
2700 } | |
2701 | |
92
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
91
diff
changeset
|
2702 if(newSensitivity > MAX_BUTTONRESPONSIVENESS) |
38 | 2703 { |
92
be35821a4974
Stable to test. button sensitiveness fix. + global_constants.
Dmitry Romanov <kitt@bk.ru>
parents:
91
diff
changeset
|
2704 newSensitivity = MAX_BUTTONRESPONSIVENESS; |
38 | 2705 } |
2706 outArray4Values[i] = newSensitivity; | |
2707 } | |
2708 } | |
2709 | |
2710 | |
2711 /** | |
2712 ****************************************************************************** | |
2713 * @brief settingsHelperButtonSens_translate_to_hwOS_values. / make 32 bit input to three buttons + storage value in [3] | |
2714 * @author heinrichs weikamp gmbh | |
2715 * @version V 01 | |
2716 * @date 19-Sept-2016 | |
2717 ****************************************************************************** | |
2718 * | |
2719 * @param inputValueRaw: | |
2720 * @param outArray4Values: [0] is right, [1] is center, [2] is left, [3] is original value with zero balance | |
2721 * @retval None | |
2722 */ | |
2723 void settingsHelperButtonSens_original_translate_to_hwOS_values(const uint32_t inputValueRaw, uint8_t *outArray4Values) | |
2724 { | |
2725 uint32_t newSensitivity; | |
2726 | |
2727 for(int i=0;i<3;i++) | |
2728 { | |
2729 newSensitivity = inputValueRaw; | |
2730 switch(settingsGetPointer()->buttonBalance[i]) | |
2731 { | |
2732 case 1: | |
2733 newSensitivity -= 20; | |
2734 break; | |
2735 case 2: | |
2736 newSensitivity -= 10; | |
2737 break; | |
2738 default: | |
2739 break; | |
2740 case 4: | |
2741 newSensitivity += 10; | |
2742 break; | |
2743 case 5: | |
2744 newSensitivity += 20; | |
2745 break; | |
2746 } | |
2747 | |
2748 if(newSensitivity > 100) | |
2749 { | |
2750 if(newSensitivity <= 105) | |
2751 newSensitivity = 10; | |
2752 else | |
2753 newSensitivity = 7; | |
2754 } | |
2755 else | |
2756 { | |
2757 newSensitivity *= 24; | |
2758 newSensitivity = 2400 - newSensitivity; | |
2759 newSensitivity /= 10; | |
2760 | |
2761 newSensitivity += 15; | |
2762 if(newSensitivity > 255) | |
2763 newSensitivity = 255; | |
2764 } | |
2765 outArray4Values[i] = newSensitivity; | |
2766 } | |
2767 | |
2768 // the unbalanced value | |
2769 newSensitivity = inputValueRaw; | |
2770 if(newSensitivity > 100) | |
2771 { | |
2772 if(newSensitivity <= 105) | |
2773 newSensitivity = 10; | |
2774 else | |
2775 newSensitivity = 7; | |
2776 } | |
2777 else | |
2778 { | |
2779 newSensitivity *= 24; | |
2780 newSensitivity = 2400 - newSensitivity; | |
2781 newSensitivity /= 10; | |
2782 | |
2783 newSensitivity += 15; | |
2784 if(newSensitivity > 255) | |
2785 newSensitivity = 255; | |
2786 } | |
2787 outArray4Values[3] = newSensitivity; | |
2788 } | |
2789 | |
2790 | |
2791 /** | |
2792 ****************************************************************************** | |
2793 * @brief settingsHelperButtonSens_translate_percentage_to_hwOS_values. | |
2794 * @author heinrichs weikamp gmbh | |
2795 * @version V 01 | |
2796 * @date 6-March-2017 | |
2797 ****************************************************************************** | |
2798 * | |
2799 * @param inputValuePercentage with buttonBalance included | |
2800 * @retval PIC compatible value | |
2801 */ | |
2802 uint8_t settingsHelperButtonSens_translate_percentage_to_hwOS_values(uint8_t inputValuePercentage) | |
2803 { | |
2804 uint32_t newSensitivity = inputValuePercentage; | |
2805 | |
2806 if(newSensitivity > 100) | |
2807 { | |
2808 if(newSensitivity <= 105) | |
2809 newSensitivity = 10; | |
2810 else | |
2811 newSensitivity = 7; | |
2812 } | |
2813 else | |
2814 { | |
2815 newSensitivity *= 24; | |
2816 newSensitivity = 2400 - newSensitivity; | |
2817 newSensitivity /= 10; | |
2818 | |
2819 newSensitivity += 15; | |
2820 if(newSensitivity > 255) | |
2821 newSensitivity = 255; | |
2822 } | |
2823 return (uint8_t)newSensitivity; | |
2824 } | |
2825 | |
2826 | |
2827 /** | |
2828 ****************************************************************************** | |
2829 * @brief settingsHelperButtonSens_translate_hwOS_values_to_percentage. | |
2830 * @author heinrichs weikamp gmbh | |
2831 * @version V 01 | |
2832 * @date 6-March-2017 | |
2833 ****************************************************************************** | |
2834 * | |
2835 * @param PIC compatible value | |
2836 * @retval Percentage | |
2837 */ | |
2838 uint8_t settingsHelperButtonSens_translate_hwOS_values_to_percentage(uint8_t inputValuePIC) | |
2839 { | |
2840 if(inputValuePIC >= 15) | |
2841 { | |
2842 return(uint8_t)((25500 - (inputValuePIC)*100) / 240); | |
2843 } | |
2844 else | |
2845 { | |
2846 if(inputValuePIC >= 10) | |
2847 { | |
2848 return 105; | |
2849 } | |
2850 else | |
2851 { | |
2852 return 110; | |
2853 } | |
2854 } | |
2855 } |