//**********************************************************************
define appv 'Sleep V1.02' //
//**********************************************************************
//
define STEPS 5 //
define VALUES (STEPS + 1) //
//
//
vmthread MAIN // void MAIN(void)
{ // {
DATAF Data //
DATA16 Inc //
DATA16 Handle //
DATA8 Value //
DATA8 Index //
DATA8 State //
DATA8 Tmp //
DATAS Text 16 //
DATAS Name FILENAMESIZE //
DATAS String FILENAMESIZE //
ARRAY8 Values VALUES //
DATA8 ShowVersion //
//
UI_BUTTON(PRESSED,RIGHT_BUTTON,ShowVersion) // UI_BUTTON(PRESSED,RIGHT_BUTTON,ShowVersion)
JR_FALSE(ShowVersion,DontShowVersion) // if (ShowVersion)
// {
UI_DRAW(FILLRECT,BG_COLOR,4,50,170,28) // UI_DRAW(FILLRECT,BG_COLOR,4,50,170,28)
UI_DRAW(RECT,FG_COLOR,6,52,166,24) // UI_DRAW(RECT,FG_COLOR,6,52,166,24)
UI_DRAW(TEXT,FG_COLOR,13,60,appv) // UI_DRAW(TEXT,FG_COLOR,13,60,appv)
UI_DRAW(UPDATE) // UI_DRAW(UPDATE)
//
ShowVersionWait: // do
// {
UI_BUTTON(PRESSED,RIGHT_BUTTON,ShowVersion) // UI_BUTTON(PRESSED,RIGHT_BUTTON,ShowVersion)
// }
JR_TRUE(ShowVersion,ShowVersionWait) // while (ShowVersion)
//
UI_BUTTON(FLUSH) // UI_BUTTON(FLUSH)
DontShowVersion: // }
//
UI_DRAW(RESTORE,0) // UI_DRAW(RESTORE,0)
UI_DRAW(TOPLINE,1) // UI_DRAW(TOPLINE,1)
UI_WRITE(LED,LED_GREEN) // UI_WRITE(LED,LED_GREEN)
//
WRITE8(2,0,Values) // Values[0] = 2
WRITE8(5,1,Values) // Values[1] = 5
WRITE8(10,2,Values) // Values[2] = 10
WRITE8(30,3,Values) // Values[3] = 30
WRITE8(60,4,Values) // Values[4] = 60
WRITE8(0,5,Values) // Values[5] = 0 = never
//
// Get last Value //
INFO(GET_MINUTES,Value) // INFO(GET_MINUTES,Value)
//
MOVE8_8(0,Index) // for (Index = 0;(Values[Index] != Value) && (Index < STEPS);Index++)
Next: //
READ8(Values,Index,Tmp) //
JR_EQ8(Tmp,Value,Found) //
JR_GTEQ8(Index,STEPS,Next) // {
ADD8(1,Index,Index) // }
JR(Next) //
Found: //
// do
Loop: // {
//
// Show popup //
UI_DRAW(BMPFILE,FG_COLOR,16,50,'144x32_POP1') // Draw bitmap
UI_DRAW(BMPFILE,FG_COLOR,24,60,'icon') // Draw bitmap
//
// Write text //
UI_DRAW(TEXT,FG_COLOR,48,62,'Sleep') // UI_DRAW(TEXT,FG_COLOR,48,62,"Sleep")
//
// Get left and right arrows //
UI_BUTTON(GET_HORZ,Inc) // UI_BUTTON(GET_HORZ,Inc)
MOVE16_8(Inc,Tmp) // Tmp = Inc
ADD8(Tmp,Index,Index) // Index = Index + Tmp
//
// Limit steps //
JR_GTEQ8(Index,0,GreatEnough) // if (Index < 0)
// {
MOVE8_8(0,Index) // Index = 0
GreatEnough: // }
JR_LTEQ8(Index,STEPS,SmallEnough) // if (Index > STEPS)
// {
MOVE8_8(STEPS,Index) // Index = STEPS
SmallEnough: // }
//
// Convert value and show //
READ8(Values,Index,Value) // Value = Values[Index]
JR_NEQ8(Value,0,NotZero) // if (Value == 0)
// {
STRINGS(DUPLICATE,'never',Text) // STRINGS(DUPLICATE,'never',Text)
//
JR(EndZero) // }
// else
NotZero: // {
//
MOVE8_F(Value,Data) // Data = Value
STRINGS(VALUE_TO_STRING,Data,2,0,Text) // STRINGS(VALUE_TO_STRING,Data,2,0,Text)
STRINGS(ADD,Text,'min',Text) // STRINGS(ADD,Text,"min",Text)
//
EndZero: // }
//
UI_DRAW(TEXT,FG_COLOR,104,62,Text) // UI_DRAW(TEXT,FG_COLOR,104,62,Text)
//
// Draw arrows if valid //
JR_LTEQ8(Index,0,NotGreatEnough) // if (Index > 0)
// {
UI_DRAW(ICON,FG_COLOR,96,60,ARROW_ICON,ICON_LEFT) // Draw bitmap
//
NotGreatEnough: // }
JR_GTEQ8(Index,STEPS,NotSmallEnough) // if (Index < STEPS)
// {
UI_DRAW(ICON,FG_COLOR,144,60,ARROW_ICON,ICON_RIGHT) // Draw bitmap
//
NotSmallEnough: // }
//
// Update display //
UI_DRAW(UPDATE) // UI_DRAW(UPDATE)
//
UI_BUTTON(WAIT_FOR_PRESS) // UI_BUTTON(WAIT_FOR_PRESS)
//
// Loop until "ENTER" //
UI_BUTTON(SHORTPRESS,ENTER_BUTTON,State) // UI_BUTTON(SHORTPRESS,ENTER_BUTTON,State)
// }
JR_FALSE(State,Loop) // while (!State)
//
// Save newsleep settings //
INFO(SET_MINUTES,Value) // INFO(SET_MINUTES,Value)
//
STRINGS(ADD,SETTINGS_DIR,'/',String) // STRINGS(ADD,SETTINGS_DIR,'/',String)
STRINGS(ADD,String,'Sleep.rtf',Name) // STRINGS(ADD,String,'Sleep.rtf',Name)
FILE(OPEN_WRITE,Name,Handle) // FILE(OPEN_WRITE,Name,Handle)
FILE(WRITE_TEXT,Handle,DEL_TAB,Text) // FILE(WRITE_TEXT,Handle,DEL_TAB,Text)
FILE(CLOSE,Handle) // FILE(CLOSE,Handle)
UI_BUTTON(FLUSH) // UI_BUTTON(FLUSH)
} // }
//
//
//!