annotate Discovery/Src/tMenuHardware.c @ 264:b3685fbada3b IPC_Sync_Improvment_2

Sync to Main 100ms time stamp & added Reinitialization of globals after startup Added function to synchronize RTE to the timestamp provided by Main 100ms callback. This was introduced to compensated small shifts in execution and program flow shifts (for example during long operation times)
author ideenmodellierer
date Sun, 14 Apr 2019 11:43:29 +0200
parents cc9c18075e00
children 5e8ad1cd353f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 ///////////////////////////////////////////////////////////////////////////////
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 /// -*- coding: UTF-8 -*-
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 /// \file Discovery/Src/tMenuHardware.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 /// \brief Main Template file for Menu Page Hardware
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 /// \author heinrichs weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 /// \date 05-Aug-2014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 /// \details
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 /// $Id$
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 ///////////////////////////////////////////////////////////////////////////////
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 /// This program is free software: you can redistribute it and/or modify
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 /// it under the terms of the GNU General Public License as published by
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 /// the Free Software Foundation, either version 3 of the License, or
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 /// (at your option) any later version.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 /// This program is distributed in the hope that it will be useful,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21 /// but WITHOUT ANY WARRANTY; without even the implied warranty of
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23 /// GNU General Public License for more details.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 /// You should have received a copy of the GNU General Public License
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 //////////////////////////////////////////////////////////////////////////////
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 #include "tMenu.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 #include "tMenuHardware.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 //#define NEXTLINE(text, textPointer) {text[(textPointer)++] = '\n'; text[textPointer++] = '\r'; text[textPointer] = 0;}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 // NEXTLINE(text,textPointer);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 //\ text[(*textPointer)++] = '\r'; text[*textPointer] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 /* Exported functions --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41 uint32_t tMHardware_refresh(uint8_t line, char *text, uint16_t *tab, char *subtext)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44 SSettings *data;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45 uint8_t textPointer, actualBrightness;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46 char sensorStatusColor[3];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47 int32_t button[4];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48 data = settingsGetPointer();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 textPointer = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50 *tab = 450;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 *subtext = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 /*
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 const char content[6] =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 { TXT_Compass,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55 TXT_o2Sensors,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56 TXT_Brightness,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 TXT_FirmwareUpdate,//TXT_Luftintegration,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58 0,//TXT_FirmwareUpdate,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59 0
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 };
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61 tM_refresh(text,&textPointer,line,content);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 if((line == 0) || (line == 1))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 text[textPointer++] = TXT_2BYTE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 text[textPointer++] = TXT2BYTE_Bluetooth;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 text[textPointer++] = '\t';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 if(settingsGetPointer()->bluetoothActive)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 text[textPointer++] = '\005';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 text[textPointer++] = '\006';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 text[textPointer] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74 nextline(text,&textPointer);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 if((line == 0) || (line == 2))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 text[textPointer++] = TXT_2BYTE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 text[textPointer++] = TXT2BYTE_Compass;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 text[textPointer++] = '\t';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 if(settingsGetPointer()->compassBearing != 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 textPointer += snprintf(&text[textPointer],20,"(%03u`)",settingsGetPointer()->compassBearing);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 text[textPointer] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 /*
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 textPointer += snprintf(&text[textPointer],20,"%i %i %i"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 ,stateUsed->lifeData.compass_DX_f
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 ,stateUsed->lifeData.compass_DY_f
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 ,stateUsed->lifeData.compass_DZ_f);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 nextline(text,&textPointer);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 if((line == 0) || (line == 3))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 text[textPointer++] = TXT_o2Sensors;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 if((stateUsed->lifeData.ppO2Sensor_bar[0] != 0) || (stateUsed->lifeData.ppO2Sensor_bar[1] != 0) || (stateUsed->lifeData.ppO2Sensor_bar[2] != 0))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 text[textPointer++] = '\t';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 sensorStatusColor[0] = '\020';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 sensorStatusColor[1] = '\020';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 sensorStatusColor[2] = '\020';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 if(stateUsed->diveSettings.ppo2sensors_deactivated)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 if(stateUsed->diveSettings.ppo2sensors_deactivated & 1)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 sensorStatusColor[0] = '\021';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 if(stateUsed->diveSettings.ppo2sensors_deactivated & 2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 sensorStatusColor[1] = '\021';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 if(stateUsed->diveSettings.ppo2sensors_deactivated & 4)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 sensorStatusColor[2] = '\021';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 textPointer += snprintf(&text[textPointer],20,"%c%01.1f %c%01.1f %c%01.1f\020"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 ,sensorStatusColor[0], stateUsed->lifeData.ppO2Sensor_bar[0]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 ,sensorStatusColor[1], stateUsed->lifeData.ppO2Sensor_bar[1]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 ,sensorStatusColor[2], stateUsed->lifeData.ppO2Sensor_bar[2]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 nextline(text,&textPointer);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122 if((line == 0) || (line == 4))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 text[textPointer++] = TXT_Brightness;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 text[textPointer++] = '\t';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 actualBrightness = data->brightness;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 if(actualBrightness == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 text[textPointer++] = TXT_Cave;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 else if(actualBrightness == 1)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 text[textPointer++] = TXT_Eco;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 else if(actualBrightness == 2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134 text[textPointer++] = TXT_Normal;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 else if(actualBrightness == 3)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136 text[textPointer++] = TXT_Bright;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 else if(actualBrightness == 4)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138 text[textPointer++] = TXT_Ultrabright;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 text[textPointer++] = '+';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 nextline(text,&textPointer);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 if((line == 0) || (line == 5))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 text[textPointer++] = TXT_2BYTE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 text[textPointer++] = TXT2BYTE_ButtonSensitivity;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 text[textPointer++] = '\t';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 for(int i=0;i<=3;i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 button[i] = (uint8_t)settingsGetPointer()->ButtonResponsiveness[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154 // textPointer += snprintf(&text[textPointer],25,"%i %i %i",button[0],button[1],button[2]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 textPointer += snprintf(&text[textPointer],25,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 "%i"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157 "\016\016"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 " %%"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 "\017",
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 button[3]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 nextline(text,&textPointer);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163
110
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
164 if((line == 0) || (line == 6))
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 {
110
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
166 text[textPointer++] = TXT_2BYTE;
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
167 text[textPointer++] = TXT2BYTE_FLIPDISPLAY;
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
168 text[textPointer++] = '\t';
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
169 if(settingsGetPointer()->FlipDisplay)
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
170 text[textPointer++] = '\005';
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
171 else
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
172 text[textPointer++] = '\006';
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
173 text[textPointer] = 0;
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
174 nextline(text,&textPointer);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 }
110
cc8e24374b83 Added option to handled mirrored display to existing functions
Ideenmodellierer
parents: 38
diff changeset
176
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 return StMHARD;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 }