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