Rt-thread Study notes (12)---Turn on the Rtgui-based LCD display function (2)

Source: Internet
Author: User

Software Environment: Win7,keil MDK 4.72a, IAR ewarm 7.2, GCC 4.2,python 2.7, SCons 2.3.2

Hardware environment: Armfly Stm32f103ze-ek v3.0 Development Board

Reference article: Rt-thread Programming Guide

rt-thread_1.2.0+lwip+rtgui0.8.0 Transplant Experience

Rt-thread RTOs Components: Rtgui tutorial Hello World

Our LCD driver was ported in the previous article and then compiled and debugged

"1" is compiled with scons on the command line and "command too long" error appears

Error that the command line is too long when you see link, such as.


Refer to the article fix scons compile-time Armlink link Error Solution:

(1) using notepad++ to open C:\Python27\Lib\site-packages\scons-2.3.2\SCons\Platform\__init__.py, navigate to 205 lines, modify the following code:

prefix = env.subst (' $TEMPFILEPREFIX ')
If not prefix:
#prefix = ' @ '
prefix = ' '

Save after modification.

< Span style= "font-size:12px" > (2) using Notepad++ Open the Stm32f103ze-ek/sconstruct file and navigate to the vicinity of Line 27, as in the following code:

< Span style= "font-size:12px" >if rtconfig. PLATFORM = = ' IAR ':
Env. Replace (cccom = [' $CC $CCFLAGS $CPPFLAGS $_cppdefflags $_cppincflags-o $TARGET $SOURCES '])
Env. Replace (arflags = ["])
Env. Replace (linkcom = [' $LINK $SOURCES $LINKFLAGS-o $TARGET--map project.map '])

if rtconfig. PLATFORM = = ' ARMCC ':
env["tempfile"] = SCons.Platform.TempFileMunge
# env["linkcom"] = "${tempfile (' $LINK-o $ TARGET $SOURCES ')} "
env[" linkcom "] =" $LINK-o $TARGET $LINKFLAGS ${tempfile ('--via $SOURCES ')} "
env[" Tempfileprefix "] =" # arm tool chain


Export (' rtt_root ')
Export (' rtconfig ')
span>

... ...

Save after the modification is complete.

And then re-scons the compilation, the results are as follows:



"2" Rtgui run test

Download the compiled generated code to the Development Board, reset to run, the terminal is displayed as follows:

< Span style= "font-size:12px" >\ | /
-Rt-thread Operating System
/| \ 1.2.2 Build APR
2006-2013 Copyright by rt-thread team
found P Art[0], begin:219152384, SIZE:1.690GB
dm9000 id:0x90000a46
Finsh/>operating at 100M full duplex mode
lwip- 1.4.1 initialized!
rtgui:could not open the font file:/resource/hzk16.fnt
Rtgui:please mount The FS first and make sure the file are there

Set Font size to +
W25Q64BV or W25Q64CV detection
F Lash0 mount to/.
sd0 Mount To/dev.
...
Hard fault on thread:init

thread pri status SP stack size max used left tick error
--------------------- -----------------------------------------
...

< Span style= "font-size:12px" > Obviously, the root of the mount is not /resource/hzk16.fnt file, so error, because the library occupies a large space, so Span style= "font-size:12px" does not currently support Chinese character functions. Open the Rtconfig.h file, locate near line 173, comment out the rtgui_using_fonthz definition, and modify the following:

< Span style= "font-size:12px" >/* Section:rt-thread/gui */
#define RT_USING_RTGUI

/* Name length of Rtgui object */
#define RTGUI_NAME_MAX
/* Support for weight font */
#define RTGUI_USING_FONT16
/* Support Chinese font */
//#define RTGUI_USING_FONTHZ
/* Use DFS as file Interface */
#define RTGUI_USING_DFS_FILERW
/* Use font file as Chinese font */
#define RTGUI_USING_HZ_FILE
/* Use Chinese bitmap font */
#define RTGUI_USING_HZ_BMP
/* Use small size in Rtgui */
#define Rtgui_using_small_ SIZE

The debug trace found that when executing _graphic_driver_vmode_init (), the Init process crashed, followed the function, and found that the INIT process crashed when the Rt_memset () was executed. Open rtgui/server/driver.c, locate near line 46, comment out rt_memset () This function, the code is modified as follows:

static void _graphic_driver_vmode_init (void) {if (_vfb_driver.width! = _driver.width | | _vfb_driver.height! = _ Driver.height) {if (_vfb_driver.framebuffer! = rt_null) Rtgui_free ((void*) _vfb_driver.framebuffer); _vfb_ Driver.device = Rt_null;_vfb_driver.pixel_format = Rtgui_vfb_pixel_fmt;_vfb_driver.bits_per_pixel = rtgui_color_get_ Bits (RTGUI_VFB_PIXEL_FMT); _vfb_driver.width  = _driver.width;_vfb_driver.height = _driver.height;_vfb_ Driver.pitch  = _driver.width * _ui_bitbytes (_vfb_driver.bits_per_pixel); _vfb_driver.framebuffer = Rtgui_malloc ( _vfb_driver.height * _vfb_driver.pitch);                Rt_memset (_vfb_driver.framebuffer, 0, _vfb_driver.height * _vfb_driver.pitch); _vfb_driver.ext_ops = RT_NULL;_vfb_ Driver.ops = Rtgui_framebuffer_get_ops (_vfb_driver.pixel_format);}}

Save after modification, recompile download, reset run, at this point the terminal displays

Finsh/>list_thread ()
Thread pri status SP stack size max used left tick error
-------- ---- ------- ---------- ---------- ---------- ---------- ---
Rtgui 0x0f suspend 0x000000f8 0x00000400 0X000000F8 0x00000005 000
Tshell 0x14 Ready 0x00000090 0x00000800 0x000001b0 0x00000008-04
Tidle 0x1f Ready 0x0000005c 0x00000100 0x00000064 0x0000001f 000
LED 0x14 suspend 0x00000078 0x00000200 0x00000078 0x00000005 000
0, 0x00000000
Finsh/>

The message shows that the Rtgui thread is in a pending state, and the following will load some demo programs for testing.

"3" Join Rtgui Demo Routine

(1) Copy the GitHub site's rtgui-master/demo/examples to the Rt-thread-1.2.2/components/rtgui directory and run SCons--tartget=mdk4-s at the command line, Once you reopen the project, you can see that the Gui-examples group has joined in, such as:


(2) Open application.c, locate to 129 line near, add Gui_appplication_init (), modify as follows:

... ...

#ifdef Rt_using_rtgui
{
extern void Rt_hw_lcd_init ();
extern void Rtgui_touch_hw_init (void);
extern void Gui_application_init (void);
rt_device_t LCD;

/* Init LCD */
Rt_hw_lcd_init ();

... ...

#ifdef rtgui_using_calibration
Calibration_set_restore (Cali_setup);
Calibration_set_after (Cali_store);
Calibration_init ();
#endif/* #ifdef rtgui_using_calibration */
Gui_application_init ();
}
#endif/* Rt_using_rtgui */

(3) Open Gui_examples Working Group under DEM_APPLICATION.C, navigate to the vicinity of 129 lines, the code is modified as follows:

vo ID gui_application_init (void)
{
Static rt_bool_t inited = Rt_false;

if (inited = = rt_false)/* Avoid repeating initialization */
{
rt_thread_t tid;

Tid = rt_thread_create ("WB",
gui_application_entry , RT _null,
2048 * 2, 25, 10);

if (tid! = rt_null)
Rt_thread_startup (TID);

inited = rt_true;
}
}

#ifdef rt_using_finsh
#include <finsh.h>
void Gui_application ()
{
Span style= "COLOR: #ff0000" >gui_application_init ();
}
/* Finsh terminal can execute gui_appplication () command to run the above function */
Finsh_function_export ( gui_application , gui Application Demo )
#endif

Then navigate to the next 31 lines and change the name of the Gui_appliction thread entry to the following:

... ...

struct Rtgui_win *main_win;
static void gui_application_entry(void *parameter)
{
struct Rtgui_app *app;
struct Rtgui_rect rect;

App = Rtgui_app_create ("Gui_demo");
if (app = = rt_null)
Return
... ...

Then locate the code near 64 lines to 120, starting with Demo_view_box (), until the code between Rtgui_win_show () is left Demo_view_button (), the other code is commented out and modified as follows:

< /p>

<pre name= "code" class= "CPP" >rtgui_container_add_child (Rtgui_container (Main_win), Rtgui_widget (The_notebook    ));    Demo_view_box ();    /* Initialize the view of each example *//* Demo_view_benchmark (); DEMO_VIEW_DC (); #ifdef Rtgui_using_ttf Demo_view_ttf (); #endif #ifndef rtgui_using_small_size demo_view_dc_buffer (); endif//demo_view_animation (); #ifndef rtgui_using_small_size Demo_view_instrument_panel (); #endif//demo_view_buff    Er_animation ();    Demo_view_window ();    Demo_view_label (); */Demo_view_button ();/* Demo_view_checkbox ();    Demo_view_progressbar ();    Demo_view_scrollbar ();    Demo_view_radiobox ();    Demo_view_textbox ();    Demo_view_listbox ();    Demo_view_menu ();    Demo_view_listctrl ();    Demo_view_combobox ();    Demo_view_slider ();    Demo_view_notebook ();    Demo_view_mywidget (); Demo_plot ();d emo_view_digtube (); #if defined (RTGUI_USING_DFS_FILERW) demo_view_edit ();//demo_view_bmp (); #endif # if Defined (RTGUI_USING_DFS_FILERW) Demo_fn_view (); #endif # if 0#if defiNed (RTGUI_USING_DFS_FILERW) demo_view_image (); #endif #ifdef rt_using_module#if defined (RTGUI_USING_DFS_FILERW) demo    _view_module (); #endif #endif Demo_listview_view (); Demo_listview_icon_view (); #endif */Rtgui_win_show (Main_win, Rt_false);

Then save, re-scons the compilation, download to the Development Board, you can see the following effect:


As a result of the shooting, the foreground color of the four buttons that are actually left should be red, blue, gray, and gray, but they are not actually displayed. and Rtgui default background color is gray, to this can be basically explained that the LCD bottom boot can work normally, the remaining problems left behind to solve.


                                                 

Rt-thread Study notes (12)---Turn on the Rtgui-based LCD display function (2)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.