Mercurial > public > ostc4
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 1034:195bfbdf961d | 1035:5b913cdaa9dc |
|---|---|
| 33 #include "tHome.h" | 33 #include "tHome.h" |
| 34 #include "tInfo.h" | 34 #include "tInfo.h" |
| 35 #include "tInfoLogger.h" | 35 #include "tInfoLogger.h" |
| 36 #include "tMenuEdit.h" | 36 #include "tMenuEdit.h" |
| 37 #include "data_exchange_main.h" | 37 #include "data_exchange_main.h" |
| 38 #include "t7.h"" | |
| 38 | 39 |
| 39 #include <string.h> | 40 #include <string.h> |
| 40 #include <inttypes.h> | 41 #include <inttypes.h> |
| 41 | 42 |
| 42 | 43 |
| 52 /* Exported functions --------------------------------------------------------*/ | 53 /* Exported functions --------------------------------------------------------*/ |
| 53 | 54 |
| 54 | 55 |
| 55 void InfoLogger_writeLine(uint8_t* pLine,uint8_t lineLength,uint8_t direction) | 56 void InfoLogger_writeLine(uint8_t* pLine,uint8_t lineLength,uint8_t direction) |
| 56 { | 57 { |
| 58 #ifdef ENABLE_LOGGER_WINDOW | |
| 57 uint8_t LogIndex = 0; | 59 uint8_t LogIndex = 0; |
| 58 | 60 |
| 59 if(lineLength <= MAX_CHAR_PER_LINE) | 61 if(!t7_customview_disabled(CVIEW_Logger)) |
| 60 { | 62 { |
| 61 memset(&lines[lineWriteIndex][0],0, (MAX_CHAR_PER_LINE + LINE_HEADER_BYTES)); | 63 if(lineLength <= MAX_CHAR_PER_LINE) |
| 62 if(direction == LOG_TX_LINE) | |
| 63 { | 64 { |
| 64 lines[lineWriteIndex][LogIndex] = '\002'; /* align right */ | 65 memset(&lines[lineWriteIndex][0],0, (MAX_CHAR_PER_LINE + LINE_HEADER_BYTES)); |
| 65 LogIndex++; | 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++; | |
| 66 } | 78 } |
| 67 memcpy(&lines[lineWriteIndex][LogIndex],pLine,lineLength); | |
| 68 lineWriteIndex++; | |
| 69 if(lineWriteIndex == MAX_LOGGER_LINES) | |
| 70 { | |
| 71 lineWriteIndex = 0; | |
| 72 } | |
| 73 receivedLinesCount++; | |
| 74 } | 79 } |
| 80 #endif | |
| 75 } | 81 } |
| 76 | 82 |
| 77 uint8_t InfoLogger_isUpdated() | 83 uint8_t InfoLogger_isUpdated() |
| 78 { | 84 { |
| 79 uint8_t ret = 0; | 85 uint8_t ret = 0; |
| 88 { | 94 { |
| 89 previousGlobalState = get_globalState(); | 95 previousGlobalState = get_globalState(); |
| 90 set_globalState(StILOGGER); | 96 set_globalState(StILOGGER); |
| 91 | 97 |
| 92 loggerUpdateTime = HAL_GetTick(); | 98 loggerUpdateTime = HAL_GetTick(); |
| 93 | |
| 94 // lineWriteIndex = 0; | |
| 95 // receivedLinesCount = 0; | |
| 96 // memset(lines,0,sizeof(lines)); | |
| 97 } | 99 } |
| 98 | 100 |
| 99 void refreshInfo_Logger(GFX_DrawCfgScreen s) | 101 void refreshInfo_Logger(GFX_DrawCfgScreen s) |
| 100 { | 102 { |
| 101 uint8_t index = 0; | 103 uint8_t index = 0; |
| 102 char text[31]; | 104 char text[31]; |
| 103 uint8_t displayLine = 0; | 105 uint8_t displayLine = 0; |
| 104 uint8_t color = CLUT_Font020; | 106 uint8_t color = CLUT_Font020; |
| 105 | 107 |
| 106 text[0] = '\001'; | 108 sprintf(text,"\001%c%c", TXT_2BYTE, TXT2BYTE_Logger); |
| 107 text[1] = TXT_PreDive; | |
| 108 text[2] = 0; | |
| 109 | 109 |
| 110 tInfo_write_content_simple( 30, 770, ME_Y_LINE_BASE, &FontT48, text, CLUT_MenuPageHardware); | 110 tInfo_write_content_simple( 30, 770, ME_Y_LINE_BASE, &FontT48, text, CLUT_InfoSurface); |
| 111 | 111 |
| 112 | 112 |
| 113 if(InfoLogger_isUpdated()) | 113 if(InfoLogger_isUpdated()) |
| 114 { | 114 { |
| 115 loggerUpdateTime = HAL_GetTick(); | 115 loggerUpdateTime = HAL_GetTick(); |
| 152 lineReadIndex = 0; | 152 lineReadIndex = 0; |
| 153 } | 153 } |
| 154 } | 154 } |
| 155 index++; | 155 index++; |
| 156 } | 156 } |
| 157 if((time_elapsed_ms(loggerUpdateTime, HAL_GetTick()) > 20000)) | 157 if((time_elapsed_ms(loggerUpdateTime, HAL_GetTick()) > 10000)) |
| 158 { | 158 { |
| 159 set_globalState(previousGlobalState); /* restore state which was active before log data was received */ | 159 set_globalState(previousGlobalState); /* restore state which was active before log data was received */ |
| 160 exitInfo(); | |
| 160 } | 161 } |
| 161 } | 162 } |
| 162 | 163 |
| 163 void sendActionToInfoLogger(uint8_t sendAction) | 164 void sendActionToInfoLogger(uint8_t sendAction) |
| 164 { | 165 { |
| 165 switch(sendAction) | 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 */ |
| 166 { | 167 set_globalState(previousGlobalState); /* restore state which was active before log data was received */ |
| 167 case ACTION_BUTTON_BACK: | 168 exitInfoSilent(); |
| 168 // exitInfo(); | |
| 169 exitMenuEdit_to_Menu_with_Menu_Update(); | |
| 170 break; | |
| 171 | |
| 172 case ACTION_BUTTON_ENTER: | |
| 173 break; | |
| 174 case ACTION_BUTTON_NEXT: | |
| 175 break; | |
| 176 case ACTION_TIMEOUT: | |
| 177 case ACTION_MODE_CHANGE: | |
| 178 case ACTION_IDLE_TICK: | |
| 179 case ACTION_IDLE_SECOND: | |
| 180 default: | |
| 181 break; | |
| 182 } | |
| 183 } | 169 } |
| 184 | 170 |
