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