/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / Menus & Background tasks

Username:     
Password:     
             

Forum

# 1   2009-07-03 12:22:46 Menus & Background tasks

adal
Member
Registered: 2009-04-22
Posts: 32

Menus & Background tasks

Hi,

I have a quick question just to save some time against a hunting session within circle3.7...

I'm trying to upgrade my application in order to be able to keep some background tasks
running while I'm on menus.
I have no problems in doing this once I select a menu option because I drop my "background statements" within the <Menu>_Handler context.
The problem is in the gap of time right *after* the menu opening and *before* the menu option selection. Looks like in that meanwhile there is no default context to run statements (the application context is not running anymore).

I was starting to think about "dirty tricks" like dropping my statements in a interrupt handler (presumably associated to timers) .......
....but if there is by default a clean way to do it (within menu framework), please let me know,

Thanks,
Adalberto

Offline

 

# 2   2009-07-03 12:25:10 Menus & Background tasks

adal
Member
Registered: 2009-04-22
Posts: 32

Re: Menus & Background tasks

I forgot to add that I'm running on the Primer2

A.

Offline

 

# 3   2009-07-06 07:59:05 Menus & Background tasks

yrt
Administrator
From: Grenoble-France
Registered: 2008-06-11
Posts: 520
Website

Re: Menus & Background tasks

Adalberto,

With the 3.71 version of CircleOS, you can manage popup menu within your application.

To display the menu, call the funtion "MENU_Set", like this :

        myMenu.Items[0].Fct_Manage = &My_menu_Handler;
        MENU_Set( &myMenu );

The Menu handler calls now "My_menu_Handler" in place of your application, while it returns "MENU_CONTINUE".

In "My_menu_Handler" you can call background functions of your application.

When closing the menu,  your menu handler must return "MENU_RESTORE_COMMAND", and the menu handler will call now your application again.

Take a look at the example application named "Dictaphone", that manage a popup menu to choose the file to delete.

Yves

Offline

 

# 4   2009-07-06 08:42:52 Menus & Background tasks

adal
Member
Registered: 2009-04-22
Posts: 32

Re: Menus & Background tasks

yrt,

I've already followed the example of dictaphone in my implementation and I know that
I can execute statements/funtions within menu Handlers, so let me try to explain better.

My problem is that right after MENU_Set I cannot run statements *unless* the menu option is selected (and the handler starts):

1)If the user selects the menu option *quickly* everithing is OK (The handler starts and I can run handler specific statements + statements to update critical information within the handler).

2)If the user takes too long to select a menu option, *the system is idle* and I cannot execute statements in the background to update critical information.

Obviously I can drop some critical statements in a timer controlled interrupt handler, but I wanted to know if menus hide some sort of feature to handle the situation implicitly.

I hope I've explained the problem better, please let me know if there is still something not clear.

Thanks,
Adalberto

Offline

 

# 5   2009-07-08 06:36:05 Menus & Background tasks

yrt
Administrator
From: Grenoble-France
Registered: 2008-06-11
Posts: 520
Website

Re: Menus & Background tasks

Adalberto,

Effectively, while any menu item is selected, no correponding handler is launched (myMenu.Items[0].Fct_Manage).
So the menu handler keeps the hand, and you cannot execute your background tasks.

The problem is due to the management of the applications by the menu handler and not a specific application handler (the application is called by the menu handler).

Maybe we have to think about another way to do this, for a further version of CircleOS,

Yves

Offline

 

Board footer