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