Mercurial > public > ostc4
annotate Discovery/Src/tDebug.c @ 1037:2af07aa38531 GasConsumption
Merge with external development branches:
Some features have been prepared for integration: Profiles, DMA UART on Firmware part, Bluetooth discovery and messges logging for development phase. All these new function are deactivated by compile switch and may be activated using the configuration.h for testing purpose.
| author | Ideenmodellierer |
|---|---|
| date | Mon, 15 Sep 2025 21:12:44 +0200 |
| parents | 5b913cdaa9dc |
| 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 { | |
| 1035 | 61 if(tD_debugModeActive) |
| 62 { | |
| 63 MX_Bluetooth_PowerOff(); | |
| 64 settingsGetPointer()->debugModeOnStart = 0; | |
| 65 tD_debugModeActive = 0; | |
| 66 } | |
| 38 | 67 } |
| 68 | |
| 69 | |
| 70 uint8_t inDebugMode(void) | |
| 71 { | |
| 72 return tD_debugModeActive; | |
| 73 /* | |
| 74 if(settingsGetPointer()->showDebugInfo == 2) | |
| 75 return 1; | |
| 76 else | |
| 77 return 0; | |
| 78 */ | |
| 79 } | |
| 80 | |
| 81 | |
| 82 void tDebug_start(void) | |
| 83 { | |
| 84 MX_Bluetooth_PowerOn(); | |
|
394
717f335cc5c9
Added start of module configuration after eache modul power on
ideenmodellierer
parents:
38
diff
changeset
|
85 tComm_StartBlueModConfig(); |
| 38 | 86 |
| 87 tD_debugModeActive = 1; | |
| 88 tD_status = 0; | |
| 89 for(int i=0;i<6;i++) | |
| 90 tD_communication[i][0] = 0; | |
| 91 | |
| 92 set_globalState(StIDEBUG); | |
| 93 } | |
| 94 | |
| 95 | |
| 96 void tDebugControl(uint8_t sendAction) | |
| 97 { | |
| 98 switch(sendAction) | |
| 99 { | |
| 100 case ACTION_BUTTON_ENTER: | |
| 101 tDebug_Action(); | |
| 102 break; | |
| 103 case ACTION_BUTTON_NEXT: | |
| 104 tDebug_NextPage(); | |
| 105 break; | |
| 106 case ACTION_TIMEOUT: | |
| 107 case ACTION_MODE_CHANGE: | |
| 108 case ACTION_BUTTON_BACK: | |
| 109 exitInfo(); | |
|
394
717f335cc5c9
Added start of module configuration after eache modul power on
ideenmodellierer
parents:
38
diff
changeset
|
110 break; |
| 38 | 111 default: |
| 112 break; | |
| 113 case ACTION_IDLE_TICK: | |
| 114 case ACTION_IDLE_SECOND: | |
| 115 break; | |
| 116 } | |
| 117 } | |
| 118 | |
| 119 | |
| 120 void tDebug_refresh(void) | |
| 121 { | |
| 122 uint8_t color; | |
| 123 char text[50]; | |
| 124 | |
| 125 tInfo_write_content_simple( 700,780, 20, &FontT24, "\0021/1", CLUT_NiceGreen); | |
| 126 | |
| 127 tInfo_write_content_simple( 20,780, 20, &FontT24, "Debug Terminal", CLUT_NiceGreen); | |
| 128 /* | |
| 129 snprintf(text,50,"X: %i Y: %i Z: %i %03.0f %03.0f" | |
| 130 ,stateUsed->lifeData.compass_DX_f | |
| 131 ,stateUsed->lifeData.compass_DY_f | |
| 132 ,stateUsed->lifeData.compass_DZ_f | |
| 133 ,stateUsed->lifeData.compass_roll | |
| 134 ,stateUsed->lifeData.compass_pitch | |
| 135 ); | |
| 136 */ | |
| 137 snprintf(text,50,"roll %.0f pitch %.0f" | |
| 138 ,stateUsed->lifeData.compass_roll | |
| 139 ,stateUsed->lifeData.compass_pitch | |
| 140 ); | |
| 141 | |
| 142 tInfo_write_content_simple( 20,780, 60, &FontT24, text, CLUT_NiceGreen); | |
| 143 | |
| 144 for(int i=0;i<6;i++) | |
| 145 { | |
| 146 if(i%2) | |
| 147 color = CLUT_WarningRed; | |
| 148 else | |
| 149 color = CLUT_WarningYellow; | |
| 150 tInfo_write_content_simple( 20,780, (60*i)+100, &FontT42, tD_communication[i], color); | |
| 151 } | |
| 152 } | |
| 153 | |
| 154 | |
| 155 void tDebug_NextPage(void) | |
| 156 { | |
| 157 | |
| 158 } | |
| 159 | |
| 160 | |
| 161 void tDebug_helper_replaceCRLF(char *text, uint8_t maxlength) | |
| 162 { | |
| 163 for(int i=0; i<maxlength; i++) | |
| 164 { | |
| 165 if(text[i] == 0) | |
| 166 break; | |
| 167 if((text[i] == '\r') || (text[i] == '\n')) | |
| 168 text[i] = ' '; | |
| 169 } | |
| 170 } | |
| 171 | |
| 172 | |
| 173 void tDebug_Action(void) | |
| 174 { | |
| 175 char aRxBuffer[50]; | |
| 176 | |
| 177 char aTxBufferEscapeSequence[4] = "+++"; | |
| 178 char aTxBufferName[22] = "AT+BNAME=OSTC4-12345\r"; | |
| 179 char aTxBufferWrite[6] = "AT&W\r"; | |
| 180 gfx_number_to_string(5,1,&aTxBufferName[15],hardwareDataGetPointer()->primarySerial); | |
| 181 | |
| 182 tD_status++; | |
| 183 | |
| 184 switch(tD_status) | |
| 185 { | |
| 186 case 1: | |
| 187 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBufferEscapeSequence, 3, 2000) == HAL_OK) | |
| 188 { | |
| 189 strcpy(tD_communication[0],aTxBufferEscapeSequence); | |
| 190 } | |
| 191 else | |
| 192 { | |
| 193 strcpy(tD_communication[0],"Error."); | |
| 194 } | |
| 195 | |
| 196 if(HAL_UART_Receive(&UartHandle, (uint8_t*)aRxBuffer, 3, 2000) == HAL_OK) | |
| 197 { | |
| 198 aRxBuffer[3] = 0; | |
| 199 tDebug_helper_replaceCRLF(aRxBuffer, 3); | |
| 200 strcpy(tD_communication[1],aRxBuffer); | |
| 201 } | |
| 202 else | |
| 203 { | |
| 204 strcpy(tD_communication[1],"Error."); | |
| 205 } | |
| 206 break; | |
| 207 | |
| 208 case 2: | |
| 209 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBufferName, 21, 2000) == HAL_OK) | |
| 210 { | |
| 211 strcpy(tD_communication[2],aTxBufferName); | |
| 212 } | |
| 213 else | |
| 214 { | |
| 215 strcpy(tD_communication[2],"Error."); | |
| 216 } | |
| 217 | |
| 218 if(HAL_UART_Receive(&UartHandle, (uint8_t*)aRxBuffer, 21+6, 2000) == HAL_OK) | |
| 219 { | |
| 220 aRxBuffer[21+6] = 0; | |
| 221 tDebug_helper_replaceCRLF(aRxBuffer, 21+6); | |
| 222 strcpy(tD_communication[3],aRxBuffer); | |
| 223 } | |
| 224 else | |
| 225 { | |
| 226 strcpy(tD_communication[3],"Error."); | |
| 227 } | |
| 228 break; | |
| 229 | |
| 230 case 3: | |
| 231 if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBufferWrite, 5, 2000) == HAL_OK) | |
| 232 { | |
| 233 strcpy(tD_communication[4],aTxBufferWrite); | |
| 234 } | |
| 235 else | |
| 236 { | |
| 237 strcpy(tD_communication[4],"Error."); | |
| 238 } | |
| 239 | |
| 240 if(HAL_UART_Receive(&UartHandle, (uint8_t*)aRxBuffer, 5+6, 2000) == HAL_OK) | |
| 241 { | |
| 242 aRxBuffer[5+6] = 0; | |
| 243 tDebug_helper_replaceCRLF(aRxBuffer, 5+6); | |
| 244 strcpy(tD_communication[5],aRxBuffer); | |
| 245 } | |
| 246 else | |
| 247 { | |
| 248 strcpy(tD_communication[5],"Error."); | |
| 249 } | |
| 250 break; | |
| 251 | |
| 252 default: | |
| 253 tD_status = 0; | |
| 254 break; | |
| 255 } | |
| 256 } | |
| 257 | |
| 258 | |
| 259 | |
| 260 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/ | |
| 261 |
