Mercurial > public > ostc4
comparison Discovery/Src/tInfoLogger.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 | 5865f0aeb438 |
| children |
comparison
equal
deleted
inserted
replaced
| 1029:e938901f6386 | 1037:2af07aa38531 |
|---|---|
| 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" | |
| 38 #include "t7.h" | |
| 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 { | |
| 58 #ifdef ENABLE_LOGGER_WINDOW | |
| 59 uint8_t LogIndex = 0; | |
| 60 | |
| 61 if(!t7_customview_disabled(CVIEW_Logger)) | |
| 62 { | |
| 63 if(lineLength <= MAX_CHAR_PER_LINE) | |
| 64 { | |
| 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++; | |
| 78 } | |
| 79 } | |
| 80 #endif | |
| 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 | |
| 108 sprintf(text,"\001%c%c", TXT_2BYTE, TXT2BYTE_Logger); | |
| 109 | |
| 110 tInfo_write_content_simple( 30, 770, ME_Y_LINE_BASE, &FontT48, text, CLUT_InfoSurface); | |
| 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 | |
| 126 if(lineReadIndex != lineWriteIndex) /* needed for isUpdated function */ | |
| 127 { | |
| 128 lineReadIndex++; | |
| 129 if(lineReadIndex == MAX_LOGGER_LINES) | |
| 130 { | |
| 131 lineReadIndex = 0; | |
| 132 } | |
| 133 } | |
| 134 while (index < displayLine) | |
| 135 { | |
| 136 color = CLUT_Font020; | |
| 137 if(lines[index][0] == '\002') | |
| 138 { | |
| 139 color = CLUT_NiceGreen; | |
| 140 } | |
| 141 if(lineReadIndex == index) | |
| 142 { | |
| 143 color = CLUT_NiceBlue; | |
| 144 } | |
| 145 tInfo_write_content_simple( 30, 770, 60 + (index * 30), &FontT24, (char*)lines[index], color); | |
| 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 } | |
| 157 if((time_elapsed_ms(loggerUpdateTime, HAL_GetTick()) > 10000)) | |
| 158 { | |
| 159 set_globalState(previousGlobalState); /* restore state which was active before log data was received */ | |
| 160 exitInfo(); | |
| 161 } | |
| 162 } | |
| 163 | |
| 164 void sendActionToInfoLogger(uint8_t sendAction) | |
| 165 { | |
| 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(); | |
| 169 } | |
| 170 |
