comparison Common/Inc/settings.h @ 38:5f11787b4f42

include in ostc4 repository
author heinrichsweikamp
date Sat, 28 Apr 2018 11:52:34 +0200
parents
children be35821a4974 fdf0272e9213
comparison
equal deleted inserted replaced
37:ccc45c0e1ea2 38:5f11787b4f42
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
35 // From Common/Drivers/
36 #include "stm32f4xx_hal.h"
37
38 #include <stdint.h>
39
40 #define NUM_GASES 5
41 #define NUM_OFFSET_DILUENT 5
42 #define SPECIAL_GAS_ID 0
43
44 #define ERROR_ 0xFF
45
46 #define CCRMODE_FixedSetpoint 0
47 #define CCRMODE_Sensors 1
48
49 #define DIVEMODE_OC 0
50 #define DIVEMODE_CCR 1
51 #define DIVEMODE_Gauge 2
52 #define DIVEMODE_Apnea 3
53
54 #define GF_MODE 1
55 #define VPM_MODE 2
56
57 #define VPM_FROM_FORTRAN 0
58 #define VPM_BACHELORWORK 1
59
60 #define BUEHLMANN_OSTC4 0
61 #define BUEHLMANN_hwOS 1
62
63 #define MMDDYY 0
64 #define DDMMYY 1
65 #define YYMMDD 2
66
67 #define LICENCEBONEX 0xFE
68
69
70 /* 2015 Jan 30, hw, deco and travel added for MenuEditGas
71 * can be used for buehlmann, vpm, etc. later but be carefull
72 * with current implemenation */
73 typedef struct{
74 uint8_t active:1;
75 uint8_t first:1;
76 uint8_t deco:1;
77 uint8_t travel:1;
78 uint8_t senderCode:4;
79 } gasubit8_t;
80
81 typedef union{
82 gasubit8_t ub;
83 uint8_t uw;
84 } gasbit8_Type;
85
86 typedef struct{
87 uint8_t standard:4;
88 uint8_t alternative:4;
89 } ubit2x4_t;
90
91 typedef union{
92 ubit2x4_t ub;
93 uint8_t uw;
94 } split2x4_Type;
95
96 typedef union{
97 uint8_t u8[4];
98 uint32_t u32;
99 } general32to8_Type;
100
101 typedef struct
102 {
103 uint8_t oxygen_percentage;
104 uint8_t helium_percentage;
105 gasbit8_Type note;
106 uint8_t depth_meter;
107 uint8_t depth_meter_travel;
108 uint8_t bottle_size_liter;
109 // uint8_t bottle_wireless_status;
110 uint16_t bottle_wireless_id;
111 } SGasLine;
112
113 typedef struct
114 {
115 uint8_t setpoint_cbar;
116 uint8_t depth_meter;
117 gasbit8_Type note;
118 } SSetpointLine;
119
120 /* SSettings
121 * gas[0] and setpoint[0] are the special ones configurable during the dive
122 */
123 typedef struct
124 {
125 uint32_t header;
126 uint8_t warning_blink_dsec;
127 uint8_t lastDiveLogId;
128 uint32_t logFlashNextSampleStartAddress;
129 SGasLine gas[1 + (2*NUM_GASES)];
130 SSetpointLine setpoint[1 + NUM_GASES];
131 uint8_t CCR_Mode;
132 uint8_t dive_mode;
133 split2x4_Type deco_type;
134 uint8_t ppO2_max_deco;
135 uint8_t ppO2_max_std;
136 uint8_t ppO2_min;
137 uint8_t CNS_max;
138 uint8_t ascent_MeterPerMinute_max;
139 uint8_t ascent_MeterPerMinute_showGraph;
140 uint8_t future_TTS;
141 uint8_t GF_high;
142 uint8_t GF_low;
143 uint8_t aGF_high;
144 uint8_t aGF_low;
145 split2x4_Type VPM_conservatism;
146 uint8_t safetystopDuration;
147 uint8_t AtemMinutenVolumenLiter;
148 uint8_t ReserveFractionDenominator;
149 uint8_t salinity;
150 uint8_t last_stop_depth_meter;
151 uint8_t stop_increment_depth_meter;
152 uint8_t brightness;
153 uint8_t date_format;
154 uint8_t selected_language;
155 char customtext[60];
156 uint16_t timeoutSurfacemode;
157 uint8_t timeoutMenuSurface;
158 uint8_t timeoutMenuDive;
159 uint8_t timeoutMenuEdit;
160 uint8_t timeoutInfo;
161 uint8_t timeoutInfoCompass;
162 uint8_t design;
163 uint16_t timeoutDiveReachedZeroDepth;
164 uint16_t divetimeToCreateLogbook;
165 uint8_t serialHigh;
166 uint8_t serialLow;
167 // SUFirmware firmwareVersion16to32bit;
168 uint32_t backup_localtime_rtc_tr;
169 uint32_t backup_localtime_rtc_dr;
170 uint16_t totalDiveCounter;
171 uint16_t personalDiveCount;
172 uint8_t showDebugInfo;
173 uint8_t ButtonResponsiveness[4];// changed content in 0xFFFF0016
174 uint8_t nonMetricalSystem;
175 uint8_t fallbackToFixedSetpoint;
176 uint8_t bluetoothActive; /* will be set to zero on each startup at the moment */
177 uint8_t safetystopDepth;
178 uint32_t updateSettingsAllowedFromHeader;
179 uint8_t scooterControl;
180 uint8_t scooterDrag;
181 uint8_t scooterLoad;
182 uint8_t scooterNumberOfBatteries;
183 uint16_t scooterBattSize;
184 uint8_t scooterSPARE1[7];
185 uint8_t scooterSPARE2[19];
186 // new in 0xFFFF0006
187 uint8_t ppo2sensors_deactivated;
188 uint8_t tX_colorscheme;
189 uint8_t tX_userselectedLeftLowerCornerPrimary;
190 uint8_t tX_userselectedLeftLowerCornerTimeout;
191 uint8_t tX_customViewPrimary;
192 uint8_t tX_customViewTimeout;
193 uint8_t timeoutEnterButtonSelectDive;
194 uint16_t logbookOffset;
195 uint8_t alwaysShowPPO2;
196 uint8_t extraDisplay;
197 uint16_t display_toogle_desc;
198 int8_t offsetPressure_mbar;
199 int8_t offsetTemperature_centigrad;
200 uint8_t gasConsumption_travel_l_min;
201 uint8_t gasConsumption_bottom_l_min;
202 uint8_t gasConsumption_deco_l_min;
203 uint8_t debugModeOnStart;
204 uint8_t IAmStolenPleaseKillMe;
205 int16_t compassBearing;
206 uint8_t lastKnownBatteryPercentage;
207 uint8_t buttonBalance[3]; // 0 = right, 1 = center, 2 = left
208 uint8_t firmwareVersion[4];
209 uint16_t timeoutSurfacemodeWithSensors;
210 // new in 0xFFFF0016
211 uint8_t VPM_model;
212 uint8_t GF_model;
213 // new in 0xFFFF0017
214 uint8_t FactoryButtonBase;
215 uint8_t FactoryButtonBalance[3];
216
217 //to be continued
218 } SSettings;
219
220 typedef struct
221 {
222 // 8 bytes
223 uint16_t primarySerial;
224 uint8_t primaryLicence;
225 uint8_t revision8bit;
226 uint8_t production_year;
227 uint8_t production_month;
228 uint8_t production_day;
229 uint8_t production_bluetooth_name_set;
230
231 // 44 bytes
232 char production_info[44];
233
234 // 8 bytes
235 uint16_t secondarySerial;
236 uint8_t secondaryLicence;
237 uint8_t secondaryReason8bit;
238 uint8_t secondary_year;
239 uint8_t secondary_month;
240 uint8_t secondary_day;
241 uint8_t secondary_bluetooth_name_set;
242
243 // 4 bytes
244 char secondary_info[4];
245 } SHardwareData;
246
247 uint8_t writeData(uint8_t *);
248 uint8_t readData(uint8_t what,uint8_t *);
249 uint8_t readDataLimits__8and16BitValues_4and7BytesOutput(uint8_t what, uint8_t * data);
250
251 uint8_t getPPO2Max(void);
252 uint8_t getPPO2Min(void);
253 uint8_t getDiveMode(void);
254 uint8_t getCCRMode(void);
255 uint8_t getDecoType(void);
256 uint8_t getFutureTTS(void);
257
258 SSettings* settingsGetPointer(void);
259 const SSettings* settingsGetPointerStandard(void);
260 void set_settings_to_Standard(void);
261 void mod_settings_for_first_start_with_empty_ext_flash(void);
262 const SFirmwareData* firmwareDataGetPointer(void);
263 const SHardwareData* hardwareDataGetPointer(void);
264 uint8_t firmwareVersion_16bit_high(void);
265 uint8_t firmwareVersion_16bit_low(void);
266 void hardwareBatchCode(uint8_t *high, uint8_t *low);
267
268 uint8_t RTEminimum_required_high(void);
269 uint8_t RTEminimum_required_low(void);
270 uint8_t FONTminimum_required_high(void);
271 uint8_t FONTminimum_required_low(void);
272
273 void setActualRTEversion(uint8_t high, uint8_t low);
274 void getActualRTEandFONTversion(uint8_t *RTEhigh, uint8_t *RTElow, uint8_t *FONThigh, uint8_t *FONTlow);
275
276 void set_new_settings_missing_in_ext_flash(void);
277 uint8_t check_and_correct_settings(void);
278 uint8_t newFirmwareVersionCheckViaSettings(void);
279 void set_settings_button_to_standard_with_individual_buttonBalance(void);
280 uint8_t getLicence(void);
281 void firmwareGetDate(RTC_DateTypeDef *SdateOutput);
282
283 void settingsHelperButtonSens_original_translate_to_hwOS_values(const uint32_t inputValueRaw, uint8_t *outArray4Values);
284
285 uint8_t buttonBalanceTranslatorHexToArray(uint8_t hexValue, uint8_t* outputArray);
286 uint8_t buttonBalanceTranslateArrayOutHex(const uint8_t* inputArray);
287 void getButtonFactorDefaults(uint8_t* basePercentage, uint8_t* buttonBalanceArray);
288 void settingsWriteFactoryDefaults(uint8_t inputValueRaw, uint8_t *inputBalanceArray);
289
290 void settingsHelperButtonSens_keepPercentageValues(uint32_t inputValueRaw, uint8_t *outArray4Values);
291 uint8_t settingsHelperButtonSens_translate_percentage_to_hwOS_values(uint8_t inputValuePercentage);
292 uint8_t settingsHelperButtonSens_translate_hwOS_values_to_percentage(uint8_t inputValuePIC);
293
294 #endif // SETTINGS_H