Mercurial > public > ostc4
annotate Discovery/Src/tInfoLogger.c @ 1035:5b913cdaa9dc Puls_Integration
Degub message logger:
Added functionality to handle logger view (in case it is enabled via compile switch) like a normal t7 custom view.
| author | Ideenmodellierer |
|---|---|
| date | Sat, 09 Aug 2025 16:55:20 +0200 |
| parents | 195bfbdf961d |
| children | 5865f0aeb438 |
| rev | line source |
|---|---|
| 1031 | 1 /////////////////////////////////////////////////////////////////////////////// |
| 2 /// -*- coding: UTF-8 -*- | |
| 3 /// | |
| 4 /// \file Discovery/Src/tInfoLogger.c | |
| 5 /// \brief Show data which is received / send through UART interface | |
| 6 /// \author heinrichs weikamp gmbh | |
| 7 /// \date 23-Feb-2015 | |
| 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 | |
| 31 #include "gfx_engine.h" | |
| 32 #include "gfx_fonts.h" | |
| 33 #include "tHome.h" | |
| 34 #include "tInfo.h" | |
| 35 #include "tInfoLogger.h" | |
| 36 #include "tMenuEdit.h" | |
| 37 #include "data_exchange_main.h" | |
| 1035 | 38 #include "t7.h"" |
| 1031 | 39 |
| 40 #include <string.h> | |
| 41 #include <inttypes.h> | |
| 42 | |
| 43 | |
| 44 /* Private variables ---------------------------------------------------------*/ | |
| 45 static uint8_t lines[MAX_LOGGER_LINES][MAX_CHAR_PER_LINE + LINE_HEADER_BYTES]; | |
| 46 static uint8_t lineWriteIndex = 0; | |
| 47 static uint8_t lineReadIndex = 0; | |
| 48 static uint32_t receivedLinesCount = 0; | |
| 49 | |
| 50 static uint32_t loggerUpdateTime = 0; | |
| 51 static uint32_t previousGlobalState = 0; | |
| 52 | |
| 53 /* Exported functions --------------------------------------------------------*/ | |
| 54 | |
| 55 | |
| 56 void InfoLogger_writeLine(uint8_t* pLine,uint8_t lineLength,uint8_t direction) | |
| 57 { | |
| 1035 | 58 #ifdef ENABLE_LOGGER_WINDOW |
| 1031 | 59 uint8_t LogIndex = 0; |
| 60 | |
| 1035 | 61 if(!t7_customview_disabled(CVIEW_Logger)) |
| 1031 | 62 { |
| 1035 | 63 if(lineLength <= MAX_CHAR_PER_LINE) |
| 1031 | 64 { |
| 1035 | 65 memset(&lines[lineWriteIndex][0],0, (MAX_CHAR_PER_LINE + LINE_HEADER_BYTES)); |
| 66 if(direction == LOG_TX_LINE) | |
| 67 { | |
| 68 lines[lineWriteIndex][LogIndex] = '\002'; /* align right */ | |
| 69 LogIndex++; | |
| 70 } | |
| 71 memcpy(&lines[lineWriteIndex][LogIndex],pLine,lineLength); | |
| 72 lineWriteIndex++; | |
| 73 if(lineWriteIndex == MAX_LOGGER_LINES) | |
| 74 { | |
| 75 lineWriteIndex = 0; | |
| 76 } | |
| 77 receivedLinesCount++; | |
| 1031 | 78 } |
| 79 } | |
| 1035 | 80 #endif |
| 1031 | 81 } |
| 82 | |
| 83 uint8_t InfoLogger_isUpdated() | |
| 84 { | |
| 85 uint8_t ret = 0; | |
| 86 if(lineReadIndex != lineWriteIndex) | |
| 87 { | |
| 88 ret = 1; | |
| 89 } | |
| 90 return ret; | |
| 91 } | |
| 92 | |
| 93 void openInfo_Logger() | |
| 94 { | |
| 95 previousGlobalState = get_globalState(); | |
| 96 set_globalState(StILOGGER); | |
| 97 | |
| 98 loggerUpdateTime = HAL_GetTick(); | |
| 99 } | |
| 100 | |
| 101 void refreshInfo_Logger(GFX_DrawCfgScreen s) | |
| 102 { | |
| 103 uint8_t index = 0; | |
| 104 char text[31]; | |
| 105 uint8_t displayLine = 0; | |
| 106 uint8_t color = CLUT_Font020; | |
| 107 | |
| 1035 | 108 sprintf(text,"\001%c%c", TXT_2BYTE, TXT2BYTE_Logger); |
| 1031 | 109 |
| 1035 | 110 tInfo_write_content_simple( 30, 770, ME_Y_LINE_BASE, &FontT48, text, CLUT_InfoSurface); |
| 1031 | 111 |
| 112 | |
| 113 if(InfoLogger_isUpdated()) | |
| 114 { | |
| 115 loggerUpdateTime = HAL_GetTick(); | |
| 116 } | |
| 117 if(receivedLinesCount > MAX_LOGGER_LINES) | |
| 118 { | |
| 119 displayLine = MAX_LOGGER_LINES-1; | |
| 120 } | |
| 121 else | |
| 122 { | |
| 123 displayLine = lineWriteIndex; | |
| 124 } | |
| 125 | |
|
1033
5f66e44d69f0
Added functionality needed for subscription of standard Bluetooth pulse service notifications
Ideenmodellierer
parents:
1031
diff
changeset
|
126 if(lineReadIndex != lineWriteIndex) /* needed for isUpdated function */ |
|
5f66e44d69f0
Added functionality needed for subscription of standard Bluetooth pulse service notifications
Ideenmodellierer
parents:
1031
diff
changeset
|
127 { |
|
5f66e44d69f0
Added functionality needed for subscription of standard Bluetooth pulse service notifications
Ideenmodellierer
parents:
1031
diff
changeset
|
128 lineReadIndex++; |
|
5f66e44d69f0
Added functionality needed for subscription of standard Bluetooth pulse service notifications
Ideenmodellierer
parents:
1031
diff
changeset
|
129 if(lineReadIndex == MAX_LOGGER_LINES) |
|
5f66e44d69f0
Added functionality needed for subscription of standard Bluetooth pulse service notifications
Ideenmodellierer
parents:
1031
diff
changeset
|
130 { |
|
5f66e44d69f0
Added functionality needed for subscription of standard Bluetooth pulse service notifications
Ideenmodellierer
parents:
1031
diff
changeset
|
131 lineReadIndex = 0; |
|
5f66e44d69f0
Added functionality needed for subscription of standard Bluetooth pulse service notifications
Ideenmodellierer
parents:
1031
diff
changeset
|
132 } |
|
5f66e44d69f0
Added functionality needed for subscription of standard Bluetooth pulse service notifications
Ideenmodellierer
parents:
1031
diff
changeset
|
133 } |
| 1031 | 134 while (index < displayLine) |
| 135 { | |
| 136 color = CLUT_Font020; | |
| 137 if(lines[index][0] == '\002') | |
| 138 { | |
|
1033
5f66e44d69f0
Added functionality needed for subscription of standard Bluetooth pulse service notifications
Ideenmodellierer
parents:
1031
diff
changeset
|
139 color = CLUT_NiceGreen; |
| 1031 | 140 } |
|
1033
5f66e44d69f0
Added functionality needed for subscription of standard Bluetooth pulse service notifications
Ideenmodellierer
parents:
1031
diff
changeset
|
141 if(lineReadIndex == index) |
| 1031 | 142 { |
|
1033
5f66e44d69f0
Added functionality needed for subscription of standard Bluetooth pulse service notifications
Ideenmodellierer
parents:
1031
diff
changeset
|
143 color = CLUT_NiceBlue; |
| 1031 | 144 } |
|
1033
5f66e44d69f0
Added functionality needed for subscription of standard Bluetooth pulse service notifications
Ideenmodellierer
parents:
1031
diff
changeset
|
145 tInfo_write_content_simple( 30, 770, 60 + (index * 30), &FontT24, (char*)lines[index], color); |
| 1031 | 146 |
| 147 if(lineReadIndex != lineWriteIndex) /* needed for isUpdated function */ | |
| 148 { | |
| 149 lineReadIndex++; | |
| 150 if(lineReadIndex == MAX_LOGGER_LINES) | |
| 151 { | |
| 152 lineReadIndex = 0; | |
| 153 } | |
| 154 } | |
| 155 index++; | |
| 156 } | |
| 1035 | 157 if((time_elapsed_ms(loggerUpdateTime, HAL_GetTick()) > 10000)) |
| 1031 | 158 { |
| 159 set_globalState(previousGlobalState); /* restore state which was active before log data was received */ | |
| 1035 | 160 exitInfo(); |
| 1031 | 161 } |
| 162 } | |
| 163 | |
| 164 void sendActionToInfoLogger(uint8_t sendAction) | |
| 165 { | |
| 1035 | 166 /* TODO: at the moment a generic return to home is used because the logger window could be opened from everywhere => implement context based return from view */ |
| 167 set_globalState(previousGlobalState); /* restore state which was active before log data was received */ | |
| 168 exitInfoSilent(); | |
| 1031 | 169 } |
| 170 |
