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