Transplantation of 1.6 Emwin and Ucgui of four-axis aircraft, comparison of Chinese characters ' external library and demo effect

Source: Internet
Author: User

Flight control of the remote control to do their own, so that the overall can master, can be controlled by the remote control parameters and flight mode to modify, and buy remote control is not to do so ha. After doing the picture transmission, the screen can also be real-time reality camera shot back picture, very good ha.

Do the remote control we choose is the Atom Battleship Development Board, the Development Board with the small overlord of the remote control, you can use this to control the flight control ha, memories of childhood has wood ... The board also has a ADXL345 accelerometer, which can also be used in the development of the board attitude control flight control posture. Ha.. It should be fun ...

The first step is to write a GUI interface, which gives me a headache. Amount: The first version of the plan is not a UI, just put the data to be displayed on the screen heap on the good ... In the past, in the school for the Atomic Development Board himself transplanted ucgui3.90a, and did a Ucos+ucgui+fatfs clean template works. intend to use directly. But found that there is a call Emwin, see the effect is much better, like Windows98 to windowsxp effect, originally on the UI interface annoyance, this effect is so much, decisive to use. Look at the next, in fact, is Ucgui, the amount. In fact, Ucgui is emwin ...

First Video:

Ucgui and Emwin transplant is similar, just emwin not open source, the transplant process some places slightly different.

First roughly say Ucgui transplant, transplant Ucgui is actually very easy, just modify gui\lcddriver inside the lcddummy.c file, fill void lcd_l0_setpixelindex (int x, int y, int pixelindex ) and unsigned int lcd_l0_getpixelindex (int x, int y) function, you can optimize the lcd_l0_fillrect to increase the refresh rate. However, there is a premise that the scanning direction of the screen needs to be aligned with the direction of the XY axis. This allows you to fill the color directly without changing the coordinate values of XY, which can be modified in bulk, much faster than a single point. Pro-Test STM32 6804 of the 3.5 screen can be about 10 times times faster. It's really that simple ...

Transplant of Emwin

We use the Stm32, can use Stemwin, but under the Stemwin, the inside of the source is not much, when the transplant will go to emwin inside to find, we directly transplant emwin good, Emwin changed to Stemwin is easy, the following again.

After downloading Emwin, Emwin may not need to download, in MDK inside is some ha, inside Keil\arm\segger\emwin, 5.0 version above MDK in keil\arm\pack\keil\mdk=middleware\5.1.4\ Emwin inside

Inside content such as 1:

Figure 1

There are so many files that need to be processed, guiconf, lcdconf, and guidrv_template, and if you need to add system support and touch, you need to port two files Gui_x_ucos and Gui_x_touch_analog.

Guiconf is the GUI configuration file, mainly initializes the GUI memory pool, lcdconf inside is mainly the LCD initialization function. Guidrv_template is mainly used to achieve the function of the dot and draw lines, it is important to note that to use the Guidrv_template file as I we drive function file, need to LCDCONF.C inside will be a # define Display_driver Guidrv_lin_32 into # define Display_driver.

The first step is to copy Lib and include into our project, Lib is the library file include is the header file ...

In my GUI there are several files, used Ucgui and transplanted Ucgui The following folder is certainly not unfamiliar.

Figure 2

The second step is to migrate the underlying code. In our lcddriver, in fact, as long as the implementation of a C file, guidrv_template.c, this file in the Sample\displaydriver folder in Figure 1 has.

GUIDRV_TEMPLATE.C inside the implementation of the DOT function can be, and then need to optimize, you can draw line, rectangle fill and other functions to optimize, there will be obvious effect.

The third step, in the LCDCONF.C inside the Lcd_x_displaydriver function Lcd_x_initcontroller: Fill in the initialization function of the screen, by the way, the touch of the initialization function can also be placed here.

Fourth step, in Guiconf.c, the GUI memory pool is initialized, and set the size of the memory, you can choose internal RAM and external Srram, here you need to see.

Fifth step, we ucos the system, and then add Gui_x_ucos to the project, to this, the transplant is finished, Emwin can run. Remember to add the library to the project.

If you try St's Stemwin, you only need to change the library to Stemwin, notify to open the CRC before GUI initialization, execute Rcc_ahbperiphclockcmd (RCC_AHBPERIPH_CRC, enable);

Touch porting:

Follow the above three steps, add the touch screen initialization function in, because we use analog chip to measure touch, and digital interrupt way a little different ha. But it's also very simple.

