cancel
Showing results for 
Search instead for 
Did you mean: 

Toggle Button off after a specific interval

Ofaro.1
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions
JTP1
Lead

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).

 

View solution in original post

3 REPLIES 3
JTP1
Lead

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.

 

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.

JTP1
Lead

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).