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