单片机 > 单片机程序设计 > 详情

stemwin 19264单色屏移植

发布时间:2020-06-16 发布时间:
|

一.GUIConf.C文件的修改  修改emwin内存


/*********************************************************************

*

*       Defines

*

**********************************************************************

*/

//

// Define the available number of bytes available for the GUI

//

#define USE_EXRAM 0//不支持外部SRAM

#define GUI_NUMBYTES (30*1024) //EMWIN 内存

#define GUI_BLOCKSIZE 0X80 //快大小


/*********************************************************************

*

*       Public code

*

**********************************************************************

*/

/*********************************************************************

*

*       GUI_X_Config

*

* Purpose:

*   Called during the initialization process in order to set up the

*   available memory for the GUI.

*/

void GUI_X_Config(void) 

{

    if(USE_EXRAM) //使用外部 RAM

    {

        //从外部 SRAM 中分配 GUI_NUMBYTES 字节的内存

        U32 *aMemory = mymalloc(SRAMEX,GUI_NUMBYTES);

        //为存储管理系统分配一个存储块

        GUI_ALLOC_AssignMemory((U32 *)aMemory, GUI_NUMBYTES);

    }

    else //使用内部 RAM

    {

        //从内部 RAM 中分配 GUI_NUMBYTES 字节的内存

        U32 *aMemory = mymalloc(SRAMIN,GUI_NUMBYTES);

        //为存储管理系统分配一个存储块

        GUI_ALLOC_AssignMemory((U32 *)aMemory, GUI_NUMBYTES);

    }

    


    //设置存储快的平均尺寸,该区越大,可用的存储快数量越少

    GUI_ALLOC_SetAvBlockSize(GUI_BLOCKSIZE);

    GUI_SetDefaultFont(GUI_FONT_6X8); //设置默认字体


//    GUI_DEVICE_CreateAndLink(DISPLAY_DRIVER, COLOR_CONVERSION, 0, 0);

//    LCD_SetSizeEx(0, 128, 64);

//    LCD_SetVSizeEx(0, 128, 64);

//    

}


二.修改GUIConf.H


1. #define GUI_OS                    (1)  // Compile with multitasking support   这里使用FREERTOS 


2.  #define GUI_SUPPORT_TOUCH       (0)  // Support touchscreen  dans单色屏不支持触摸


3.其余xuan选项默认


#define GUI_DEFAULT_FONT          &GUI_Font6x8


#define GUI_NUM_LAYERS            10    // Maximum number of available layers


#define GUI_SUPPORT_MOUSE             (1)    /* Support a mouse */

#define GUI_WINSUPPORT                (1)    /* Use window manager */

#define GUI_SUPPORT_MEMDEV            (1)    /* Memory device package available */

#define GUI_SUPPORT_DEVICES           (1)    /* Enable use of device pointers */


三.GUIDRV_Template.c  修改


1.static void _SetPixelIndex(GUI_DEVICE * pDevice, int x, int y, int PixelIndex)函数的修改  添加单色屏打点函数如下


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);

    {

      //

      // Write into hardware ... Adapt to your system

      //

      // TBD by customer...

      //

            LCD_DrawDots(xPhys, yPhys, PixelIndex);

    }

    #if (LCD_MIRROR_X == 0) && (LCD_MIRROR_Y == 0) && (LCD_SWAP_XY == 0)

      #undef xPhys

      #undef yPhys

    #endif

}


2.static unsigned int _GetPixelIndex(GUI_DEVICE * pDevice, int x, int y)   添加 单色屏获取某一点的颜色的函数 如下


static unsigned int _GetPixelIndex(GUI_DEVICE * pDevice, int x, int y) {

  unsigned 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);

    {

      //

      // Write into hardware ... Adapt to your system

      //

      // TBD by customer...

      //

      PixelIndex = LCD_GetDots(xPhys, yPhys);

    }

    #if (LCD_MIRROR_X == 0) && (LCD_MIRROR_Y == 0) && (LCD_SWAP_XY == 0)

      #undef xPhys

      #undef yPhys

    #endif

  return PixelIndex;

}


3.static void * _GetDevData(GUI_DEVICE * pDevice, int Index)的修改  如下


static void * _GetDevData(GUI_DEVICE * pDevice, int Index) {

  GUI_USE_PARA(pDevice);

  #if GUI_SUPPORT_MEMDEV

    switch (Index) {

    case LCD_DEVDATA_MEMDEV:

      //return (void *)&GUI_MEMDEV_DEVICE_16; // TBD: Has to be adapted to the right memory device depending on the used color depth!

     /* µ¥É«ÆÁ ·µ»Ø1 */

      return (void *)&GUI_MEMDEV_DEVICE_1; // TBD: Has to be adapted to the right memory device depending on the used color depth!    }

        }

  #else

    GUI_USE_PARA(Index);

  #endif

  return NULL;

}


四.LCDConf_FlexColor_Template.c文件修改


1.修改lcd X Y的尺寸,固定调色板模式为单色 


// 

// Physical display size

//

#define XSIZE_PHYS                               192 // To be adapted to x-screen size

#define YSIZE_PHYS                                64  // To be adapted to y-screen size


#define VXSIZE_PHYS                             192 //给定层虚拟区的X尺寸 (单位像素)

#define VYSIZE_PHYS                              64  //给定层虚拟区的Y尺寸 (单位像素)

#define LCD_CONTROLLER                   UC1604

#define LCD_BITSPERPIXEL                 1

#define LCD_USE_PARALLEL_16        0


//

// Color conversion

//

#define COLOR_CONVERSION   GUICC_1    //单色屏

//

// Display driver

//

#define DISPLAY_DRIVER &GUIDRV_Template_API


2. LCD_X_Config()函数


/*********************************************************************

*

*       LCD_X_Config

*

* Function description:

*   Called during the initialization process in order to set up the

*   display driver configuration.

*

*/

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_FLEXCOLOR, COLOR_CONVERSION, 0, 0);

  GUI_DEVICE_CreateAndLink(GUIDRV_TEMPLATE, GUICC_1, 0, 0);//

    //

  // Display driver configuration, required for Lin-driver

  //

  LCD_SetSizeEx (0, XSIZE_PHYS , YSIZE_PHYS);

  LCD_SetVSizeEx(0, VXSIZE_PHYS, VYSIZE_PHYS);

//  //

//  // Orientation

//  //

//  Config.Orientation = GUI_SWAP_XY | GUI_MIRROR_Y;

//  GUIDRV_FlexColor_Config(pDevice, &Config);

//  //

//  // Set controller and operation mode

//  //

//  PortAPI.pfWrite16_A0  = LcdWriteReg;

//  PortAPI.pfWrite16_A1  = LcdWriteData;

//  PortAPI.pfWriteM16_A1 = LcdWriteDataMultiple;

//  PortAPI.pfReadM16_A1  = LcdReadDataMultiple;

//  GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66708, GUIDRV_FLEXCOLOR_M16C0B16);

}


五.添加 GUI_X_FreeRTOS.C 


因为使用的freertos 所以需要添加STemWinLibrary522OS目录下的GUI_X_FreeRTOS.C 


六.添加stemwin库  STemWin522_CM4_OS_Keil.lib  


我是用的STM32F407 支持操作系统 su  所以添加STemWin522_CM4_OS_Keil.lib  


至此编译然后修改就可以了


关键字:stemwin  19264单色屏  移植

『本文转载自网络,版权归原作者所有,如有侵权请联系删除』

热门文章 更多
PIC单片机基础知识之二