changeset 1031:cd4561c33758 Puls_Integration

New Logger View: The logger view allows developers to display development messages on the screen. This is done by rerouting the refresh function to the logger view. The view is opened when a new string is received and is closing after a certain time while no new message was entered. For better communication protocol visualization it is possible to mark a scring as received or transmitted. The strind will then be displayed left / right aligned
author Ideenmodellierer
date Mon, 28 Jul 2025 18:32:23 +0200
parents d492d4b165fb
children 33b91584d827
files Discovery/Inc/tInfoLogger.h Discovery/Src/tInfo.c Discovery/Src/tInfoLogger.c
diffstat 3 files changed, 230 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Discovery/Inc/tInfoLogger.h	Mon Jul 28 18:32:23 2025 +0200
@@ -0,0 +1,45 @@
+///////////////////////////////////////////////////////////////////////////////
+/// -*- coding: UTF-8 -*-
+///
+/// \file   Discovery/Inc/tInfoSensor.h
+/// \brief  Infopage content for visualisation of UART protocol flow
+/// \author heinrichs weikamp gmbh
+/// \date   17-07-2025
+///
+/// $Id$
+///////////////////////////////////////////////////////////////////////////////
+/// \par Copyright (c) 2014-2025 Heinrichs Weikamp gmbh
+///
+///     This program is free software: you can redistribute it and/or modify
+///     it under the terms of the GNU General Public License as published by
+///     the Free Software Foundation, either version 3 of the License, or
+///     (at your option) any later version.
+///
+///     This program is distributed in the hope that it will be useful,
+///     but WITHOUT ANY WARRANTY; without even the implied warranty of
+///     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+///     GNU General Public License for more details.
+///
+///     You should have received a copy of the GNU General Public License
+///     along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//////////////////////////////////////////////////////////////////////////////
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef TINFO_LOGGER_H
+#define TINFO_LOGGER_H
+
+#define LINE_HEADER_BYTES (3u)
+#define MAX_CHAR_PER_LINE (50u)
+#define MAX_LOGGER_LINES	(12u)
+
+#define LOG_TX_LINE	(0u)
+#define LOG_RX_LINE (1u)
+
+/* Exported functions --------------------------------------------------------*/
+void openInfo_Logger();
+void refreshInfo_Logger(GFX_DrawCfgScreen s);
+void sendActionToInfoLogger(uint8_t sendAction);
+void InfoLogger_writeLine(uint8_t* pLine,uint8_t lineLength,uint8_t direction);
+uint8_t InfoLogger_isUpdated();
+
+#endif /* TINFO_LOGGER_H */
--- a/Discovery/Src/tInfo.c	Thu Jul 03 14:37:54 2025 +0200
+++ b/Discovery/Src/tInfo.c	Mon Jul 28 18:32:23 2025 +0200
@@ -38,6 +38,7 @@
 #include "tInfoCompass.h"
 #include "tInfoSensor.h"
 #include "tInfoPreDive.h"
+#include "tInfoLogger.h"
 #include "tMenu.h"
 #include "tMenuEdit.h"
 
@@ -227,6 +228,10 @@
     							infoColor = CLUT_MenuPageGasCC;
     							refreshInfo_PreDive(tIscreen);
     				break;
+    		case StILOGGER: 	tIscreen.FBStartAdress = getFrame(14);
+    							infoColor = CLUT_MenuPageCvOption;
+    							refreshInfo_Logger(tIscreen);
+    				break;
 
     		default:
     				break;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Discovery/Src/tInfoLogger.c	Mon Jul 28 18:32:23 2025 +0200
