Porting ucgui to S3C2410
1. Write drivers, mainly LCD drivers and touch screen drivers:
LCD Driver implements the image point function lcd2410_setpixel (X, Y, c ). For the LCD ON THE dm2410 lab board, the upper left is the origin (0, 0)
The Touch Screen driver calculates the coordinates (x, y) of the touch screen. For the touch screen on the dm2410 lab board, the lower left is the origin, but not necessarily)
2. Touch Screen calibration:
Measure the Minx, miny, and Maxx and Maxy coordinates in the lower left corner.
Enter guitouchconf. h as follows:
# Define gui_touch_ad_left minx
# Define gui_touch_ad_top Maxy
# Define gui_touch_ad_right Maxx
# Define gui_touch_ad_bottom miny
# Define gui_touch_swap_xy 0
# Define gui_touch_1__x 1
# Define gui_touch_mirror_y 1
3. Enter guiconf. h as follows:
# Define gui_ OS (1)/* compile with multitasking support */
# Define gui_support_touch (1)/* support a touch screen (req. Win-manager )*/
# Define gui_support_unicode (1)/* Support mixed ASCII/Unicode strings */
# Define gui_support_chinese (1)
# Define gui_default_font & gui_font6x8
# Define gui_alloc_size 22500/* size of dynamic memory... For WM and memory devices */
# Define gui_winsupport 1/* Window Manager package available */
# Define gui_support_memdev 1/* memory devices available */
# Define gui_support_aa 1
4. Fill in lcdconf. h as follows:
# Define LCD _xsize (800)/* X-resolution of LCD, logical COOR .*/
# Define LCD _ysize (480)/* Y-resolution of LCD, logical COOR .*/
# Define LCD _bitsperpixel (16)
# Define LCD _controller 1
# Define LCD _swap_rb_0 1
5. Connection Between ucgui and LCD Driver function:
In lcdwin. C, Remove useless header file inclusion.
# Define setpixel (X, Y, c) lcd2410_setpixel (X, Y, c)
# Define getpixel (x, y) lcd2410_getpixel (x, y)
Change "lcdsim_xx" to "lcd2410_xx". These two functions are in the LCD Driver file.
6. Some compilers do not initialize global variables, so do the following:
1) modify the following function: (located in guicore. c)
Static void _ initcontext (gui_context * pcontext ){
Memset (pcontext, 0, sizeof (gui_context); // Add
# If gui_support_memdev
Gui_selectlcd ();
# Else
LCD _setcliprectmax (); // LCD _l0_getrect
# Endif
Pcontext-> plcd_hl = & LCD _hl_apilist;
Pcontext-> pafont = gui_default_font;
Pcontext-> pcliprect_hl = & gui_context.cliprect;
Pcontext-> pensize = 1;
Pcontext-> drawmode = gui_drawmode_normal; // Add
Pcontext-> textmode = gui_textmode_normal; // Add
Pcontext-> textalign = gui_ta_left | gui_ta_top; // Add
Pcontext-> aa_hiresenable = 0; // Add
/* Variables in WM module */
# If gui_winsupport
Pcontext-> hawin = wm_getdesktopwindow ();
# Endif
/* Variables in gui_aa module */
Pcontext-> aa_factor = 3;
LCD _setbkcolor (gui_default_bkcolor );
LCD _setcolor (gui_default_color );
}
2) write the following functions:
Void myinit ()
{
Isinitialized = 0; // memdev
_ Isinited = 0; // win
WM _ createflags = 0;
Gui_cursor_pftemphide = NULL;
Gui_context.hdevdata = 0;
WM _ hcapture = 0;
WM _ hwinfocus = 0;
Wm_pfpollpid = 0;
Wm_pfhandlepid = 0;
Gui_pftimerexec = 0;
_ Keymsgcnt = 0;
}
This function should be called before gui_init () is called.
7. Because the UCOS operating system is not added, write the following function to simulate the latency:
Int Ost = 0;
Void my_x_delay (int p)
{
Int I = 0;
Int J = 0;
For (I = 0; I <p; ++ I)
For (j = 0; j <p; ++ J );
Ost + = P;
}
Void mydly (INT period)
{
Int endtime;
Int Trem;/* remaining time */
Ost = 0;
Endtime = ost + period;
While (Trem = endtime-ost, Trem> 0 ){
Gui_exec ();
My_x_delay (Trem> 100 )? 100: Trem );
}
}
Therefore, set gui_delay (x) In the example to mydly (X ).
8. Modify the following function to initialize the LCD: (located in LCD. c)
Int LCD _init (void ){
Int R;
Gui_debug_log ("\ nlcd_init ...");
LCD _setcliprectmax ();
If (r = lcd2410_init ())! = 0) // lcd2410_init (), set the LCD register
Return R;
# If LCD _num_displays> 1
If (r = LCD _l0_1_init ())! = 0)
Return R;
# Endif
LCD _initlut ();
/* Clear video memory */
LCD _setdrawmode (gui_drawmode_rev );
LCD _fillrect (0, 0, gui_xmax, gui_ymax );
LCD _setdrawmode (0 );
/* Switch LCD on */
LCD _on ();
Return 0;
}
9. Modify gui_x.c as follows:
Int gui_x_gettime (void)
{
Return 0;
// Return ostimeget ();
}
Void gui_x_delay (int ms)
{
// Ostimedly (MS );
Int I = 0;
For (I = 0; I <Ms * 10; ++ I)
;
}
Void gui_x_execidle (void ){
Gui_x_delay (1 );
}
Void gui_x_unlock (void)
{
// Ossempost (dispsem );
}
Void gui_x_lock (void)
{
// U8 err;
// Ossempend (dispsem, 0, & ERR );
}
U32 gui_x_gettaskid (void)
{
// If (bguiinitialized ){
// Return (int32u) (ostcbcur-> ostcbprio);/* <64 ??? ?? ??) */
//}
// Else {
Return 100 ;/*?? When a ± response? Latency> 64? ′? É */
//}
}
Void gui_x_initos (void)
{
// Dispsem = ossemcreate (1 );
}
Void gui_x_errorout (const char * s ){}
Void gui_x_warn (const char * s ){}
/*************************************** ******************************
*
* Gui_x_init ()
*
* Note:
* Gui_x_init () is called from gui_init is a possibility to init
* Some hardware which needs to be up and running before the GUI.
* If not required, leave this routine blank.
*/
Void gui_x_init (void ){
Settsinterrupt (); // interrupt settings for touch screen access
Gui_touch_setdefaultcalibration (); // key functions
}
Int gui_touch_x_measurex (void ){
Return TX;
}
Int gui_touch_x_measurey (void ){
Return ty;
}
Void gui_touch_x_activatex (void ){}
Void gui_touch_x_activatey (void ){}
Void gui_x_log (const char * s ){}
10. To respond to the touch screen, do the following:
1) when the touch screen is interrupted, the following function should be called after obtaining the touch coordinate:
Gui_touch_exec ();
2) modify the gui_touch_exec () function as follows ():
Void gui_touch_exec (void ){
# Ifndef Win32
Static u8 readstate;
Int X, Y;
/* Calculate min/max values */
If (xyminmax [gui_coord_x]. Min <xyminmax [gui_coord_x]. max ){
Xmin = xyminmax [gui_coord_x]. min;
Xmax = xyminmax [gui_coord_x]. Max;
} Else {
Xmax = xyminmax [gui_coord_x]. min;
Xmin = xyminmax [gui_coord_x]. Max;
}
If (xyminmax [gui_coord_y]. Min <xyminmax [gui_coord_y]. max ){
Ymin = xyminmax [gui_coord_y]. min;
Ymax = xyminmax [gui_coord_y]. Max;
} Else {
Ymax = xyminmax [gui_coord_y]. min;
Ymin = xyminmax [gui_coord_y]. Max;
}
/* Execute the state machine which reads the touch */
// Switch (readstate ){
// Case 0:
Yphys = touch_x_measurey ();
// Touch_x_activatey ();/* prepare X-measurement */
// Readstate ++;
// Break;
// Default:
Xphys = touch_x_measurex ();
// Touch_x_activatex ();/* prepare y-measurement */
/* Convert values into logical values */
# If! Gui_touch_swap_xy/* is x/y swapped? */
X = xphys;
Y = yphys;
# Else
X = yphys;
Y = xphys;
# Endif
If (x <xmin) | (x> xmax) | (Y <ymin) | (Y> Ymax )){
Gui_touch_storeunstable (-1,-1 );
} Else {
X = ad2x (X );
Y = ad2y (y );
Gui_touch_storeunstable (x, y );
}
/* Reset state machine */
// Readstate = 0;
// Break;
//}
# Endif/* Win32 */
}
Note: If the display is slow, check whether the cache is enabled. You can also modify the drawbitmap function as needed.
This article is original. Please indicate the source of the post.
Welcome to exchange: hongyhm@hotmail.com
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/yhmhappy2006/archive/2006/12/05/1431389.aspx