Page 1 of 1

Updating Button Text And Colour

Posted: Wed Jul 03, 2019 2:03 pm
by Andrew
Hello,

Thanks for taking the time to read my dismal plea for help.

I am wanting to have a button change color and text once pressed.

Here's my code:

Ft_Gpu_CoCmd_FgColor(phost,0xB5B5B5);
Ft_App_WrCoCmd_Buffer(phost,TAG_MASK(1));
Ft_App_WrCoCmd_Buffer(phost,TAG(1));
Ft_Gpu_CoCmd_Button(phost,11, 407, 175, 60, 31, 0, "DO IT!");
Ft_App_WrCoCmd_Buffer(phost,TAG_MASK(0));


Above this code at the start of my function:


while(1)
{
tag = Ft_Gpu_Hal_Rd8(phost,REG_TOUCH_TAG);

if(tag==1) // was do it pressed?
{
Ft_Gpu_CoCmd_Dlstart(phost);
Ft_App_WrCoCmd_Buffer(phost,CLEAR(1,1,1)); //Buffer Clear
Ft_Gpu_CoCmd_FgColor(phost,0xE5E5C5);

Ft_Gpu_CoCmd_Button(phost,11, 407, 175, 60, 31, 0, "GO BACK");
Ft_App_WrCoCmd_Buffer(phost,DISPLAY());
Ft_Gpu_CoCmd_Swap(phost);




What I want is:

When user presses Do It! The button color changes, the text changes and Do It! does something.
It could be anything.

Thanks for your help.

Re: Updating Button Text And Colour

Posted: Thu Jul 04, 2019 5:03 pm
by Daniel Divino
Hi Andrew,

Welcome to the forums!

Here's a piece of code that will change the state of the button when it's held down.

Code: Select all

	int tag = 0;
	while (1)
	{
		tag = Ft_Gpu_Hal_Rd8(phost, REG_TOUCH_TAG);
		Ft_Gpu_CoCmd_Dlstart(phost);
		Ft_App_WrCoCmd_Buffer(phost, CLEAR_COLOR_RGB(255, 255, 255));
		Ft_App_WrCoCmd_Buffer(phost, CLEAR(1, 1, 1));
		Ft_App_WrCoCmd_Buffer(phost, COLOR_RGB(0x80, 0x80, 0x00));

		switch (tag)
		{
		case 1:								
			Ft_Gpu_CoCmd_FgColor(phost, 0xE5E5C5);
			Ft_App_WrCoCmd_Buffer(phost, TAG(1));
			Ft_Gpu_CoCmd_Button(phost, 11, 407, 175, 60, 31, 0, "GO BACK");
			break;
		default:			
			Ft_Gpu_CoCmd_FgColor(phost, 0xB5B5B5);			
			Ft_App_WrCoCmd_Buffer(phost, TAG(1));
			Ft_Gpu_CoCmd_Button(phost, 11, 407, 175, 60, 31, 0, "DO IT!");			
			break;
		}
		Ft_App_WrCoCmd_Buffer(phost, DISPLAY());
		Ft_Gpu_CoCmd_Swap(phost);
		 //Download the commands into fifo 
		Ft_App_Flush_Co_Buffer(phost);

		//Wait till coprocessor completes the operation
		Ft_Gpu_Hal_WaitCmdfifo_empty(phost);			
	}
Give it a shot.

You'll have to manipulate the code a little bit in order for the button to act as a toggle instead of a momentary push button, but I suggest you try this code out first. Once you are familiar with how the code runs, you can make a few modifications and have the button act as a toggle instead.

Cheers,
Daniel

Re: Updating Button Text And Colour

Posted: Mon Jul 08, 2019 10:45 am
by Andrew
Thanks, I will give it a try.

Re: Updating Button Text And Colour

Posted: Mon Jul 08, 2019 10:49 am
by Andrew
The code does not work.

At this point, we will be dumping this
display.

Only one of the examples provided worked.
The support is dismal.

Your GTT solution sounds promising.


Thanks

Re: Updating Button Text And Colour

Posted: Mon Jul 08, 2019 12:13 pm
by Andrew
Hi Daniel, thanks for your time today.

The GTT display with software sounds like what we
have been looking for.

Thanks again for your time.
Regards
Andrew

Re: Updating Button Text And Colour

Posted: Mon Jul 08, 2019 4:00 pm
by Daniel Divino
Hi Andrew,

I'm sorry to hear that your experience with our EVE was not optimal. Understandably, the FT812/813, though very capable, has quite a steep learning curve.

I'm glad to hear that you would be willing to try out our GTT. Our GTT will be much easier to develop for, and I'm confident you'll find the experience to be much easier to learn and work with than the EVE series. As always, if you have any questions about the GTT, please let us know!

Cheers,
Daniel