/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / MENU handling

Username:     
Password:     
             

Forum

# 1   2010-09-14 09:31:27 MENU handling

rikubon
Member
Registered: 2009-08-21
Posts: 16

MENU handling

I am writing a "digital sampling scope" application for Primer 2. The application receives a signal from the outside primer 2, A/D convert it, then display it on the screen in the DMA handler. I have done with the primary functions, and I could observe signal waveforms with the primer2. It's really handy. smile

BTW, I want to use a Menu and the toolbar to control  the application, e.g. changing the time scale or the amplitude scale, but I am stacking with both of them.  I checked "dictaphone" project but it was not enough for me. Could someone help me?

OK, I want to use a menu consisting of 2 menu-items as follows;

my MENU
-----------
Item 1
Quit

To implement the above, I wrote as follows;

Code:

tMenu myMenu = {
  1,"my MENU",2,0,0,0,0,0,0,{
    { "Item 1", Item1_Ini, Item1_Handler , 0 },
    { "Quit",     fQuit, 0, 1 }
  }
};

enum MENU_code Application_Handler(void)
{
  if(BUTTON_GetState() == BUTTON_PUSHED) {
    BUTTON_WaitForRelease();
    TIM_Cmd(TIM1,DISABLE); // disable screen refresh triggered by TIM1
    MENU_Set( &myMenu );
    return MENU_CHANGE;
  }
  return MENU_CONTINUE; 
}

void Item1_Ini(void)
{
  TIM_Cmd(TIM1,ENABLE); // enable screen refresh again
  return MENU_CONTINUE;
}

void Item1_Handler(void)
{
   // some lines to do some tasks
   return MENU_CONTINUE;
}

With the above code, I could see the menu and it disappeared when I chose "Item1" with the menu. However, when I moved the joystick up and down, a part of the menu was displayed again and I could choose every item on the menu.

My first question is, "How can I disable the Menu after selecting one item on the menu?"
I could not find any hint from the "dictaphone" application.

When I moved the line "TIM_Cmd(TIM1, ENABLE);" from Item1_Ini() to Item1_Handler(), my application did not restart refreshing the screen.

My second question is, "What is the division of roles between xx_Ini() function (enum MENU_code (*Fct_Init)(), I mean) and xx_Handler() (Fct_Manage) regarding the menu handling?". I am reading "menu.c" but it is too tough for me...

On TOOLBAR... I will struggle with it by myself...

Any help will be greatly appreciated.

ARIGATO!

Offline

 

# 2   2010-09-16 06:00:48 MENU handling

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

Re: MENU handling

Hi,
First, you code seems to be correct, except the "MENU_CONTINUE" does  your menu always be called by the system (see below).

$1 : at the end of the "Item1_Handler handler function, you have to return "MENU_RESTORE_COMMAND", and then the application handler will be called again, which has first to refresh the screen, in order to delete (graphically) the menu.

$1 :  the function "Fct_Init" is called only one time for initialization or screen background display,  when "Fct_Manage" is continously called by the menu handler, after the "Fct_Init", and until the code "MENU_RESTORE_COMMAND" is returned.
Remark : the items of an application menu are managed with the same way that application itself (which are menu items). The only difference is the return code ("MENU_QUIT" for application vs "MENU_RESTORE_COMMAND" for application menus.

$1 : the declaration of a toolbar is about the same thing that menu : declare your toolbar structure with addresses of item icons, and associated functions. Then call "TOOLBAR_Set(&myToolbar)", and the system will manage you own toolbar.
Finaly, call "TOOLBAR_SetDefaultToolbar()" if you want to restore the system toolbar.

Hope this helps.
Yves

Offline

 

# 3   2010-09-27 05:09:02 MENU handling

rikubon
Member
Registered: 2009-08-21
Posts: 16

Re: MENU handling

Thank you very much yrt! I had waited long that the stm32circle.com recovers from its maintenace to read your reply. smile This is just a reply to say thank you. After I check it tonight, I will reply again. Thanks again.

Offline

 

# 4   2010-09-29 07:30:07 MENU handling

rikubon
Member
Registered: 2009-08-21
Posts: 16

Re: MENU handling

It has worked at last. There were three mistakes in the above code.

1) Item1_Ini() and Item1_Handler() were defined as "void". It must be defined as "enum MENU_code".
2) Item1_Ini() returned "MENU_CONTINUE". It must return "MENU_CONTINUE_COMMAND".
3) Item1_Handler() did not call DRAW_Clear(). Because of that the menu did not be cleared.

enum MENU_code Item1_Ini(void)
{
//  TIM_Cmd(TIM1,ENABLE); // enable screen refresh again
  return MENU_CONTINUE_COMMAND;
}

enum MENU_code Item1_Handler(void)
{
   // some lines to do some tasks
   BUZZER_SetMode( BUZZER_SHORTBEEP );
   BUTTON_SetMode( BUTTON_ONOFF );
//   CurrentMenu = 0;
   DRAW_Clear();
   return MENU_RESTORE_COMMAND;
}

In addition, I added a call "BUTTON_SetMode(BUTTON_ONOFF)" in the Item1_Handler(). I am not sure it is required, but without it, I could not recall the menu again.

On TOOLBAR... I could not test it even with "TOUCHSCREEN CALIBRATION" in the config menu. Any help?

Offline

 

Board footer