/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / Whats going on??

Username:     
Password:     
             

Forum

# 1   2009-02-09 20:13:00 Whats going on??

samarkh
Member
From: Gloucester UK
Registered: 2009-01-07
Posts: 84

Whats going on??

Hi,
I'm in the process of developing my first application, and so my knowledge is limited. So can some one please explain what is happening when this line is commented out?

This Line :

displayTEMPERATURE();

from the following

Code:

/********************** (C) COPYRIGHT 2007-2009 RAISONANCE ********************
* File Name          :  g_meter.c
* Author             :  Simon Markham
* Date First Issued  :  Feb 2009
* 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"
#define Green_LED 0                //Define LED Colour
#define Red_LED 1
#define Off 0                      //Define LED Mode
#define On 1
#define Flash 2
#define Flicker 3

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

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


/* Private function prototypes -----------------------------------------------+++++++++++++++*/
void displayTEMPERATURE(void);
void getMEMS(void);

/* Public variables ----------------------------------------------------------*/
const char Application_Name[8+1] = {"g_meter"};       // Max 8 characters

    s16 Current_MEMS_X;
    s16 Current_MEMS_Y;



/*******************************************************************************
* 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 )
    {
    if(strcmp(UTIL_GetVersion(), NEEDEDVERSION) < 0)
        {
        return MsgVersion();
        }

    LCD_SetScreenOrientation( V12 ); //Match orientation with MEMS information  

    //--------------------------------------------------------------------
//  DRAW_DisplayString(XXX,YYY,"$$$$$$$$$$$$$$$$$$",Len_$<max18>);
    DRAW_DisplayStringInverted(1,115,"Acceleration X - Y",18);

    //-----------------------------------------------------------------------------------------
    //  LED_Set(<0-Green/1-Red>, <0-off/1-on/2-flash/3-fast>); // Green_LED=D3 / Red_LED=D4
    LED_Set(Green_LED, Off );  
    LED_Set(Red_LED  , Off );  

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

    if( BUTTON_GetState() == BUTTON_PUSHED )        //Standard exit routine
        {
        BUTTON_WaitForRelease();         
        return MENU_Quit();
        }
       
   getMEMS();     

    LCD_DrawPixel(Current_MEMS_X,Current_MEMS_Y,128);        //void  DRAW_Line( x1,  y1,  x2,  y2,  color ); 
 //   DRAW_Line(Current_MEMS_X,Current_MEMS_Y,Current_MEMS_X+1,Current_MEMS_Y+1,128);        //void  DRAW_Line( x1,  y1,  x2,  y2,  color );

 
    displayTEMPERATURE();                           // Get & display current system temp

    }
/*******************************************************************************
* Function Name  : getMEMS
* Description    : Get current X/Y reading and scale for screem
*                  
*
* Input          : None
* Return         : None
*******************************************************************************/
 void getMEMS()
    {
    LED_Set(Green_LED, Off );  
    Current_MEMS_X  = (MEMS_GetInfo())->OutX_F16;    // MEMS X out average of 16
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    
    char xTXT[11] = " 0.000";                  // reset local rwTXT    
    UTIL_int2str(xTXT,Current_MEMS_X,11,1);   // Convert to string
    
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
    Current_MEMS_X  = Current_MEMS_X/256+64;
    
        if (Current_MEMS_X > SCREEN_WIDTH)
            {
            Current_MEMS_X = SCREEN_WIDTH;
            LED_Set(Green_LED, On ); 
            }
        else if (Current_MEMS_X < 0)
            {
            Current_MEMS_X = 0;
            LED_Set(Green_LED, On );
            }
        
    LED_Set(Red_LED  , Off );
    Current_MEMS_Y  = (MEMS_GetInfo())->OutY_F16;    // MEMS Y out average of 16
         Current_MEMS_Y  = Current_MEMS_Y/256+64;
       if (Current_MEMS_Y > SCREEN_HEIGHT)
            {
            Current_MEMS_Y = SCREEN_HEIGHT;
            LED_Set(Red_LED  , On );
            }
        else if (Current_MEMS_Y < 0)
            {
            Current_MEMS_Y = 0;
            LED_Set(Red_LED  , On );
            }

 /*
          
   s16 Out<axis>;                
   s16 Out<axis>_F4;       
   s16 Out<axis>_F16;      
   s32 Out<axis>_F64;      
   s32 Out<axis>_F256; 
 */     



    }

