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