Original link: http://www.cnblogs.com/NickQ/p/8748011.html
Environment: keil5.20 STM32F407ZGT6 LCD (320*240) stemwin:stemwin_library_v1.1.2
Get ready:
Stemwin on bare metal porting, need to prepare Stemwin library (stemwin:stemwin_library_v1.1.2.rar Link: https://pan.baidu.com/s/1rUxgjQwQPY0-m_ AEOFXMRW Password: FZP8), LCD empty project (with LCD draw point, read point function).
Start porting
The first step: Unzip the Stemwin_library_v1.1.2.rar, the directory structure is as follows
Open Directory stemwin_library_v1.1.2\libraries\stemwinlibrary522, copy config,inc,os,lib four directories into the project folder
Delete the lcdconf_lin_template.c,lcdconf_lin_template.h file in config.
Keep the lib files as needed to delete the other files. The F407,keil IDE with the CM4 kernel is used here, preserving the stemwin522_cm4_keil.lib.
Keep the appropriate files in the OS folder, depending on whether you are using the OS. The OS is not used here and the gui_x.c is reserved.
Add the left file into the project and include the path to the header file.
Leave the file.
The second step, modify some files,
Modify GUICONF.C to modify the amount of memory allocated to the GUI, here is 16K
1 // Define The available number of bytes available for the GUI 2 #define Gui_numbytes 0x4000 //16KB 2018/04/15-17:52:54 by Nick
Modifying the GUIConf.h configuration GUI-related features
1 #ifndef guiconf_h2 #defineGuiconf_h3 4 //Multi Layer/display Support5 #defineGui_num_layers 2//Maximum number of available layers6 7 //Multi tasking support8 #ifdef Os_support9 #defineGui_os (1)//Compile with multitasking supportTen #else One #defineGui_os (0) A #endif - - //Configuration of Touch Suppor the #ifndef Gui_support_touch - #defineGui_support_touch (1)//Support touchscreen - #endif - + //Default Font - #defineGui_default_font &gui_font6x8 + A //Configuration of available packages at #defineGui_support_mouse (1)/* Support a MOUSE */ - #defineGui_winsupport (1)/* Use Window Manager */ - #defineGui_support_memdev (1)/* Memory Device Package available */ - #defineGui_support_devices (1)/* Enable use of device pointers */ - - #endif/* Avoid Multiple inclusion */
Modify guidrv_template.c to modify PIP and read point functions, note to introduce your own LCD header file
1 /*********************************************************************2 *3 * _setpixelindex4 *5 * Purpose:6 * Sets the index of the given pixel. The upper layers7 * Calling this routine make sure, the coordinates is in range, so8 * That's no check on the parameters needs to be performed.9 */Ten Static void_setpixelindex (Gui_device * pdevice,intXintYintPixelindex) { One // A //Convert logical to physical coordinates (DEP. on LCDConf.h) - // - #if(lcd_mirror_x = = 1) | | (lcd_mirror_y = = 1) | | (Lcd_swap_xy = = 1) the intXphys, Yphys; - -Xphys =log2phys_x (X, y); -Yphys =log2phys_y (x, Y); + #else - #defineXphys x + #defineYphys y A #endif at Gui_use_para (pdevice); - Gui_use_para (x); - Gui_use_para (y); - Gui_use_para (pixelindex); - { -Lcd_drawpoint (Xphys,yphys,pixelindex);//2018/04/15-18:47:44 by Nick in } - #if(lcd_mirror_x = = 0) && (lcd_mirror_y = = 0) && (lcd_swap_xy = = 0) to #undefXphys + #undefYphys - #endif the } * $ /*********************************************************************Panax Notoginseng * - * _getpixelindex the * + * Purpose: A * Returns The index of the given pixel. The upper layers the * Calling this routine make sure, the coordinates is in range, so + * That's no check on the parameters needs to be performed. - */ $ StaticUnsignedint_getpixelindex (Gui_device * pdevice,intXinty) { $UnsignedintPixelindex; - // - //Convert logical to physical coordinates (DEP. on LCDConf.h) the // - #if(lcd_mirror_x = = 1) | | (lcd_mirror_y = = 1) | | (Lcd_swap_xy = = 1)Wuyi intXphys, Yphys; the -Xphys =log2phys_x (X, y); WuYphys =log2phys_y (x, Y); - #else About #defineXphys x $ #defineYphys y - #endif - Gui_use_para (pdevice); - Gui_use_para (x); A Gui_use_para (y); + { thePixelindex = Lcd_read_gram (Xphys,yphys);//2018/04/15-18:47:29 by Nick - } $ #if(lcd_mirror_x = = 0) && (lcd_mirror_y = = 0) && (lcd_swap_xy = = 0) the #undefXphys the #undefYphys the #endif the returnPixelindex; -}
Modify the guidrv_flexcolor.c file Configuration screen size (here is 320*240), you can use the macro, Nick here is not the reason for the macro is to facilitate the LCD initialization function automatically recognize the screen, passed to the GUI
1#include"nick_lcd.h" 2#include"GUI.h"3#include"Guidrv_flexcolor.h"4 5 6U16 Xsize_phys,ysize_phys,vxsize_phys,vysize_phys;//2018/04/15-18:48:10 by Nick7 8 #ifndef guicc_5659 #errorColor Conversion not defined!Ten #endif One #ifndef Guidrv_flexcolor A #errorNo Display Driver defined! - #endif - the voidLcd_x_config (void) {//2018/04/15-18:48:24 by Nick - //Physical display size -Xsize_phys = Lcddev.width;//To is adapted to x-screen size -Ysize_phys = Lcddev.height;//To is adapted to y-screen size +Vxsize_phys =Xsize_phys; -Vysize_phys =Ysize_phys; +Gui_device_createandlink (&guidrv_template_api,guicc_m565,0,0); ALcd_setsizeex (0, Xsize_phys,ysize_phys); atLcd_setvsizeex (0, Vxsize_phys,vysize_phys); - } - - - intLcd_x_displaydriver (unsigned layerindex, unsigned Cmd,void*pData) { - intR; in(void) Layerindex; -(void) PData; to + Switch(CMD) { - CaseLcd_x_initcontroller: { the return 0; * } $ default:Panax NotoginsengR =-1; - } the returnR; +}
Here, the modification is complete.
The third step is to write the test program.
#include"stm32f4xx_conf.h"#include"GUI.h"#include"nick_lcd.h"intMainvoid) {Lcd_init (0);//LCD InitializationRcc_ahb1periphclockcmd (rcc_ahb1periph_crc,enable);//enable CRC clock, otherwise stemwin can not be usedGui_init (); Gui_setcolor (gui_red); Gui_setbkcolor (Gui_blue); Gui_setfont (&gui_font24_ascii); Gui_clear (); Gui_dispstringat ("Hello World",Ten,Ten); }
You can see the phenomenon here.
Of course, by this stemwin the transplant is over. The next article will add a touch screen click Feature.
Stm32f407+stemwin Stemwin Transplant of learning notes