Skip to main content
Ofaro.1
Associate III
June 19, 2023
Solved

Toggle Button off after a specific interval

  • June 19, 2023
  • 2 replies
  • 1913 views

Hi,

I want to switch off the toggle button itself after a specific interval, let's say 60 sec.

Currently it works fine in View.cpp using handleTickEvent but as soon as I navigate to different screen, it doesn't update.

Is it possible to run this counter in the backend?

I'm using STM32F429.

Thanks

This topic has been closed for replies.
Best answer by JTP1

Hello

Here is simple example how timing can be done in model- class and also how to communicate from view to presenter and presenter to model.  Just open the MVP_toggleBtnEx.touchgfx file from TouchGFX folder with TGFX desingner 4.21.4 or later and run the simulator. Because of new 5 MB attachment size limit, project is simplified to minimum.

Please note that presenter of every screen doesn't need to implement 'switchTimeElapsed' function since its defined virtual in base class of presenter (modelListener).

 

2 replies

Graduate II
June 20, 2023

Hello

What else must happen when toggle switch is swiched off after some time period ?

You probably could use model::tick- function to implement this kind of functionality handled by model- class.

Just set some functions to presenter- class to tell model-class to start/stop counter and then add the functionatily also to model- class.

 

Ofaro.1
Ofaro.1Author
Associate III
June 21, 2023

Hi,

Thanks for responding. Basically toggle button is switching on and off the light. I want once toggle is on, it switch off itself after 60sec. It works fine as long as I stay in that same screen but as soon as I navigate to different screen it doesn't update.

JTP1Best answer
Graduate II
June 21, 2023

Hello

Here is simple example how timing can be done in model- class and also how to communicate from view to presenter and presenter to model.  Just open the MVP_toggleBtnEx.touchgfx file from TouchGFX folder with TGFX desingner 4.21.4 or later and run the simulator. Because of new 5 MB attachment size limit, project is simplified to minimum.

Please note that presenter of every screen doesn't need to implement 'switchTimeElapsed' function since its defined virtual in base class of presenter (modelListener).