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