source: soft/tp16/correction/main_pipe.c @ 33

Last change on this file since 33 was 15, checked in by alain, 14 years ago

Introducing tp18

File size: 2.2 KB
Line 
1#include "stdio.h"
2
3#define NBLOCS 32
4#define THRESHOLD 200
5
6//////////////////////////////////////////////
7inline void  load_image(int index, char* buf)
8{
9        if( ioc_read(index*NBLOCS, buf, NBLOCS) )
10        {
11                tty_printf("echec ioc_read for image %d\n", index);
12                exit();
13        }
14}
15//////////////////////////////////////////////////////////////
16inline void modif_image(int index, char* buf_in, char* buf_out)
17{
18        int i;
19        for(i=0 ; i<128*128 ; i++) {
20                if( buf_in[i] > THRESHOLD )     buf_out[i] = 255;
21                else                            buf_out[i] = buf_in[i];
22        } 
23}
24//////////////////////////////////////////////
25inline void  display_image(int index, char* buf)
26{
27        if( fb_write(0,buf,128*128) )
28        { 
29                tty_printf("echec fb_write for image %d\n", index);
30                exit();
31        }
32} 
33///////////
34int main()
35{
36        char            buf_in_0[128*128];
37        char            buf_in_1[128*128];
38        char            buf_out_0[128*128];
39        char            buf_out_1[128*128];
40
41        /* Macro-period 0 */
42        tty_printf("\n *** macro-period 0 at date = %d \n", proctime());
43        load_image(0, buf_in_0);
44        ioc_completed();
45
46        /* Macro-period 1 */
47        tty_printf("\n *** macro-period 1 at date = %d \n", proctime());
48        load_image(1, buf_in_1);
49        modif_image(0, buf_in_0, buf_out_0);
50        ioc_completed();
51
52        /* Macro-preriod 2 */
53        tty_printf("\n *** macro-period 2 at date = %d \n", proctime());
54        load_image(2, buf_in_0);
55        display_image(0, buf_out_0);
56        modif_image(1, buf_in_1, buf_out_1);
57        fb_completed();
58        ioc_completed();
59
60        /* Macro-period 3 */
61        tty_printf("\n *** macro-period 3 at date = %d \n", proctime());
62        load_image(3,buf_in_1);
63        display_image(1, buf_out_1);
64        modif_image(2, buf_in_0, buf_out_0);
65        fb_completed();
66        ioc_completed();
67
68        /* Macro-period 4 */
69        tty_printf("\n *** macro-period 4 at date = %d \n", proctime());
70        load_image(4,buf_in_0);
71        display_image(2, buf_out_0);
72        modif_image(3, buf_in_1, buf_out_1);
73        fb_completed();
74
75        /* Macro-period 5 */
76        tty_printf("\n *** macro-period 5 at date = %d \n", proctime());
77        display_image(3, buf_out_1);
78        modif_image(4, buf_in_0, buf_out_0);
79        fb_completed();
80
81        /* Macro-period 6 */
82        tty_printf("\n *** macro-period 6 at date = %d \n", proctime());
83        display_image(4, buf_out_0);
84        fb_completed();
85
86        /* end program */
87        tty_printf("\n *** end of program at date = %d \n", proctime());
88        exit(0);
89
90        return 0;
91} // end main
92
Note: See TracBrowser for help on using the repository browser.