changeset 537:0ad0b26ec56b

Added center / right alignment option to custom text display: Per default custom text was shown left aligned. Using '^' for center and '?' for right alignment the display of the custom text may now be improved. For proper operation the alignment had to be set to common handling mode and the blank characters had to be removed from the transmitted string. To avoid display of special strings (e.g. multilanguage) the write text via com interface will now block special characters
author Ideenmodellierer
date Wed, 07 Oct 2020 18:07:10 +0200
parents 54c5ec8416c4
children b1eee27cd02b
files Discovery/Src/gfx_engine.c Discovery/Src/t7.c Discovery/Src/tComm.c
diffstat 3 files changed, 34 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/Discovery/Src/gfx_engine.c	Wed Oct 07 17:15:27 2020 +0200
+++ b/Discovery/Src/gfx_engine.c	Wed Oct 07 18:07:10 2020 +0200
@@ -2033,10 +2033,10 @@
 			if(*pText == '\r') // carriage return, no newline
 				settings.Xdelta = 0;
 			else
-			if((*pText == '\001') && !minimal) // center
+			if((*pText == '\001')) // center
 				settings.Xdelta = GFX_write__Modify_Xdelta__Centered(&settings, hgfx, pText+1);
 			else
-			if((*pText == '\002') && !minimal) // right
+			if((*pText == '\002')) // right
 				settings.Xdelta = GFX_write__Modify_Xdelta__RightAlign(&settings, hgfx, pText+1);
 			else
 			if((*pText == '\003') && !minimal) // doubleSize
@@ -2986,7 +2986,7 @@
 	
 	pText = (uint32_t)pTextInput;
 	counter = 0;
-	while((counter < 100) && (*(char*)pText != 0) && (*(char*)pText != '\r'))
+	while((counter < 100) && (*(char*)pText != 0) && (*(char*)pText != '\r') && (*(char*)pText != '\n'))
 	{
 		if((*(char*)pText) == TXT_2BYTE)
 		{
--- a/Discovery/Src/t7.c	Wed Oct 07 17:15:27 2020 +0200
+++ b/Discovery/Src/t7.c	Wed Oct 07 18:07:10 2020 +0200
@@ -2762,12 +2762,34 @@
         do
         {
             nextChar = settingsGetPointer()->customtext[i+j];
-            i++;
-            if((!nextChar) || (nextChar =='\n')  || (nextChar =='\r'))
-                break;
-            text[textptr++] = nextChar;
+         	if(nextChar == '^')		/* center */
+           	{
+           		text[textptr++] = '\001';
+           		i++;
+           	}else
+           	if(nextChar == 180)		/* '´' => Right */
+           	{
+           		text[textptr++] = '\002';
+           		i++;
+           	}else
+           	{
+           		i++;
+           		if((!nextChar) || (nextChar =='\n')  || (nextChar =='\r'))
+           		{
+           			break;
+           		}
+           		text[textptr++] = nextChar;
+           	}
         } while (i < 12);
 
+        if(i == 12)		/* exit by limit => check for blanks at the end of the string */
+        {
+        	while((textptr - 1 > 0) && (text[textptr - 1] == 32))
+			{
+				textptr--;
+			}
+        }
+
         if(!nextChar)
             break;
 
--- a/Discovery/Src/tComm.c	Wed Oct 07 17:15:27 2020 +0200
+++ b/Discovery/Src/tComm.c	Wed Oct 07 18:07:10 2020 +0200
@@ -240,6 +240,8 @@
 
 void tComm_refresh(void)
 {
+	char localString[255];
+
     if(tCscreen.FBStartAdress == 0)
     {
         GFX_hwBackgroundOn();
@@ -258,11 +260,13 @@
     else if(display_text[255])
     {
         display_text[(uint8_t)display_text[255]] = 0;
+        localString[0] = TXT_MINIMAL;
+        strcpy (&localString[1],display_text);
         releaseFrame(18,tCscreen.FBStartAdress);
         tCscreen.FBStartAdress = getFrame(18);
         write_content_simple(&tCscreen, 0, 800, 480-24, &FontT24,"Exit",CLUT_ButtonSurfaceScreen);
         write_content_simple(&tCscreen, 800 - 70, 800, 480-24, &FontT24,"Signal",CLUT_ButtonSurfaceScreen);
-        GFX_write_string(&FontT48, &tCwindow, display_text,2);
+        GFX_write_string(&FontT48, &tCwindow, localString,2);
         GFX_SetFrameTop(tCscreen.FBStartAdress);
         display_text[0] = 0;
         display_text[255] = 0;