/********************** (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 3.7"
/* Private functions ---------------------------------------------------------*/
static enum MENU_code MsgVersion(void);
/* Public variables ----------------------------------------------------------*/
const char Application_Name[8+1] = {"My App"}; // Max 8 characters
int sTime, cTime;
/*******************************************************************************
* 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.
int hh,mm,ss;
RTC_GetTime( &hh, &mm, &ss);
sTime = hh*3600+mm*60+ss;
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.
u8 ptr[10];
int hh,mm,ss;
RTC_GetTime( &hh, &mm, &ss);
cTime = hh*3600+mm*60+ss;
if((sTime+10)%(24*3600)==cTime) SHUTDOWN_Action();
UTIL_uint2str (ptr, 10-cTime+sTime, 8, 0);
DRAW_DisplayString (10, 10, ptr, 10);
// This routine will get called repeatedly by CircleOS, until we
// return MENU_LEAVE
#if 1
// If the button is pressed, the application is exited
if(BUTTON_GetState() == BUTTON_PUSHED)
{
BUTTON_WaitForRelease();
return MENU_Quit();
}
#endif
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_REFRESH
*******************************************************************************/
static enum MENU_code MsgVersion(void)
{
int hh,mm,ss,ss2;
DRAW_DisplayString(5,60,"CircleOS",17);
DRAW_DisplayString(80,60,UTIL_GetVersion(),6);
DRAW_DisplayString(5,34,NEEDEDVERSION,6);
DRAW_DisplayString(50,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
DRAW_Clear();
return MENU_REFRESH;
}
'컴퓨터 > STM32 primer 2' 카테고리의 다른 글
STM32 Primer2 LED 제어하기 (0) | 2010.01.26 |
---|---|
Circle OS API를 활용하여 LCD에 Hello World 출력하는 프로그램 작성 (2) | 2010.01.22 |
STM32 circle primer 2 통합개발환경 꾸미기 (0) | 2010.01.22 |