diff Discovery/Src/t7.c @ 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 c880907fd1d7
children d784f281833a
line wrap: on
line diff
--- 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;