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