cancel
Showing results for 
Search instead for 
Did you mean: 

Where is Code editor in TouchGFX also where is output window to know errors generated? Run failed for me, where to check for errors?

ABeck.1
Associate II

I am new to TouchGFX. I am working on STM32 controller based project. In that TFT LCD screen is one of the peripherals. I want to create screens using TouchGFX so that i can set value on screen and run timer according to the value entered on screen, during this complete duration my led will be ON

25 REPLIES 25

Is this the only way to display time on every screen or any other way I can do, so that at one place only I have to write logic and everywhere/every screen can update its respective clock?

../TouchGFX/gui/src/main_screen/MainView.cpp:29:23: error: expected unqualified-id before '.' token

       CustomContainer.initialize();

I got this error on adding

void MainView::setupScreen()

{

   setCount(0);

      CustomContainer.initialize(); // on adding this

The screens are not linked to each other and each screen has its own base class generated by TouchGFX Designer. Therefore, in your case, you need to implement the handleClickEvent for every screen.

CustomContainer is your class not an object (if I understand your overall code correctly), you need to call [name of your object].initialize()

/Alexandre

Hi @Alexandre RENOUX​ ,

I did exactly what you said. But somehow handletickevent() of custom container is not working.

I have called initialize function is setupscreen function. And in handletickevent() function called its base class handlekeyevent() function but timing is not updated.

Can you help me for that?

//Custom container
Background_Layer::Background_Layer()
{
    digitalHours = digitalClock1.getCurrentHour();
    digitalMinutes = digitalClock1.getCurrentMinute();
    digitalSeconds = digitalClock1.getCurrentSecond();
}
 
void Background_Layer::initialize()
{
    Background_LayerBase::initialize();
}
 
void Background_Layer::handleTickEvent()
{
  tickCounter++;
 
    if (tickCounter % 60 == 0)
    {
        if (++digitalSeconds >= 60)
        {
            digitalSeconds = 0;
            if (++digitalMinutes >= 60)
            {
                digitalMinutes = 0;
                if (++digitalHours >= 24)
                {
                    digitalHours = 0;
                }
            }
        }
 
        // Update the clock
        digitalClock1.setTime24Hour(digitalHours, digitalMinutes, digitalSeconds);
    }
}

Screen view code is as per below.

void Screen1View::setupScreen()
{
    Screen1ViewBase::setupScreen();
 
    background_Layer1.initialize(); //Object of custom container
}
 
 
void Screen1View::handleTickEvent()
{
	Screen1ViewBase::handleTickEvent();
}

Is there anything required other than this?

Hello,

You have 2 ways of making your handleTickEvent() from Background_Layer work:

  • You call Background_Layer.handleTickEvent() in your Screen1View::handleTickEvent()
void Screen1View::handleTickEvent()
{
        Background_Layer.handleTickEvent();
	Screen1ViewBase::handleTickEvent();
}

  • You write
touchgfx::Application::getInstance()->registerTimerWidget(this);

in the constructor of your Background_Layer class

Background_Layer::Background_Layer()
{
    touchgfx::Application::getInstance()->registerTimerWidget(this);
 
    digitalHours = digitalClock1.getCurrentHour();
    digitalMinutes = digitalClock1.getCurrentMinute();
    digitalSeconds = digitalClock1.getCurrentSecond();
}

Note : If at some point you are not using your handleTickEvent() function, unregister the timer

touchgfx::Application::getInstance()->unregisterTimerWidget(this);

/Alexandre

Hi @Alexandre RENOUX​ ,

As you have said, I have did that and now clock is working perfectly. I have used 2nd way to work this.

But now problem is that as I changed my screen, clock will initialize to its default value.

digitalSeconds = digitalClock1.getCurrentSecond();

How to use model -- presenter to propagate clock values to another screen?

If getCurrentSecond() function is called in container initialization then it will give default value only. So how can we provide actual seconds values?

EDIT :

I have remove below code from constructor and now time is updating properly after changing screens.

	touchgfx::Application::getInstance()->registerTimerWidget(this);
 
  //  digitalHours = digitalClock1.getCurrentHour();
  //  digitalMinutes = digitalClock1.getCurrentMinute();
  //  digitalSeconds = digitalClock1.getCurrentSecond();
 
    // Update the clock
    digitalClock1.setTime24Hour(digitalHours, digitalMinutes, digitalSeconds);

But now my issue is that, I want to set time. For that I have made one screen but in that screen I unable to access Background_Layer container's digitalClock1 item. Because that is defined in base class as protected. Now what I will do to access them or any other method to implement this functionality?

Please have a look at this tutorial in the documentation website : https://support.touchgfx.com/docs/tutorials/tutorial-03#step-2-saving-data

This explains how to save data in the model.

/Alexandre

Hi @Alexandre RENOUX​ ,

So in that case I have to write storing Value of time function in every presenter screen?

And in that function ( in presenter screen ) model function should be called, right?

Indeed that is the current way.

We are investigating another way to do it for a next release but nothing has been decided yet.

You only need to implement the function in the necessary presenters. If a screen does not use the function, no need to implement it.

/Alexandre

Thanks @Alexandre RENOUX​ .

  1. I have implement digital clock in custom container and I have removed getCurrentHour(); function from constructor so time is not initialized every time when I changed the screen. Is that okay or I have to change the way?
  2. Have to check about tickcounter. As if that is not maintained then in long run time may get affected.
  3. I have to just edit the time value in one screen in which I will use model presenter scheme.

And I want to ask that is there any functions or items available for display date?

EDIT:

I am unable to use model presenter scheme as I have put digital clock in custom container and no presenter file is available for custom container.

How to solve this issue?