/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / List management question

Username:     
Password:     
             

Forum

# 1   2009-01-26 15:27:35 List management question

sjoerd
Member
From: Stad aan het Haringvliet
Registered: 2008-09-04
Posts: 65

List management question

I'm trying to get a list working but can't figure out how the handling should be.


Init list:

   char DirItems[30][12];
   tList DirMenu =    {    1,    "Explorer",    30,    0,0,0,0,0,    6,    0,    0,    };

   ..
   ..
   // loop to fill items in menu
  {
   DirMenu.Items[i].Text = DirItems[i];
   }
 
    MENU_SetAppliDivider(10);  // not sure what this does but is used in menu_app.c
    LIST_Set(&DirMenu,0,0,1);
 
   return MENU_CONTINUE_COMMAND;

Main handler:

   i=LIST_Manager ();
   if (i != -1)
    {
    DirMenu.SelectedItem = i;
    // and perhaps some more handling here ??
    }
  return MENU_CONTINUE;




I've analysed the list handling in menu_app.c but it's not completely clear how this should work.

Offline

 

# 2   2009-01-26 15:45:59 List management question

Francis
Administrator
From: France-Grenoble
Registered: 2007-07-09
Posts: 890

Re: List management question

I am not the expert, but I believe that it workls as follows:
1. You have to initialize each item in your list. In menu_App (an example  for using a list), you will find that the text of each item is initialized with the names of the available application). The number of items has also to be set.
When you are 'ready', you can call LIST_Set().
2. Then you have to call the LIST_Manager()  from your own handler. It will return (-1) as long as no item has been selected. Once an item has been selected, it will retun an integer that matches with the index of this item.

In Menu_App, the list (and the items) are static. For sure it would be much better to build dynamically the list. I believe that you can use the standard memory allocator  (malloc/free) in your application. To be confirmed...

Offline

 

# 3   2009-01-26 16:16:31 List management question

sjoerd
Member
From: Stad aan het Haringvliet
Registered: 2008-09-04
Posts: 65

Re: List management question

I'm able to display a list with items but the LIST_Manager doesn't return anything else then 0 when I tilt the Primer.
The list slowly scrolls down and the list is filled with blue lines..


As soon as I press the button, the main App menu is shown so I guess something is wrong.. but what?

And who's responsible for scrolling in the menu with MEMS etc? I assume that's all handled somewhere magically in CircleOs wink

Last edited by sjoerd (2009-01-26 16:24:25)

Offline

 

# 4   2009-01-26 16:34:14 List management question

Francis
Administrator
From: France-Grenoble
Registered: 2007-07-09
Posts: 890

Re: List management question

Everything is managed in list.c.
The normal behaviour should be:
    You change the selection by touching, or with the joystick (tilting vertically should also generate a scroll).  It should return -1 until you push on the button, or you double click (MEMS), or you keep a long pressure with the touchscreen on one item. In this situation, it should return the index of the item.
We will check with a simple application (we never tested the list called from an application, but we just use it to select the application in CircleOS).

Offline

 

# 5   2009-01-26 16:57:07 List management question

Francis
Administrator
From: France-Grenoble
Registered: 2007-07-09
Posts: 890

Re: List management question

I wrote the following applications, and it  works  pretty well: 

Code:

/********************** (C) COPYRIGHT 2007-2009 RAISONANCE ********************
* File Name          :  Application.c
* Author             :
* Date First Issued  :
* Description        :  Circle_App CircleOS application template.
* Revision           :
*******************************************************************************/

/* Includes ------------------------------------------------------------------*/
#include "circle_api.h"

/* Private defines -----------------------------------------------------------*/

// The following should be the minimal CircleOS version needed by your application
#define NEEDEDVERSION "V 1.5"

/* Private variables ---------------------------------------------------------*/

/* Private functions ---------------------------------------------------------*/
enum MENU_code MsgVersion(void);

/* Public variables ----------------------------------------------------------*/

const char Application_Name[8+1] = {"ListTest"};      // Max 8 characters

tList ListItems =
    {
    1,
    "Testing",
    16,
    0,0,0,0,0,
    6,
    0,
    0,
        "Test 1",
        "Test 2",
        "Test 3",
        "Test 4",
        "Test 5",
        "Test 6",
        "Test 7",
        "Test 8",
        "Test 9",
        "Test 10",
        "Test 11",
        "Test 12",
        "Test 13",
        "Test 14",
        "Test 15",
        "Test 16"
    };


