查看: 5633|回复: 2

爱玩板卡+基于GD32F450的emwin图形库移植

[复制链接]
  • TA的每日心情
    奋斗
    2022-6-20 16:11
  • 签到天数: 19 天

    连续签到: 1 天

    [LV.4]偶尔看看III

    发表于 2017-6-28 21:10:38 | 显示全部楼层 |阅读模式
    分享到:
    老早就收到开发板,无奈最近一直很忙,终于抽出时间发帖,分享一下我移植emwin的过程。
    ①:调屏,要emwin首先要把TFT液晶屏调通,我用的是spi接口的显示器,分辨率320*240.屏幕调试很简单,商家给的驱屏程序移植过来改一下接口就能用。
    • 底层驱动:
    • void LCD_WR_DATA8( char da ) /* 发送数据-8位参数 */
    • {
    •         while ( RESET == spi_i2s_flag_get( SPI0, SPI_FLAG_TBE ) );
    •         LCD_DC_H;
    •         SPI_DATA( SPI0 ) = (uint32_t) da;
    • }
    • void LCD_WR_DATA( int da )
    • {
    •         while ( RESET == spi_i2s_flag_get( SPI0, SPI_FLAG_TBE ) );
    •         LCD_DC_H;
    •         SPI_DATA( SPI0 ) = (uint32_t) (da >> 8);
    •         while ( RESET == spi_i2s_flag_get( SPI0, SPI_FLAG_TBE ) );
    •         SPI_DATA( SPI0 ) = (uint32_t) da;
    • }
    • void LCD_WR_REG( char da )
    • {
    •         while ( RESET == spi_i2s_flag_get( SPI0, SPI_FLAG_TBE ) );
    •         LCD_DC_L;
    •         SPI_DATA( SPI0 ) = (uint32_t) da;
    • }
    • void LCD_WR_REG_DATA( int reg, int da )
    • {
    •         LCD_WR_REG( reg );
    •         LCD_WR_DATA( da );
    • }

    [color=rgb(51, 102, 153) !important]复制代码

    屏幕测试:显示"Hello World",附加垂直滚动效果
    视频:

    代码很简单:
    • while(1)
    •         {
    •                 LCD_ShowString(0,i++,"Hello World!");
    •                 delay_ms(10);
    •         }

    [color=rgb(51, 102, 153) !important]复制代码

    屏幕正常点亮之后就要进行第二步,添加emwin到工程。添加的文件不多,如下图所示:

    添加库文件之后,要配置emwin与屏幕驱动的接口。代码如下:
    • static void _SetPixelIndex(GUI_DEVICE * pDevice, int x, int y, int PixelIndex) {
    •     //
    •     // Convert logical into physical coordinates (Dep. on LCDConf.h)
    •     //
    •     #if (LCD_MIRROR_X == 1) || (LCD_MIRROR_Y == 1) || (LCD_SWAP_XY == 1)
    •       int xPhys, yPhys;
    •       xPhys = LOG2PHYS_X(x, y);
    •       yPhys = LOG2PHYS_Y(x, y);
    •     #else
    •       #define xPhys x
    •       #define yPhys y
    •     #endif
    •     GUI_USE_PARA(pDevice);
    •     GUI_USE_PARA(x);
    •     GUI_USE_PARA(y);
    •     GUI_USE_PARA(PixelIndex);
    •     {
    •                         POINT_COLOR = PixelIndex;
    •                         LCD_DrawPoint(x,y);
    •     }
    •     #if (LCD_MIRROR_X == 0) && (LCD_MIRROR_Y == 0) && (LCD_SWAP_XY == 0)
    •       #undef xPhys
    •       #undef yPhys
    •     #endif
    • }


    [color=rgb(51, 102, 153) !important]复制代码

    添加读点和写点函数emwin就能正常工作,但是我这个屏幕商家没提供读点函数,自己也不想捣鼓了,添加写点函数就能满足emwin大部分操作,我就只添加了LCD_DrawPoint(x,y);。
    下一步还得进行emwin的相关配置,比如屏幕分辨率,色彩,显存大小等。
    • #define XSIZE_PHYS  240 // To be adapted to x-screen size
    • #define YSIZE_PHYS  320 // To be adapted to y-screen size
    • void LCD_X_Config(void) {
    •   GUI_DEVICE * pDevice;
    • //  CONFIG_FLEXCOLOR Config = {0};
    • //  GUI_PORT_API PortAPI = {0};
    •   //
    •   // Set display driver and color conversion
    •   //
    •   pDevice = GUI_DEVICE_CreateAndLink(&GUIDRV_Template_API, GUICC_M565, 0, 0);
    •   //
    •   // Display driver configuration, required for Lin-driver
    •   //
    •   LCD_SetSizeEx (0, XSIZE_PHYS , YSIZE_PHYS);
    •   LCD_SetVSizeEx(0, VXSIZE_PHYS, VYSIZE_PHYS);
    •   //
    •   // Orientation
    •   //
    • }

    [color=rgb(51, 102, 153) !important]复制代码

    我给了64KB的内存空间供emwin使用。
    • #define GUI_NUMBYTES  64*1024
    • #define GUI_BLOCKSIZE 0X80  //块大小

    [color=rgb(51, 102, 153) !important]复制代码

    现在可以执行emwin初始化以及它自带的Demo了。跑起来看看效果:
    • int main()
    • {
    •         Lcd_Init();
    •         delay_ms(10);
    •         GUI_Init();
    •         GUI_Clear();
    •         GUIDEMO_Main();
    • }

    [color=rgb(51, 102, 153) !important]复制代码




    这个当时没有拍视频,demo的样子大家都知道。

    好了,到此为止GD32F450移植emwin就完成了,欢迎大家拍砖。

    分享我的预期成果:基于GD32F450以及ESP8266的网络信息发布屏
    回复

    使用道具 举报

    该用户从未签到

    发表于 2022-9-16 17:14:59 | 显示全部楼层
    你好。 请问下 ,移植的EMWIN 是什么版本的。
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    发表于 2022-9-16 20:13:37 | 显示全部楼层
    你好。 请问下 EMWIM 是什么版本的
    回复 支持 反对

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /2 下一条



    手机版|小黑屋|与非网

    GMT+8, 2024-5-4 11:21 , Processed in 0.131662 second(s), 19 queries , MemCache On.

    ICP经营许可证 苏B2-20140176  苏ICP备14012660号-2   苏州灵动帧格网络科技有限公司 版权所有.

    苏公网安备 32059002001037号

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.