Mercurial > public > ostc4
annotate Discovery/Src/tDebug.c @ 744:dd5db6e2c9a4
Added DiveO2 fatal error detection:
The digital sensor provides status information which are now considered in the sanity check for sensor values. The behavior in case of an error is the same as if an analog sensor would provide a out of bounce voltage.
author | Ideenmodellierer |
---|---|
date | Sun, 19 Feb 2023 21:51:19 +0100 |
parents | 717f335cc5c9 |
children |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/tDebug.c | |
5 /// \brief Screen with Terminal Out | |
6 /// \author heinrichs weikamp gmbh | |
7 /// \date 06-April-2016 | |
8 /// | |
9 /// \details | |
10 /// | |
11 /// $Id$ | |
12 /////////////////////////////////////////////////////////////////////////////// | |
13 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh | |
14 /// | |
15 /// This program is free software: you can redistribute it and/or modify | |
16 /// it under the terms of the GNU General Public License as published by | |
17 /// the Free Software Foundation, either version 3 of the License, or | |
18 /// (at your option) any later version. | |
19 /// | |
20 /// This program is distributed in the hope that it will be useful, | |
21 /// but WITHOUT ANY WARRANTY; without even the implied warranty of | |
22 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
23 /// GNU General Public License for more details. | |
24 /// | |
25 /// You should have received a copy of the GNU General Public License | |
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>. | |
27 ////////////////////////////////////////////////////////////////////////////// | |
28 | |
29 /* Includes ------------------------------------------------------------------*/ | |
30 #include "tDebug.h" | |
31 | |
32 #include "data_exchange_main.h" | |
33 #include "gfx_engine.h" | |
34 #include "gfx_fonts.h" | |
35 #include "ostc.h" | |
36 #include "tInfo.h" | |
394
717f335cc5c9
Added start of module configuration after eache modul power on
ideenmodellierer
parents:
38
diff
changeset
|
37 #include "tComm.h" |
38 | 38 |
39 #include "stm32f4xx_hal.h" | |
40 | |
41 #include <string.h> | |
42 | |
43 uint8_t tD_selection_page = 1; | |
44 uint8_t tD_debugModeActive = 0; | |
45 uint8_t tD_status = 0; | |
46 | |
47 char tD_communication[6][40]; | |
48 | |
49 void tDebug_Action(void); | |
50 void tDebug_NextPage(void); | |
51 | |
52 | |
53 void setDebugMode(void) | |
54 { | |
55 tD_debugModeActive = 1; | |
56 } | |
57 | |
58 | |
59 void exitDebugMode(void) | |
60 { | |
61 MX_Bluetooth_PowerOff(); | |
62 settingsGetPointer()->debugModeOnStart = 0; | |
63 tD_debugModeActive = 0; | |
64 } | |
65 | |
66 | |
67 uint8_t inDebugMode(void) | |
68 { | |
69 return tD_debugModeActive; | |
70 /* | |
71 if(settingsGetPointer()->showDebugInfo == 2) | |
72 return 1; | |
73 else | |
74 return 0; | |
75 */ | |
76 } | |
77 | |
78 | |
79 void tDebug_start(void) | |
80 { | |
81 MX_Bluetooth_PowerOn(); | |
394
717f335cc5c9
Added start of module configuration after eache modul power on
ideenmodellierer
parents:
38
diff
changeset
|
82 tComm_StartBlueModConfig(); |
38 | 83 |
84 tD_debugModeActive = 1; | |
85 tD_status = 0; | |
86 for(int i=0;i<6;i++) | |
87 tD_communication[i][0] = 0; | |
88 | |
89 set_globalState(StIDEBUG); | |
90 } | |
91 | |
92 | |
93 void tDebugControl(uint8_t sendAction) | |
94 { | |
95 switch(sendAction) | |
96 { | |
97 case ACTION_BUTTON_ENTER: | |
98 tDebug_Action(); | |
99 break; | |
100 case ACTION_BUTTON_NEXT: | |
101 tDebug_NextPage(); | |
102 break; | |
103 case ACTION_TIMEOUT: | |
104 case ACTION_MODE_CHANGE: | |
105 case ACTION_BUTTON_BACK: | |
106 exitInfo(); | |
394
717f335cc5c9
Added start of module configuration after eache modul power on
ideenmodellierer
parents:
38
diff
changeset
|
107 break; |
38 | 108 default: |
109 break; | |
110 case ACTION_IDLE_TICK: | |
111 case ACTION_IDLE_SECOND: | |
112 break; | |
113 } | |
114 } | |
115 | |
116 | |
117 void tDebug_refresh(void) | |
118 { | |
119 uint8_t color; | |
120 char text[50]; | |
121 | |
122 tInfo_write_content_simple( 700,780, 20, &FontT24, "\0021/1", CLUT_NiceGreen); | |
123 | |
124 tInfo_write_content_simple( 20,780, 20, &FontT24, "Debug Terminal", CLUT_NiceGreen); | |
125 /* | |
126 snprintf(text,50,"X: %i Y: %i Z: %i %03.0f %03.0f" | |
127 ,stateUsed->lifeData.compass_DX_f | |
128 ,stateUsed->lifeData.compass_DY_f | |
129 ,stateUsed->lifeData.compass_DZ_f | |
130 ,stateUsed->lifeData.compass_roll | |
131 ,stateUsed->lifeData.compass_pitch | |
132 ); | |
133 */ | |
134 snprintf(text,50,"roll %.0f pitch %.0f" | |
135 ,stateUsed->lifeData.compass_roll | |
136 ,stateUsed->lifeData.compass_pitch | |
137 ); | |
138 | |
139 tInfo_write_content_simple( 20,780, 60, &FontT24, text, CLUT_NiceGreen); | |
140 | |
141 for(int i=0;i<6;i++) | |
142 { | |
143 if(i%2) | |
144 color = CLUT_WarningRed; | |
145 else | |
146 color = CLUT_WarningYellow; | |
147 tInfo_write_content_simple( 20,780, (60*i)+100, &FontT42, tD_communication[i], color); | |
148 } | |
149 } | |
150 | |
151 | |
152 void tDebug_NextPage(void) | |
153 { | |
154 | |
155 } | |
156 | |
157 | |
158 void tDebug_helper_replaceCRLF(char *text, uint8_t maxlength) | |
159 { | |
160 for(int i=0; i<maxlength; i++) | |
161 { | |
162 if(text[i] == 0) | |
163 break; | |
164 if((text[i] == '\r') || (text[i] == '\n')) | |
165 text[i] = ' '; | |
166 } | |
167 } | |
168 | |
169 | |
170 void tDebug_Action(void) | |
171 { | |
172 char aRxBuffer[50]; | |
173 | |
174 char aTxBufferEscapeSequence[4] = "+++"; | |
175 char aTxBufferName[22] = "AT+BNAME=OSTC4-12345\r"; | |
176 char aTxBufferWrite[6] = "AT&W\r"; | |
177 gfx_number_to_string(5,1,&aTxBufferName[15],hardwareDataGetPointer()->primarySerial); | |
178 | |
179 tD_status++; | |
180 | |
181 switch(tD_status) | |
182 { | |
183 case 1: | |
184 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBufferEscapeSequence, 3, 2000) == HAL_OK) | |
185 { | |
186 strcpy(tD_communication[0],aTxBufferEscapeSequence); | |
187 } | |
188 else | |
189 { | |
190 strcpy(tD_communication[0],"Error."); | |
191 } | |
192 | |
193 if(HAL_UART_Receive(&UartHandle, (uint8_t*)aRxBuffer, 3, 2000) == HAL_OK) | |
194 { | |
195 aRxBuffer[3] = 0; | |
196 tDebug_helper_replaceCRLF(aRxBuffer, 3); | |
197 strcpy(tD_communication[1],aRxBuffer); | |
198 } | |
199 else | |
200 { | |
201 strcpy(tD_communication[1],"Error."); | |
202 } | |
203 break; | |
204 | |
205 case 2: | |
206 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBufferName, 21, 2000) == HAL_OK) | |
207 { | |
208 strcpy(tD_communication[2],aTxBufferName); | |
209 } | |
210 else | |
211 { | |
212 strcpy(tD_communication[2],"Error."); | |
213 } | |
214 | |
215 if(HAL_UART_Receive(&UartHandle, (uint8_t*)aRxBuffer, 21+6, 2000) == HAL_OK) | |
216 { | |
217 aRxBuffer[21+6] = 0; | |
218 tDebug_helper_replaceCRLF(aRxBuffer, 21+6); | |
219 strcpy(tD_communication[3],aRxBuffer); | |
220 } | |
221 else | |
222 { | |
223 strcpy(tD_communication[3],"Error."); | |
224 } | |
225 break; | |
226 | |
227 case 3: | |
228 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBufferWrite, 5, 2000) == HAL_OK) | |
229 { | |
230 strcpy(tD_communication[4],aTxBufferWrite); | |
231 } | |
232 else | |
233 { | |
234 strcpy(tD_communication[4],"Error."); | |
235 } | |
236 | |
237 if(HAL_UART_Receive(&UartHandle, (uint8_t*)aRxBuffer, 5+6, 2000) == HAL_OK) | |
238 { | |
239 aRxBuffer[5+6] = 0; | |
240 tDebug_helper_replaceCRLF(aRxBuffer, 5+6); | |
241 strcpy(tD_communication[5],aRxBuffer); | |
242 } | |
243 else | |
244 { | |
245 strcpy(tD_communication[5],"Error."); | |
246 } | |
247 break; | |
248 | |
249 default: | |
250 tD_status = 0; | |
251 break; | |
252 } | |
253 } | |
254 | |
255 | |
256 | |
257 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/ | |
258 |