Mercurial > public > ostc4
annotate Small_CPU/Inc/scheduler.h @ 471:73da921869d9 fix-bat-2
bugfix: implement battery charge percentage in dive header
This commit is (much) less trivial than the related 919e5cb51c92.
First, rename the CCRmode attribute (corresponding to byte Ox59) of
the SLogbookHeaderOSTC3. This byte (according to the hwOS interface
document) does not contain any CCR related value, but it contains
"battery information". Already since 2017, this byte is used from
libdivecomputer to interface the charge percentage. So, its
renamed from CCRmode to batteryCharge, to reflect its true purpose.
Now, simply add a batteryCharge attribute to the SLogbookHeader
(and see below why that is possible, without breaking things).
The remaining changes are trivial to implement battery charge
percentage in dive header.
Caveat: do not get confused by the exact role of the individual
logbook header types. SLogbookHeaderOSTC3 is the formal type of
the logbook format that the OSTC4 produces. This format is
supposed to identical to the format, as is used in hwOS for the
series of small OSTCs. Only some values of attributes are different.
For example, the OSTC4 supports VPM, so byte 0x79 (deco model used
for this dive) also has a value for VPM. But the SLogbookHeader
type, despite its name and structure, is *not* a true logbook
header, as it includes attributes that are not available in the
SLogbookHeaderOSTC3 formal header type.
Signed-off-by: Jan Mulder <jan@jlmulder.nl>
author | Jan Mulder <jlmulder@xs4all.nl> |
---|---|
date | Wed, 22 Apr 2020 13:08:57 +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****/ |