Mercurial > public > ostc4
annotate Common/Inc/data_central.h @ 1078:082825daccb5 Icon_Integration tip
Added control views for HUD:
The HUD implementation may now be activated by the compile switch ENABLE_HUD_SUPPORT. The HUD will become visible onces detected in the CvOpt overview menu. The first implementation is for testing only => The LEDs may be operated by a number field. Positiv values activate the red, negativ the green LEDs. Depending on the value blink sequences will be scheduled.
At the moment no dive specific data is mapped to the LED operation (like e.g. warnings).
| author | Ideenmodellierer |
|---|---|
| date | Mon, 02 Mar 2026 17:30:38 +0100 |
| parents | 3c73180fde1d |
| children |
| rev | line source |
|---|---|
| 38 | 1 /////////////////////////////////////////////////////////////////////////////// |
| 2 /// -*- coding: UTF-8 -*- | |
| 3 /// | |
| 4 /// \file Common/Inc/data_central.h | |
| 5 /// \brief Common Dadatypes Declarations | |
| 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 DATA_CENTRAL_H | |
| 28 #define DATA_CENTRAL_H | |
| 29 | |
| 30 #include <stdint.h> | |
|
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
31 #include <stdbool.h> |
| 38 | 32 |
| 33 #include "settings.h" | |
| 34 #include "stm32f4xx_hal.h" | |
| 672 | 35 #include "configuration.h" |
| 38 | 36 |
| 37 #define BUEHLMANN_STRUCT_MAX_GASES 11 | |
| 38 #define BUEHLMANN_STRUCT_MAX_ASCENDRATES 3 | |
| 39 #define DECOINFO_STRUCT_MAX_STOPS 50 | |
| 40 | |
| 41 #define false 0 | |
| 42 #define true 1 | |
| 43 | |
| 796 | 44 #define EXT_INTERFACE_SENSOR_CNT (8u) /* 1 MUX + 7 sensors may be connected to the external interface (1 MUX + 3 ADC + 4 UART) */ |
| 45 #define EXT_INTERFACE_MUX_OFFSET (3u) /* the sensor struct starts with 3 ADC sensors */ | |
|
728
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
714
diff
changeset
|
46 |
| 996 | 47 #define EXT_INTERFACE_BUZZER_ON_TIME_MS (2000u) /* max time the buzzer should be active without break (continuous Operation) */ |
| 48 #define EXT_INTERFACE_BUZZER_PING_TIME_MS (1000u) /* max time the buzzer should be active for single ping */ | |
| 951 | 49 #define EXT_INTERFACE_BUZZER_STABLE_TIME_MS (500u) /* min time a state (ON / OFF) should be stable before it may be changed */ |
| 50 | |
| 1078 | 51 #define EXT_INTERFACE_HUD_LED_MAX (16u) /* max number of supported LED for HUD operation */ |
| 52 | |
| 951 | 53 |
| 38 | 54 /* Helper structs ------------------------------------------------------------*/ |
| 55 | |
| 56 //struct SGas | |
| 57 //contains gasinfos of single gas for deco calculation | |
| 58 typedef struct | |
| 59 { | |
| 60 uint8_t nitrogen_percentage; | |
| 61 uint8_t helium_percentage; | |
| 62 uint8_t setPoint_cbar; | |
| 63 uint8_t change_during_ascent_depth_meter_otherwise_zero; | |
| 64 uint8_t GasIdInSettings; | |
| 662 | 65 uint8_t AppliedDiveMode; |
| 66 float pscr_factor; | |
| 38 | 67 } SGas; |
| 68 | |
| 69 typedef struct | |
| 70 { | |
| 71 float use_from_depth_bar; | |
| 72 float rate_bar_per_minute; | |
| 73 } SAscentrate; | |
| 74 | |
| 75 | |
| 76 typedef struct{ | |
| 77 uint32_t date_rtc_dr; | |
| 78 uint32_t time_rtc_tr; | |
| 79 int32_t value_int32; | |
| 80 } SDeviceLine; | |
| 81 | |
| 82 | |
| 83 typedef struct | |
| 84 { | |
| 85 uint16_t ageInMilliSeconds; | |
| 86 uint8_t numberOfBytes; | |
| 87 uint8_t status; | |
| 88 uint8_t data[12]; | |
| 89 } SDataWireless; | |
| 90 | |
| 662 | 91 |
| 92 typedef struct | |
| 93 { | |
| 748 | 94 uint32_t CO2_ppm; |
| 662 | 95 uint16_t signalStrength; |
| 96 } SCO2Sensor; | |
| 97 | |
| 38 | 98 /* Main structs -------------------------------------------------------------*/ |
| 99 | |
| 100 | |
| 101 //struct SDecoinfo | |
| 102 //contains result of deco calculation | |
| 103 typedef struct | |
| 104 { | |
| 105 unsigned short output_stop_length_seconds[DECOINFO_STRUCT_MAX_STOPS]; | |
| 106 int output_time_to_surface_seconds; | |
| 107 int output_ndl_seconds; | |
| 108 float output_ceiling_meter; | |
|
247
3949781096d4
feature: Relative GF to Saturation renames
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
109 float super_saturation; |
| 1049 | 110 float gf_surf; |
| 38 | 111 uint32_t tickstamp; |
| 112 } SDecoinfo; | |
| 113 | |
| 114 | |
| 115 typedef struct | |
| 116 { | |
| 117 //crushing pressure | |
| 118 //in/out | |
| 119 float max_crushing_pressure_he[16]; | |
| 120 float max_crushing_pressure_n2[16]; | |
| 121 // | |
| 122 float run_time_start_of_deco_zone_save; | |
| 123 float depth_start_of_deco_zone_save; | |
| 124 float max_first_stop_depth_save; | |
| 125 short decomode_vpm_plus_conservatism_last_dive; | |
| 126 _Bool deco_zone_reached; | |
| 127 //State variables for repetetive dives | |
| 128 _Bool repetitive_variables_not_valid; | |
| 129 float adjusted_crushing_pressure_he[16]; | |
| 130 float adjusted_crushing_pressure_n2[16]; | |
| 131 float adjusted_critical_radius_he[16]; | |
| 132 float adjusted_critical_radius_n2[16]; | |
| 133 float initial_allowable_gradient_he[16]; | |
| 134 float initial_allowable_gradient_n2[16]; | |
| 135 float max_actual_gradient[16]; | |
| 136 } SVpm; | |
| 137 | |
| 138 typedef struct | |
| 139 { | |
| 140 _Bool repetitive_variables_not_valid; | |
| 141 _Bool is_data_from_RTE_CPU; | |
| 142 _Bool spare2; | |
| 143 _Bool spare3; | |
| 144 float adjusted_crushing_pressure_he[16]; | |
| 145 float adjusted_crushing_pressure_n2[16]; | |
| 146 float adjusted_critical_radius_he[16]; | |
| 147 float adjusted_critical_radius_n2[16]; | |
| 148 float initial_allowable_gradient_he[16]; | |
| 149 float initial_allowable_gradient_n2[16]; | |
| 150 float max_actual_gradient[16]; | |
| 151 } SVpmRepetitiveData; | |
| 152 | |
| 153 //struct SDevice | |
| 154 //contains information about usage | |
| 155 typedef struct | |
| 156 { | |
| 157 SDeviceLine batteryChargeCycles; | |
| 158 SDeviceLine batteryChargeCompleteCycles; | |
| 159 SDeviceLine temperatureMinimum; | |
| 160 SDeviceLine temperatureMaximum; | |
| 161 SDeviceLine depthMaximum; | |
| 162 SDeviceLine diveCycles; | |
| 163 SDeviceLine voltageMinimum; | |
| 164 SDeviceLine hoursOfOperation; | |
| 165 SDeviceLine diveAccident; | |
| 166 } SDevice; | |
| 167 | |
| 168 /* | |
| 169 typedef struct | |
| 170 { | |
| 171 SDevice device; | |
| 172 SVpmRepetitiveData vpm; | |
| 173 } SDeviceState; | |
| 174 */ | |
| 175 | |
|
899
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
868
diff
changeset
|
176 typedef struct |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
868
diff
changeset
|
177 { |
| 931 | 178 float fLat; |
| 179 float fLon; | |
| 941 | 180 }SGnssCoord; |
| 181 | |
| 949 | 182 |
| 183 typedef struct | |
| 184 { | |
| 185 uint8_t year; | |
| 186 uint8_t month; | |
| 187 uint8_t day; | |
| 188 uint8_t hour; | |
| 189 uint8_t min; | |
| 190 uint8_t sec; | |
| 191 }SDateTime; | |
| 192 | |
| 941 | 193 typedef struct |
| 194 { | |
| 195 SGnssCoord coord; | |
| 940 | 196 uint8_t alive; |
| 931 | 197 uint8_t fixType; |
| 198 uint8_t numSat; /* number of available satellites */ | |
| 199 uint8_t signalQual[4]; /* signal quality indicator for x sats */ | |
| 949 | 200 SDateTime DateTime; /* UTC time information */ |
| 931 | 201 } SGnssInfo; |
|
899
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
868
diff
changeset
|
202 |
| 945 | 203 typedef enum |
| 204 { | |
| 205 SE_INIT = 0, | |
| 206 SE_REINIT, | |
| 207 SE_ACTIVE, | |
| 208 SE_END | |
| 209 } SSlowExitState; | |
| 210 | |
|
899
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
868
diff
changeset
|
211 |
| 38 | 212 /* struct SLifeData |
| 213 * contains data all actual data (pressure, stuturation, etc. as received from second ship | |
| 214 * and has actualGas to be send to Small CPU (second chip) | |
| 215 * contains data calculated from actual data after receiption from Small CPU | |
| 216 */ | |
| 217 typedef struct | |
| 218 { | |
| 219 /* from Small CPU */ | |
| 1078 | 220 uint8_t extIf_sensor_data[EXT_INTERFACE_SENSOR_CNT][32]; /* The external sensor may contain a 64 bit ID. It has been placed at the beginning of the structure to avoid problems in alignment */ |
|
752
4f19336a3f21
Dev Bugfix: Alignment problem in lifedata structure:
Ideenmodellierer
parents:
748
diff
changeset
|
221 uint8_t extIf_sensor_map[EXT_INTERFACE_SENSOR_CNT]; |
|
4f19336a3f21
Dev Bugfix: Alignment problem in lifedata structure:
Ideenmodellierer
parents:
748
diff
changeset
|
222 |
| 38 | 223 int32_t dive_time_seconds; |
| 224 int32_t dive_time_seconds_without_surface_time; | |
| 225 uint32_t surface_time_seconds; | |
| 226 float pressure_ambient_bar; | |
| 227 float pressure_surface_bar; | |
| 228 float tissue_nitrogen_bar[16]; | |
| 229 float tissue_helium_bar[16]; | |
| 230 float cns; | |
| 231 float otu; | |
| 232 uint16_t desaturation_time_minutes; | |
| 233 uint16_t no_fly_time_minutes; | |
| 234 float temperature_celsius; | |
| 235 float compass_heading; | |
| 236 float compass_roll; | |
| 237 float compass_pitch; | |
| 238 int16_t compass_DX_f; | |
| 239 int16_t compass_DY_f; | |
| 240 int16_t compass_DZ_f; | |
| 241 uint16_t counterSecondsShallowDepth; | |
| 242 float ascent_rate_meter_per_min; | |
| 243 uint32_t timeBinaryFormat; | |
| 244 uint32_t dateBinaryFormat; | |
| 245 float battery_voltage; | |
| 246 float battery_charge; | |
| 247 uint16_t ambient_light_level; | |
| 248 SDataWireless wireless_data[4]; | |
| 249 uint8_t buttonPICdata[4]; | |
| 662 | 250 SCO2Sensor CO2_data; |
|
714
045ff7800501
Added customizable data area for specific sensor data:
Ideenmodellierer
parents:
672
diff
changeset
|
251 uint8_t extIf_sensor_Id; |
| 38 | 252 |
| 253 /* by create DiveSettings() and by setActualGas() | |
| 254 * is send to Small CPU2 for nitrogen calculation | |
| 255 * includes setpoint information | |
| 256 */ | |
| 257 SGas actualGas; | |
|
771
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
752
diff
changeset
|
258 |
| 38 | 259 uint8_t lastDiluent_GasIdInSettings; |
|
771
29d9b5bc7946
Revised automatic setpoint change. The proposed approach is essentially the approach used by most controllers of eCCR ('upshift' on descent, 'downshift' on ascent), so that the OSTC4 when used as a backup computer for eCCR will make the changes at the same time as the eCCR itself.
heinrichsweikamp
parents:
752
diff
changeset
|
260 float lastSetpointChangeDepthM; |
|
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
parents:
780
diff
changeset
|
261 bool setpointDecoActivated; |
|
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
parents:
780
diff
changeset
|
262 bool setpointLowDelayed; |
| 38 | 263 |
| 264 /* calculated by DataEX_copy_to_LifeData() | |
| 265 bottle_bar array size is made like this to have multiples of 32bit | |
| 266 */ | |
| 267 float ppO2; | |
| 268 float depth_meter; | |
| 269 float max_depth_meter; | |
| 270 float average_depth_meter; | |
| 271 float apnea_total_max_depth_meter; | |
| 272 float apnea_last_max_depth_meter; | |
| 273 int32_t apnea_last_dive_time_seconds; | |
| 274 uint16_t bottle_bar[2 * NUM_GASES +1]; | |
| 275 uint16_t bottle_bar_age_MilliSeconds[2 * NUM_GASES + 1]; | |
| 276 uint16_t apnea_total_counter; | |
| 277 | |
| 278 /* control of DataEX_copy_to_LifeData() | |
| 279 */ | |
| 280 uint8_t boolResetAverageDepth; | |
| 281 uint8_t bool_temp1; | |
| 282 uint8_t bool_temp2; | |
| 283 | |
| 284 /* from local sensor or direct HUD communication */ | |
| 285 //pp O2 Sensor | |
| 286 float ppO2Sensor_bar[3]; | |
| 287 float sensorVoltage_mV[3]; | |
| 288 float HUD_battery_voltage_V; | |
| 662 | 289 |
| 290 /* for PSCR Mode */ | |
| 291 float ppo2Simulated_bar; | |
|
899
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
868
diff
changeset
|
292 /* GNSS data */ |
| 931 | 293 SGnssInfo gnssData; |
| 1058 | 294 /* last GF_Surf when shallow area was entered */ |
| 295 uint8_t gf_surf_log; | |
|
899
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
868
diff
changeset
|
296 |
| 1078 | 297 /* HUD control data */ |
| 298 uint8_t HUD_led_sequence[EXT_INTERFACE_HUD_LED_MAX]; | |
| 299 uint8_t HUD_led_brightness; | |
| 38 | 300 } SLifeData; |
| 301 | |
| 302 | |
| 303 typedef struct | |
| 304 { | |
| 305 uint16_t tissue_nitrogen_desaturation_time_minutes[16]; | |
| 306 uint16_t tissue_helium_desaturation_time_minutes[16]; | |
| 307 } SLifeData2; | |
| 308 | |
| 309 | |
| 310 typedef struct | |
| 311 { | |
| 312 //warnings | |
| 313 int8_t decoMissed; | |
| 314 int8_t aGf; | |
| 315 int8_t ascentRateHigh; | |
| 316 int8_t ppO2Low; | |
| 317 int8_t ppO2High; | |
| 318 int8_t cnsHigh; | |
| 319 int8_t slowWarning; | |
| 320 int8_t lowBattery; | |
| 321 int8_t numWarnings; | |
| 322 int8_t sensorLinkLost; | |
| 323 int8_t sensorOutOfBounds[3]; | |
| 324 int8_t betterGas; | |
| 325 int8_t fallback; | |
| 326 int8_t betterSetpoint; | |
|
752
4f19336a3f21
Dev Bugfix: Alignment problem in lifedata structure:
Ideenmodellierer
parents:
748
diff
changeset
|
327 int8_t co2High; |
|
478
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
309
diff
changeset
|
328 #ifdef ENABLE_BOTTLE_SENSOR |
|
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
309
diff
changeset
|
329 int8_t newPressure; |
|
58200d756365
Development option only: Show Pressure update for a short time in the custom field (as warning)
ideenmodellierer
parents:
309
diff
changeset
|
330 #endif |
| 857 | 331 #ifdef HAVE_DEBUG_WARNINGS |
| 332 int8_t debug; | |
| 333 #endif | |
| 38 | 334 } SWarnings; |
| 335 | |
| 336 | |
| 337 typedef struct | |
| 338 { | |
| 339 //Events logbook only | |
| 340 int16_t manualMarker; | |
| 341 int16_t gasChange; | |
| 342 int16_t info_GasChange; | |
| 343 int16_t setpointChange; | |
| 344 int16_t info_SetpointChange; | |
| 281 | 345 int16_t manualGasSet; |
| 346 int16_t info_manualGasSetHe; | |
| 347 int16_t info_manualGasSetO2; | |
| 38 | 348 int16_t bailout; |
| 349 int16_t info_bailoutHe; | |
| 350 int16_t info_bailoutO2; | |
|
929
63c340abd70e
Add a line to the compass heading dive menu that shows the currently set heading to enable the
heinrichsweikamp
parents:
925
diff
changeset
|
351 int16_t compassHeadingUpdate; |
|
63c340abd70e
Add a line to the compass heading dive menu that shows the currently set heading to enable the
heinrichsweikamp
parents:
925
diff
changeset
|
352 uint16_t info_compassHeadingUpdate; |
| 941 | 353 int16_t gnssPositionUpdate; |
| 354 SGnssCoord info_gnssPosition; | |
|
1014
8c0134a287da
Add a log data event to the scrubber timer at the start of the dive and every time the timer (in minutes)
heinrichsweikamp
parents:
996
diff
changeset
|
355 int16_t scrubberState; |
|
8c0134a287da
Add a log data event to the scrubber timer at the start of the dive and every time the timer (in minutes)
heinrichsweikamp
parents:
996
diff
changeset
|
356 uint16_t info_scrubberState; |
|
929
63c340abd70e
Add a line to the compass heading dive menu that shows the currently set heading to enable the
heinrichsweikamp
parents:
925
diff
changeset
|
357 } SEvents; |
| 38 | 358 |
| 359 | |
| 360 | |
| 361 //struct SDiveSettings | |
| 362 //contains settings necessary for deco calculation | |
| 363 typedef struct | |
| 364 { | |
| 365 float last_stop_depth_bar; | |
| 366 float input_next_stop_increment_depth_bar; | |
| 367 float input_second_to_last_stop_depth_bar; | |
| 368 float ascentRate_meterperminute; | |
| 369 uint8_t diveMode; /* OC, CC, .. */ | |
| 370 uint8_t CCR_Mode; | |
| 371 uint8_t future_TTS_minutes; | |
| 372 | |
| 373 /* If beginning of dive is CCR than ccrOption is set true | |
| 374 * true allows returning from bailout (OC) back to CCR | |
| 375 * true activates CC gas and setpoint pages in dive menu | |
| 376 */ | |
| 377 uint8_t ccrOption; | |
| 378 uint8_t fallbackOption; | |
| 379 uint8_t ppo2sensors_deactivated; | |
| 380 | |
| 381 split2x4_Type deco_type; /* GF or VPM for standard and alternative seperate */ | |
| 382 | |
| 383 /* VPM conservatism, do not change during dive!!! | |
| 384 * do not change in between dives otherwise repetitve dive is not possible | |
| 385 */ | |
| 386 uint8_t vpm_conservatism; | |
| 387 | |
| 902 | 388 /* VPM table mode, do not change during dive!!! |
| 389 */ | |
| 390 uint8_t vpm_tableMode; | |
| 391 | |
| 38 | 392 /* B�hlmann GF |
| 393 * and a variable that is used by Buehlmann during the dive | |
| 394 * to remember the position of GF low during ascend | |
| 395 */ | |
| 396 uint8_t gf_high; | |
| 397 uint8_t gf_low; | |
| 398 | |
| 399 /* copy of the Settings GasList and SetpintList | |
| 400 * that can be modified during the dive | |
| 401 * especially gases can be actived and deactivated | |
| 402 * gas[0] and setpoint[0] are the special ones configurable during the dive | |
| 403 */ | |
| 404 SGasLine gas[1 + (2*NUM_GASES)]; | |
| 405 SSetpointLine setpoint[1 + NUM_GASES]; | |
| 406 | |
| 407 /* List of GasChanges in the actual order | |
| 408 * this is necessary for VPM and Buehlmann and will be created on start of each calculation | |
| 409 */ | |
| 410 SGas decogaslist[BUEHLMANN_STRUCT_MAX_GASES]; // unused filled with 0xFF | |
| 411 | |
| 412 /* | |
| 413 */ | |
| 414 float internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero; | |
| 415 uint16_t compassHeading; | |
| 662 | 416 |
| 417 uint8_t pscr_o2_drop; | |
| 418 uint8_t pscr_lung_ratio; | |
|
834
2a8af51ab04d
Added event based display changes for big font view:
Ideenmodellierer
parents:
805
diff
changeset
|
419 |
|
2a8af51ab04d
Added event based display changes for big font view:
Ideenmodellierer
parents:
805
diff
changeset
|
420 uint32_t activeAFViews; |
| 38 | 421 } SDiveSettings; |
| 422 | |
| 423 enum CHARGE_STATUS{ | |
| 424 CHARGER_off = 0, | |
| 425 CHARGER_running, | |
| 426 CHARGER_complete, | |
| 427 CHARGER_lostConnection | |
| 428 }; | |
| 429 | |
|
805
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
799
diff
changeset
|
430 typedef enum { |
|
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
799
diff
changeset
|
431 TIMER_STATE_OFF = 0, |
|
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
799
diff
changeset
|
432 TIMER_STATE_PRESTART, |
|
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
799
diff
changeset
|
433 TIMER_STATE_RUNNING, |
|
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
799
diff
changeset
|
434 TIMER_STATE_WAIT_FINISHED, |
|
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
799
diff
changeset
|
435 TIMER_STATE_FINISHED, |
|
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
799
diff
changeset
|
436 } timerState_e; |
|
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
799
diff
changeset
|
437 |
| 38 | 438 typedef struct |
| 439 { | |
| 440 SDiveSettings diveSettings; | |
| 441 SLifeData lifeData; | |
| 442 SVpm vpm; | |
| 443 SEvents events; | |
| 444 SWarnings warnings; | |
| 445 SDecoinfo decolistVPM; | |
| 446 SDecoinfo decolistFutureVPM; | |
| 447 SDecoinfo decolistBuehlmann; // | |
| 448 SDecoinfo decolistFutureBuehlmann; | |
| 449 uint8_t mode; /* hw for sleep, surface, dive, .. */ | |
| 450 uint8_t chargeStatus; | |
| 451 uint8_t data_old__lost_connection_to_slave; | |
| 452 | |
| 453 uint32_t pressure_uTick_new; | |
| 454 uint32_t compass_uTick_new; | |
| 455 | |
| 456 uint32_t pressure_uTick_old; | |
| 457 uint32_t compass_uTick_old; | |
| 458 | |
| 459 uint32_t pressure_uTick_local_new; | |
| 460 uint32_t compass_uTick_local_new; | |
| 461 | |
| 462 uint8_t cnsHigh_at_the_end_of_dive; | |
| 463 uint8_t decoMissed_at_the_end_of_dive; | |
| 464 | |
| 465 uint8_t sensorErrorsRTE; | |
| 466 | |
| 467 uint8_t lastKnownBatteryPercentage; | |
|
805
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
799
diff
changeset
|
468 |
|
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
799
diff
changeset
|
469 timerState_e timerState; |
|
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
799
diff
changeset
|
470 int timerStartedS; |
| 925 | 471 |
| 472 SScrubberData scrubberDataDive[2]; | |
| 38 | 473 } SDiveState; |
| 474 | |
| 475 | |
| 476 typedef struct{ | |
| 477 uint8_t bit0:1; | |
| 478 uint8_t bit1:1; | |
| 479 uint8_t bit2:1; | |
| 480 uint8_t bit3:1; | |
| 481 uint8_t bit4:1; | |
| 482 uint8_t bit5:1; | |
| 483 uint8_t bit6:1; | |
| 484 uint8_t bit7:1; | |
| 485 } ubit8_t; | |
| 486 | |
| 487 typedef union{ | |
| 488 ubit8_t ub; | |
| 489 uint8_t uw; | |
| 490 } bit8_Type; | |
| 491 | |
| 492 extern SDiveState stateSim; | |
| 493 extern SDiveState stateDeco; | |
| 494 extern uint8_t decoLock; | |
|
271
1303747b5ba2
cleanup: also write gas and setpoint changes in simulator mode
Jan Mulder <jlmulder@xs4all.nl>
parents:
270
diff
changeset
|
495 extern const SDiveState *stateUsed; |
|
1303747b5ba2
cleanup: also write gas and setpoint changes in simulator mode
Jan Mulder <jlmulder@xs4all.nl>
parents:
270
diff
changeset
|
496 extern SDiveState *stateUsedWrite; |
| 38 | 497 |
| 498 enum DECO_LOCK{ | |
| 499 DECO_CALC_running, | |
| 500 DECO_CALC_ready, | |
| 501 DECO_CALC_FINSHED_Buehlmann, | |
| 502 DECO_CALC_FINSHED_vpm, | |
| 503 DECO_CALC_FINSHED_FutureBuehlmann, | |
| 504 DECO_CALC_FINSHED_Futurevpm, | |
| 505 DECO_CALC_init_as_is_start_of_dive, | |
| 506 DECO_CALC_undefined | |
| 507 }; | |
| 508 | |
|
728
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
714
diff
changeset
|
509 typedef enum |
|
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
714
diff
changeset
|
510 { |
|
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
714
diff
changeset
|
511 SENSOR_NONE, |
| 745 | 512 SENSOR_SEARCH, |
| 733 | 513 SENSOR_OPTIC, |
|
728
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
714
diff
changeset
|
514 SENSOR_ANALOG, |
|
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
714
diff
changeset
|
515 SENSOR_DIGO2, |
| 796 | 516 SENSOR_DIGO2M, |
| 745 | 517 SENSOR_SENTINEL, |
|
842
c3dd461ca3f9
Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents:
834
diff
changeset
|
518 SENSOR_SENTINELM, |
| 745 | 519 SENSOR_TYPE_O2_END, |
|
728
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
714
diff
changeset
|
520 SENSOR_CO2, |
| 799 | 521 SENSOR_CO2M, |
| 920 | 522 SENSOR_GNSS, |
| 523 SENSOR_GNSSM, | |
| 1078 | 524 SENSOR_HUD, |
| 780 | 525 SENSOR_MUX, |
|
728
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
714
diff
changeset
|
526 SENSOR_END |
|
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
714
diff
changeset
|
527 } externalInterfaceSensorType; |
|
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
714
diff
changeset
|
528 |
| 745 | 529 #define DVO2_FATAL_INTENSITY_LOW (0x00000001) |
| 530 #define DVO2_FATAL_AMBIENT_HIGH (0x00000002) | |
| 531 #define DVO2_FATAL_REFINT_LOW (0x00000004) | |
| 532 #define DVO2_FATAL_REFAMB_HIGH (0x00000008) | |
| 533 #define DVO2_FATAL_TEMPERATURE (0x00000010) | |
| 534 | |
| 535 #define DVO2_FATAL_ERROR (DVO2_FATAL_INTENSITY_LOW | DVO2_FATAL_AMBIENT_HIGH | DVO2_FATAL_REFINT_LOW | DVO2_FATAL_REFAMB_HIGH | DVO2_FATAL_TEMPERATURE) | |
|
728
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
714
diff
changeset
|
536 |
| 38 | 537 uint32_t time_elapsed_ms(uint32_t ticksstart,uint32_t ticksnow); |
| 538 | |
| 539 void set_stateUsedToSim(void); | |
| 540 void set_stateUsedToReal(void); | |
| 541 | |
| 542 _Bool is_stateUsedSetToSim(void); | |
| 543 | |
| 544 const SDiveState * stateRealGetPointer(void); | |
| 545 const SDiveState * stateSimGetPointer(void); | |
| 546 SDiveState * stateRealGetPointerWrite(void); | |
| 547 SDiveState * stateSimGetPointerWrite(void); | |
| 548 const SDevice * stateDeviceGetPointer(void); | |
| 549 SDevice * stateDeviceGetPointerWrite(void); | |
| 550 const SVpmRepetitiveData * stateVpmRepetitiveDataGetPointer(void); | |
| 551 SVpmRepetitiveData * stateVpmRepetitiveDataGetPointerWrite(void); | |
| 552 | |
| 553 void UpdateLifeDataTest(SDiveState * diveState); | |
| 554 | |
| 555 void setSimulationValues(int _ascent_rate_meter_per_min, int _descent_rate_meter_per_min, int _max_depth, int _bottom_time ); | |
| 556 | |
| 557 void createDiveSettings(void); | |
| 558 void copyDiveSettingsToSim(void); | |
| 559 void copyVpmRepetetiveDataToSim(void); | |
| 560 //void fallbackToFixedSetpoints(SLifeData *lifeData); | |
| 561 void setActualGasFirst(SLifeData *lifeData); | |
| 562 void setActualGasAir(SLifeData *lifeData); | |
| 563 void setActualGas(SLifeData *lifeData, uint8_t gasId, uint8_t setpoint_cbar); | |
| 564 void setActualGas_ExtraGas(SLifeData *lifeData, uint8_t oxygen, uint8_t helium, uint8_t setpoint_cbar); | |
| 565 void setActualGas_DM(SLifeData *lifeData, uint8_t gasId, uint8_t setpoint_cbar); | |
| 566 void setWeekday(RTC_DateTypeDef *sDate); | |
| 567 void setDate(RTC_DateTypeDef Sdate); | |
| 568 void setTime(RTC_TimeTypeDef Stime); | |
| 569 void setBatteryPercentage(uint8_t newChargePercentage); | |
| 570 void setButtonResponsiveness(uint8_t *ButtonSensitivyList); | |
| 571 void calibrateCompass(void); | |
|
539
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
478
diff
changeset
|
572 void compass_Inertia(float newHeading); |
|
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
478
diff
changeset
|
573 float compass_getCompensated(); |
| 38 | 574 void clearDeco(void); |
| 575 void translateDate(uint32_t datetmpreg, RTC_DateTypeDef *sDate); | |
| 576 void translateTime(uint32_t tmpreg, RTC_TimeTypeDef *sTime); | |
| 577 void updateSetpointStateUsed(void); | |
| 578 | |
| 579 uint8_t calc_MOD(uint8_t gasId); | |
| 580 uint8_t calc_MinOD(uint8_t gasId); | |
| 581 //float calc_ppO2(float input_ambient_pressure_bar, SGas* pGas); | |
| 582 int current_second(void); | |
| 583 _Bool vpm_crush(SDiveState* pDiveState); | |
| 584 _Bool deco_zone_reached(void); | |
|
270
2e58a4094770
feature, debug: make simulator write a logbook entry
Jan Mulder <jlmulder@xs4all.nl>
parents:
247
diff
changeset
|
585 void resetEvents(const SDiveState *pStateUsed); |
| 38 | 586 |
| 587 uint32_t crc32c_checksum(uint8_t* message, uint16_t length, uint8_t* message2, uint16_t length2); | |
| 588 uint32_t CRC_CalcBlockCRC(uint32_t *buffer, uint32_t words); | |
| 589 uint32_t CRC_CalcBlockCRC_moreThan768000(uint32_t *buffer1, uint32_t *buffer2, uint32_t words); | |
| 590 | |
| 591 _Bool is_ambient_pressure_close_to_surface(SLifeData *lifeData); | |
| 592 | |
| 662 | 593 uint8_t isLoopMode(uint8_t Mode); |
| 594 | |
|
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
595 bool isCompassCalibrated(void); |
|
929
63c340abd70e
Add a line to the compass heading dive menu that shows the currently set heading to enable the
heinrichsweikamp
parents:
925
diff
changeset
|
596 void logCompassHeading(uint16_t heading); |
|
63c340abd70e
Add a line to the compass heading dive menu that shows the currently set heading to enable the
heinrichsweikamp
parents:
925
diff
changeset
|
597 void clearCompassHeading(void); |
|
774
6169309d6eb9
more menu items for the compass menu: Delete bearing, and reset to land based bearing. I have also re-enabled the real time bearing display in the menu - makes it easier to set the correct bearing. (mikeller)
heinrichsweikamp
parents:
771
diff
changeset
|
598 void setCompassHeading(uint16_t heading); |
|
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
parents:
780
diff
changeset
|
599 |
|
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
parents:
780
diff
changeset
|
600 const SDecoinfo *getDecoInfo(void); |
|
805
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
799
diff
changeset
|
601 |
|
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
799
diff
changeset
|
602 void disableTimer(void); |
|
868
db92692c014f
Introduce speed dependend coloring of depth:
Ideenmodellierer
parents:
857
diff
changeset
|
603 |
|
db92692c014f
Introduce speed dependend coloring of depth:
Ideenmodellierer
parents:
857
diff
changeset
|
604 uint8_t drawingColor_from_ascentspeed(float speed); |
|
db92692c014f
Introduce speed dependend coloring of depth:
Ideenmodellierer
parents:
857
diff
changeset
|
605 |
| 1038 | 606 void formatStringOfTime(char* pString, uint8_t strLen, RTC_TimeTypeDef Stime, uint8_t showAlive, uint8_t showSeconds); |
| 944 | 607 void convertStringOfDate_DDMMYY(char* pString, uint8_t strLen, uint8_t day, uint8_t month, uint8_t year); |
| 608 void getStringOfFormat_DDMMYY(char* pString, uint8_t strLen); | |
| 949 | 609 void convertUTCToLocal(uint8_t utcHours, uint8_t utcMinutes, uint8_t* pLocalHours, uint8_t* pLocalMinutes); |
| 944 | 610 |
| 945 | 611 uint8_t calculateSlowExit(uint16_t* pCountDownSec, float* pExitDepthMeter, uint8_t* pColor); |
| 944 | 612 |
|
1014
8c0134a287da
Add a log data event to the scrubber timer at the start of the dive and every time the timer (in minutes)
heinrichsweikamp
parents:
996
diff
changeset
|
613 bool isScrubberTimerEnabled(const SSettings *settings); |
|
8c0134a287da
Add a log data event to the scrubber timer at the start of the dive and every time the timer (in minutes)
heinrichsweikamp
parents:
996
diff
changeset
|
614 bool isScrubberTimerRunning(const SDiveState *diveState, const SSettings *settings); |
| 38 | 615 #endif // DATA_CENTRAL_H |
