cancel
Showing results for 
Search instead for 
Did you mean: 

Weird causes with my touchgfx project

Thomas8607
Senior

Hi everybody!

I implemented a keyboard into my project. (I tested the keyboard widget in a separated project, and it worked well).

If I use the keyboard in my dashboard project, it make weird things.
If i entry a value, i write to the eeprom(M95320). If is restart the dashboard, i read all eeprom value.

On the "Beállítások 1" screen work perfect the keyboard and value entry. 
But on the "Beállítások 2" doesn't it work good. The end of the video you can see this.
Keyboard text area wrong and when(2:29) i entry a value to "Levegő tartály szorzó", then change the values some textarea to zero and "Emap nyomás szorzó" will be 5.0.

I don't know where to look for the error, but it's very strange that it doesn't always do it.
Here is the video:
Youtube video 

Thanks!

28 REPLIES 28

Can you show me your issue on a short video?

Already I have only one error, with keyboard only on two screens.

Keyboard Textarea ??? 

and on the other screen the letters

@GaetanGodart 
@MM..1 
I created an 3 pages project with my modificated keyboard.
The keyboard is working not normal, here is the same issue.

If i use one screen, the keyboard works well.

Thank you very much!

Hello @Thomas8607 ,

 

Yes, you can send me your drive link by private message.

You selected one of MM's message as best answer, did you solve the issue? It doesn't seems like you did.

You said that you have issue when using 2 or 3 screens but not when using 1 screen.
I think I already told you, but when using multiple screens, we usually use the MVP design to store values between screens. This could be the reason of your issue :
 - TouchGFX MVP guide 
 - TouchGFX MVP tutorial 

Your last video is not available on YouTube anymore.

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)

Hello @mncraftmod ,

 

Can you quickly explain your problem here?

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)

Hello Gaetan,

There were several mistakes in what I wrote in the very first message.
I entered a value with the keyboard and another value changed, and several values were reset to zero. This is resolved, I marked MM's answer for this.

Now there is only 1 bug, strange characters appearing on the keyboard display. This can also be seen in the simulator project in my last message(attached file: Key.rar). This error can also be seen in the simulator, only in the case of screen2 and screen 3. You can also see the bad contents of the buffer variable using Touchgfx print.

I can rewrite it using Touchgfx MVP, but will that fix the keyboard bug?

Thank you

GaetanGodart
ST Employee

Hello @Thomas8607 ,

 

Great that you solve your issue.

 

Regarding the unexpected characters, I found the issue.
When changing screen, the allocated memory space for the buffer was not empty so we have to reset it at initialization.
To do so I added a resetBuffer(); at the end of the initialization function (void containerNumKeyboard::initialize() ).
Also, I had to modify the reset function that was optimized to only reset the position that were not empty, but this time they are all non empty so I changed the line
for(int i = 1; i<=positionText; ++i) buffer[i] = '\0';
by
for(unsigned int i = 1; i<=sizeof(buffer); ++i) buffer[i] = '\0';

That solved the issue.

 

Also, I have found un unexpected behavior of your "0" key.
When trying to update the area 3, if pressing 0, I cannot press another key after, so I cannot, for instance, enter the number 806 or 1002 or 2024.

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)

I checked, so there is no waste in the buffer memory.

I checked what you write with zero errors. I reviewed the terms and conditions and rewrote them.

I'll test tomorrow to see if everything is off.

 

Thanks for the help!

I'm sorry that only one answer can be accepted, yours was also helpful.

Best regards, 

Tamas

Hello Gaetan,

 

It works well:

void containerNumKeyboard::functionWriteButtonCharacter(uint8_t value)
{
		if (positionText < 10) { // string length limit
            if(value == '.')
            {
                if((positionText < 0) || isDot )   // either already have a dot or is at first position
                {
                    return;                         // so it is wrong call to point character so don't do anything.
                }
            }
            if(value == '.')
            {
            	isDot = true;
            	isZero = false;
            	dotPositionSave = positionText;
            }
            if (value == '0' && isZero) {
                if ((!isNegative && positionText == 0) || (isNegative && positionText == 1)) {
                    return; // Zero again not allowed
                }
            }
            if(value == '0')		// First zero
            {
            	isZero = true;
            }
            if(isDot == false && ((positionText == 0) || positionText == 1))
            {
            	if((isZero && ((value == '1') || (value == '2') || (value == '3') || (value == '4') || (value == '5') || (value == '6') || (value == '7') || (value == '8') || (value == '9'))))
            	{
            		return;
            	}
            }
			positionText++;
			buffer[positionText] = value; 												// adds the character to the string char (buffer)
			Unicode::strncpy(textAreaKeyboardBuffer, buffer, TEXTAREAKEYBOARD_SIZE);	// assign the string to the Text
			textAreaKeyboard.resizeHeightToCurrentText();
			textAreaKeyboard.invalidate();
		}
		else
		{
			return;
		}
}

Hello @Thomas8607 ,

 

That is great to hear!

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)