@@ -0,0 +1,180 @@
+///////////////////////////////////////////////////////////////////////////////
+/// -*- coding: UTF-8 -*-
+///
+/// \file   Discovery/Src/tInfoLogger.c
+/// \brief  Show data which is received / send through UART interface
+/// \author heinrichs weikamp gmbh
+/// \date   23-Feb-2015
+///
+/// \details
+///
+/// $Id$
+///////////////////////////////////////////////////////////////////////////////
+/// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh
+///
+///     This program is free software: you can redistribute it and/or modify
+///     it under the terms of the GNU General Public License as published by
+///     the Free Software Foundation, either version 3 of the License, or
+///     (at your option) any later version.
+///
+///     This program is distributed in the hope that it will be useful,
+///     but WITHOUT ANY WARRANTY; without even the implied warranty of
+///     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+///     GNU General Public License for more details.
+///
+///     You should have received a copy of the GNU General Public License
+///     along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//////////////////////////////////////////////////////////////////////////////
+
+/* Includes ------------------------------------------------------------------*/
+
+#include "gfx_engine.h"
+#include "gfx_fonts.h"
+#include "tHome.h"
+#include "tInfo.h"
+#include "tInfoLogger.h"
+#include "tMenuEdit.h"
+#include "data_exchange_main.h"
+
+#include <string.h>
+#include <inttypes.h>
+
+
+/* Private variables ---------------------------------------------------------*/
+static uint8_t lines[MAX_LOGGER_LINES][MAX_CHAR_PER_LINE + LINE_HEADER_BYTES];
+static uint8_t lineWriteIndex = 0;
+static uint8_t lineReadIndex = 0;
+static uint32_t receivedLinesCount = 0;
+
+static uint32_t loggerUpdateTime = 0;
+static uint32_t previousGlobalState = 0;
+
+/* Exported functions --------------------------------------------------------*/
+
+
+void InfoLogger_writeLine(uint8_t* pLine,uint8_t lineLength,uint8_t direction)
+{
+	uint8_t LogIndex = 0;
+
+	if(lineLength <= MAX_CHAR_PER_LINE)
+	{
+		if(direction == LOG_TX_LINE)
+		{
+			lines[lineWriteIndex][LogIndex] = '\002';	/* align right */
+			LogIndex++;
+		}
+		memcpy(&lines[lineWriteIndex][LogIndex],pLine,lineLength);
+		lines[lineWriteIndex][LogIndex + lineLength] = 0;	/* make sure string is zero terminated */
+		lineWriteIndex++;
+		if(lineWriteIndex == MAX_LOGGER_LINES)
+		{
+			lineWriteIndex = 0;
+		}
+		receivedLinesCount++;
+	}
+}
+
+uint8_t InfoLogger_isUpdated()
+{
+	uint8_t ret = 0;
+	if(lineReadIndex != lineWriteIndex)
+	{
+		ret = 1;
+	}
+	return ret;
+}
+
+void openInfo_Logger()
+{
+	previousGlobalState = get_globalState();
+	set_globalState(StILOGGER);
+
+	loggerUpdateTime = HAL_GetTick();
+
+ //   lineWriteIndex = 0;
+ //   receivedLinesCount = 0;
+ //   memset(lines,0,sizeof(lines));
+}
+
+extern void refresh_Heartbeat(void);
+void refreshInfo_Logger(GFX_DrawCfgScreen s)
+{
+	uint8_t index = 0;
+    char text[31];
+    uint8_t displayLine = 0;
+    uint8_t color = CLUT_Font020;
+
+    text[0] = '\001';
+	text[1] = TXT_PreDive;
+	text[2] = 0;
+
+	tInfo_write_content_simple(  30, 770, ME_Y_LINE_BASE, &FontT48, text, CLUT_MenuPageHardware);
+
+
+	if(InfoLogger_isUpdated())
+	{
+		loggerUpdateTime = HAL_GetTick();
+	}
+	if(receivedLinesCount > MAX_LOGGER_LINES)
+	{
+		displayLine = MAX_LOGGER_LINES-1;
+	}
+	else
+	{
+		displayLine = lineWriteIndex;
+	}
+
+	while (index < displayLine)
+	{
+		color = CLUT_Font020;
+		if(lines[index][0] == '\002')
+		{
+			color = CLUT_Font021;
+		}
+		if(lineReadIndex == lineWriteIndex)
+		{
+			color = CLUT_Font022;
+		}
+		tInfo_write_content_simple(  30, 770, 50 + (index * 30), &FontT24, (char*)lines[index], color);
+
+		if(lineReadIndex != lineWriteIndex)			/* needed for isUpdated function */
+		{
+			lineReadIndex++;
+			if(lineReadIndex == MAX_LOGGER_LINES)
+			{
+				lineReadIndex = 0;
+			}
+		}
+		index++;
+	}
+
+
+	if((time_elapsed_ms(loggerUpdateTime, HAL_GetTick()) > 20000))
+	{
+		set_globalState(previousGlobalState); /* restore state which was active before log data was received */
+	}
+	refresh_Heartbeat();
+}
+
+void sendActionToInfoLogger(uint8_t sendAction)
+{
+    switch(sendAction)
+    {
+    	case ACTION_BUTTON_BACK:
+    	//	exitInfo();
+    		exitMenuEdit_to_Menu_with_Menu_Update();
+    			break;
+
+    	case ACTION_BUTTON_ENTER:
+    		break;
+		case ACTION_BUTTON_NEXT:
+			break;
+		case ACTION_TIMEOUT:
+		case ACTION_MODE_CHANGE:
+	    case ACTION_IDLE_TICK:
+	    case ACTION_IDLE_SECOND:
+		default:
+	        break;
+    }
+}
+