Mercurial > public > ostc4
annotate Discovery/Src/tInfoLogger.c @ 1033:5f66e44d69f0 Puls_Integration
Added functionality needed for subscription of standard Bluetooth pulse service notifications
| author | Ideenmodellierer |
|---|---|
| date | Sat, 02 Aug 2025 22:42:51 +0200 |
| parents | cd4561c33758 |
| children | 195bfbdf961d |
| 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" | |
| 38 | |
| 39 #include <string.h> | |
| 40 #include <inttypes.h> | |
| 41 | |
| 42 | |
| 43 /* Private variables ---------------------------------------------------------*/ | |
| 44 static uint8_t lines[MAX_LOGGER_LINES][MAX_CHAR_PER_LINE + LINE_HEADER_BYTES]; | |
| 45 static uint8_t lineWriteIndex = 0; | |
| 46 static uint8_t lineReadIndex = 0; | |
| 47 static uint32_t receivedLinesCount = 0; | |
| 48 | |
| 49 static uint32_t loggerUpdateTime = 0; | |
| 50 static uint32_t previousGlobalState = 0; | |
| 51 | |
| 52 /* Exported functions --------------------------------------------------------*/ | |
| 53 | |
| 54 | |
| 55 void InfoLogger_writeLine(uint8_t* pLine,uint8_t lineLength,uint8_t direction) | |
| 56 { | |
| 57 uint8_t LogIndex = 0; | |
| 58 | |
| 59 if(lineLength <= MAX_CHAR_PER_LINE) | |
| 60 { | |
|
1033
5f66e44d69f0
Added functionality needed for subscription of standard Bluetooth pulse service notifications
Ideenmodellierer
parents:
1031
diff
changeset
|
61 memset(&lines[lineWriteIndex][0],0, (MAX_CHAR_PER_LINE + LINE_HEADER_BYTES)); |
| 1031 | 62 if(direction == LOG_TX_LINE) |
| 63 { | |
| 64 lines[lineWriteIndex][LogIndex] = '\002'; /* align right */ | |
| 65 LogIndex++; | |
| 66 } | |
| 67 memcpy(&lines[lineWriteIndex][LogIndex],pLine,lineLength); | |
| 68 lineWriteIndex++; | |
| 69 if(lineWriteIndex == MAX_LOGGER_LINES) | |
| 70 { | |
| 71 lineWriteIndex = 0; | |
| 72 } | |
| 73 receivedLinesCount++; | |
| 74 } | |
| 75 } | |
| 76 | |
| 77 uint8_t InfoLogger_isUpdated() | |
| 78 { | |
| 79 uint8_t ret = 0; | |
| 80 if(lineReadIndex != lineWriteIndex) | |
| 81 { | |
| 82 ret = 1; | |
| 83 } | |
| 84 return ret; | |
| 85 } | |
| 86 | |
| 87 void openInfo_Logger() | |
| 88 { | |
| 89 previousGlobalState = get_globalState(); | |
| 90 set_globalState(StILOGGER); | |
| 91 | |
| 92 loggerUpdateTime = HAL_GetTick(); | |
| 93 | |
| 94 // lineWriteIndex = 0; | |
| 95 // receivedLinesCount = 0; | |
| 96 // memset(lines,0,sizeof(lines)); | |
| 97 } | |
| 98 | |
| 99 extern void refresh_Heartbeat(void); | |
| 100 void refreshInfo_Logger(GFX_DrawCfgScreen s) | |
| 101 { | |
| 102 uint8_t index = 0; | |
| 103 char text[31]; | |
| 104 uint8_t displayLine = 0; | |
| 105 uint8_t color = CLUT_Font020; | |
| 106 | |
| 107 text[0] = '\001'; | |
| 108 text[1] = TXT_PreDive; | |
| 109 text[2] = 0; | |
| 110 | |
| 111 tInfo_write_content_simple( 30, 770, ME_Y_LINE_BASE, &FontT48, text, CLUT_MenuPageHardware); | |
| 112 | |
| 113 | |
| 114 if(InfoLogger_isUpdated()) | |
| 115 { | |
| 116 loggerUpdateTime = HAL_GetTick(); | |
| 117 } | |
| 118 if(receivedLinesCount > MAX_LOGGER_LINES) | |
| 119 { | |
| 120 displayLine = MAX_LOGGER_LINES-1; | |
| 121 } | |
| 122 else | |
| 123 { | |
| 124 displayLine = lineWriteIndex; | |
| 125 } | |
| 126 | |
|
1033
5f66e44d69f0
Added functionality needed for subscription of standard Bluetooth pulse service notifications
Ideenmodellierer
parents:
1031
diff
changeset
|
127 if(lineReadIndex != lineWriteIndex) /* needed for isUpdated function */ |
|
5f66e44d69f0
Added functionality needed for subscription of standard Bluetooth pulse service notifications
Ideenmodellierer
parents:
1031
diff
changeset
|
128 { |
|
5f66e44d69f0
Added functionality needed for subscription of standard Bluetooth pulse service notifications
Ideenmodellierer
parents:
1031
diff
changeset
|
129 lineReadIndex++; |
|
5f66e44d69f0
Added functionality needed for subscription of standard Bluetooth pulse service notifications
Ideenmodellierer
parents:
1031
diff
changeset
|
130 if(lineReadIndex == MAX_LOGGER_LINES) |
|
5f66e44d69f0
Added functionality needed for subscription of standard Bluetooth pulse service notifications
Ideenmodellierer
parents:
1031
diff
changeset
|
131 { |
|
5f66e44d69f0
Added functionality needed for subscription of standard Bluetooth pulse service notifications
Ideenmodellierer
parents:
1031
diff
changeset
|
132 lineReadIndex = 0; |
|
5f66e44d69f0
Added functionality needed for subscription of standard Bluetooth pulse service notifications
Ideenmodellierer
parents:
1031
diff
changeset
|
133 } |
|
5f66e44d69f0
Added functionality needed for subscription of standard Bluetooth pulse service notifications
Ideenmodellierer
parents:
1031
diff
changeset
|
134 } |
| 1031 | 135 while (index < displayLine) |
| 136 { | |
| 137 color = CLUT_Font020; | |
| 138 if(lines[index][0] == '\002') | |
| 139 { | |
|
1033
5f66e44d69f0
Added functionality needed for subscription of standard Bluetooth pulse service notifications
Ideenmodellierer
parents:
1031
diff
changeset
|
140 color = CLUT_NiceGreen; |
| 1031 | 141 } |
|
1033
5f66e44d69f0
Added functionality needed for subscription of standard Bluetooth pulse service notifications
Ideenmodellierer
parents:
1031
diff
changeset
|
142 if(lineReadIndex == index) |
| 1031 | 143 { |
|
1033
5f66e44d69f0
Added functionality needed for subscription of standard Bluetooth pulse service notifications
Ideenmodellierer
parents:
1031
diff
changeset
|
144 color = CLUT_NiceBlue; |
| 1031 | 145 } |
|
1033
5f66e44d69f0
Added functionality needed for subscription of standard Bluetooth pulse service notifications
Ideenmodellierer
parents:
1031
diff
changeset
|
146 tInfo_write_content_simple( 30, 770, 60 + (index * 30), &FontT24, (char*)lines[index], color); |
| 1031 | 147 |
| 148 if(lineReadIndex != lineWriteIndex) /* needed for isUpdated function */ | |
| 149 { | |
| 150 lineReadIndex++; | |
| 151 if(lineReadIndex == MAX_LOGGER_LINES) | |
| 152 { | |
| 153 lineReadIndex = 0; | |
| 154 } | |
| 155 } | |
| 156 index++; | |
| 157 } | |
| 158 | |
| 159 | |
| 160 if((time_elapsed_ms(loggerUpdateTime, HAL_GetTick()) > 20000)) | |
| 161 { | |
| 162 set_globalState(previousGlobalState); /* restore state which was active before log data was received */ | |
| 163 } | |
| 164 refresh_Heartbeat(); | |
| 165 } | |
| 166 | |
| 167 void sendActionToInfoLogger(uint8_t sendAction) | |
| 168 { | |
| 169 switch(sendAction) | |
| 170 { | |
| 171 case ACTION_BUTTON_BACK: | |
| 172 // exitInfo(); | |
| 173 exitMenuEdit_to_Menu_with_Menu_Update(); | |
| 174 break; | |
| 175 | |
| 176 case ACTION_BUTTON_ENTER: | |
| 177 break; | |
| 178 case ACTION_BUTTON_NEXT: | |
| 179 break; | |
| 180 case ACTION_TIMEOUT: | |
| 181 case ACTION_MODE_CHANGE: | |
| 182 case ACTION_IDLE_TICK: | |
| 183 case ACTION_IDLE_SECOND: | |
| 184 default: | |
| 185 break; | |
| 186 } | |
| 187 } | |
| 188 |
