Mercurial > public > ostc4
annotate Small_CPU/Inc/scheduler.h @ 306:2f43419102c8 cleanup-4
bugfix, cleanup: do not clip depth to 0
A real dive with the previous commits shows that testing from the simulator
cannot be fully trusted in relation to logic that is close to the depth
sensor (that is obviously bypassed using the simulator). So 1) there is
3 second interval between the stopwatch and the divetime, and 2) the depth
flips from 1m depth to surface 0m depth, and that is visible in the
profile data.
Point 2) is definitely caused by the removed code in this commit. It likely
is not right to clip the depth value at all. It is fine to base decisions like is
done in is_ambient_pressure_close_to_surface on it, but clipping the depth value
itself is seems wrong. This has become more prominent with commit eba8d1eb5bef
where the clipping depth changed from 40cm of depth to 1m of depth. When
comparing profiles from an OSTC Plus, it shows that no depth clipping is
present there, so that is one more argument to remove it here.
Point 1) The 3 sec interval is likely not a coincidence. It is the time
to travel for 1m depth with a default descend speed of 20m/min.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author | Jan Mulder <jlmulder@xs4all.nl> |
---|---|
date | Wed, 22 May 2019 14:39:04 +0200 |
parents | a91d99265884 |
children | aa6006975e76 |
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 |
265
a91d99265884
Increase SPI com timeout for cold start and wake up
ideenmodellierer
parents:
264
diff
changeset
|
43 #define SPI_COM_TIMEOUT_START (5) /* *100 ms timeout to avoid tiemout e.g. after Main wakeup */ |
a91d99265884
Increase SPI com timeout for cold start and wake up
ideenmodellierer
parents:
264
diff
changeset
|
44 #define SPI_COM_TIMEOUT_COMMON (3) /* *100ms shorter timeout during normal operation to have a faster error reaction */ |
a91d99265884
Increase SPI com timeout for cold start and wake up
ideenmodellierer
parents:
264
diff
changeset
|
45 |
38 | 46 typedef struct |
47 { | |
48 uint8_t mode; | |
49 short conservatism; | |
50 short repetitive_dive; | |
51 long seconds_since_last_dive; | |
52 long no_fly_time_minutes; | |
53 uint8_t whichGas; | |
54 SGas aktualGas[2]; | |
55 float ceiling_from_main_CPU_mbar; | |
56 SLifeData lifeData; | |
57 SVpm vpm; | |
58 SSettings settings; | |
59 SDevice deviceData; | |
60 SDataExchangeSlaveToMasterDeviceData deviceDataSendToMaster; | |
61 SDataExchangeSlaveToMaster dataSendToMaster; | |
62 SDataReceiveFromMaster dataSendToSlave; | |
63 _Bool demo_mode; | |
64 uint8_t dataSendToSlaveIsValid; | |
65 uint8_t dataSendToSlavePending; | |
66 uint32_t sync_error_count; | |
67 uint32_t check_sync_not_running; | |
68 uint8_t ButtonResponsiveness[4]; | |
69 uint8_t chargerStatus; | |
70 uint8_t dataSendToSlaveIsNotValidCount; | |
71 uint8_t ButtonPICdata[4]; | |
72 uint8_t accidentFlag; | |
73 uint32_t accidentRemainingSeconds; | |
74 uint8_t sensorError[MAX_SENSORS]; | |
241
2b9775f71e30
cleanup: factor out I2C1_Status() and cleanup type
Jan Mulder <jlmulder@xs4all.nl>
parents:
239
diff
changeset
|
75 HAL_StatusTypeDef I2C_SystemStatus; |
38 | 76 } SGlobal; |
77 | |
78 typedef struct | |
79 { | |
80 long seconds_since_last_dive; | |
81 long no_fly_time_minutes; | |
82 } SBackup; | |
83 | |
144 | 84 typedef struct |
85 { | |
86 uint8_t counterSPIdata100msec; | |
87 uint8_t counterPressure100msec; | |
88 uint8_t counterCompass100msec; | |
89 uint8_t counterAmbientLight100msec; | |
265
a91d99265884
Increase SPI com timeout for cold start and wake up
ideenmodellierer
parents:
264
diff
changeset
|
90 uint8_t communicationTimeout; |
220
e524a824d8f2
Added schedule point for functions executed once in a second
ideenmodellierer
parents:
207
diff
changeset
|
91 uint32_t tick_execute1second; |
144 | 92 uint32_t tickstart; |
93 } SScheduleCtrl; | |
94 | |
95 | |
38 | 96 /* Variables ---------------------------------------------------------*/ |
97 extern SGlobal global; | |
98 | |
99 | |
100 /* Function prototypes -----------------------------------------------*/ | |
101 | |
102 void initGlobals(void); | |
264
b3685fbada3b
Sync to Main 100ms time stamp & added Reinitialization of globals after startup
ideenmodellierer
parents:
241
diff
changeset
|
103 void reinitGlobals(void); |
38 | 104 |
105 void scheduleSurfaceMode(void); | |
106 void scheduleDiveMode(void); | |
107 void scheduleSleepMode(void); | |
108 void scheduleCompassCalibrationMode(void); | |
109 void scheduleTestMode(void); | |
110 | |
111 void scheduleUpdateLifeData(int32_t asynchron_milliseconds_since_last); | |
112 void scheduleSpecial_Evaluate_DataSendToSlave(void); | |
113 void scheduleUpdateDeviceDataChargerFull(void); | |
114 void scheduleUpdateDeviceDataChargerCharging(void); | |
115 | |
207 | 116 void Scheduler_Request_sync_with_SPI(uint8_t SyncMethod); |
264
b3685fbada3b
Sync to Main 100ms time stamp & added Reinitialization of globals after startup
ideenmodellierer
parents:
241
diff
changeset
|
117 void Scheduler_SyncToSPI(uint8_t TXtick); |
207 | 118 |
38 | 119 uint8_t scheduleSetButtonResponsiveness(void); |
120 | |
121 void copyBatteryData(void); | |
122 | |
123 //void scheduleSurfaceMode_test(void); | |
124 //void scheduleSleepMode_test(void); | |
125 | |
126 #ifdef __cplusplus | |
127 } | |
128 #endif | |
129 | |
130 #endif /* SCHEDULER_H */ | |
131 | |
132 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/ |