/************************* (C) COPYRIGHT 2007 RAISONANCE **********************
* File Name : Application.c
* Author :
* Date First Issued :
* Description : Circle_App CircleOS application template.
* Revision :
*******************************************************************************/
/* Includes ------------------------------------------------------------------*/
#include "circle_api.h"
/* Private defines -----------------------------------------------------------*/
#define NEEDEDVERSION "V 1.5" // Put here the minimal CircleOS version needed by your application
/* Private variables ---------------------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
enum MENU_code MsgVersion(void);
/* Public variables ----------------------------------------------------------*/
const char Application_Name[8+1] = {"HELLO"}; // max 8 characters for application name
/*******************************************************************************
* 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();
}
// TODO: Write your application initialization function here.
BUTTON_SetMode(BUTTON_ONOFF);
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 )
{
// TODO: Write your application handling here.
// This routine will get called repeatedly by CircleOS, until we
// return MENU_LEAVE
const char msg[] = "Hello, World!";
u32 btn_status;
LED_Set(LED_GREEN,LED_ON);
DRAW_DisplayString( 5, 20, msg, sizeof(msg)); // X, Y, string, length
btn_status = BUTTON_GetState();
if(btn_status == BUTTON_PUSHED)
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 secondes
ss = ss%60;
do
{
RTC_GetTime(&hh,&mm,&ss2);
}while (ss2 != ss); // do while < 4 secondes
return MENU_REFRESH;
}