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