Rev 4973 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4973 | right-hear | 1 | #include |
2 | |||
3 | #define B_SZ 10 |
||
4 | |||
5 | static char * Title="BinClock"; |
||
6 | |||
5098 | clevermous | 7 | static void draw_small_box(int x,int y,int is_on) |
4973 | right-hear | 8 | { |
9 | __menuet__bar(x,y,B_SZ,B_SZ,is_on ? 0xFF0000 : 0x103000); |
||
10 | } |
||
11 | |||
5098 | clevermous | 12 | static void draw_box_group(int x,int y,int num) |
4973 | right-hear | 13 | { |
14 | int i,j; |
||
15 | char buf[2]; |
||
16 | buf[0]=(num&(1+2+4+8))+'0'; |
||
17 | buf[1]='\0'; |
||
18 | for(i=0;i<4;i++) |
||
19 | { |
||
20 | j=(B_SZ+2)*i; |
||
21 | draw_small_box(x,y+((B_SZ+2)*i),num & (1<<(3-i)) ? 1 : 0); |
||
22 | } |
||
23 | __menuet__bar(x,y+((B_SZ+2)*4),B_SZ,B_SZ,0x800000); |
||
24 | __menuet__write_text(x+2,y+((B_SZ+2)*4)+3,0xFFFFFF,buf,1); |
||
25 | } |
||
26 | |||
5098 | clevermous | 27 | static void draw_bcd_num(int x,int y,int num) |
4973 | right-hear | 28 | { |
29 | int v1,v2; |
||
30 | v1=(num>>4)&(1+2+4+8); |
||
31 | v2=num & (1+2+4+8); |
||
32 | draw_box_group(x,y,v1); |
||
33 | draw_box_group(x+B_SZ+2,y,v2); |
||
34 | } |
||
35 | |||
5098 | clevermous | 36 | static void draw_hms(int x,int y) |
4973 | right-hear | 37 | { |
38 | __u32 t; |
||
39 | int h,m,s; |
||
40 | t=__menuet__getsystemclock(); |
||
41 | s=(t & 0x00FF0000)>>16; |
||
42 | m=(t & 0x0000FF00)>>8; |
||
43 | h=(t & 0x000000FF); |
||
44 | draw_bcd_num(x,y,h); |
||
45 | x+=((B_SZ+2)<<1)+2; |
||
46 | draw_bcd_num(x,y,m); |
||
47 | x+=((B_SZ+2)<<1)+2; |
||
48 | draw_bcd_num(x,y,s); |
||
49 | } |
||
50 | |||
5098 | clevermous | 51 | static void draw_h(void) |
4973 | right-hear | 52 | { |
53 | draw_hms(22,28); |
||
54 | } |
||
55 | |||
5098 | clevermous | 56 | static void paint(void) |
4973 | right-hear | 57 | { |
58 | __menuet__window_redraw(1); |
||
59 | __menuet__define_window(100,100,40+((B_SZ+2)*6)+4,30+((B_SZ+2)*4)+16,0x03000080,0x800000FF,0x000080); |
||
60 | __menuet__write_text(3,3,0xFFFFFF,Title,strlen(Title)); |
||
61 | __menuet__bar(20,26,((B_SZ+2)*6)+4+2,4+((B_SZ+1)*4)+2,0); |
||
62 | draw_h(); |
||
63 | __menuet__window_redraw(2); |
||
64 | } |
||
65 | |||
66 | void main(void) |
||
67 | { |
||
68 | int i; |
||
69 | paint(); |
||
70 | for(;;) |
||
71 | { |
||
72 | __menuet__delay100(20); |
||
73 | i=__menuet__check_for_event(); |
||
74 | draw_h(); |
||
75 | switch(i) |
||
76 | { |
||
77 | case 1: |
||
78 | paint(); |
||
79 | continue; |
||
80 | case 2: |
||
81 | __menuet__getkey(); |
||
82 | continue; |
||
83 | case 3: |
||
84 | if(__menuet__get_button_id()==1) __menuet__sys_exit(); |
||
85 | continue; |
||
86 | } |
||
87 | } |
||
88 | }1)+2; |
||
89 |