Mercurial > public > ostc4
annotate Discovery/Src/tInfoLogger.c @ 1034:195bfbdf961d Puls_Integration
Pulse measurement integration:
Added function to parse standart GATT pulse service. Added compile switch to remove code from non dev builds.
| author | Ideenmodellierer |
|---|---|
| date | Thu, 07 Aug 2025 20:18:52 +0200 |
| parents | 5f66e44d69f0 |
| children | 5b913cdaa9dc |
| 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 void refreshInfo_Logger(GFX_DrawCfgScreen s) | |
| 100 { | |
| 101 uint8_t index = 0; | |
| 102 char text[31]; | |
| 103 uint8_t displayLine = 0; | |
| 104 uint8_t color = CLUT_Font020; | |
| 105 | |
| 106 text[0] = '\001'; | |
| 107 text[1] = TXT_PreDive; | |
| 108 text[2] = 0; | |
| 109 | |
| 110 tInfo_write_content_simple( 30, 770, ME_Y_LINE_BASE, &FontT48, text, CLUT_MenuPageHardware); | |
| 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 } | |
| 157 if((time_elapsed_ms(loggerUpdateTime, HAL_GetTick()) > 20000)) | |
| 158 { | |
| 159 set_globalState(previousGlobalState); /* restore state which was active before log data was received */ | |
| 160 } | |
| 161 } | |
| 162 | |
| 163 void sendActionToInfoLogger(uint8_t sendAction) | |
| 164 { | |
| 165 switch(sendAction) | |
| 166 { | |
| 167 case ACTION_BUTTON_BACK: | |
| 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 } | |
| 184 |
