Mercurial > public > ostc4
annotate Small_CPU/Inc/scheduler.h @ 228:f9ba924d188e div-fixes-4-1
Bugfix: set battery percentage correctly after RTE update
When the RTE is rebooted, the battery percentage on the display is zeroed.
However, when selecting SYS2-reboot-maintenance, the previously known
battery percentage can be manually restored. Interestingly, when
the restore reported a percentage A, choosing that resulted in a
percentage B to be displayed again. With B much smaller than A.
So, rebooting the RTE multiple times resulted in an seemingly
empty battery, while it definitely is not.
The reason for this is a relatively simple bug in the RTE code. This
commit fixes the conversion between the internal LTC2941 registers
and the percentage value to be displayed. Obviously, from and to
the internal registers need to be symmetrical.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author | Jan Mulder <jlmulder@xs4all.nl> |
---|---|
date | Tue, 02 Apr 2019 14:53:15 +0200 |
parents | e524a824d8f2 |
children | e4207f0aaa4b |
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; | |
88 | 63 uint8_t dataSendToSlaveStopEval; |
38 | 64 uint32_t sync_error_count; |
65 uint32_t check_sync_not_running; | |
66 uint8_t ButtonResponsiveness[4]; | |
67 uint8_t chargerStatus; | |
68 uint8_t dataSendToSlaveIsNotValidCount; | |
69 uint8_t ButtonPICdata[4]; | |
70 uint8_t accidentFlag; | |
71 uint32_t accidentRemainingSeconds; | |
72 uint8_t sensorError[MAX_SENSORS]; | |
73 uint8_t I2C_SystemStatus; | |
74 } SGlobal; | |
75 | |
76 typedef struct | |
77 { | |
78 long seconds_since_last_dive; | |
79 long no_fly_time_minutes; | |
80 } SBackup; | |
81 | |
144 | 82 typedef struct |
83 { | |
84 uint8_t counterSPIdata100msec; | |
85 uint8_t counterPressure100msec; | |
86 uint8_t counterCompass100msec; | |
87 uint8_t counterAmbientLight100msec; | |
220
e524a824d8f2
Added schedule point for functions executed once in a second
ideenmodellierer
parents:
207
diff
changeset
|
88 uint32_t tick_execute1second; |
144 | 89 uint32_t tickstart; |
90 } SScheduleCtrl; | |
91 | |
92 | |
38 | 93 /* Variables ---------------------------------------------------------*/ |
94 extern SGlobal global; | |
95 | |
96 | |
97 /* Function prototypes -----------------------------------------------*/ | |
98 | |
99 void initGlobals(void); | |
100 | |
101 void scheduleSurfaceMode(void); | |
102 void scheduleDiveMode(void); | |
103 void scheduleSleepMode(void); | |
104 void scheduleCompassCalibrationMode(void); | |
105 void scheduleTestMode(void); | |
106 | |
107 void scheduleUpdateLifeData(int32_t asynchron_milliseconds_since_last); | |
108 void scheduleSpecial_Evaluate_DataSendToSlave(void); | |
109 void scheduleUpdateDeviceDataChargerFull(void); | |
110 void scheduleUpdateDeviceDataChargerCharging(void); | |
111 | |
207 | 112 void Scheduler_Request_sync_with_SPI(uint8_t SyncMethod); |
113 void Scheduler_SyncToSPI(void); | |
114 | |
38 | 115 uint8_t scheduleSetButtonResponsiveness(void); |
116 | |
117 void copyBatteryData(void); | |
118 | |
119 //void scheduleSurfaceMode_test(void); | |
120 //void scheduleSleepMode_test(void); | |
121 | |
122 #ifdef __cplusplus | |
123 } | |
124 #endif | |
125 | |
126 #endif /* SCHEDULER_H */ | |
127 | |
128 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/ |