Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

hwtest.c

00001 /* Graphics Display Board Specific Operations Tests
00002    Copyright (C) 2003 Free Software Foundation, Inc.
00003    Written by Stephane Carrez (stcarrez@nerim.fr)       
00004 
00005 This file is free software; you can redistribute it and/or modify it
00006 under the terms of the GNU General Public License as published by the
00007 Free Software Foundation; either version 2, or (at your option) any
00008 later version.
00009 
00010 In addition to the permissions in the GNU General Public License, the
00011 Free Software Foundation gives you unlimited permission to link the
00012 compiled version of this file with other programs, and to distribute
00013 those programs without any restriction coming from the use of this
00014 file.  (The General Public License restrictions do apply in other
00015 respects; for example, they cover modification of the file, and
00016 distribution when not linked into another program.)
00017 
00018 This file is distributed in the hope that it will be useful, but
00019 WITHOUT ANY WARRANTY; without even the implied warranty of
00020 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00021 General Public License for more details.
00022 
00023 You should have received a copy of the GNU General Public License
00024 along with this program; see the file COPYING.  If not, write to
00025 the Free Software Foundation, 59 Temple Place - Suite 330,
00026 Boston, MA 02111-1307, USA.  */
00027 
00046 #include <gdm/display.h>
00047 #include <gdm/display-hw.h>
00048 #include <time.h>
00049 
00050 gdm_display display;
00051 
00052 /* Draw a small filled 8x8 square at the LCD X, Y location.  */
00053 static void
00054 draw (unsigned short x, unsigned short y, unsigned char data)
00055 {
00056   unsigned short y1;
00057 
00058   for (y1 = y; y1 < y + 8 && y1 < 128; y1++)
00059     {
00060       unsigned char line = y1 < 64;
00061 
00062       _gdm_hw_set_side (&display, line);
00063       _gdm_hw_set_x (&display, x);
00064       _gdm_hw_set_y (&display, y1 >= 64 ? y1 - 64 : y1);
00065       _gdm_hw_set_data (&display, data);
00066     }
00067 }
00068 
00069 /* Draw on the complete LCD display several crossing lines.  */
00070 static void
00071 draw_crossing (unsigned short cnt)
00072 {
00073   unsigned short x1, y1;
00074 
00075   /* Set the full display to crossing lines.  */
00076   for (x1 = 0; x1 <= 7; x1++)
00077     {
00078       unsigned short line;
00079 
00080       for (line = 0; line < 2; line++)
00081         {
00082           _gdm_hw_set_side (&display, line);
00083           _gdm_hw_set_x (&display, x1);
00084           _gdm_hw_set_y (&display, 0);
00085           for (y1 = 0; y1 < 64; y1++)
00086             {
00087               unsigned char val;
00088 
00089               val = 1 << ((cnt + y1) & 7);
00090               val |= 1 << ((cnt - y1) & 7);
00091               _gdm_hw_set_data (&display, val);
00092             }
00093         }
00094     }
00095 }
00096 
00097 int
00098 main ()
00099 {
00100   unsigned short x = 0;
00101   unsigned short y = 0;
00102   unsigned cnt = 0;
00103   unsigned short oldx = 0;
00104   unsigned short oldy = 0;
00105   unsigned short test = 0;
00106 
00107   gdm_initialize (&display);
00108 
00109   while (1)
00110     {
00111       switch (test % 2)
00112         {
00113         case 0:
00114           /* Draw the crossing lines on the display.  */
00115           draw_crossing (cnt++);
00116           udelay (10000);
00117           test++;
00118           break;
00119 
00120         case 1:
00121           /* Erase previous square and redraw it at its
00122              new location.  */
00123           draw (oldx, oldy, 0x00);
00124           oldx = x;
00125           oldy = y;
00126           draw (x, y++, 0xFF);
00127           udelay (100000);
00128 
00129           if (y >= 128)
00130             {
00131               y = 0;
00132               x++;
00133               if (x >= 8)
00134                 {
00135                   test++;
00136                   x = 0;
00137                 }
00138             }
00139           break;
00140         }
00141     }
00142 }