//==================================================================
//
// StopWatch
//
//==================================================================
%{
// Header Section
#DEFINE SCRIPTVER 2 // GVM 2X
#DEFINE LCDCLASS 255 // LCD Class : Any class
#DEFINE IMAGETYPE 255 // Image Type : Any type
#DEFINE AUDIOTYPE 255 // Audio Type : Any Type
#DEFINE VOCTYPE 1 // Carrier Type : SKT
#DEFINE SCRIPTCPID 1 // Script CPID
#DEFINE SCRIPTID 1 // Script ID
#DEFINE SCRIPTNAME "StopWatch" // Script Name
%}
#include "..\SScript.h"
#include "Sound.ssd"
#include "Image.sbm"
#define Prog 0
#define Key 1
#define Stop 2
#define Run 3
int State;
int mSec;
int Sec;
int minu;
int Hour;
string strTime;
int hwcfg[4];
///////////////////////////////////////////////////////////////
// 스톱 워치 초기화//////////////////////////////////////////
void StopWatchInit()
{
SetStrFont(S_FONT_SMALL);
State = Prog;
mSec = 0;
Sec = 0;
minu = 0;
Hour = 0;
GetHwConfig(hwcfg);
}
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
// 초기 화면 표시/////////////////////////////////////////////
void ShowProg()
{
if(hwcfg[2] == 1)
{
PlaySound(Sound);
}
else
{
DrawText(5, ((swHeight-50)/2)+50, "Unable Sound!!");
SaveLCD();
}
ClearWhite();
RestoreLCD();
CopyImage((swWidth-100)/2, 1, Image);
DrawStr2(1, ((swHeight-50)/2)+60, "Press any key to continue.", 2 4);
Flush();
}
///////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
// 사용 키 설명 화면 표시////////////////////////////////////
void ShowKey()
{
ClearWhite();
SetStrFont(S_FONT_MEDIUM);
DrawStr(1, (swHeight/6)*1, "Start : Key 1");
DrawStr(1, (swHeight/6)*2, "Stop : Key 3");
DrawStr(1, (swHeight/6)*3, "Reset : key 2");
SetStrFont(S_FONT_SMALL);
DrawStr(1, (swHeight/6)*5, "Press any key to continue.");
Flush();
}
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
// 스톱워치 시간 표시////////////////////////////////////////
void ShowTime()
{
ClearWhite();
MakeStr4(strTime, "%d : %d : %d : %d", Hour, minu, Sec, mSec);
DrawText(swWidth/7, swHeight/3, strTime);
Flush();
}
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
// main 함수 //////////////////////////////////////////////////
void main()
{
StopWatchInit();
ShowProg();
}
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
// 타이머 이벤트 //////////////////////////////////////////////
void EVENT_TIMEOUT()
{
if(State == Run)
{
if(mSec == 9)
{
mSec = 0;
Sec = Sec + 1;
if(Sec == 60)
{
Sec = 0;
minu = minu + 1;
if(minu == 60)
{
minu = 0;
Hour = Hour + 1;
}
}
}
else
{
mSec = mSec + 1;
}
}
ShowTime();
}
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
// 키 이벤트 /////////////////////////////////////////////////
void EVENT_KEYPRESS()
{
switch(State)
{
case Prog :
State = Key;
ShowKey();
break;
case Key :
State = Run;
ShowTime();
break;
case Stop :
break;
case Run :
if(swData == SWAP_KEY_1)
{
SetTimer(100, S_TM_REPEAT);
}
if(swData == SWAP_KEY_3)
{
ResetTimer();
ShowTime();
}
if(swData == SWAP_KEY_2)
{
ResetTimer();
mSec = 0;
Sec = 0;
minu = 0;
Hour = 0;
ShowTime();
}
break;
}
}
///////////////////////////////////////////////////////
//
// StopWatch
//
//==================================================================
%{
// Header Section
#DEFINE SCRIPTVER 2 // GVM 2X
#DEFINE LCDCLASS 255 // LCD Class : Any class
#DEFINE IMAGETYPE 255 // Image Type : Any type
#DEFINE AUDIOTYPE 255 // Audio Type : Any Type
#DEFINE VOCTYPE 1 // Carrier Type : SKT
#DEFINE SCRIPTCPID 1 // Script CPID
#DEFINE SCRIPTID 1 // Script ID
#DEFINE SCRIPTNAME "StopWatch" // Script Name
%}
#include "..\SScript.h"
#include "Sound.ssd"
#include "Image.sbm"
#define Prog 0
#define Key 1
#define Stop 2
#define Run 3
int State;
int mSec;
int Sec;
int minu;
int Hour;
string strTime;
int hwcfg[4];
///////////////////////////////////////////////////////////////
// 스톱 워치 초기화//////////////////////////////////////////
void StopWatchInit()
{
SetStrFont(S_FONT_SMALL);
State = Prog;
mSec = 0;
Sec = 0;
minu = 0;
Hour = 0;
GetHwConfig(hwcfg);
}
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
// 초기 화면 표시/////////////////////////////////////////////
void ShowProg()
{
if(hwcfg[2] == 1)
{
PlaySound(Sound);
}
else
{
DrawText(5, ((swHeight-50)/2)+50, "Unable Sound!!");
SaveLCD();
}
ClearWhite();
RestoreLCD();
CopyImage((swWidth-100)/2, 1, Image);
DrawStr2(1, ((swHeight-50)/2)+60, "Press any key to continue.", 2 4);
Flush();
}
///////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
// 사용 키 설명 화면 표시////////////////////////////////////
void ShowKey()
{
ClearWhite();
SetStrFont(S_FONT_MEDIUM);
DrawStr(1, (swHeight/6)*1, "Start : Key 1");
DrawStr(1, (swHeight/6)*2, "Stop : Key 3");
DrawStr(1, (swHeight/6)*3, "Reset : key 2");
SetStrFont(S_FONT_SMALL);
DrawStr(1, (swHeight/6)*5, "Press any key to continue.");
Flush();
}
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
// 스톱워치 시간 표시////////////////////////////////////////
void ShowTime()
{
ClearWhite();
MakeStr4(strTime, "%d : %d : %d : %d", Hour, minu, Sec, mSec);
DrawText(swWidth/7, swHeight/3, strTime);
Flush();
}
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
// main 함수 //////////////////////////////////////////////////
void main()
{
StopWatchInit();
ShowProg();
}
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
// 타이머 이벤트 //////////////////////////////////////////////
void EVENT_TIMEOUT()
{
if(State == Run)
{
if(mSec == 9)
{
mSec = 0;
Sec = Sec + 1;
if(Sec == 60)
{
Sec = 0;
minu = minu + 1;
if(minu == 60)
{
minu = 0;
Hour = Hour + 1;
}
}
}
else
{
mSec = mSec + 1;
}
}
ShowTime();
}
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
// 키 이벤트 /////////////////////////////////////////////////
void EVENT_KEYPRESS()
{
switch(State)
{
case Prog :
State = Key;
ShowKey();
break;
case Key :
State = Run;
ShowTime();
break;
case Stop :
break;
case Run :
if(swData == SWAP_KEY_1)
{
SetTimer(100, S_TM_REPEAT);
}
if(swData == SWAP_KEY_3)
{
ResetTimer();
ShowTime();
}
if(swData == SWAP_KEY_2)
{
ResetTimer();
mSec = 0;
Sec = 0;
minu = 0;
Hour = 0;
ShowTime();
}
break;
}
}
///////////////////////////////////////////////////////
덧글을 달아 주세요