2014-06-12 14:43:21 +04:00
|
|
|
#include<menuet/os.h>
|
|
|
|
|
|
|
|
#define B_SZ 10
|
|
|
|
|
|
|
|
static char * Title="BinClock";
|
|
|
|
|
2014-09-12 19:15:23 +04:00
|
|
|
static void draw_small_box(int x,int y,int is_on)
|
2014-06-12 14:43:21 +04:00
|
|
|
{
|
|
|
|
__menuet__bar(x,y,B_SZ,B_SZ,is_on ? 0xFF0000 : 0x103000);
|
|
|
|
}
|
|
|
|
|
2014-09-12 19:15:23 +04:00
|
|
|
static void draw_box_group(int x,int y,int num)
|
2014-06-12 14:43:21 +04:00
|
|
|
{
|
|
|
|
int i,j;
|
|
|
|
char buf[2];
|
|
|
|
buf[0]=(num&(1+2+4+8))+'0';
|
|
|
|
buf[1]='\0';
|
|
|
|
for(i=0;i<4;i++)
|
|
|
|
{
|
|
|
|
j=(B_SZ+2)*i;
|
|
|
|
draw_small_box(x,y+((B_SZ+2)*i),num & (1<<(3-i)) ? 1 : 0);
|
|
|
|
}
|
|
|
|
__menuet__bar(x,y+((B_SZ+2)*4),B_SZ,B_SZ,0x800000);
|
|
|
|
__menuet__write_text(x+2,y+((B_SZ+2)*4)+3,0xFFFFFF,buf,1);
|
|
|
|
}
|
|
|
|
|
2014-09-12 19:15:23 +04:00
|
|
|
static void draw_bcd_num(int x,int y,int num)
|
2014-06-12 14:43:21 +04:00
|
|
|
{
|
|
|
|
int v1,v2;
|
|
|
|
v1=(num>>4)&(1+2+4+8);
|
|
|
|
v2=num & (1+2+4+8);
|
|
|
|
draw_box_group(x,y,v1);
|
|
|
|
draw_box_group(x+B_SZ+2,y,v2);
|
|
|
|
}
|
|
|
|
|
2014-09-12 19:15:23 +04:00
|
|
|
static void draw_hms(int x,int y)
|
2014-06-12 14:43:21 +04:00
|
|
|
{
|
|
|
|
__u32 t;
|
|
|
|
int h,m,s;
|
|
|
|
t=__menuet__getsystemclock();
|
|
|
|
s=(t & 0x00FF0000)>>16;
|
|
|
|
m=(t & 0x0000FF00)>>8;
|
|
|
|
h=(t & 0x000000FF);
|
|
|
|
draw_bcd_num(x,y,h);
|
|
|
|
x+=((B_SZ+2)<<1)+2;
|
|
|
|
draw_bcd_num(x,y,m);
|
|
|
|
x+=((B_SZ+2)<<1)+2;
|
|
|
|
draw_bcd_num(x,y,s);
|
|
|
|
}
|
|
|
|
|
2014-09-12 19:15:23 +04:00
|
|
|
static void draw_h(void)
|
2014-06-12 14:43:21 +04:00
|
|
|
{
|
|
|
|
draw_hms(22,28);
|
|
|
|
}
|
|
|
|
|
2014-09-12 19:15:23 +04:00
|
|
|
static void paint(void)
|
2014-06-12 14:43:21 +04:00
|
|
|
{
|
|
|
|
__menuet__window_redraw(1);
|
|
|
|
__menuet__define_window(100,100,40+((B_SZ+2)*6)+4,30+((B_SZ+2)*4)+16,0x03000080,0x800000FF,0x000080);
|
|
|
|
__menuet__write_text(3,3,0xFFFFFF,Title,strlen(Title));
|
|
|
|
__menuet__bar(20,26,((B_SZ+2)*6)+4+2,4+((B_SZ+1)*4)+2,0);
|
|
|
|
draw_h();
|
|
|
|
__menuet__window_redraw(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void main(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
paint();
|
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
__menuet__delay100(20);
|
|
|
|
i=__menuet__check_for_event();
|
|
|
|
draw_h();
|
|
|
|
switch(i)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
paint();
|
|
|
|
continue;
|
|
|
|
case 2:
|
|
|
|
__menuet__getkey();
|
|
|
|
continue;
|
|
|
|
case 3:
|
|
|
|
if(__menuet__get_button_id()==1) __menuet__sys_exit();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|