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