38
+ − 1 ///////////////////////////////////////////////////////////////////////////////
+ − 2 /// -*- coding: UTF-8 -*-
+ − 3 ///
+ − 4 /// \file Common/Inc/settings.h
+ − 5 /// \brief
+ − 6 /// \author Heinrichs Weikamp
+ − 7 /// \date 2018
+ − 8 ///
+ − 9 /// $Id$
+ − 10 ///////////////////////////////////////////////////////////////////////////////
+ − 11 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh
+ − 12 ///
+ − 13 /// This program is free software: you can redistribute it and/or modify
+ − 14 /// it under the terms of the GNU General Public License as published by
+ − 15 /// the Free Software Foundation, either version 3 of the License, or
+ − 16 /// (at your option) any later version.
+ − 17 ///
+ − 18 /// This program is distributed in the hope that it will be useful,
+ − 19 /// but WITHOUT ANY WARRANTY; without even the implied warranty of
+ − 20 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ − 21 /// GNU General Public License for more details.
+ − 22 ///
+ − 23 /// You should have received a copy of the GNU General Public License
+ − 24 /// along with this program. If not, see <http://www.gnu.org/licenses/>.
+ − 25 //////////////////////////////////////////////////////////////////////////////
+ − 26
+ − 27 #ifndef SETTINGS_H
+ − 28 #define SETTINGS_H
+ − 29
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
diff
changeset
+ − 30 #include <stdint.h>
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
diff
changeset
+ − 31 #include <stdbool.h>
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
diff
changeset
+ − 32
38
+ − 33 // From Common/Inc:
+ − 34 #include "FirmwareData.h"
+ − 35
+ − 36 //#include "data_central.h"
+ − 37
92
+ − 38 #include "global_constants.h"
38
+ − 39 // From Common/Drivers/
+ − 40 #include "stm32f4xx_hal.h"
710
+ − 41 #include "stm32f4xx_hal_rtc.h"
38
+ − 42
691
+ − 43 #include "configuration.h"
+ − 44
92
+ − 45
38
+ − 46 #define NUM_GASES 5
+ − 47 #define NUM_OFFSET_DILUENT 5
+ − 48 #define SPECIAL_GAS_ID 0
864
+ − 49 #define NO_GAS_ID 255
38
+ − 50
+ − 51 #define ERROR_ 0xFF
+ − 52
+ − 53 #define CCRMODE_FixedSetpoint 0
+ − 54 #define CCRMODE_Sensors 1
662
+ − 55 #define CCRMODE_Simulation 2
38
+ − 56
+ − 57 #define DIVEMODE_OC 0
+ − 58 #define DIVEMODE_CCR 1
+ − 59 #define DIVEMODE_Gauge 2
+ − 60 #define DIVEMODE_Apnea 3
662
+ − 61 #define DIVEMODE_PSCR 4
38
+ − 62
+ − 63 #define GF_MODE 1
+ − 64 #define VPM_MODE 2
+ − 65
+ − 66 #define VPM_FROM_FORTRAN 0
+ − 67 #define VPM_BACHELORWORK 1
+ − 68
+ − 69 #define BUEHLMANN_OSTC4 0
+ − 70 #define BUEHLMANN_hwOS 1
+ − 71
+ − 72 #define MMDDYY 0
+ − 73 #define DDMMYY 1
+ − 74 #define YYMMDD 2
+ − 75
337
+ − 76 #define PRESSURE_OFFSET_LIMIT_MBAR 50
+ − 77
560
+ − 78 #define MAX_COMPASS_COMP (2u)
640
+ − 79 #define MAX_VIEWPORT_MODE (0x7F)
560
+ − 80
676
+ − 81 #define MAX_SCRUBBER_TIME (999u)
758
b6d8a6fbf4fd
- Colours for scrubber display when time remaining falls below a threshold value
heinrichsweikamp
diff
changeset
+ − 82 #define MIN_SCRUBBER_TIME -99
652
+ − 83 #define MIN_PPO2_SP_CBAR (40u)
650
+ − 84
662
+ − 85 #define PSCR_MAX_O2_DROP (15u)
+ − 86 #define PSCR_MIN_LUNG_RATIO (5u)
+ − 87 #define PSCR_MAX_LUNG_RATIO (20u)
+ − 88
691
+ − 89 #define UART_MAX_PROTOCOL (2u)
+ − 90
805
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
diff
changeset
+ − 91 #define FUTURE_SPARE_SIZE (0u) /* Applied for reuse of old, not used, scooter block (was 32 bytes)*/
662
+ − 92
560
+ − 93 typedef enum
+ − 94 {
+ − 95 O2_SENSOR_SOURCE_OPTIC = 0,
+ − 96 O2_SENSOR_SOURCE_ANALOG,
702
+ − 97 O2_SENSOR_SOURCE_DIGITAL,
+ − 98 O2_SENSOR_SOURCE_ANADIG,
691
+ − 99 #ifdef ENABLE_SENTINEL_MODE
+ − 100 O2_SENSOR_SOURCE_SENTINEL,
+ − 101 #endif
560
+ − 102 O2_SENSOR_SOURCE_MAX
+ − 103 } SensorSource;
+ − 104 #define MAX_O2_SENSOR_SOURCE (2u)
546
+ − 105
654
+ − 106 typedef enum
+ − 107 {
+ − 108 SCRUB_TIMER_OFF = 0,
+ − 109 SCRUB_TIMER_MINUTES,
+ − 110 SCRUB_TIMER_PERCENT,
+ − 111 SCRUB_TIMER_END
+ − 112 } ScrubTimerMode_e;
+ − 113
38
+ − 114 /* 2015 Jan 30, hw, deco and travel added for MenuEditGas
+ − 115 * can be used for buehlmann, vpm, etc. later but be carefull
+ − 116 * with current implemenation */
+ − 117 typedef struct{
+ − 118 uint8_t active:1;
+ − 119 uint8_t first:1;
+ − 120 uint8_t deco:1;
+ − 121 uint8_t travel:1;
526
+ − 122 uint8_t off:1;
830
+ − 123 uint8_t decocalc:1;
+ − 124 uint8_t spare:2;
38
+ − 125 } gasubit8_t;
+ − 126
+ − 127 typedef union{
+ − 128 gasubit8_t ub;
+ − 129 uint8_t uw;
+ − 130 } gasbit8_Type;
+ − 131
+ − 132 typedef struct{
+ − 133 uint8_t standard:4;
+ − 134 uint8_t alternative:4;
+ − 135 } ubit2x4_t;
+ − 136
+ − 137 typedef union{
+ − 138 ubit2x4_t ub;
+ − 139 uint8_t uw;
+ − 140 } split2x4_Type;
+ − 141
+ − 142 typedef union{
+ − 143 uint8_t u8[4];
+ − 144 uint32_t u32;
+ − 145 } general32to8_Type;
+ − 146
+ − 147 typedef struct
+ − 148 {
+ − 149 uint8_t oxygen_percentage;
+ − 150 uint8_t helium_percentage;
+ − 151 gasbit8_Type note;
+ − 152 uint8_t depth_meter;
+ − 153 uint8_t depth_meter_travel;
+ − 154 uint8_t bottle_size_liter;
+ − 155 // uint8_t bottle_wireless_status;
+ − 156 uint16_t bottle_wireless_id;
+ − 157 } SGasLine;
+ − 158
+ − 159 typedef struct
+ − 160 {
+ − 161 uint8_t setpoint_cbar;
+ − 162 uint8_t depth_meter;
+ − 163 gasbit8_Type note;
+ − 164 } SSetpointLine;
+ − 165
654
+ − 166
710
+ − 167 typedef struct
+ − 168 {
+ − 169 uint16_t TimerMax;
758
b6d8a6fbf4fd
- Colours for scrubber display when time remaining falls below a threshold value
heinrichsweikamp
diff
changeset
+ − 170 int16_t TimerCur;
710
+ − 171 RTC_DateTypeDef lastDive;
+ − 172 } SScrubberData;
+ − 173
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
diff
changeset
+ − 174 enum {
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
diff
changeset
+ − 175 SETPOINT_INDEX_CUSTOM = 0,
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
diff
changeset
+ − 176 SETPOINT_INDEX_AUTO_LOW,
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
diff
changeset
+ − 177 SETPOINT_INDEX_AUTO_HIGH,
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
diff
changeset
+ − 178 SETPOINT_INDEX_AUTO_DECO,
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
diff
changeset
+ − 179 };
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
diff
changeset
+ − 180
819
+ − 181 typedef struct
+ − 182 {
+ − 183 uint8_t FirstCorrection;
+ − 184 uint8_t Corrections;
+ − 185 } SSettingsStatus;
654
+ − 186
949
+ − 187
+ − 188 typedef struct
+ − 189 {
+ − 190 int8_t hours;
+ − 191 uint8_t minutes;
+ − 192 } StimeZone;
+ − 193
+ − 194
38
+ − 195 /* SSettings
+ − 196 * gas[0] and setpoint[0] are the special ones configurable during the dive
+ − 197 */
+ − 198 typedef struct
+ − 199 {
+ − 200 uint32_t header;
+ − 201 uint8_t warning_blink_dsec;
+ − 202 uint8_t lastDiveLogId;
+ − 203 uint32_t logFlashNextSampleStartAddress;
+ − 204 SGasLine gas[1 + (2*NUM_GASES)];
+ − 205 SSetpointLine setpoint[1 + NUM_GASES];
+ − 206 uint8_t CCR_Mode;
+ − 207 uint8_t dive_mode;
+ − 208 split2x4_Type deco_type;
+ − 209 uint8_t ppO2_max_deco;
+ − 210 uint8_t ppO2_max_std;
+ − 211 uint8_t ppO2_min;
+ − 212 uint8_t CNS_max;
+ − 213 uint8_t ascent_MeterPerMinute_max;
+ − 214 uint8_t ascent_MeterPerMinute_showGraph;
+ − 215 uint8_t future_TTS;
+ − 216 uint8_t GF_high;
+ − 217 uint8_t GF_low;
+ − 218 uint8_t aGF_high;
+ − 219 uint8_t aGF_low;
+ − 220 split2x4_Type VPM_conservatism;
+ − 221 uint8_t safetystopDuration;
+ − 222 uint8_t AtemMinutenVolumenLiter;
+ − 223 uint8_t ReserveFractionDenominator;
+ − 224 uint8_t salinity;
+ − 225 uint8_t last_stop_depth_meter;
+ − 226 uint8_t stop_increment_depth_meter;
+ − 227 uint8_t brightness;
+ − 228 uint8_t date_format;
+ − 229 uint8_t selected_language;
+ − 230 char customtext[60];
+ − 231 uint16_t timeoutSurfacemode;
+ − 232 uint8_t timeoutMenuSurface;
+ − 233 uint8_t timeoutMenuDive;
+ − 234 uint8_t timeoutMenuEdit;
+ − 235 uint8_t timeoutInfo;
+ − 236 uint8_t timeoutInfoCompass;
+ − 237 uint8_t design;
+ − 238 uint16_t timeoutDiveReachedZeroDepth;
+ − 239 uint16_t divetimeToCreateLogbook;
+ − 240 uint8_t serialHigh;
+ − 241 uint8_t serialLow;
+ − 242 // SUFirmware firmwareVersion16to32bit;
+ − 243 uint32_t backup_localtime_rtc_tr;
+ − 244 uint32_t backup_localtime_rtc_dr;
+ − 245 uint16_t totalDiveCounter;
560
+ − 246 uint16_t personalDiveCount;
38
+ − 247 uint8_t showDebugInfo;
+ − 248 uint8_t ButtonResponsiveness[4];// changed content in 0xFFFF0016
+ − 249 uint8_t nonMetricalSystem;
+ − 250 uint8_t fallbackToFixedSetpoint;
+ − 251 uint8_t bluetoothActive; /* will be set to zero on each startup at the moment */
+ − 252 uint8_t safetystopDepth;
+ − 253 uint32_t updateSettingsAllowedFromHeader;
662
+ − 254 uint8_t pscr_lung_ratio; /* redefined in 0xFFFF0020 */
+ − 255 uint8_t pscr_o2_drop; /* redefined in 0xFFFF0020 */
+ − 256 uint8_t co2_sensor_active; /* redefined in 0xFFFF0021 */
691
+ − 257 uint8_t ext_uart_protocol; /* redefined in 0xFFFF0022 */
710
+ − 258
+ − 259 uint8_t scubberActiveId; /* redefined in 0xFFFF0023 */
+ − 260 SScrubberData scrubberData[2];
796
+ − 261 uint8_t ext_sensor_map_Obsolete[5];
+ − 262 uint8_t buttonLockActive; /* redefined in 0xFFFF0025 */
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
diff
changeset
+ − 263 int8_t compassDeclinationDeg;
805
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
diff
changeset
+ − 264 uint8_t delaySetpointLow;
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
diff
changeset
+ − 265 uint16_t timerDurationS; /* redefined in 0xFFFF0026 */
662
+ − 266 uint8_t Future_SPARE[FUTURE_SPARE_SIZE]; /* redefined in 0xFFFF0020 (old scooter Block was 32 byte)*/
38
+ − 267 // new in 0xFFFF0006
+ − 268 uint8_t ppo2sensors_deactivated;
+ − 269 uint8_t tX_colorscheme;
+ − 270 uint8_t tX_userselectedLeftLowerCornerPrimary;
+ − 271 uint8_t tX_userselectedLeftLowerCornerTimeout;
+ − 272 uint8_t tX_customViewPrimary;
+ − 273 uint8_t tX_customViewTimeout;
+ − 274 uint8_t timeoutEnterButtonSelectDive;
+ − 275 uint16_t logbookOffset;
+ − 276 uint8_t alwaysShowPPO2;
+ − 277 uint8_t extraDisplay;
+ − 278 uint16_t display_toogle_desc;
+ − 279 int8_t offsetPressure_mbar;
+ − 280 int8_t offsetTemperature_centigrad;
+ − 281 uint8_t gasConsumption_travel_l_min;
+ − 282 uint8_t gasConsumption_bottom_l_min;
+ − 283 uint8_t gasConsumption_deco_l_min;
+ − 284 uint8_t debugModeOnStart;
+ − 285 uint8_t IAmStolenPleaseKillMe;
+ − 286 int16_t compassBearing;
+ − 287 uint8_t lastKnownBatteryPercentage;
+ − 288 uint8_t buttonBalance[3]; // 0 = right, 1 = center, 2 = left
+ − 289 uint8_t firmwareVersion[4];
+ − 290 uint16_t timeoutSurfacemodeWithSensors;
+ − 291 // new in 0xFFFF0016
+ − 292 uint8_t VPM_model;
+ − 293 uint8_t GF_model;
+ − 294 // new in 0xFFFF0017
+ − 295 uint8_t FactoryButtonBase;
+ − 296 uint8_t FactoryButtonBalance[3];
112
+ − 297 /* new in 0xFFFF0018 */
+ − 298 uint8_t FlipDisplay;
210
+ − 299 /* new in 0xFFFF0019 */
+ − 300 uint32_t cv_configuration;
368
50ea68c7a153
Added menu item for motion detection. There are several possibility to use motion detection for user action input. To select of the a new menu entry has been added to the Sys2 =>Custom View Menu (Variables in german)
ideenmodellierer
diff
changeset
+ − 301 /* new in 0xFFFF001A */
50ea68c7a153
Added menu item for motion detection. There are several possibility to use motion detection for user action input. To select of the a new menu entry has been added to the Sys2 =>Custom View Menu (Variables in german)
ideenmodellierer
diff
changeset
+ − 302 uint8_t MotionDetection;
498
4811f3dfaa52
Added dew parameter to enable selection of customer BigFont screens to be displayed
Ideenmodellierer
diff
changeset
+ − 303 /* new in 0xFFFF001B */
4811f3dfaa52
Added dew parameter to enable selection of customer BigFont screens to be displayed
Ideenmodellierer
diff
changeset
+ − 304 uint32_t cv_config_BigScreen;
539
+ − 305 /* new in 0xFFFF001C */
+ − 306 uint8_t compassInertia;
542
+ − 307 uint8_t tX_customViewPrimaryBF;
546
+ − 308 /* new in 0xFFFF001D */
626
+ − 309 uint8_t viewPortMode; /* 7-Reserve| 6..5 - Focus spot size | 4-Focusframe | 3-Reserve | 2..0-BacklightBoost */
546
+ − 310 uint16_t viewRoll;
+ − 311 uint16_t viewPitch;
+ − 312 uint16_t viewYaw;
560
+ − 313 /* new in 0xFFFF001E */
+ − 314 uint8_t ppo2sensors_source;
+ − 315 float ppo2sensors_calibCoeff[3];
567
+ − 316 uint8_t amPMTime;
650
+ − 317 /* new in 0xFFFF001F */
+ − 318 uint8_t autoSetpoint;
710
+ − 319 uint16_t scrubTimerMax_Obsolete; /* have been replaced with new scrubber data format */
+ − 320 uint16_t scrubTimerCur_Obsolete; /* have been replaced with new scrubber data format */
654
+ − 321 uint8_t scrubTimerMode;
796
+ − 322 uint8_t ext_sensor_map[8]; /* redefined in 0xFFFF0027 */
834
+ − 323 uint8_t cvAutofocus;
882
+ − 324 uint8_t slowExitTime;
949
+ − 325 /* new in 0xFFFF002c */
+ − 326 StimeZone timeZone;
951
+ − 327 uint8_t warningBuzzer;
38
+ − 328 } SSettings;
+ − 329
+ − 330 typedef struct
+ − 331 {
+ − 332 // 8 bytes
+ − 333 uint16_t primarySerial;
+ − 334 uint8_t primaryLicence;
+ − 335 uint8_t revision8bit;
+ − 336 uint8_t production_year;
+ − 337 uint8_t production_month;
+ − 338 uint8_t production_day;
+ − 339 uint8_t production_bluetooth_name_set;
+ − 340
+ − 341 // 44 bytes
+ − 342 char production_info[44];
+ − 343
+ − 344 // 8 bytes
+ − 345 uint16_t secondarySerial;
+ − 346 uint8_t secondaryLicence;
+ − 347 uint8_t secondaryReason8bit;
+ − 348 uint8_t secondary_year;
+ − 349 uint8_t secondary_month;
+ − 350 uint8_t secondary_day;
+ − 351 uint8_t secondary_bluetooth_name_set;
+ − 352
+ − 353 // 4 bytes
+ − 354 char secondary_info[4];
+ − 355 } SHardwareData;
+ − 356
+ − 357 uint8_t writeData(uint8_t *);
+ − 358 uint8_t readData(uint8_t what,uint8_t *);
+ − 359 uint8_t readDataLimits__8and16BitValues_4and7BytesOutput(uint8_t what, uint8_t * data);
+ − 360
+ − 361 uint8_t getPPO2Max(void);
+ − 362 uint8_t getPPO2Min(void);
+ − 363 uint8_t getDiveMode(void);
+ − 364 uint8_t getCCRMode(void);
+ − 365 uint8_t getDecoType(void);
+ − 366 uint8_t getFutureTTS(void);
+ − 367
+ − 368 SSettings* settingsGetPointer(void);
+ − 369 const SSettings* settingsGetPointerStandard(void);
+ − 370 void set_settings_to_Standard(void);
+ − 371 void mod_settings_for_first_start_with_empty_ext_flash(void);
+ − 372 const SFirmwareData* firmwareDataGetPointer(void);
+ − 373 const SHardwareData* hardwareDataGetPointer(void);
+ − 374 uint8_t firmwareVersion_16bit_high(void);
+ − 375 uint8_t firmwareVersion_16bit_low(void);
+ − 376 void hardwareBatchCode(uint8_t *high, uint8_t *low);
+ − 377
+ − 378 uint8_t RTEminimum_required_high(void);
+ − 379 uint8_t RTEminimum_required_low(void);
+ − 380 uint8_t FONTminimum_required_high(void);
+ − 381 uint8_t FONTminimum_required_low(void);
+ − 382
+ − 383 void setActualRTEversion(uint8_t high, uint8_t low);
+ − 384 void getActualRTEandFONTversion(uint8_t *RTEhigh, uint8_t *RTElow, uint8_t *FONThigh, uint8_t *FONTlow);
+ − 385
+ − 386 void set_new_settings_missing_in_ext_flash(void);
+ − 387 uint8_t check_and_correct_settings(void);
+ − 388 uint8_t newFirmwareVersionCheckViaSettings(void);
765
da8126d5ea9f
After a firmware update, use the factory settings for button sensitivity if these exist, the default settings otherwise.
heinrichsweikamp
diff
changeset
+ − 389 void set_settings_button_to_factory_with_individual_buttonBalance(void);
38
+ − 390 uint8_t getLicence(void);
+ − 391 void firmwareGetDate(RTC_DateTypeDef *SdateOutput);
+ − 392
+ − 393 void settingsHelperButtonSens_original_translate_to_hwOS_values(const uint32_t inputValueRaw, uint8_t *outArray4Values);
+ − 394
+ − 395 uint8_t buttonBalanceTranslatorHexToArray(uint8_t hexValue, uint8_t* outputArray);
+ − 396 uint8_t buttonBalanceTranslateArrayOutHex(const uint8_t* inputArray);
+ − 397 void getButtonFactorDefaults(uint8_t* basePercentage, uint8_t* buttonBalanceArray);
+ − 398 void settingsWriteFactoryDefaults(uint8_t inputValueRaw, uint8_t *inputBalanceArray);
+ − 399
+ − 400 void settingsHelperButtonSens_keepPercentageValues(uint32_t inputValueRaw, uint8_t *outArray4Values);
+ − 401 uint8_t settingsHelperButtonSens_translate_percentage_to_hwOS_values(uint8_t inputValuePercentage);
+ − 402 uint8_t settingsHelperButtonSens_translate_hwOS_values_to_percentage(uint8_t inputValuePIC);
+ − 403
819
+ − 404 void get_CorrectionStatus(SSettingsStatus* Status);
662
+ − 405 void reset_SettingWarning();
+ − 406 uint8_t isSettingsWarning();
+ − 407
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
diff
changeset
+ − 408 bool checkAndFixSetpointSettings(void);
38
+ − 409 #endif // SETTINGS_H