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