Mercurial > public > ostc4
annotate Small_CPU/Inc/scheduler.h @ 250:822416168585 bm-2
Buelmann: new implementation for ceiling
Since my first functional fix in the ceiling computation in
commit ceecabfddb57, I noticed that the computation used a
linear search, that became rather computational expensive after
that commit. The simple question is: why not a binary search?
So, this commit implements the binary search. But there is a long
story attached to this. Comparing ceiling results from hwOS and this
OSTC4 code were very different. Basically, the original OSTC4
algorithm computed the ceiling using the same GFlow to GFhigh
slope, in such a way, that the ceiling was in sync with the
presented deco stops, where the hwOS code presents a GFhigh
based ceiling.
This said, it is more logical when the OSTC4 and hwOS code give
similar results. This new recursive algorithm gives very similar
results for the ceiling compared to hwOS.
To be complete here, the Buelmann ceiling is the depth to which
you can ascend, so that the leading tissue reaches GFhigh. This
also explains why the deepest deco stop is normally deeper than
the ceiling (unless one dives with GF like 80/80).
The code implemented here is rather straightforward recursion.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author | Jan Mulder <jlmulder@xs4all.nl> |
---|---|
date | Thu, 11 Apr 2019 17:48:48 +0200 |
parents | 2b9775f71e30 |
children | b3685fbada3b |
rev | line source |
---|---|
38 | 1 /** |
2 ****************************************************************************** | |
3 * @file scheduler.h | |
4 * @author heinrichs weikamp gmbh | |
5 * @version V0.0.5 | |
6 * @date 27-March-2014 | |
7 * @brief | |
8 * | |
9 ****************************************************************************** | |
10 * @attention | |
11 * | |
12 * <h2><center>© COPYRIGHT(c) 2015 heinrichs weikamp</center></h2> | |
13 * | |
14 ****************************************************************************** | |
15 */ | |
16 | |
17 | |
18 #ifndef SCHEDULER_H | |
19 #define SCHEDULER_H | |
20 | |
21 #ifdef __cplusplus | |
22 extern "C" { | |
23 #endif | |
24 | |
25 | |
26 /* Includes ------------------------------------------------------------------*/ | |
27 #include "data_central.h" | |
28 #include "data_exchange.h" | |
29 #include "settings.h" | |
30 | |
31 /* Types -------------------------------------------------------------*/ | |
32 #define SENSOR_PRESSURE_ID 0 | |
33 #define MAX_SENSORS 1 | |
181 | 34 |
207 | 35 #define SPI_SYNC_METHOD_NONE (0u) |
36 #define SPI_SYNC_METHOD_HARD (1u) /* Scheduler shall reset all counters to 0 */ | |
37 #define SPI_SYNC_METHOD_SOFT (2u) /* Scheduler shall reset adjust counters to 100ms SPI data exchange cycle */ | |
38 #define SPI_SYNC_METHOD_INVALID (4u) | |
39 | |
220
e524a824d8f2
Added schedule point for functions executed once in a second
ideenmodellierer
parents:
207
diff
changeset
|
40 #define SCHEDULER_TICK_EXE1SEC (980u) /* tick count based on cycle start which is used to trigger functions which */ |
e524a824d8f2
Added schedule point for functions executed once in a second
ideenmodellierer
parents:
207
diff
changeset
|
41 /* shall be executed once in a second (20ms before cycle restarts) */ |
e524a824d8f2
Added schedule point for functions executed once in a second
ideenmodellierer
parents:
207
diff
changeset
|
42 |
38 | 43 typedef struct |
44 { | |
45 uint8_t mode; | |
46 short conservatism; | |
47 short repetitive_dive; | |
48 long seconds_since_last_dive; | |
49 long no_fly_time_minutes; | |
50 uint8_t whichGas; | |
51 SGas aktualGas[2]; | |
52 float ceiling_from_main_CPU_mbar; | |
53 SLifeData lifeData; | |
54 SVpm vpm; | |
55 SSettings settings; | |
56 SDevice deviceData; | |
57 SDataExchangeSlaveToMasterDeviceData deviceDataSendToMaster; | |
58 SDataExchangeSlaveToMaster dataSendToMaster; | |
59 SDataReceiveFromMaster dataSendToSlave; | |
60 _Bool demo_mode; | |
61 uint8_t dataSendToSlaveIsValid; | |
62 uint8_t dataSendToSlavePending; | |
63 uint32_t sync_error_count; | |
64 uint32_t check_sync_not_running; | |
65 uint8_t ButtonResponsiveness[4]; | |
66 uint8_t chargerStatus; | |
67 uint8_t dataSendToSlaveIsNotValidCount; | |
68 uint8_t ButtonPICdata[4]; | |
69 uint8_t accidentFlag; | |
70 uint32_t accidentRemainingSeconds; | |
71 uint8_t sensorError[MAX_SENSORS]; | |
241
2b9775f71e30
cleanup: factor out I2C1_Status() and cleanup type
Jan Mulder <jlmulder@xs4all.nl>
parents:
239
diff
changeset
|
72 HAL_StatusTypeDef I2C_SystemStatus; |
38 | 73 } SGlobal; |
74 | |
75 typedef struct | |
76 { | |
77 long seconds_since_last_dive; | |
78 long no_fly_time_minutes; | |
79 } SBackup; | |
80 | |
144 | 81 typedef struct |
82 { | |
83 uint8_t counterSPIdata100msec; | |
84 uint8_t counterPressure100msec; | |
85 uint8_t counterCompass100msec; | |
86 uint8_t counterAmbientLight100msec; | |
220
e524a824d8f2
Added schedule point for functions executed once in a second
ideenmodellierer
parents:
207
diff
changeset
|
87 uint32_t tick_execute1second; |
144 | 88 uint32_t tickstart; |
89 } SScheduleCtrl; | |
90 | |
91 | |
38 | 92 /* Variables ---------------------------------------------------------*/ |
93 extern SGlobal global; | |
94 | |
95 | |
96 /* Function prototypes -----------------------------------------------*/ | |
97 | |
98 void initGlobals(void); | |
99 | |
100 void scheduleSurfaceMode(void); | |
101 void scheduleDiveMode(void); | |
102 void scheduleSleepMode(void); | |
103 void scheduleCompassCalibrationMode(void); | |
104 void scheduleTestMode(void); | |
105 | |
106 void scheduleUpdateLifeData(int32_t asynchron_milliseconds_since_last); | |
107 void scheduleSpecial_Evaluate_DataSendToSlave(void); | |
108 void scheduleUpdateDeviceDataChargerFull(void); | |
109 void scheduleUpdateDeviceDataChargerCharging(void); | |
110 | |
207 | 111 void Scheduler_Request_sync_with_SPI(uint8_t SyncMethod); |
112 void Scheduler_SyncToSPI(void); | |
113 | |
38 | 114 uint8_t scheduleSetButtonResponsiveness(void); |
115 | |
116 void copyBatteryData(void); | |
117 | |
118 //void scheduleSurfaceMode_test(void); | |
119 //void scheduleSleepMode_test(void); | |
120 | |
121 #ifdef __cplusplus | |
122 } | |
123 #endif | |
124 | |
125 #endif /* SCHEDULER_H */ | |
126 | |
127 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/ |