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
+ − 30 // From Common/Inc:
+ − 31 #include "FirmwareData.h"
+ − 32
+ − 33 //#include "data_central.h"
+ − 34
92
+ − 35 #include "global_constants.h"
38
+ − 36 // From Common/Drivers/
+ − 37 #include "stm32f4xx_hal.h"
+ − 38
691
+ − 39 #include "configuration.h"
+ − 40
38
+ − 41 #include <stdint.h>
+ − 42
92
+ − 43
38
+ − 44 #define NUM_GASES 5
+ − 45 #define NUM_OFFSET_DILUENT 5
+ − 46 #define SPECIAL_GAS_ID 0
+ − 47
+ − 48 #define ERROR_ 0xFF
+ − 49
+ − 50 #define CCRMODE_FixedSetpoint 0
+ − 51 #define CCRMODE_Sensors 1
662
+ − 52 #define CCRMODE_Simulation 2
38
+ − 53
+ − 54 #define DIVEMODE_OC 0
+ − 55 #define DIVEMODE_CCR 1
+ − 56 #define DIVEMODE_Gauge 2
+ − 57 #define DIVEMODE_Apnea 3
662
+ − 58 #define DIVEMODE_PSCR 4
38
+ − 59
+ − 60 #define GF_MODE 1
+ − 61 #define VPM_MODE 2
+ − 62
+ − 63 #define VPM_FROM_FORTRAN 0
+ − 64 #define VPM_BACHELORWORK 1
+ − 65
+ − 66 #define BUEHLMANN_OSTC4 0
+ − 67 #define BUEHLMANN_hwOS 1
+ − 68
+ − 69 #define MMDDYY 0
+ − 70 #define DDMMYY 1
+ − 71 #define YYMMDD 2
+ − 72
337
+ − 73 #define PRESSURE_OFFSET_LIMIT_MBAR 50
+ − 74
560
+ − 75 #define MAX_COMPASS_COMP (2u)
640
+ − 76 #define MAX_VIEWPORT_MODE (0x7F)
560
+ − 77
676
+ − 78 #define MAX_SCRUBBER_TIME (999u)
652
+ − 79 #define MIN_PPO2_SP_CBAR (40u)
650
+ − 80
662
+ − 81 #define PSCR_MAX_O2_DROP (15u)
+ − 82 #define PSCR_MIN_LUNG_RATIO (5u)
+ − 83 #define PSCR_MAX_LUNG_RATIO (20u)
+ − 84
691
+ − 85 #define UART_MAX_PROTOCOL (2u)
+ − 86
+ − 87 #define FUTURE_SPARE_SIZE (28u) /* Applied for reuse of old, not used, scooter block (was 32 bytes)*/
662
+ − 88
560
+ − 89 typedef enum
+ − 90 {
+ − 91 O2_SENSOR_SOURCE_OPTIC = 0,
+ − 92 O2_SENSOR_SOURCE_ANALOG,
702
+ − 93 O2_SENSOR_SOURCE_DIGITAL,
+ − 94 O2_SENSOR_SOURCE_ANADIG,
691
+ − 95 #ifdef ENABLE_SENTINEL_MODE
+ − 96 O2_SENSOR_SOURCE_SENTINEL,
+ − 97 #endif
560
+ − 98 O2_SENSOR_SOURCE_MAX
+ − 99 } SensorSource;
+ − 100 #define MAX_O2_SENSOR_SOURCE (2u)
546
+ − 101
654
+ − 102 typedef enum
+ − 103 {
+ − 104 SCRUB_TIMER_OFF = 0,
+ − 105 SCRUB_TIMER_MINUTES,
+ − 106 SCRUB_TIMER_PERCENT,
+ − 107 SCRUB_TIMER_END
+ − 108 } ScrubTimerMode_e;
+ − 109
38
+ − 110 /* 2015 Jan 30, hw, deco and travel added for MenuEditGas
+ − 111 * can be used for buehlmann, vpm, etc. later but be carefull
+ − 112 * with current implemenation */
+ − 113 typedef struct{
+ − 114 uint8_t active:1;
+ − 115 uint8_t first:1;
+ − 116 uint8_t deco:1;
+ − 117 uint8_t travel:1;
526
+ − 118 uint8_t off:1;
+ − 119 uint8_t spare:3;
38
+ − 120 } gasubit8_t;
+ − 121
+ − 122 typedef union{
+ − 123 gasubit8_t ub;
+ − 124 uint8_t uw;
+ − 125 } gasbit8_Type;
+ − 126
+ − 127 typedef struct{
+ − 128 uint8_t standard:4;
+ − 129 uint8_t alternative:4;
+ − 130 } ubit2x4_t;
+ − 131
+ − 132 typedef union{
+ − 133 ubit2x4_t ub;
+ − 134 uint8_t uw;
+ − 135 } split2x4_Type;
+ − 136
+ − 137 typedef union{
+ − 138 uint8_t u8[4];
+ − 139 uint32_t u32;
+ − 140 } general32to8_Type;
+ − 141
+ − 142 typedef struct
+ − 143 {
+ − 144 uint8_t oxygen_percentage;
+ − 145 uint8_t helium_percentage;
+ − 146 gasbit8_Type note;
+ − 147 uint8_t depth_meter;
+ − 148 uint8_t depth_meter_travel;
+ − 149 uint8_t bottle_size_liter;
+ − 150 // uint8_t bottle_wireless_status;
+ − 151 uint16_t bottle_wireless_id;
+ − 152 } SGasLine;
+ − 153
+ − 154 typedef struct
+ − 155 {
+ − 156 uint8_t setpoint_cbar;
+ − 157 uint8_t depth_meter;
+ − 158 gasbit8_Type note;
+ − 159 } SSetpointLine;
+ − 160
654
+ − 161
+ − 162
38
+ − 163 /* SSettings
+ − 164 * gas[0] and setpoint[0] are the special ones configurable during the dive
+ − 165 */
+ − 166 typedef struct
+ − 167 {
+ − 168 uint32_t header;
+ − 169 uint8_t warning_blink_dsec;
+ − 170 uint8_t lastDiveLogId;
+ − 171 uint32_t logFlashNextSampleStartAddress;
+ − 172 SGasLine gas[1 + (2*NUM_GASES)];
+ − 173 SSetpointLine setpoint[1 + NUM_GASES];
+ − 174 uint8_t CCR_Mode;
+ − 175 uint8_t dive_mode;
+ − 176 split2x4_Type deco_type;
+ − 177 uint8_t ppO2_max_deco;
+ − 178 uint8_t ppO2_max_std;
+ − 179 uint8_t ppO2_min;
+ − 180 uint8_t CNS_max;
+ − 181 uint8_t ascent_MeterPerMinute_max;
+ − 182 uint8_t ascent_MeterPerMinute_showGraph;
+ − 183 uint8_t future_TTS;
+ − 184 uint8_t GF_high;
+ − 185 uint8_t GF_low;
+ − 186 uint8_t aGF_high;
+ − 187 uint8_t aGF_low;
+ − 188 split2x4_Type VPM_conservatism;
+ − 189 uint8_t safetystopDuration;
+ − 190 uint8_t AtemMinutenVolumenLiter;
+ − 191 uint8_t ReserveFractionDenominator;
+ − 192 uint8_t salinity;
+ − 193 uint8_t last_stop_depth_meter;
+ − 194 uint8_t stop_increment_depth_meter;
+ − 195 uint8_t brightness;
+ − 196 uint8_t date_format;
+ − 197 uint8_t selected_language;
+ − 198 char customtext[60];
+ − 199 uint16_t timeoutSurfacemode;
+ − 200 uint8_t timeoutMenuSurface;
+ − 201 uint8_t timeoutMenuDive;
+ − 202 uint8_t timeoutMenuEdit;
+ − 203 uint8_t timeoutInfo;
+ − 204 uint8_t timeoutInfoCompass;
+ − 205 uint8_t design;
+ − 206 uint16_t timeoutDiveReachedZeroDepth;
+ − 207 uint16_t divetimeToCreateLogbook;
+ − 208 uint8_t serialHigh;
+ − 209 uint8_t serialLow;
+ − 210 // SUFirmware firmwareVersion16to32bit;
+ − 211 uint32_t backup_localtime_rtc_tr;
+ − 212 uint32_t backup_localtime_rtc_dr;
+ − 213 uint16_t totalDiveCounter;
560
+ − 214 uint16_t personalDiveCount;
38
+ − 215 uint8_t showDebugInfo;
+ − 216 uint8_t ButtonResponsiveness[4];// changed content in 0xFFFF0016
+ − 217 uint8_t nonMetricalSystem;
+ − 218 uint8_t fallbackToFixedSetpoint;
+ − 219 uint8_t bluetoothActive; /* will be set to zero on each startup at the moment */
+ − 220 uint8_t safetystopDepth;
+ − 221 uint32_t updateSettingsAllowedFromHeader;
662
+ − 222 uint8_t pscr_lung_ratio; /* redefined in 0xFFFF0020 */
+ − 223 uint8_t pscr_o2_drop; /* redefined in 0xFFFF0020 */
+ − 224 uint8_t co2_sensor_active; /* redefined in 0xFFFF0021 */
691
+ − 225 uint8_t ext_uart_protocol; /* redefined in 0xFFFF0022 */
662
+ − 226 uint8_t Future_SPARE[FUTURE_SPARE_SIZE]; /* redefined in 0xFFFF0020 (old scooter Block was 32 byte)*/
38
+ − 227 // new in 0xFFFF0006
+ − 228 uint8_t ppo2sensors_deactivated;
+ − 229 uint8_t tX_colorscheme;
+ − 230 uint8_t tX_userselectedLeftLowerCornerPrimary;
+ − 231 uint8_t tX_userselectedLeftLowerCornerTimeout;
+ − 232 uint8_t tX_customViewPrimary;
+ − 233 uint8_t tX_customViewTimeout;
+ − 234 uint8_t timeoutEnterButtonSelectDive;
+ − 235 uint16_t logbookOffset;
+ − 236 uint8_t alwaysShowPPO2;
+ − 237 uint8_t extraDisplay;
+ − 238 uint16_t display_toogle_desc;
+ − 239 int8_t offsetPressure_mbar;
+ − 240 int8_t offsetTemperature_centigrad;
+ − 241 uint8_t gasConsumption_travel_l_min;
+ − 242 uint8_t gasConsumption_bottom_l_min;
+ − 243 uint8_t gasConsumption_deco_l_min;
+ − 244 uint8_t debugModeOnStart;
+ − 245 uint8_t IAmStolenPleaseKillMe;
+ − 246 int16_t compassBearing;
+ − 247 uint8_t lastKnownBatteryPercentage;
+ − 248 uint8_t buttonBalance[3]; // 0 = right, 1 = center, 2 = left
+ − 249 uint8_t firmwareVersion[4];
+ − 250 uint16_t timeoutSurfacemodeWithSensors;
+ − 251 // new in 0xFFFF0016
+ − 252 uint8_t VPM_model;
+ − 253 uint8_t GF_model;
+ − 254 // new in 0xFFFF0017
+ − 255 uint8_t FactoryButtonBase;
+ − 256 uint8_t FactoryButtonBalance[3];
112
+ − 257 /* new in 0xFFFF0018 */
+ − 258 uint8_t FlipDisplay;
210
+ − 259 /* new in 0xFFFF0019 */
+ − 260 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
+ − 261 /* 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
+ − 262 uint8_t MotionDetection;
498
4811f3dfaa52
Added dew parameter to enable selection of customer BigFont screens to be displayed
Ideenmodellierer
diff
changeset
+ − 263 /* new in 0xFFFF001B */
4811f3dfaa52
Added dew parameter to enable selection of customer BigFont screens to be displayed
Ideenmodellierer
diff
changeset
+ − 264 uint32_t cv_config_BigScreen;
539
+ − 265 /* new in 0xFFFF001C */
+ − 266 uint8_t compassInertia;
542
+ − 267 uint8_t tX_customViewPrimaryBF;
546
+ − 268 /* new in 0xFFFF001D */
626
+ − 269 uint8_t viewPortMode; /* 7-Reserve| 6..5 - Focus spot size | 4-Focusframe | 3-Reserve | 2..0-BacklightBoost */
546
+ − 270 uint16_t viewRoll;
+ − 271 uint16_t viewPitch;
+ − 272 uint16_t viewYaw;
560
+ − 273 /* new in 0xFFFF001E */
+ − 274 uint8_t ppo2sensors_source;
+ − 275 float ppo2sensors_calibCoeff[3];
567
+ − 276 uint8_t amPMTime;
650
+ − 277 /* new in 0xFFFF001F */
+ − 278 uint8_t autoSetpoint;
+ − 279 uint16_t scrubTimerMax;
+ − 280 uint16_t scrubTimerCur;
654
+ − 281 uint8_t scrubTimerMode;
38
+ − 282 } SSettings;
+ − 283
+ − 284 typedef struct
+ − 285 {
+ − 286 // 8 bytes
+ − 287 uint16_t primarySerial;
+ − 288 uint8_t primaryLicence;
+ − 289 uint8_t revision8bit;
+ − 290 uint8_t production_year;
+ − 291 uint8_t production_month;
+ − 292 uint8_t production_day;
+ − 293 uint8_t production_bluetooth_name_set;
+ − 294
+ − 295 // 44 bytes
+ − 296 char production_info[44];
+ − 297
+ − 298 // 8 bytes
+ − 299 uint16_t secondarySerial;
+ − 300 uint8_t secondaryLicence;
+ − 301 uint8_t secondaryReason8bit;
+ − 302 uint8_t secondary_year;
+ − 303 uint8_t secondary_month;
+ − 304 uint8_t secondary_day;
+ − 305 uint8_t secondary_bluetooth_name_set;
+ − 306
+ − 307 // 4 bytes
+ − 308 char secondary_info[4];
+ − 309 } SHardwareData;
+ − 310
+ − 311 uint8_t writeData(uint8_t *);
+ − 312 uint8_t readData(uint8_t what,uint8_t *);
+ − 313 uint8_t readDataLimits__8and16BitValues_4and7BytesOutput(uint8_t what, uint8_t * data);
+ − 314
+ − 315 uint8_t getPPO2Max(void);
+ − 316 uint8_t getPPO2Min(void);
+ − 317 uint8_t getDiveMode(void);
+ − 318 uint8_t getCCRMode(void);
+ − 319 uint8_t getDecoType(void);
+ − 320 uint8_t getFutureTTS(void);
+ − 321
+ − 322 SSettings* settingsGetPointer(void);
+ − 323 const SSettings* settingsGetPointerStandard(void);
+ − 324 void set_settings_to_Standard(void);
+ − 325 void mod_settings_for_first_start_with_empty_ext_flash(void);
+ − 326 const SFirmwareData* firmwareDataGetPointer(void);
+ − 327 const SHardwareData* hardwareDataGetPointer(void);
+ − 328 uint8_t firmwareVersion_16bit_high(void);
+ − 329 uint8_t firmwareVersion_16bit_low(void);
+ − 330 void hardwareBatchCode(uint8_t *high, uint8_t *low);
+ − 331
+ − 332 uint8_t RTEminimum_required_high(void);
+ − 333 uint8_t RTEminimum_required_low(void);
+ − 334 uint8_t FONTminimum_required_high(void);
+ − 335 uint8_t FONTminimum_required_low(void);
+ − 336
+ − 337 void setActualRTEversion(uint8_t high, uint8_t low);
+ − 338 void getActualRTEandFONTversion(uint8_t *RTEhigh, uint8_t *RTElow, uint8_t *FONThigh, uint8_t *FONTlow);
+ − 339
+ − 340 void set_new_settings_missing_in_ext_flash(void);
+ − 341 uint8_t check_and_correct_settings(void);
+ − 342 uint8_t newFirmwareVersionCheckViaSettings(void);
+ − 343 void set_settings_button_to_standard_with_individual_buttonBalance(void);
+ − 344 uint8_t getLicence(void);
+ − 345 void firmwareGetDate(RTC_DateTypeDef *SdateOutput);
+ − 346
+ − 347 void settingsHelperButtonSens_original_translate_to_hwOS_values(const uint32_t inputValueRaw, uint8_t *outArray4Values);
+ − 348
+ − 349 uint8_t buttonBalanceTranslatorHexToArray(uint8_t hexValue, uint8_t* outputArray);
+ − 350 uint8_t buttonBalanceTranslateArrayOutHex(const uint8_t* inputArray);
+ − 351 void getButtonFactorDefaults(uint8_t* basePercentage, uint8_t* buttonBalanceArray);
+ − 352 void settingsWriteFactoryDefaults(uint8_t inputValueRaw, uint8_t *inputBalanceArray);
+ − 353
+ − 354 void settingsHelperButtonSens_keepPercentageValues(uint32_t inputValueRaw, uint8_t *outArray4Values);
+ − 355 uint8_t settingsHelperButtonSens_translate_percentage_to_hwOS_values(uint8_t inputValuePercentage);
+ − 356 uint8_t settingsHelperButtonSens_translate_hwOS_values_to_percentage(uint8_t inputValuePIC);
+ − 357
662
+ − 358 void reset_SettingWarning();
+ − 359 uint8_t isSettingsWarning();
+ − 360
38
+ − 361 #endif // SETTINGS_H