Sistema l'errore da me commesso in fase di conversione...
[bertos.git] / drv / lcd_gfx_test.c
1 /**
2  * \file
3  * <!--
4  * Copyright 2006 Develer S.r.l. (http://www.develer.com/)
5  * This file is part of DevLib - See README.devlib for information.
6  * -->
7  *
8  * \version $Id$
9  *
10  * \author Bernardo Innocenti <bernie@develer.com>
11  *
12  * \brief dot-matrix LCD test.
13  */
14
15 /*#*
16  *#* $Log$
17  *#* Revision 1.3  2006/01/17 23:00:26  bernie
18  *#* Don't use hardcoded coordinates.
19  *#*
20  *#* Revision 1.2  2006/01/17 02:31:57  bernie
21  *#* Test gfx with the usual pentagons.
22  *#*
23  *#* Revision 1.1  2006/01/16 03:51:35  bernie
24  *#* Add LCD Qt emulator.
25  *#*
26  *#*/
27
28 #include <emul/emul.h>
29 #include <drv/lcd_gfx.h>
30 #include <gfx/gfx.h>
31
32 static void magic(struct Bitmap *bitmap, coord_t x, coord_t y)
33 {
34         static const coord_t coords[] = { 120, 34, 90, 90, 30, 90, 0, 34, 60, 0, 90, 90, 0, 34, 120, 34, 30, 90, 60, 0 };
35         unsigned int i;
36
37         gfx_moveTo(bitmap, coords[countof(coords)-2]/2 + x, coords[countof(coords)-1]/3 + y);
38         for (i = 0; i < countof(coords); i += 2)
39                 gfx_lineTo(bitmap, coords[i]/2 + x, coords[i+1]/3 + y);
40 }
41
42 int main(int argc, char *argv[])
43 {
44         emul_init(&argc, argv);
45         lcd_init();
46
47         coord_t x = 0, y = LCD_WIDTH / 2;
48         coord_t xdir = +1, ydir = -1;
49         Bitmap *bm = &lcd_bitmap;
50
51         for(;;)
52         {
53                 gfx_bitmapClear(bm);
54                 gfx_setClipRect(bm, 0, 0, bm->width, bm->height);
55                 gfx_rectDraw(bm, 10, 10, bm->width-10, bm->height-10);
56                 gfx_setClipRect(bm, 11, 11, bm->width-11, bm->height-11);
57                 magic(bm, x, y);
58
59                 x += xdir;
60                 y += ydir;
61                 if (x >= bm->width)  xdir = -1;
62                 if (x <= -50)        xdir = +1;
63                 if (y >= bm->height) ydir = -1;
64                 if (y <= -50)        ydir = +1;
65
66                 lcd_blit_bitmap(bm);
67                 emul_idle();
68                 usleep(10000);
69         }
70
71         emul_cleanup();
72         return 0;
73 }