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!
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 :-)
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...).
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.
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 ?
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.