Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1085 | pj | 1 | |
2 | #include "config.h" |
||
3 | |||
4 | #include <kernel/func.h> |
||
5 | #include <kernel/const.h> |
||
6 | #include <kernel/model.h> |
||
7 | #include <kernel/types.h> |
||
8 | |||
9 | #include <drivers/glib.h> |
||
10 | |||
11 | #include <stdlib.h> |
||
12 | |||
13 | #include "mutex.h" |
||
14 | #include "gclock.h" |
||
15 | |||
16 | #ifdef FULLCOLOR |
||
17 | #define COLORFG rgb16(255,255,255) |
||
18 | #define COLORBG rgb16(0,0,0) |
||
19 | #else |
||
20 | #define COLORFG 255 |
||
21 | #define COLORBG 0 |
||
22 | #endif |
||
23 | |||
24 | struct info { |
||
25 | int x; |
||
26 | int y; |
||
27 | }; |
||
28 | |||
29 | static TASK grxclock(struct info *ptr) |
||
30 | { |
||
31 | char buffer[16]; |
||
32 | int min,sec; |
||
33 | |||
34 | min=sec=0; |
||
35 | for (;;) { |
||
36 | sprintf(buffer,"%02i:%02i",min,sec); |
||
37 | #ifndef NOGRX |
||
38 | grxlock(); |
||
39 | grx_text(buffer,ptr->x,ptr->y,COLORFG,COLORBG); |
||
40 | grxunlock(); |
||
41 | #endif |
||
42 | sec++; |
||
43 | if (sec==60) { |
||
44 | sec=0; |
||
45 | min++; |
||
46 | if (min==60) min=0; |
||
47 | } |
||
48 | task_endcycle(); |
||
49 | } |
||
50 | return NULL; |
||
51 | } |
||
52 | |||
53 | PID gclock_init(int x, int y) |
||
54 | { |
||
55 | SOFT_TASK_MODEL model; |
||
56 | struct info *ptr; |
||
57 | |||
58 | ptr=(struct info *)malloc(sizeof(struct info)); |
||
59 | if (ptr==NULL) return -1; |
||
60 | ptr->x=x+1; |
||
61 | ptr->y=y+1; |
||
62 | |||
63 | #ifndef NOGRX |
||
64 | grxlock(); |
||
65 | grx_box(x-1,y-1,x+GCLOCKDX-1,y+GCLOCKDY-1,COLORBG); |
||
66 | grx_rect(x-1,y-1,x+GCLOCKDX-1,y+GCLOCKDY-1,COLORFG); |
||
67 | grx_text("00:00",ptr->x,ptr->y,COLORFG,COLORBG); |
||
68 | grx_text("Clock",ptr->x,ptr->y-12,COLORFG,COLORBG); |
||
69 | grxunlock(); |
||
70 | #endif |
||
71 | |||
72 | soft_task_default_model(model); |
||
73 | soft_task_def_met(model,5000); |
||
74 | soft_task_def_wcet(model,5000); |
||
75 | soft_task_def_period(model,1000000); |
||
76 | soft_task_def_periodic(model); |
||
77 | soft_task_def_arg(model,(void*)ptr); |
||
78 | //soft_task_def_ctrl_jet(model); |
||
79 | |||
80 | return task_create("grxclock", grxclock, &model, NULL); |
||
81 | } |