2020-02-05 03:43 AM
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
2020-03-04 03:34 AM
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?
2020-03-04 03:45 AM
../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
2020-03-04 04:35 AM
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
2020-09-14 02:20 AM
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?
2020-09-14 05:20 AM
Hello,
You have 2 ways of making your handleTickEvent() from Background_Layer work:
void Screen1View::handleTickEvent()
{
Background_Layer.handleTickEvent();
Screen1ViewBase::handleTickEvent();
}
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
2020-09-14 10:41 PM
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?
2020-09-15 04:18 AM
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
2020-09-16 02:10 AM
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?
2020-09-16 02:16 AM
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
2020-09-16 02:27 AM
Thanks @Alexandre RENOUX .
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?