|
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 {
|
|
|
61 if(direction == LOG_TX_LINE)
|
|
|
62 {
|
|
|
63 lines[lineWriteIndex][LogIndex] = '\002'; /* align right */
|
|
|
64 LogIndex++;
|
|
|
65 }
|
|
|
66 memcpy(&lines[lineWriteIndex][LogIndex],pLine,lineLength);
|
|
|
67 lines[lineWriteIndex][LogIndex + lineLength] = 0; /* make sure string is zero terminated */
|
|
|
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
|
|
|
127 while (index < displayLine)
|
|
|
128 {
|
|
|
129 color = CLUT_Font020;
|
|
|
130 if(lines[index][0] == '\002')
|
|
|
131 {
|
|
|
132 color = CLUT_Font021;
|
|
|
133 }
|
|
|
134 if(lineReadIndex == lineWriteIndex)
|
|
|
135 {
|
|
|
136 color = CLUT_Font022;
|
|
|
137 }
|
|
|
138 tInfo_write_content_simple( 30, 770, 50 + (index * 30), &FontT24, (char*)lines[index], color);
|
|
|
139
|
|
|
140 if(lineReadIndex != lineWriteIndex) /* needed for isUpdated function */
|
|
|
141 {
|
|
|
142 lineReadIndex++;
|
|
|
143 if(lineReadIndex == MAX_LOGGER_LINES)
|
|
|
144 {
|
|
|
145 lineReadIndex = 0;
|
|
|
146 }
|
|
|
147 }
|
|
|
148 index++;
|
|
|
149 }
|
|
|
150
|
|
|
151
|
|
|
152 if((time_elapsed_ms(loggerUpdateTime, HAL_GetTick()) > 20000))
|
|
|
153 {
|
|
|
154 set_globalState(previousGlobalState); /* restore state which was active before log data was received */
|
|
|
155 }
|
|
|
156 refresh_Heartbeat();
|
|
|
157 }
|
|
|
158
|
|
|
159 void sendActionToInfoLogger(uint8_t sendAction)
|
|
|
160 {
|
|
|
161 switch(sendAction)
|
|
|
162 {
|
|
|
163 case ACTION_BUTTON_BACK:
|
|
|
164 // exitInfo();
|
|
|
165 exitMenuEdit_to_Menu_with_Menu_Update();
|
|
|
166 break;
|
|
|
167
|
|
|
168 case ACTION_BUTTON_ENTER:
|
|
|
169 break;
|
|
|
170 case ACTION_BUTTON_NEXT:
|
|
|
171 break;
|
|
|
172 case ACTION_TIMEOUT:
|
|
|
173 case ACTION_MODE_CHANGE:
|
|
|
174 case ACTION_IDLE_TICK:
|
|
|
175 case ACTION_IDLE_SECOND:
|
|
|
176 default:
|
|
|
177 break;
|
|
|
178 }
|
|
|
179 }
|
|
|
180
|