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