The first step: Set the macro definition inside the guiconf, #define Gui_support_touch (1) to turn on the touch screen function, found in the \sample\gui_x in Figure 1 Gui_x_touch_ Analog.c folder, if it is a chip using digital direct output coordinates, try the gui_x_touch_storestate.c file. Our touch screen output is analog data, so the use of gui_x_touch_analog.c, in the inside only need to implement

an int gui_touch_x_measurex (void) and an int gui_touch_x_measurey (void) function that directly invokes the Atom's Tp_read_xy2 (&x,&y); This touchscreen can also be used.

Transplantation of Chinese character library with external characters

A bit lazy ha, originally intended to use English forget, before Ucgui inside also did not transplant Chinese character library into, today think about, or get in it,

You can refer to this http://bbs.armfly.com/read.php?tid=1604 directly.

Here is only a general explanation of the implementation of the Chinese character principle.

We can see that the Gui_font is set to the following, in order to realize the function of Chinese characters, we need to implement the function of the structure of the formulation function.

1 structGui_font {2Gui_dispchar *Pfdispchar;3GUI_GETCHARDISTX *Pfgetchardistx;4Gui_getfontinfo *Pfgetfontinfo;5Gui_isinfont *Pfisinfont;6Gui_getcharinfo *Pfgetcharinfo;7   Consttgui_enc_apilist*Pafencode;8 U8 ysize;9 U8 ydist;Ten U8 Xmag; One U8 Ymag; A Union { -     Const voidGui_uni_ptr *Pfontdata; -     ConstGui_font_mono Gui_uni_ptr *Pmono; the     ConstGui_font_prop Gui_uni_ptr *Pprop; -     ConstGui_font_prop_ext Gui_uni_ptr *Ppropext; - } p; - U8 Baseline; +U8 lheight;/*Height of a small lower case character (a,x)*/ -U8 Cheight;/*Height of a small upper case character (A,X)*/ +};

Let's look at the definition of our Kanji font:

1Gui_const_storage Gui_charinfo gui_fonthz24_charinfo[2] =2 {     3{ A, A,2, (void*)"0:/system/font/asc12x24.bin"},    4{ -, -,3, (void*)"0:/system/font/hz24x24.bin"},        5 }; 6Gui_const_storage Gui_font_prop gui_fonthz24_prophz= { 7       0XA1A1,  8       0xFEFE,  9&gui_fonthz24_charinfo[1], Ten(void*)0,   One };  AGui_const_storage Gui_font_prop gui_fonthz24_propasc= {  -       0x0000,   -       0x007F,   the&gui_fonthz24_charinfo[0],  -(voidGui_const_storage *) &Gui_fonthz24_prophz, - };  -Gui_const_storage Gui_font gui_fonthz24 = + {  - Gui_fonttype_prop_hz, +      -,   A      -,   at     1,    -     1,    -(voidGui_const_storage *) &GUI_FONTHZ24_PROPASC -};
Gui_fonthz24 inside by pointing to Gui_fonthz24_prop (Gui_font inside the gui_font_prop is a linked list structure ha) ASC ASCII code font, and then through Gui_fonthz24_prop inside Gui_ Fonthz24_prophz points to the corresponding Chinese character font.
And we're looking at the corresponding gui_font inside.
1 Gui_dispchar *2 gui_getchardistx *3 gui_getfontinfo *4 Gui_isinfont * Pfisinfont; 5 Gui_getcharinfo * pfgetcharinfo; 6 const tgui_enc_apilist* pafencode;
Gui_fonttype_prop_hz,
Gui_fonttype_prop_hz for
 1   #define  Gui_fonttype_prop_hz Span style= "color: #008080;" >2   Guiprop_x_dispchar,  3   Guiprop_x_getchardistx,  4   Guimono_g             Etfontinfo,  5   Guimono_isinfont,  6  (Gui_getcharinfo *) 0  ,  7  (tgui_enc_apilist*) 0  
If you look at http://bbs.armfly.com/read.php?tid=1604, it's right up here. Guiprop_x_dispchar and Guiprop_x_getchardistx is implemented in GUICHARPEX.C, this is also the specific reading of the Chinese character library, where we read through the FATFA SD card font. If you also need to add additional fonts, just implement the corresponding Gui_font structure can be .....

Transplantation of 1.6 Emwin and Ucgui of four-axis aircraft, comparison of Chinese characters ' external library and demo effect

Related Article

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.