/*******************************************************************************
* Function Name  : Application_Ini
* Description    : Initialization function of Circle_App. This function will
*                  be called only once by CircleOS.
* Input          : None
* Return         : MENU_CONTINUE_COMMAND
*******************************************************************************/
enum MENU_code Application_Ini ( void )
    {
    // Ensure that the current OS version is recent enough
    if(strcmp(UTIL_GetVersion(), NEEDEDVERSION) < 0)
        {
        return MsgVersion();
        }


    // TODO: Write your application initialization function here.
    MENU_SetAppliDivider(10);
    LIST_Set( &ListItems, 0, 0, 1 );


    return MENU_CONTINUE_COMMAND;
    }

/*******************************************************************************
* Function Name  : Application_Handler
* Description    : Management of the Circle_App.
*
* Input          : None
* Return         : MENU_CONTINUE
*******************************************************************************/
enum MENU_code Application_Handler ( void )
    {
    int ItemSel  = 0;

    // TODO: Write your application handling here.
   if ( BUTTON_GetState() == BUTTON_PUSHED )
      {
      BUTTON_WaitForRelease();
      return MENU_Quit();
      }

    // This routine will get called repeatedly by CircleOS, until we
    ItemSel = LIST_Manager();  
    
    // If choice done
    if (ItemSel != -1)
        {
        return MENU_Quit();
        }

    return MENU_CONTINUE;   // Returning MENU_LEAVE will quit to CircleOS
    }

/*******************************************************************************
* Function Name  : MsgVersion
* Description    : Display the current CircleOS version and the version needed
*                  exit to main menu after 4 secondes
*
* Input          : None
* Return         : MENU_CONTINUE
*******************************************************************************/
enum MENU_code MsgVersion(void)
    {
    int hh,mm,ss,ss2;

    DRAW_DisplayString(5,60,"CircleOS",17);
    DRAW_DisplayString(80,60,UTIL_GetVersion(),3);
    DRAW_DisplayString(5,34,NEEDEDVERSION,3);
    DRAW_DisplayString(40,34," required",12);

    RTC_GetTime(&hh,&mm,&ss);
    ss = ss + 4;                    // 4 seconds
    ss = ss%60;

    do
        {
        RTC_GetTime(&hh,&mm,&ss2);
        }
    while (ss2 != ss);              // do while < 4 seconds

        return MENU_REFRESH;
    }

Offline

 

# 6   2009-01-26 19:13:54 List management question

sjoerd
Member
From: Stad aan het Haringvliet
Registered: 2008-09-04
Posts: 65

Re: List management question

argh.. just a stupid mistake from my side to keep some vars inside scope of local  function in stead of static global..

It works now but without MEMS.. is this correct?

Offline

 

# 7   2009-01-26 21:56:53 List management question

Francis
Administrator
From: France-Grenoble
Registered: 2007-07-09
Posts: 890

Re: List management question

To make it working with MEMS, I believe that you have to modify the settings (Menu->config=>Interface=>User input=>MEMS+JOYSTICK...

Offline

 

# 8   2009-01-26 22:21:10 List management question

sjoerd
Member
From: Stad aan het Haringvliet
Registered: 2008-09-04
Posts: 65

Re: List management question

Joystick seems to work when it's set to both Mems+joystick.

Selecting something with the touchscreen is a bit tricky but this might be caused by some calibration issues.
I guess it's also possible to catch joystick events?


Another question.. how to dismiss a list and display a new one.. MENU_Quit stops the whole app.


Initial implementation of a file browser here:
http://www.yousendit.com/download/WnBTa … YVBIRGc9PQ  still alpha code but could be usefull for others to experiment with

Offline

 

# 9   2009-01-27 08:11:14 List management question

Francis
Administrator
From: France-Grenoble
Registered: 2007-07-09
Posts: 890

Re: List management question

Try to call again LIST_Set with the new list. The list manager is not reentrant and you will reinitialize it.

Note that the background is not saved (neither for the menu, nor for the screen that work on the same principle). We don't have so much memory for keeping an image of the previous screen contents. It would be probably better (above all for lists), to use the whole screen to display information with a larger font.

Offline

 

# 10   2009-01-27 08:19:03 List management question

sjoerd
Member
From: Stad aan het Haringvliet
Registered: 2008-09-04
Posts: 65

Re: List management question

Ah.. that explains why it looks like the previous menu is still there smile

I'll extend the list in such a way it covers more of the screen.

Offline

 

# 11   2009-01-27 08:40:46 List management question

Francis
Administrator
From: France-Grenoble
Registered: 2007-07-09
Posts: 890

Re: List management question

At the moment, the scrolling of the list is done by software (we don't use the LCD capabilitiy because it works only with one direction (vertical) and we wanted to keep the free rotation...
A larger screen will make the scrolling slower. However, we use DMA for scrolling and it could be acceptable...

For a full screen list, I meant that we should modify the source in order to remove the border (useless for a full screen mode). It is not implemented yet.

Offline

 

Board footer