/*******************************************************************************
* Function Name  : displayTEMPERATURE
* Description    : Gets current system temperature
*                : inserts DP, and displays, eg 123 becomes 12.3c
*                :
* Input          : Nne
* Return         : None
* --------------------------------------
* Remap, NOTE MSB is first....
*    123 = 12.3c
* Example...    
* Position    [1] [2] [3] {4] [5] [   6    ]
* Original    [x] [y] [z]
* Maps to     [x] [y] [.] [z] [c] [new_line]
*******************************************************************************/ 
void displayTEMPERATURE()
    {
    char rwTXT[5] = "00.0c";                  // reset local rwTXT
    UTIL_int2str(rwTXT,UTIL_GetTemp(),3,0);   // Convert to string

        rwTXT[0]=rwTXT[1];                    // Add DP
        rwTXT[1]=rwTXT[2];
        rwTXT[3]=rwTXT[3];

        rwTXT[2]='.';
        rwTXT[4]='c';
        DRAW_DisplayString( 1, 5, rwTXT, 5); // X, Y, string, length
    }

/*******************************************************************************
* Function Name  : MsgVersion
* Description    : Display the current CircleOS version and the version needed
*                  exit to main menu after 4 seconds
*
* Input          : None
* Return         : MENU_CONTINUE
*******************************************************************************/
enum MENU_code MsgVersion()
    {
    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;
    }

This displays as a dot the current x-y output of the MEMS, along with current Temp.
However if the current temp is not displayed then a blue bouncing ball is shown!

Yours Simon M.

Offline

 

# 2   2009-02-09 22:18:05 Whats going on??

zwieblum
Member
Registered: 2008-12-19
Posts: 68

Re: Whats going on??

That's the pointer, you need to turn it off.

Offline

 

# 3   2009-02-09 22:45:13 Whats going on??

samarkh
Member
From: Gloucester UK
Registered: 2009-01-07
Posts: 84

Re: Whats going on??

Hi zwieblum, and thanks,
Err what pointer, & where & why?

Yours Simon M.

Offline

 

# 4   2009-02-09 23:06:48 Whats going on??

zwieblum
Member
Registered: 2008-12-19
Posts: 68

Re: Whats going on??

That thing that is controlled by the mems. By default it is turned on and you can move that blue ball around. Reference is here: http://www.stm32circle.com/circleos_doc/pointer_8c.html - the function you need to call is  POINTER_SetMode(POINTER_OFF). But I do not use CircleOS any more, I went to FreeRTOS :-)

Offline

 

# 5   2009-02-09 23:13:05 Whats going on??

samarkh
Member
From: Gloucester UK
Registered: 2009-01-07
Posts: 84

Re: Whats going on??

Many thanks again zwieblum, I thought you ment pointer as in (char * somename)
Yours Simon M.

Offline

 

# 6   2009-02-10 07:59:51 Whats going on??

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

Re: Whats going on??

Note that "enum MENU_code Application_Handler( void )" should return something... Depending on the returned value, the caller could consider that the application will exit (no more calls...).

Offline

 

# 7   2009-02-10 10:32:55 Whats going on??

samarkh
Member
From: Gloucester UK
Registered: 2009-01-07
Posts: 84

Re: Whats going on??

This may look to most of you like a stupid question, but where did I use

enum MENU_code Application_Handler( void )

?
Yours Simon M.

Offline

 

# 8   2009-02-10 10:38:46 Whats going on??

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

Re: Whats going on??

MENU_code Application_Handler is called automatically by CircleOS at the frequency = Systick_freq / AppliDivider.
Systick frequency is 1kHz by default (depending on the speed). AppliDivider is equal to 100 by default, but it can be modified by calling the function MENU_SetAppliDivider.

Offline

 

# 9   2009-02-10 11:13:23 Whats going on??

samarkh
Member
From: Gloucester UK
Registered: 2009-01-07
Posts: 84

Re: Whats going on??

OK, so as I understand it CircleOS services MENU_code Application_Handler automaticaly as part of its rtos style workings, thus I need to have something returned by MENU_code Application_Handler to keep it happy? Should I have return 0; at the end of it?

But, why does sending formatted text to the screen  - displayTEMPERATURE() stop this ?

Yours Simon M.

Offline

 

# 10   2009-02-10 12:49:36 Whats going on??

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

Re: Whats going on??

No, you need to return MENU_CONTINUE (=1). Your handler (and DisplayTemperature) should be called again.
Note that you can debug your application (setting breakpoints, etc...) once it has been launched.

Offline

 

# 11   2009-02-10 13:53:06 Whats going on??

samarkh
Member
From: Gloucester UK
Registered: 2009-01-07
Posts: 84

Re: Whats going on??

Thanks Francis, that helped, I had missed the 

Code:

 return MENU_CONTINUE;

at the end of

Code:

 enum MENU_code Application_Handler( void )

And the reason it worked when the

Code:

 displayTEMPERATURE()

function was called is because I missesd a return at the end of it so it fell off the end into

Code:

enum MENU_code MsgVersion()

Offline

 

# 12   2009-02-10 14:46:56 Whats going on??

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

Re: Whats going on??

Yes, it was what I saw, but my message was not so clear. I apologize.

Offline

 

Board footer