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