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