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