学习目标

  • 体会移植流程
  • 了解LVGL不同平台的移植

    学习内容

    ST7789屏幕驱动

    原理图

    130.png131.png
    引脚对应关系:

  • OLED_SCL: GP06

  • OLED_SDA: GP08
  • OLED_RST: GP05
  • OLED_DC: GP07

    驱动获取

    通过购买渠道获取相关资料:
    132.png
    解压,选择对应的文件夹,我们选择串口,因为我们采用的是单线SPI进行数据传输的。
    133.png
    接着选择可参考的例程,由于我们需要的平台是鸿蒙的,没有提供对应平台的示例代码,因此我们需要通过其他平台的驱动进行移植,我们任选一个即可,在此,我选择的是stm32平台的。
    135.png
    打开分析后,大致可以得出结论:
    lcd.clcd.h是驱动文件,有oledfont.hbmp.h这两个文件依赖

    移植准备

  1. lcd.h拷贝到项目中,进行重命名,修改为lcd_st7789.h
  2. lcd.c拷贝到项目中,进行重命名,修改为lcd_st7789.c
  3. oledfont.h拷贝到项目中
  4. bmp.h拷贝到项目中
  5. 将官方示例逻辑拷贝到自己项目中,如下:

    1. u8 i, m;
    2. float t = 0;
    3. delay_init(); // 延时函数初始化
    4. NVIC_Configuration(); // 设置NVIC中断分组2:2位抢占优先级,2位响应优先级
    5. Lcd_Init(); // 初始化OLED
    6. LCD_Clear(WHITE);
    7. BACK_COLOR = WHITE;
    8. LED_ON;
    9. while (1)
    10. {
    11. LCD_ShowChinese(10, 0, 0, 32, RED); // 中
    12. LCD_ShowChinese(45, 0, 1, 32, RED); // 景
    13. LCD_ShowChinese(80, 0, 2, 32, RED); // 园
    14. LCD_ShowChinese(115, 0, 3, 32, RED); // 电
    15. LCD_ShowChinese(150, 0, 4, 32, RED); // 子
    16. LCD_ShowChinese(10, 75, 0, 16, RED); // 中
    17. LCD_ShowChinese(45, 75, 1, 16, RED); // 景
    18. LCD_ShowChinese(80, 75, 2, 16, RED); // 园
    19. LCD_ShowChinese(115, 75, 3, 16, RED); // 电
    20. LCD_ShowChinese(150, 75, 4, 16, RED); // 子
    21. LCD_ShowString(10, 35, "2.4 TFT SPI 240*320", RED);
    22. LCD_ShowString(10, 55, "LCD_W:", RED);
    23. LCD_ShowNum(70, 55, LCD_W, 3, RED);
    24. LCD_ShowString(110, 55, "LCD_H:", RED);
    25. LCD_ShowNum(160, 55, LCD_H, 3, RED);
    26. for (i = 0; i < 5; i++)
    27. {
    28. for (m = 0; m < 6; m++)
    29. {
    30. LCD_ShowPicture(0 + m * 40, 120 + i * 40, 39 + m * 40, 159 + i * 40);
    31. }
    32. }
    33. while (1)
    34. {
    35. LCD_ShowNum1(80, 95, t, 5, RED);
    36. t += 0.01;
    37. }
    38. }

    驱动初始化修改

  6. lcd_st7789.hinclude问题。

  • 删除#include "sys.h" #include "stdlib.h"引用
  • 添加引脚定义:
    1. #define SDC IOT_IO_NAME_6
    2. #define SDIN IOT_IO_NAME_8
    3. #define RST IOT_IO_NAME_5
    4. #define DC IOT_IO_NAME_7
  1. 引入gpio相关的头

    1. #include "iot_gpio.h"
    2. #include "iot_gpio_ex.h"
  2. 当前平台,gpio功能调用修改 ```c //————————-测试LED端口定义————————

define LED_ON GPIO_ResetBits(GPIOA,GPIO_Pin_15)

define LED_OFF GPIO_SetBits(GPIOA,GPIO_Pin_15)

//————————-OLED端口定义————————

define OLED_SCLK_Clr() GPIO_ResetBits(GPIOA,GPIO_Pin_0)//SDC

define OLED_SCLK_Set() GPIO_SetBits(GPIOA,GPIO_Pin_0)

define OLED_SDIN_Clr() GPIO_ResetBits(GPIOA,GPIO_Pin_1)//SDA

define OLED_SDIN_Set() GPIO_SetBits(GPIOA,GPIO_Pin_1)

define OLED_RST_Clr() GPIO_ResetBits(GPIOA,GPIO_Pin_2)//RES

define OLED_RST_Set() GPIO_SetBits(GPIOA,GPIO_Pin_2)

define OLED_DC_Clr() GPIO_ResetBits(GPIOA,GPIO_Pin_3)//DC

define OLED_DC_Set() GPIO_SetBits(GPIOA,GPIO_Pin_3)

define OLED_CS_Clr() GPIO_ResetBits(GPIOA,GPIO_Pin_4)//CS

define OLED_CS_Set() GPIO_SetBits(GPIOA,GPIO_Pin_4)

define OLED_BLK_Clr() GPIO_ResetBits(GPIOA,GPIO_Pin_5)//BLK

define OLED_BLK_Set() GPIO_SetBits(GPIOA,GPIO_Pin_5)

  1. ```c
  2. #define SDC_FUNC IOT_GPIO_FUNC_GPIO_6_GPIO
  3. #define SDIN_FUNC IOT_GPIO_FUNC_GPIO_8_GPIO
  4. #define RST_FUNC IOT_GPIO_FUNC_GPIO_5_GPIO
  5. #define DC_FUNC IOT_GPIO_FUNC_GPIO_7_GPIO
  6. #define OLED_SCLK_Set() IoTGpioSetOutputVal(SDC, 1)
  7. #define OLED_SCLK_Clr() IoTGpioSetOutputVal(SDC, 0)
  8. #define OLED_SDIN_Set() IoTGpioSetOutputVal(SDIN, 1);
  9. #define OLED_SDIN_Clr() IoTGpioSetOutputVal(SDIN, 0);
  10. #define OLED_RST_Set() IoTGpioSetOutputVal(RST, 1);
  11. #define OLED_RST_Clr() IoTGpioSetOutputVal(RST, 0);
  12. #define OLED_DC_Set() IoTGpioSetOutputVal(DC, 1);
  13. #define OLED_DC_Clr() IoTGpioSetOutputVal(DC, 0);
  • 去掉当前原理图中没有设计的引脚功能定义
    1. 修改delay_ms实现,替换为usleep
      1. #include <unistd.h>
      2. ....
      3. usleep(ms * 1000);
  1. 编写当前平台GPIO初始化逻辑

    1. GPIO_InitTypeDef GPIO_InitStructure;
    2. RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_AFIO, ENABLE); //使能A端口时钟
    3. GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
    4. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_15;
    5. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出
    6. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//速度50MHz
    7. GPIO_Init(GPIOA, &GPIO_InitStructure); //初始化GPIOA
    8. GPIO_SetBits(GPIOA,GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_15);
    1. #define LCD_PIN_INIT() \
    2. IoTGpioInit(SDC); \
    3. IoTGpioSetFunc(SDC, SDC_FUNC); \
    4. IoTGpioSetDir(SDC, IOT_GPIO_DIR_OUT); \
    5. IoTGpioInit(SDIN); \
    6. IoTGpioSetFunc(SDIN, SDIN_FUNC); \
    7. IoTGpioSetDir(SDIN, IOT_GPIO_DIR_OUT); \
    8. IoTGpioInit(RST); \
    9. IoTGpioSetFunc(RST, RST_FUNC); \
    10. IoTGpioSetDir(RST, IOT_GPIO_DIR_OUT); \
    11. IoTGpioInit(DC); \
    12. IoTGpioSetFunc(DC, DC_FUNC); \
    13. IoTGpioSetDir(DC, IOT_GPIO_DIR_OUT);
  2. Lcd_init() 中调用GPIO初始化

    1. void Lcd_Init(void)
    2. {
    3. LCD_PIN_INIT();
    4. ......
    5. }
  3. 注释lcd_st7789.c中没有用到的gpio调用。

    1. // OLED_CS_Clr();
    2. ......
    3. // OLED_CS_Set();
    4. ......
    5. // OLED_BLK_Set();
  4. 注释无法通过编译的函数:

    移植出现的问题

    当编译通过,烧录运行后,发现屏幕无法显示。
    需要怀疑的问题:

  5. 移植过程中,GPIO是否初始化正确。

  6. 示例代码是否有编写。

以上为代码级别的问题,确保无误后,需要怀疑结构性问题。

  1. 当前移植的驱动,是通过gpio引脚,发送高低电平的方式,模拟spi协议进行LCD屏幕控制。

也就是当前移植的驱动为软实现,软实现受到当前执行效率的限制,可能无法达到屏幕驱动的速率。

SPI硬实现

  1. 修改引脚功能

    1. #define SDC_FUNC IOT_GPIO_FUNC_GPIO_6_SPI0_CK
    2. #define SDIN_FUNC IOT_GPIO_FUNC_GPIO_8_SPI0_TXD
  2. SPI初始化

    1. #define ST7789_SPI_INIT() \
    2. IoTSpiCfgInitParam param; \
    3. param.isSlave = 0; \
    4. IoTSpiCfgBasicInfo info; \
    5. info.cpol = IOT_SPI_CFG_CLOCK_CPOL_1; \
    6. info.cpha = IOT_SPI_CFG_CLOCK_CPHA_1; \
    7. info.framMode = IOT_SPI_CFG_FRAM_MODE_MOTOROLA; \
    8. info.dataWidth = IOT_SPI_CFG_DATA_WIDTH_E_8BIT; \
    9. info.endian = IOT_SPI_CFG_ENDIAN_LITTLE; \
    10. info.pad = 31; \
    11. info.freq = 40000000; \
    12. IoTSpiInit(0, param, &info);
  3. lcd_st7789.cLcd_init()初始化中调用

    1. void Lcd_Init(void)
    2. {
    3. LCD_PIN_INIT();
    4. LCD_SPI_INIT();
    5. ......
    6. }
  4. 修改LCD_Writ_Bus函数如下

    1. void LCD_Writ_Bus(u8 dat)
    2. {
    3. // u8 i;
    4. // // OLED_CS_Clr();
    5. // for(i=0;i<8;i++)
    6. // {
    7. // OLED_SCLK_Clr();
    8. // if(dat&0x80)
    9. // {OLED_SDIN_Set();}
    10. // else
    11. // {OLED_SDIN_Clr();}
    12. // OLED_SCLK_Set();
    13. // dat<<=1;
    14. // }
    15. // // OLED_CS_Set();
    16. IoTSpiHostWrite(0, &dat, 1);
    17. }

    完整代码

    ```c

    ifndef __LCD_H

    define __LCD_H

    include “iot_gpio.h”

    include “iot_gpio_ex.h”

    include “iot_spi.h”

define USE_HORIZONTAL 0 //设置横屏或者竖屏显示 0或1为竖屏 2或3为横屏

if USE_HORIZONTAL==0||USE_HORIZONTAL==1

define LCD_W 240

define LCD_H 240

else

define LCD_W 240

define LCD_H 240

endif

define u8 unsigned char

define u16 unsigned int

define u32 unsigned long

define SDC IOT_IO_NAME_6

define SDIN IOT_IO_NAME_8

define RST IOT_IO_NAME_5

define DC IOT_IO_NAME_7

define SDC_FUNC IOT_GPIO_FUNC_GPIO_6_SPI0_CK

define SDIN_FUNC IOT_GPIO_FUNC_GPIO_8_SPI0_TXD

define RST_FUNC IOT_GPIO_FUNC_GPIO_5_GPIO

define DC_FUNC IOT_GPIO_FUNC_GPIO_7_GPIO

define LCD_PIN_INIT() \

  1. IoTGpioInit(SDC); \
  2. IoTGpioSetFunc(SDC, SDC_FUNC); \
  3. IoTGpioSetDir(SDC, IOT_GPIO_DIR_OUT); \
  4. IoTGpioInit(SDIN); \
  5. IoTGpioSetFunc(SDIN, SDIN_FUNC); \
  6. IoTGpioSetDir(SDIN, IOT_GPIO_DIR_OUT); \
  7. IoTGpioInit(RST); \
  8. IoTGpioSetFunc(RST, RST_FUNC); \
  9. IoTGpioSetDir(RST, IOT_GPIO_DIR_OUT); \
  10. IoTGpioInit(DC); \
  11. IoTGpioSetFunc(DC, DC_FUNC); \
  12. IoTGpioSetDir(DC, IOT_GPIO_DIR_OUT);

define ST7789_SPI_INIT() \

  1. IoTSpiCfgInitParam param; \
  2. param.isSlave = 0; \
  3. IoTSpiCfgBasicInfo info; \
  4. info.cpol = IOT_SPI_CFG_CLOCK_CPOL_1; \
  5. info.cpha = IOT_SPI_CFG_CLOCK_CPHA_1; \
  6. info.framMode = IOT_SPI_CFG_FRAM_MODE_MOTOROLA; \
  7. info.dataWidth = IOT_SPI_CFG_DATA_WIDTH_E_8BIT; \
  8. info.endian = IOT_SPI_CFG_ENDIAN_LITTLE; \
  9. info.pad = 31; \
  10. info.freq = 40000000; \
  11. IoTSpiInit(0, param, &info);

define OLED_SCLK_Set() IoTGpioSetOutputVal(SDC, 1)

define OLED_SCLK_Clr() IoTGpioSetOutputVal(SDC, 0)

define OLED_SDIN_Set() IoTGpioSetOutputVal(SDIN, 1);

define OLED_SDIN_Clr() IoTGpioSetOutputVal(SDIN, 0);

define OLED_RST_Set() IoTGpioSetOutputVal(RST, 1);

define OLED_RST_Clr() IoTGpioSetOutputVal(RST, 0);

define OLED_DC_Set() IoTGpioSetOutputVal(DC, 1);

define OLED_DC_Clr() IoTGpioSetOutputVal(DC, 0);

define OLED_CMD 0 //写命令

define OLED_DATA 1 //写数据

extern u16 BACK_COLOR; //背景色

void LCD_Writ_Bus(u8 dat); void LCD_WR_DATA8(u8 dat); void LCD_WR_DATA(u16 dat); void LCD_WR_REG(u8 dat); void LCD_Address_Set(u16 x1,u16 y1,u16 x2,u16 y2); void Lcd_Init(void); void LCD_Clear(u16 Color); void LCD_ShowChinese(u16 x,u16 y,u8 index,u8 size,u16 color); void LCD_DrawPoint(u16 x,u16 y,u16 color); void LCD_DrawPoint_big(u16 x,u16 y,u16 colory); void LCD_Fill(u16 xsta,u16 ysta,u16 xend,u16 yend,u16 color); void LCD_DrawLine(u16 x1,u16 y1,u16 x2,u16 y2,u16 color); void LCD_DrawRectangle(u16 x1, u16 y1, u16 x2, u16 y2,u16 color); void Draw_Circle(u16 x0,u16 y0,u8 r,u16 color); void LCD_ShowChar(u16 x,u16 y,u8 num,u8 mode,u16 color); void LCD_ShowString(u16 x,u16 y,const u8 *p,u16 color); u32 mypow(u8 m,u8 n); void LCD_ShowNum(u16 x,u16 y,u16 num,u8 len,u16 color); void LCD_ShowNum1(u16 x,u16 y,float num,u8 len,u16 color); void LCD_ShowPicture(u16 x1,u16 y1,u16 x2,u16 y2);

//画笔颜色

define WHITE 0xFFFF

define BLACK 0x0000

define BLUE 0x001F

define BRED 0XF81F

define GRED 0XFFE0

define GBLUE 0X07FF

define RED 0xF800

define MAGENTA 0xF81F

define GREEN 0x07E0

define CYAN 0x7FFF

define YELLOW 0xFFE0

define BROWN 0XBC40 //棕色

define BRRED 0XFC07 //棕红色

define GRAY 0X8430 //灰色

//GUI颜色

define DARKBLUE 0X01CF //深蓝色

define LIGHTBLUE 0X7D7C //浅蓝色

define GRAYBLUE 0X5458 //灰蓝色

//以上三色为PANEL的颜色

define LIGHTGREEN 0X841F //浅绿色

define LGRAY 0XC618 //浅灰色(PANNEL),窗体背景色

define LGRAYBLUE 0XA651 //浅灰蓝色(中间层颜色)

define LBBLUE 0X2B12 //浅棕蓝色(选择条目的反色)

endif

  1. ```c
  2. #include "lcd_st7789.h"
  3. #include "oledfont.h"
  4. #include <unistd.h>
  5. #include "bmp.h"
  6. u16 BACK_COLOR; //背景色
  7. /******************************************************************************
  8. 函数说明:LCD串行数据写入函数
  9. 入口数据:dat 要写入的串行数据
  10. 返回值: 无
  11. ******************************************************************************/
  12. void LCD_Writ_Bus(u8 dat)
  13. {
  14. // u8 i;
  15. // //OLED_CS_Clr();
  16. // for(i=0;i<8;i++)
  17. // {
  18. // OLED_SCLK_Clr();
  19. // if(dat&0x80) {
  20. // OLED_SDIN_Set();
  21. // }
  22. // else {
  23. // OLED_SDIN_Clr();
  24. // }
  25. // OLED_SCLK_Set();
  26. // dat<<=1;
  27. // }
  28. // //OLED_CS_Set();
  29. IoTSpiHostWrite(0, &dat, 1);
  30. }
  31. /******************************************************************************
  32. 函数说明:LCD写入数据
  33. 入口数据:dat 写入的数据
  34. 返回值: 无
  35. ******************************************************************************/
  36. void LCD_WR_DATA8(u8 dat)
  37. {
  38. OLED_DC_Set();//写数据
  39. LCD_Writ_Bus(dat);
  40. }
  41. /******************************************************************************
  42. 函数说明:LCD写入数据
  43. 入口数据:dat 写入的数据
  44. 返回值: 无
  45. ******************************************************************************/
  46. void LCD_WR_DATA(u16 dat)
  47. {
  48. OLED_DC_Set();//写数据
  49. LCD_Writ_Bus(dat>>8);
  50. LCD_Writ_Bus(dat);
  51. }
  52. /******************************************************************************
  53. 函数说明:LCD写入命令
  54. 入口数据:dat 写入的命令
  55. 返回值: 无
  56. ******************************************************************************/
  57. void LCD_WR_REG(u8 dat)
  58. {
  59. OLED_DC_Clr();//写命令
  60. LCD_Writ_Bus(dat);
  61. }
  62. /******************************************************************************
  63. 函数说明:设置起始和结束地址
  64. 入口数据:x1,x2 设置列的起始和结束地址
  65. y1,y2 设置行的起始和结束地址
  66. 返回值: 无
  67. ******************************************************************************/
  68. void LCD_Address_Set(u16 x1,u16 y1,u16 x2,u16 y2)
  69. {
  70. if(USE_HORIZONTAL==0)
  71. {
  72. LCD_WR_REG(0x2a);//列地址设置
  73. LCD_WR_DATA(x1);
  74. LCD_WR_DATA(x2);
  75. LCD_WR_REG(0x2b);//行地址设置
  76. LCD_WR_DATA(y1);
  77. LCD_WR_DATA(y2);
  78. LCD_WR_REG(0x2c);//储存器写
  79. }
  80. else if(USE_HORIZONTAL==1)
  81. {
  82. LCD_WR_REG(0x2a);//列地址设置
  83. LCD_WR_DATA(x1);
  84. LCD_WR_DATA(x2);
  85. LCD_WR_REG(0x2b);//行地址设置
  86. LCD_WR_DATA(y1+80);
  87. LCD_WR_DATA(y2+80);
  88. LCD_WR_REG(0x2c);//储存器写
  89. }
  90. else if(USE_HORIZONTAL==2)
  91. {
  92. LCD_WR_REG(0x2a);//列地址设置
  93. LCD_WR_DATA(x1);
  94. LCD_WR_DATA(x2);
  95. LCD_WR_REG(0x2b);//行地址设置
  96. LCD_WR_DATA(y1);
  97. LCD_WR_DATA(y2);
  98. LCD_WR_REG(0x2c);//储存器写
  99. }
  100. else
  101. {
  102. LCD_WR_REG(0x2a);//列地址设置
  103. LCD_WR_DATA(x1+80);
  104. LCD_WR_DATA(x2+80);
  105. LCD_WR_REG(0x2b);//行地址设置
  106. LCD_WR_DATA(y1);
  107. LCD_WR_DATA(y2);
  108. LCD_WR_REG(0x2c);//储存器写
  109. }
  110. }
  111. /******************************************************************************
  112. 函数说明:LCD初始化函数
  113. 入口数据:无
  114. 返回值: 无
  115. ******************************************************************************/
  116. void Lcd_Init(void)
  117. {
  118. LCD_PIN_INIT();
  119. LCD_SPI_INIT();
  120. OLED_RST_Clr();
  121. usleep(20 * 1000);
  122. OLED_RST_Set();
  123. usleep(20 * 1000);
  124. // OLED_BLK_Set();
  125. //************* Start Initial Sequence **********//
  126. LCD_WR_REG(0x36);
  127. if(USE_HORIZONTAL==0)LCD_WR_DATA8(0x00);
  128. else if(USE_HORIZONTAL==1)LCD_WR_DATA8(0xC0);
  129. else if(USE_HORIZONTAL==2)LCD_WR_DATA8(0x70);
  130. else LCD_WR_DATA8(0xA0);
  131. LCD_WR_REG(0x3A);
  132. LCD_WR_DATA8(0x05);
  133. LCD_WR_REG(0xB2);
  134. LCD_WR_DATA8(0x0C);
  135. LCD_WR_DATA8(0x0C);
  136. LCD_WR_DATA8(0x00);
  137. LCD_WR_DATA8(0x33);
  138. LCD_WR_DATA8(0x33);
  139. LCD_WR_REG(0xB7);
  140. LCD_WR_DATA8(0x35);
  141. LCD_WR_REG(0xBB);
  142. LCD_WR_DATA8(0x37);
  143. LCD_WR_REG(0xC0);
  144. LCD_WR_DATA8(0x2C);
  145. LCD_WR_REG(0xC2);
  146. LCD_WR_DATA8(0x01);
  147. LCD_WR_REG(0xC3);
  148. LCD_WR_DATA8(0x12);
  149. LCD_WR_REG(0xC4);
  150. LCD_WR_DATA8(0x20);
  151. LCD_WR_REG(0xC6);
  152. LCD_WR_DATA8(0x0F);
  153. LCD_WR_REG(0xD0);
  154. LCD_WR_DATA8(0xA4);
  155. LCD_WR_DATA8(0xA1);
  156. LCD_WR_REG(0xE0);
  157. LCD_WR_DATA8(0xD0);
  158. LCD_WR_DATA8(0x04);
  159. LCD_WR_DATA8(0x0D);
  160. LCD_WR_DATA8(0x11);
  161. LCD_WR_DATA8(0x13);
  162. LCD_WR_DATA8(0x2B);
  163. LCD_WR_DATA8(0x3F);
  164. LCD_WR_DATA8(0x54);
  165. LCD_WR_DATA8(0x4C);
  166. LCD_WR_DATA8(0x18);
  167. LCD_WR_DATA8(0x0D);
  168. LCD_WR_DATA8(0x0B);
  169. LCD_WR_DATA8(0x1F);
  170. LCD_WR_DATA8(0x23);
  171. LCD_WR_REG(0xE1);
  172. LCD_WR_DATA8(0xD0);
  173. LCD_WR_DATA8(0x04);
  174. LCD_WR_DATA8(0x0C);
  175. LCD_WR_DATA8(0x11);
  176. LCD_WR_DATA8(0x13);
  177. LCD_WR_DATA8(0x2C);
  178. LCD_WR_DATA8(0x3F);
  179. LCD_WR_DATA8(0x44);
  180. LCD_WR_DATA8(0x51);
  181. LCD_WR_DATA8(0x2F);
  182. LCD_WR_DATA8(0x1F);
  183. LCD_WR_DATA8(0x1F);
  184. LCD_WR_DATA8(0x20);
  185. LCD_WR_DATA8(0x23);
  186. LCD_WR_REG(0x21);
  187. LCD_WR_REG(0x11);
  188. //Delay (120);
  189. LCD_WR_REG(0x29);
  190. }
  191. /******************************************************************************
  192. 函数说明:LCD清屏函数
  193. 入口数据:无
  194. 返回值: 无
  195. ******************************************************************************/
  196. void LCD_Clear(u16 Color)
  197. {
  198. u16 i,j;
  199. LCD_Address_Set(0,0,LCD_W-1,LCD_H-1);
  200. for(i=0;i<LCD_W;i++)
  201. {
  202. for (j=0;j<LCD_H;j++)
  203. {
  204. LCD_WR_DATA(Color);
  205. }
  206. }
  207. }
  208. /******************************************************************************
  209. 函数说明:LCD显示汉字
  210. 入口数据:x,y 起始坐标
  211. index 汉字的序号
  212. size 字号
  213. 返回值: 无
  214. ******************************************************************************/
  215. void LCD_ShowChinese(u16 x,u16 y,u8 index,u8 size,u16 color)
  216. {
  217. u8 i,j;
  218. u8 *temp,size1;
  219. if(size==16){temp=Hzk16;}//选择字号
  220. if(size==32){temp=Hzk32;}
  221. LCD_Address_Set(x,y,x+size-1,y+size-1); //设置一个汉字的区域
  222. size1=size*size/8;//一个汉字所占的字节
  223. temp+=index*size1;//写入的起始位置
  224. for(j=0;j<size1;j++)
  225. {
  226. for(i=0;i<8;i++)
  227. {
  228. if((*temp&(1<<i))!=0)//从数据的低位开始读
  229. {
  230. LCD_WR_DATA(color);//点亮
  231. }
  232. else
  233. {
  234. LCD_WR_DATA(BACK_COLOR);//不点亮
  235. }
  236. }
  237. temp++;
  238. }
  239. }
  240. /******************************************************************************
  241. 函数说明:LCD显示汉字
  242. 入口数据:x,y 起始坐标
  243. 返回值: 无
  244. ******************************************************************************/
  245. void LCD_DrawPoint(u16 x,u16 y,u16 color)
  246. {
  247. LCD_Address_Set(x,y,x,y);//设置光标位置
  248. LCD_WR_DATA(color);
  249. }
  250. /******************************************************************************
  251. 函数说明:LCD画一个大的点
  252. 入口数据:x,y 起始坐标
  253. 返回值: 无
  254. ******************************************************************************/
  255. void LCD_DrawPoint_big(u16 x,u16 y,u16 color)
  256. {
  257. LCD_Fill(x-1,y-1,x+1,y+1,color);
  258. }
  259. /******************************************************************************
  260. 函数说明:在指定区域填充颜色
  261. 入口数据:xsta,ysta 起始坐标
  262. xend,yend 终止坐标
  263. 返回值: 无
  264. ******************************************************************************/
  265. void LCD_Fill(u16 xsta,u16 ysta,u16 xend,u16 yend,u16 color)
  266. {
  267. u16 i,j;
  268. LCD_Address_Set(xsta,ysta,xend,yend); //设置光标位置
  269. for(i=ysta;i<=yend;i++)
  270. {
  271. for(j=xsta;j<=xend;j++)LCD_WR_DATA(color);//设置光标位置
  272. }
  273. }
  274. /******************************************************************************
  275. 函数说明:画线
  276. 入口数据:x1,y1 起始坐标
  277. x2,y2 终止坐标
  278. 返回值: 无
  279. ******************************************************************************/
  280. void LCD_DrawLine(u16 x1,u16 y1,u16 x2,u16 y2,u16 color)
  281. {
  282. u16 t;
  283. int xerr=0,yerr=0,delta_x,delta_y,distance;
  284. int incx,incy,uRow,uCol;
  285. delta_x=x2-x1; //计算坐标增量
  286. delta_y=y2-y1;
  287. uRow=x1;//画线起点坐标
  288. uCol=y1;
  289. if(delta_x>0)incx=1; //设置单步方向
  290. else if (delta_x==0)incx=0;//垂直线
  291. else {incx=-1;delta_x=-delta_x;}
  292. if(delta_y>0)incy=1;
  293. else if (delta_y==0)incy=0;//水平线
  294. else {incy=-1;delta_y=-delta_x;}
  295. if(delta_x>delta_y)distance=delta_x; //选取基本增量坐标轴
  296. else distance=delta_y;
  297. for(t=0;t<distance+1;t++)
  298. {
  299. LCD_DrawPoint(uRow,uCol,color);//画点
  300. xerr+=delta_x;
  301. yerr+=delta_y;
  302. if(xerr>distance)
  303. {
  304. xerr-=distance;
  305. uRow+=incx;
  306. }
  307. if(yerr>distance)
  308. {
  309. yerr-=distance;
  310. uCol+=incy;
  311. }
  312. }
  313. }
  314. /******************************************************************************
  315. 函数说明:画矩形
  316. 入口数据:x1,y1 起始坐标
  317. x2,y2 终止坐标
  318. 返回值: 无
  319. ******************************************************************************/
  320. void LCD_DrawRectangle(u16 x1, u16 y1, u16 x2, u16 y2,u16 color)
  321. {
  322. LCD_DrawLine(x1,y1,x2,y1,color);
  323. LCD_DrawLine(x1,y1,x1,y2,color);
  324. LCD_DrawLine(x1,y2,x2,y2,color);
  325. LCD_DrawLine(x2,y1,x2,y2,color);
  326. }
  327. /******************************************************************************
  328. 函数说明:画圆
  329. 入口数据:x0,y0 圆心坐标
  330. r 半径
  331. 返回值: 无
  332. ******************************************************************************/
  333. void Draw_Circle(u16 x0,u16 y0,u8 r,u16 color)
  334. {
  335. int a,b;
  336. int di;
  337. a=0;b=r;
  338. while(a<=b)
  339. {
  340. LCD_DrawPoint(x0-b,y0-a,color); //3
  341. LCD_DrawPoint(x0+b,y0-a,color); //0
  342. LCD_DrawPoint(x0-a,y0+b,color); //1
  343. LCD_DrawPoint(x0-a,y0-b,color); //2
  344. LCD_DrawPoint(x0+b,y0+a,color); //4
  345. LCD_DrawPoint(x0+a,y0-b,color); //5
  346. LCD_DrawPoint(x0+a,y0+b,color); //6
  347. LCD_DrawPoint(x0-b,y0+a,color); //7
  348. a++;
  349. if((a*a+b*b)>(r*r))//判断要画的点是否过远
  350. {
  351. b--;
  352. }
  353. }
  354. }
  355. /******************************************************************************
  356. 函数说明:显示字符
  357. 入口数据:x,y 起点坐标
  358. num 要显示的字符
  359. mode 1叠加方式 0非叠加方式
  360. 返回值: 无
  361. ******************************************************************************/
  362. void LCD_ShowChar(u16 x,u16 y,u8 num,u8 mode,u16 color)
  363. {
  364. u8 temp;
  365. u8 pos,t;
  366. u16 x0=x;
  367. if(x>LCD_W-16||y>LCD_H-16)return; //设置窗口
  368. num=num-' ';//得到偏移后的值
  369. LCD_Address_Set(x,y,x+8-1,y+16-1); //设置光标位置
  370. if(!mode) //非叠加方式
  371. {
  372. for(pos=0;pos<16;pos++)
  373. {
  374. temp=asc2_1608[(u16)num*16+pos]; //调用1608字体
  375. for(t=0;t<8;t++)
  376. {
  377. if(temp&0x01)LCD_WR_DATA(color);
  378. else LCD_WR_DATA(BACK_COLOR);
  379. temp>>=1;
  380. x++;
  381. }
  382. x=x0;
  383. y++;
  384. }
  385. }else//叠加方式
  386. {
  387. for(pos=0;pos<16;pos++)
  388. {
  389. temp=asc2_1608[(u16)num*16+pos]; //调用1608字体
  390. for(t=0;t<8;t++)
  391. {
  392. if(temp&0x01)LCD_DrawPoint(x+t,y+pos,color);//画一个点
  393. temp>>=1;
  394. }
  395. }
  396. }
  397. }
  398. /******************************************************************************
  399. 函数说明:显示字符串
  400. 入口数据:x,y 起点坐标
  401. *p 字符串起始地址
  402. 返回值: 无
  403. ******************************************************************************/
  404. void LCD_ShowString(u16 x,u16 y,const u8 *p,u16 color)
  405. {
  406. while(*p!='\0')
  407. {
  408. if(x>LCD_W-16){x=0;y+=16;}
  409. if(y>LCD_H-16){y=x=0;LCD_Clear(RED);}
  410. LCD_ShowChar(x,y,*p,0,color);
  411. x+=8;
  412. p++;
  413. }
  414. }
  415. /******************************************************************************
  416. 函数说明:显示数字
  417. 入口数据:m底数,n指数
  418. 返回值: 无
  419. ******************************************************************************/
  420. u32 mypow(u8 m,u8 n)
  421. {
  422. u32 result=1;
  423. while(n--)result*=m;
  424. return result;
  425. }
  426. /******************************************************************************
  427. 函数说明:显示数字
  428. 入口数据:x,y 起点坐标
  429. num 要显示的数字
  430. len 要显示的数字个数
  431. 返回值: 无
  432. ******************************************************************************/
  433. void LCD_ShowNum(u16 x,u16 y,u16 num,u8 len,u16 color)
  434. {
  435. u8 t,temp;
  436. u8 enshow=0;
  437. for(t=0;t<len;t++)
  438. {
  439. temp=(num/mypow(10,len-t-1))%10;
  440. if(enshow==0&&t<(len-1))
  441. {
  442. if(temp==0)
  443. {
  444. LCD_ShowChar(x+8*t,y,' ',0,color);
  445. continue;
  446. }else enshow=1;
  447. }
  448. LCD_ShowChar(x+8*t,y,temp+48,0,color);
  449. }
  450. }
  451. /******************************************************************************
  452. 函数说明:显示小数
  453. 入口数据:x,y 起点坐标
  454. num 要显示的小数
  455. len 要显示的数字个数
  456. 返回值: 无
  457. ******************************************************************************/
  458. void LCD_ShowNum1(u16 x,u16 y,float num,u8 len,u16 color)
  459. {
  460. u8 t,temp;
  461. u8 enshow=0;
  462. u16 num1;
  463. num1=num*100;
  464. for(t=0;t<len;t++)
  465. {
  466. temp=(num1/mypow(10,len-t-1))%10;
  467. if(t==(len-2))
  468. {
  469. LCD_ShowChar(x+8*(len-2),y,'.',0,color);
  470. t++;
  471. len+=1;
  472. }
  473. LCD_ShowChar(x+8*t,y,temp+48,0,color);
  474. }
  475. }
  476. /******************************************************************************
  477. 函数说明:显示40x40图片
  478. 入口数据:x,y 起点坐标
  479. 返回值: 无
  480. ******************************************************************************/
  481. void LCD_ShowPicture(u16 x1,u16 y1,u16 x2,u16 y2)
  482. {
  483. int i;
  484. LCD_Address_Set(x1,y1,x2,y2);
  485. for(i=0;i<1600;i++)
  486. {
  487. LCD_WR_DATA8(image[i*2+1]);
  488. LCD_WR_DATA8(image[i*2]);
  489. }
  490. }
  1. //////////////////////////////////////////////////////////////////////////////////
  2. //本程序只供学习使用,未经作者许可,不得用于其它任何用途
  3. //中景园电子
  4. //店铺地址:http://shop73023976.taobao.com/?spm=2013.1.0.0.M4PqC2
  5. //
  6. // 文 件 名 : main.c
  7. // 版 本 号 : v2.0
  8. // 作 者 : HuangKai
  9. // 生成日期 : 2014-0101
  10. // 最近修改 :
  11. // 功能描述 : OLED 4接口演示例程(stm32系列)
  12. // 说明:
  13. // ----------------------------------------------------------------
  14. // GND 电源地
  15. // VCC 接5V或3.3v电源
  16. // D0 接CLK(SCL)
  17. // D1 接MOSI(SDA)
  18. // RES 接PD4
  19. // DC 接PD5
  20. // CS 接PD3
  21. // ----------------------------------------------------------------
  22. // 修改历史 :
  23. // 日 期 :
  24. // 作 者 : HuangKai
  25. // 修改内容 : 创建文件
  26. //版权所有,盗版必究。
  27. //Copyright(C) 中景园电子2014/3/16
  28. //All rights reserved
  29. //******************************************************************************/
  30. #ifndef __BMP_H
  31. #define __BMP_H
  32. #define u8 unsigned char
  33. const u8 image[]={ /* 0X00,0X10,0X28,0X00,0X28,0X00,0X01,0X1B,*/
  34. 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  35. 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XBE,0XF7,0X7D,0XEF,
  36. 0XBA,0XD6,0XB6,0XB5,0XF3,0X9C,0XB2,0X94,0XB3,0X9C,0XB2,0X94,0X34,0XA5,0XF7,0XBD,
  37. 0XFB,0XDE,0X7D,0XEF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  38. 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  39. 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  40. 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XBE,0XF7,0XFB,0XDE,0XF3,0X9C,0XCB,0X5A,
  41. 0XC7,0X39,0X04,0X21,0X82,0X10,0X42,0X10,0X42,0X10,0X41,0X08,0X83,0X18,0X45,0X29,
  42. 0XC7,0X39,0X0C,0X63,0X75,0XAD,0X3C,0XE7,0XBE,0XF7,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  43. 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  44. 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  45. 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X3C,0XE7,0XB2,0X94,0X08,0X42,0XC3,0X18,0X82,0X10,
  46. 0X04,0X21,0X45,0X29,0X86,0X31,0X86,0X31,0X86,0X31,0X86,0X31,0X45,0X29,0X04,0X21,
  47. 0X82,0X10,0X41,0X08,0XC3,0X18,0X08,0X42,0XF3,0X9C,0X3C,0XE7,0XFF,0XFF,0XFF,0XFF,
  48. 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  49. 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  50. 0XFF,0XFF,0XFF,0XFF,0XFB,0XDE,0X0C,0X63,0XC3,0X18,0XC3,0X18,0X45,0X29,0XC7,0X39,
  51. 0X08,0X42,0X08,0X42,0X08,0X42,0X08,0X42,0X08,0X42,0X08,0X42,0XC7,0X39,0XC7,0X39,
  52. 0X86,0X31,0X86,0X31,0X04,0X21,0X41,0X08,0X82,0X10,0XCB,0X5A,0XBA,0XD6,0XFF,0XFF,
  53. 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  54. 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  55. 0XFF,0XFF,0XFB,0XDE,0XCB,0X5A,0X82,0X10,0X45,0X29,0XC7,0X39,0X08,0X42,0X08,0X42,
  56. 0X09,0X4A,0X49,0X4A,0X49,0X4A,0X49,0X4A,0X49,0X4A,0X49,0X4A,0X08,0X42,0XC7,0X39,
  57. 0XC7,0X39,0XC7,0X39,0X86,0X31,0X45,0X29,0X83,0X18,0X00,0X00,0XC8,0X41,0X38,0XC6,
  58. 0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0X31,0XC9,0X39,0XB3,0X84,0XBB,0XC6,
  97. 0XF8,0XB5,0XCC,0X5A,0X86,0X31,0XC7,0X39,0XC7,0X39,0X86,0X31,0X45,0X29,0X45,0X29,
  98. 0XC4,0X20,0X41,0X08,0X30,0X84,0X3C,0XE7,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  99. 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X3C,0XE7,0X8A,0X4A,0XC3,0X10,
  100. 0XC7,0X39,0X08,0X42,0X49,0X4A,0X49,0X4A,0X4A,0X4A,0X4A,0X42,0X09,0X3A,0X08,0X4A,
  101. 0X09,0X6B,0X49,0X7B,0XC6,0X7A,0X05,0X83,0X46,0X83,0XC5,0X7A,0XC6,0X72,0X09,0X7B,
  102. 0X48,0X5A,0X87,0X31,0X88,0X21,0X88,0X29,0X86,0X31,0X86,0X31,0X45,0X29,0X45,0X29,
  103. 0X04,0X21,0X41,0X08,0X4A,0X4A,0XBA,0XD6,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  104. 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XF7,0XC5,0X82,0X50,0X05,0X41,
  105. 0XC7,0X29,0X08,0X42,0X49,0X4A,0X4A,0X42,0X49,0X4A,0X09,0X7B,0X88,0X9B,0XC6,0XB3,
  106. 0X21,0XD4,0XA0,0XDC,0XE1,0XE4,0X61,0XED,0X61,0XED,0X21,0XED,0XA0,0XE4,0X20,0XDC,
  107. 0X80,0XCB,0X43,0XAB,0XC4,0X82,0X06,0X5A,0X47,0X21,0X46,0X29,0X45,0X29,0X04,0X29,
  108. 0X04,0X19,0X82,0X10,0X82,0X18,0XF3,0X9C,0X7D,0XEF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  109. 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X7D,0XEF,0X4D,0X93,0X00,0XA0,0X82,0XB8,
  110. 0XC7,0X31,0X09,0X32,0X49,0X4A,0X86,0X7A,0X43,0XC3,0X6B,0XED,0XF4,0XF6,0XEB,0XFD,
  111. 0X20,0XFD,0X20,0XFD,0X60,0XFD,0XA0,0XFD,0XA0,0XFD,0X60,0XFD,0X60,0XFD,0X20,0XFD,
  112. 0XE0,0XFC,0XA0,0XFC,0X60,0XF4,0XC1,0XDB,0X83,0X9A,0XC5,0X49,0X45,0X29,0X04,0X19,
  113. 0XC4,0X20,0X82,0X38,0X00,0X50,0XCB,0X6A,0XBA,0XD6,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  114. 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFB,0XEE,0X04,0XA1,0X00,0XC0,0X00,0XF0,
  115. 0XC3,0XA0,0XC8,0X41,0X49,0X42,0X05,0X9B,0X20,0XFC,0XA4,0XFC,0X69,0XFD,0XE8,0XFD,
  116. 0X63,0XFD,0X20,0XFD,0X60,0XFD,0X60,0XFD,0X60,0XFD,0X20,0XFD,0X20,0XFD,0XE0,0XFC,
  117. 0XE0,0XFC,0XA0,0XFC,0X60,0XFC,0X20,0XFC,0X41,0XD3,0XC5,0X49,0X45,0X19,0XC4,0X38,
  118. 0X82,0X68,0X41,0X88,0X00,0X70,0X49,0X5A,0X79,0XCE,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  119. 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFB,0XF6,0X82,0XC0,0X00,0XD0,0X86,0XC1,
  120. 0X46,0XF1,0X41,0XC8,0X45,0X79,0X89,0X52,0X88,0X62,0X86,0X6A,0XC6,0X7A,0XC4,0XBB,
  121. 0XE1,0XFC,0X60,0XFD,0X60,0XFD,0XA0,0XFD,0XA0,0XFD,0X60,0XFD,0X60,0XFD,0XE0,0XFC,
  122. 0X60,0XE4,0X03,0X93,0X84,0X72,0X44,0X6A,0XC5,0X41,0X45,0X29,0XC3,0X58,0X41,0XA8,
  123. 0X40,0X98,0X00,0XB0,0X00,0X60,0X0C,0X6B,0X79,0XCE,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  124. 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X7D,0XEF,0XCE,0X83,0X82,0X88,0X00,0XF8,0XC4,0XD8,
  125. 0X0C,0XF3,0X8A,0XFA,0X82,0XE8,0X82,0XB0,0X45,0X69,0XC7,0X51,0X08,0X42,0X08,0X3A,
  126. 0X86,0X5A,0X83,0X9B,0XA2,0XBC,0X22,0XCD,0X21,0XCD,0XA1,0XC4,0X22,0XB4,0XC4,0X7A,
  127. 0X06,0X3A,0X86,0X29,0X45,0X29,0X05,0X31,0XC4,0X50,0X41,0X90,0X00,0XC0,0X00,0XA8,
  128. 0X00,0XA0,0X00,0XA8,0X00,0X30,0X4A,0X4A,0XBA,0XD6,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  129. 0XFF,0XFF,0XFF,0XFF,0X7D,0XEF,0X8E,0X73,0XC3,0X18,0X05,0X39,0X82,0XA8,0X00,0XF8,
  130. 0XC3,0XF8,0X4D,0XFB,0X4D,0XFB,0XC7,0XF9,0XC3,0XF0,0X82,0XD8,0XC3,0XB0,0X04,0X81,
  131. 0X45,0X61,0X46,0X51,0X86,0X49,0X86,0X49,0X46,0X41,0X45,0X41,0X45,0X41,0X45,0X41,
  132. 0X05,0X49,0X04,0X61,0X82,0X90,0X41,0XB0,0X00,0XD0,0X00,0XC8,0X00,0XA8,0X00,0XA8,
  133. 0X00,0XB8,0X41,0X58,0X82,0X10,0X82,0X10,0XB2,0X94,0XBE,0XF7,0XFF,0XFF,0XFF,0XFF,
  134. 0XFF,0XFF,0XBE,0XF7,0XCF,0X7B,0X82,0X10,0X04,0X21,0X86,0X29,0X86,0X41,0X04,0X99,
  135. 0X40,0XE8,0X41,0XF8,0X86,0XF9,0XCB,0XFA,0X49,0XFA,0X82,0XF8,0X00,0XF8,0X00,0XF0,
  136. 0X00,0XE8,0X41,0XD8,0X41,0XD0,0X41,0XC0,0X41,0XC0,0X41,0XC0,0X41,0XC0,0X41,0XC8,
  137. 0X00,0XD0,0X00,0XE0,0X00,0XE0,0X00,0XD8,0X00,0XD0,0X00,0XB8,0X00,0XA8,0X41,0X88,
  138. 0X82,0X48,0X82,0X10,0X82,0X10,0X00,0X00,0X45,0X29,0X79,0XCE,0XFF,0XFF,0XFF,0XFF,
  139. 0XBE,0XF7,0XF3,0X9C,0X82,0X10,0XC3,0X18,0X45,0X29,0X86,0X31,0XC7,0X31,0X30,0X7C,
  140. 0XF3,0XDC,0X86,0XE1,0X00,0XF0,0X00,0XF8,0X41,0XF8,0X41,0XF8,0X00,0XF8,0X00,0XF8,
  141. 0X00,0XF8,0X00,0XF8,0X00,0XF8,0X00,0XF8,0X00,0XF8,0X00,0XF8,0X00,0XF8,0X00,0XF8,
  142. 0X00,0XE8,0X00,0XE0,0X00,0XE0,0X00,0XD8,0X00,0XC8,0X41,0XA0,0X8A,0X9A,0X0C,0X63,
  143. 0X04,0X11,0X82,0X10,0X82,0X10,0X41,0X08,0X00,0X00,0X4D,0X6B,0X7D,0XEF,0XFF,0XFF,
  144. 0XFB,0XDE,0X08,0X42,0X42,0X10,0X45,0X29,0X86,0X31,0X86,0X31,0X49,0X4A,0X38,0XBE,
  145. 0XFF,0XFF,0X38,0XD6,0X86,0XA9,0X00,0XC8,0X00,0XE0,0X00,0XF0,0X00,0XF8,0X00,0XF8,
  146. 0X00,0XF8,0X00,0XF8,0X00,0XF8,0X00,0XF8,0X00,0XF8,0X00,0XF8,0X00,0XF0,0X00,0XF0,
  147. 0X00,0XE8,0X00,0XE0,0X00,0XD0,0XC3,0X98,0X8A,0X8A,0XB2,0XA4,0XBA,0XC6,0XF7,0XB5,
  148. 0X08,0X42,0X41,0X08,0X82,0X10,0X41,0X08,0X00,0X00,0X45,0X29,0XF7,0XBD,0XFF,0XFF,
  149. 0X71,0X8C,0X41,0X08,0X04,0X21,0X45,0X29,0X86,0X31,0X86,0X31,0X0C,0X63,0X3C,0XE7,
  150. 0XFF,0XFF,0X79,0XD6,0X46,0XB9,0X00,0XE0,0X42,0XC8,0X82,0XA8,0X82,0XB0,0X41,0XD8,
  151. 0X82,0XE8,0X82,0XF0,0X41,0XE8,0X41,0XE8,0X41,0XE8,0X41,0XF0,0X41,0XE8,0X41,0XD8,
  152. 0X04,0XC1,0X08,0X92,0X4D,0X8B,0X34,0XA5,0XFB,0XC6,0XFB,0XD6,0XBA,0XCE,0X3C,0XE7,
  153. 0X30,0X84,0XC3,0X18,0X41,0X08,0X41,0X08,0X00,0X00,0X41,0X08,0XCF,0X7B,0X7D,0XEF,
  154. 0X49,0X4A,0X00,0X00,0X04,0X21,0X45,0X29,0X46,0X31,0X86,0X31,0X30,0X84,0XFF,0XFF,
  155. 0XFF,0XF7,0XF7,0XDD,0X09,0XDA,0X83,0XF8,0X01,0XF0,0X42,0XC0,0X82,0X98,0X49,0X9A,
  156. 0XF3,0XB4,0XF3,0XCC,0X71,0XBC,0X8E,0XBB,0X8E,0XBB,0X30,0XBC,0X71,0XBC,0XF3,0XBC,
  157. 0XB6,0XBD,0XFB,0XCE,0XBE,0XE7,0X7D,0XE7,0X3B,0XDF,0XBA,0XD6,0X79,0XCE,0XFB,0XDE,
  158. 0X75,0XAD,0X86,0X31,0X41,0X08,0X41,0X08,0X00,0X00,0X00,0X00,0X49,0X4A,0XFB,0XDE,
  159. 0X04,0X21,0X41,0X08,0X04,0X21,0X45,0X29,0X45,0X29,0X87,0X39,0XB2,0X94,0XFF,0XFF,
  160. 0XBE,0XF7,0X34,0XDD,0X0C,0XEB,0X09,0XFA,0X00,0XF0,0X01,0XD8,0X00,0XD8,0X8B,0XD2,
  161. 0X7D,0XE7,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  162. 0XFF,0XFF,0XBE,0XFF,0X7D,0XEF,0XFB,0XDE,0XFB,0XDE,0XBA,0XD6,0X79,0XCE,0XBA,0XD6,
  163. 0X78,0XC6,0XC7,0X39,0X00,0X00,0X41,0X08,0X00,0X00,0X00,0X00,0XC7,0X39,0X79,0XCE,
  164. 0X00,0X00,0X82,0X10,0XC3,0X18,0X04,0X21,0X05,0X29,0X86,0X31,0XB3,0X9C,0XFF,0XFF,
  165. 0XFF,0XF7,0X75,0XDD,0XC7,0XE9,0XC7,0XF9,0X01,0XF8,0X01,0XF0,0X00,0XE8,0X49,0XE2,
  166. 0XFB,0XEE,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  167. 0XFF,0XFF,0XBE,0XF7,0X7D,0XEF,0XFB,0XDE,0XFB,0XDE,0XBA,0XD6,0X79,0XCE,0XBA,0XD6,
  168. 0XB9,0XCE,0X08,0X42,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0XC7,0X39,0X38,0XC6,
  169. 0X00,0X00,0X82,0X10,0X82,0X10,0X04,0X21,0X04,0X21,0X45,0X29,0X30,0X84,0XFF,0XFF,
  170. 0XFF,0XFF,0X38,0XDE,0XC4,0XD0,0X00,0XF0,0X01,0XF8,0X00,0XF8,0X00,0XF0,0X08,0XD2,
  171. 0XFB,0XE6,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  172. 0XFF,0XFF,0XBE,0XF7,0X7D,0XEF,0XFB,0XDE,0XBA,0XD6,0X79,0XCE,0X79,0XCE,0XBA,0XD6,
  173. 0X79,0XCE,0XC7,0X39,0X41,0X08,0X00,0X00,0X00,0X00,0X00,0X00,0X86,0X31,0X38,0XC6,
  174. 0X00,0X00,0X00,0X00,0XC3,0X18,0XCB,0X5A,0X86,0X31,0XC3,0X18,0XCB,0X5A,0X7D,0XEF,
  175. 0XFF,0XFF,0X7D,0XEF,0XCF,0XBB,0XC3,0XB0,0X41,0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XA3,0X42,0X93,0XC3,0X7A,
  226. 0X85,0X62,0X0B,0X63,0X71,0X84,0XB6,0XB5,0X79,0XCE,0X79,0XC6,0XB5,0XAD,0X70,0X94,
  227. 0X4A,0X8B,0X06,0X83,0X04,0X93,0X04,0X9B,0X43,0X9B,0X43,0X9B,0X43,0X93,0X04,0X83,
  228. 0X08,0X73,0X8D,0X73,0XB3,0X94,0X79,0XCE,0X7D,0XEF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  229. 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X3C,0XDF,0X38,0XBE,
  230. 0X75,0XB5,0X33,0XA5,0X33,0XA5,0XF3,0X9C,0XF3,0X9C,0XF3,0X9C,0XF3,0X94,0XF3,0X9C,
  231. 0X35,0XA5,0XF8,0XBD,0XFB,0XDE,0XBE,0XF7,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X7E,0XEF,
  232. 0XBB,0XD6,0XF8,0XBD,0XB6,0XAD,0X75,0XAD,0X34,0XA5,0X33,0X9D,0X34,0X9D,0X35,0XA5,
  233. 0XB7,0XAD,0X79,0XC6,0X3C,0XE7,0XBE,0XF7,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  234. };
  235. #endif
  1. #ifndef __OLEDFONT_H
  2. #define __OLEDFONT_H
  3. //常用ASCII表
  4. //偏移量32
  5. //ASCII字符集
  6. //偏移量32
  7. //大小:12*6
  8. #define u8 unsigned char
  9. #define u16 unsigned int
  10. #define u32 unsigned long
  11. /************************************6*8的点阵************************************/
  12. /****************************************32*32的点阵************************************/
  13. u8 Hzk32[]={
  14. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x01,0x00,
  15. 0x00,0x80,0x01,0x00,0x00,0x80,0x01,0x00,0x00,0x80,0x01,0x00,0x00,0x80,0x01,0x00,
  16. 0x10,0x80,0x01,0x0C,0xF0,0xFF,0xFF,0x0F,0x30,0x80,0x01,0x04,0x30,0x80,0x01,0x04,
  17. 0x30,0x80,0x01,0x04,0x30,0x80,0x01,0x04,0x30,0x80,0x01,0x04,0x30,0x80,0x01,0x04,
  18. 0x30,0x80,0x01,0x04,0x30,0x80,0x01,0x04,0xF0,0xFF,0xFF,0x07,0x30,0x80,0x01,0x04,
  19. 0x30,0x80,0x01,0x04,0x00,0x80,0x01,0x00,0x00,0x80,0x01,0x00,0x00,0x80,0x01,0x00,
  20. 0x00,0x80,0x01,0x00,0x00,0x80,0x01,0x00,0x00,0x80,0x01,0x00,0x00,0x80,0x01,0x00,
  21. 0x00,0x80,0x01,0x00,0x00,0x80,0x01,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,/*"中",0*/
  22. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x01,
  23. 0x00,0xFF,0xFF,0x01,0x00,0x03,0x80,0x01,0x00,0x03,0x80,0x01,0x00,0xFF,0xFF,0x01,
  24. 0x00,0x03,0x80,0x01,0x00,0x03,0x80,0x01,0x00,0xFF,0xFF,0x01,0x00,0x81,0x81,0x00,
  25. 0x00,0x00,0x03,0x00,0x00,0x00,0x03,0x1C,0xFC,0xFF,0xFF,0x3F,0x00,0x00,0x40,0x00,
  26. 0x00,0x03,0xC0,0x01,0x00,0xFF,0xFF,0x01,0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,
  27. 0x00,0x03,0xC0,0x00,0x00,0xFF,0xFF,0x00,0x00,0x01,0x41,0x00,0x00,0x04,0x01,0x00,
  28. 0x00,0x0E,0x71,0x00,0x00,0x07,0x81,0x01,0x80,0x01,0x01,0x07,0x60,0x00,0x01,0x0E,
  29. 0x18,0x98,0x01,0x1C,0x04,0xE0,0x01,0x18,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,/*"景",1*/
  30. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0xF0,0xFF,0xFF,0x1F,
  31. 0x30,0x00,0x00,0x0C,0x30,0x00,0x00,0x0C,0x30,0x00,0x10,0x0C,0x30,0xFE,0x3F,0x0C,
  32. 0x30,0x04,0x00,0x0C,0x30,0x00,0x00,0x0C,0x30,0x00,0x00,0x0C,0x30,0x00,0x00,0x0C,
  33. 0x30,0x00,0xC0,0x0C,0xF0,0xFF,0xFF,0x0D,0x30,0x30,0x06,0x0E,0x30,0x30,0x06,0x0C,
  34. 0x30,0x10,0x06,0x0C,0x30,0x10,0x06,0x0C,0x30,0x10,0x06,0x0C,0x30,0x18,0x86,0x0C,
  35. 0x30,0x18,0x86,0x0C,0x30,0x08,0x06,0x0D,0x30,0x0C,0x86,0x0D,0x30,0x06,0xEE,0x0F,
  36. 0x30,0x02,0xFC,0x0D,0x30,0x01,0x00,0x0C,0xF0,0x00,0x00,0x0C,0x30,0x00,0x00,0x0C,
  37. 0xF0,0xFF,0xFF,0x0F,0x30,0x00,0x00,0x0C,0x10,0x00,0x00,0x04,0x00,0x00,0x00,0x00,/*"园",2*/
  38. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0xC0,0x01,0x00,
  39. 0x00,0xC0,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0xC0,0x00,0x00,
  40. 0xE0,0xFF,0xFF,0x03,0x60,0xC0,0x00,0x03,0x60,0xC0,0x00,0x03,0x60,0xC0,0x00,0x03,
  41. 0x60,0xC0,0x00,0x03,0x60,0xC0,0x00,0x03,0x60,0xC0,0x00,0x03,0xE0,0xFF,0xFF,0x03,
  42. 0x60,0xC0,0x00,0x03,0x60,0xC0,0x00,0x03,0x60,0xC0,0x00,0x03,0x60,0xC0,0x00,0x03,
  43. 0x60,0xC0,0x00,0x03,0xE0,0xFF,0xFF,0x03,0x60,0xC0,0x00,0x01,0x60,0xC0,0x00,0x00,
  44. 0x00,0xC0,0x00,0x08,0x00,0xC0,0x00,0x10,0x00,0xC0,0x00,0x10,0x00,0xC0,0x00,0x18,
  45. 0x00,0xC0,0x01,0x38,0x00,0x80,0xFF,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"电",3*/
  46. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
  47. 0xC0,0xFF,0xFF,0x07,0x00,0x00,0x80,0x07,0x00,0x00,0xC0,0x00,0x00,0x00,0x60,0x00,
  48. 0x00,0x00,0x18,0x00,0x00,0x00,0x0C,0x00,0x00,0x80,0x03,0x00,0x00,0x80,0x03,0x00,
  49. 0x00,0x80,0x01,0x00,0x00,0x80,0x01,0x08,0x00,0x80,0x01,0x1C,0xFC,0xFF,0xFF,0x3F,
  50. 0x00,0x80,0x01,0x00,0x00,0x80,0x01,0x00,0x00,0x80,0x01,0x00,0x00,0x80,0x01,0x00,
  51. 0x00,0x80,0x01,0x00,0x00,0x80,0x01,0x00,0x00,0x80,0x01,0x00,0x00,0x80,0x01,0x00,
  52. 0x00,0x80,0x01,0x00,0x00,0x80,0x01,0x00,0x00,0x80,0x01,0x00,0x00,0x80,0x01,0x00,
  53. 0x00,0xFC,0x01,0x00,0x00,0xE0,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,/*"子",4*/};
  54. const u8 asc2_1608[1520]={
  55. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  56. 0x00,0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00,0x18,0x18,0x00,0x00,
  57. 0x00,0x48,0x6C,0x24,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  58. 0x00,0x00,0x00,0x24,0x24,0x24,0x7F,0x12,0x12,0x12,0x7F,0x12,0x12,0x12,0x00,0x00,
  59. 0x00,0x00,0x08,0x1C,0x2A,0x2A,0x0A,0x0C,0x18,0x28,0x28,0x2A,0x2A,0x1C,0x08,0x08,
  60. 0x00,0x00,0x00,0x22,0x25,0x15,0x15,0x15,0x2A,0x58,0x54,0x54,0x54,0x22,0x00,0x00,
  61. 0x00,0x00,0x00,0x0C,0x12,0x12,0x12,0x0A,0x76,0x25,0x29,0x11,0x91,0x6E,0x00,0x00,
  62. 0x00,0x06,0x06,0x04,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  63. 0x00,0x40,0x20,0x10,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x10,0x10,0x20,0x40,0x00,
  64. 0x00,0x02,0x04,0x08,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x08,0x08,0x04,0x02,0x00,
  65. 0x00,0x00,0x00,0x00,0x08,0x08,0x6B,0x1C,0x1C,0x6B,0x08,0x08,0x00,0x00,0x00,0x00,
  66. 0x00,0x00,0x00,0x00,0x08,0x08,0x08,0x08,0x7F,0x08,0x08,0x08,0x08,0x00,0x00,0x00,
  67. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x04,0x03,
  68. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  69. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x00,0x00,
  70. 0x00,0x00,0x80,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x04,0x04,0x02,0x02,0x00,
  71. 0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18,0x00,0x00,
  72. 0x00,0x00,0x00,0x08,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00,
  73. 0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x20,0x20,0x10,0x08,0x04,0x42,0x7E,0x00,0x00,
  74. 0x00,0x00,0x00,0x3C,0x42,0x42,0x20,0x18,0x20,0x40,0x40,0x42,0x22,0x1C,0x00,0x00,
  75. 0x00,0x00,0x00,0x20,0x30,0x28,0x24,0x24,0x22,0x22,0x7E,0x20,0x20,0x78,0x00,0x00,
  76. 0x00,0x00,0x00,0x7E,0x02,0x02,0x02,0x1A,0x26,0x40,0x40,0x42,0x22,0x1C,0x00,0x00,
  77. 0x00,0x00,0x00,0x38,0x24,0x02,0x02,0x1A,0x26,0x42,0x42,0x42,0x24,0x18,0x00,0x00,
  78. 0x00,0x00,0x00,0x7E,0x22,0x22,0x10,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00,
  79. 0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x24,0x18,0x24,0x42,0x42,0x42,0x3C,0x00,0x00,
  80. 0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x64,0x58,0x40,0x40,0x24,0x1C,0x00,0x00,
  81. 0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,
  82. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x04,
  83. 0x00,0x00,0x00,0x40,0x20,0x10,0x08,0x04,0x02,0x04,0x08,0x10,0x20,0x40,0x00,0x00,
  84. 0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,
  85. 0x00,0x00,0x00,0x02,0x04,0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x04,0x02,0x00,0x00,
  86. 0x00,0x00,0x00,0x3C,0x42,0x42,0x46,0x40,0x20,0x10,0x10,0x00,0x18,0x18,0x00,0x00,
  87. 0x00,0x00,0x00,0x1C,0x22,0x5A,0x55,0x55,0x55,0x55,0x2D,0x42,0x22,0x1C,0x00,0x00,
  88. 0x00,0x00,0x00,0x08,0x08,0x18,0x14,0x14,0x24,0x3C,0x22,0x42,0x42,0xE7,0x00,0x00,
  89. 0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x1E,0x22,0x42,0x42,0x42,0x22,0x1F,0x00,0x00,
  90. 0x00,0x00,0x00,0x7C,0x42,0x42,0x01,0x01,0x01,0x01,0x01,0x42,0x22,0x1C,0x00,0x00,
  91. 0x00,0x00,0x00,0x1F,0x22,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x22,0x1F,0x00,0x00,
  92. 0x00,0x00,0x00,0x3F,0x42,0x12,0x12,0x1E,0x12,0x12,0x02,0x42,0x42,0x3F,0x00,0x00,
  93. 0x00,0x00,0x00,0x3F,0x42,0x12,0x12,0x1E,0x12,0x12,0x02,0x02,0x02,0x07,0x00,0x00,
  94. 0x00,0x00,0x00,0x3C,0x22,0x22,0x01,0x01,0x01,0x71,0x21,0x22,0x22,0x1C,0x00,0x00,
  95. 0x00,0x00,0x00,0xE7,0x42,0x42,0x42,0x42,0x7E,0x42,0x42,0x42,0x42,0xE7,0x00,0x00,
  96. 0x00,0x00,0x00,0x3E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00,
  97. 0x00,0x00,0x00,0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x11,0x0F,
  98. 0x00,0x00,0x00,0x77,0x22,0x12,0x0A,0x0E,0x0A,0x12,0x12,0x22,0x22,0x77,0x00,0x00,
  99. 0x00,0x00,0x00,0x07,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x42,0x7F,0x00,0x00,
  100. 0x00,0x00,0x00,0x77,0x36,0x36,0x36,0x36,0x2A,0x2A,0x2A,0x2A,0x2A,0x6B,0x00,0x00,
  101. 0x00,0x00,0x00,0xE3,0x46,0x46,0x4A,0x4A,0x52,0x52,0x52,0x62,0x62,0x47,0x00,0x00,
  102. 0x00,0x00,0x00,0x1C,0x22,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x22,0x1C,0x00,0x00,
  103. 0x00,0x00,0x00,0x3F,0x42,0x42,0x42,0x42,0x3E,0x02,0x02,0x02,0x02,0x07,0x00,0x00,
  104. 0x00,0x00,0x00,0x1C,0x22,0x41,0x41,0x41,0x41,0x41,0x4D,0x53,0x32,0x1C,0x60,0x00,
  105. 0x00,0x00,0x00,0x3F,0x42,0x42,0x42,0x3E,0x12,0x12,0x22,0x22,0x42,0xC7,0x00,0x00,
  106. 0x00,0x00,0x00,0x7C,0x42,0x42,0x02,0x04,0x18,0x20,0x40,0x42,0x42,0x3E,0x00,0x00,
  107. 0x00,0x00,0x00,0x7F,0x49,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x1C,0x00,0x00,
  108. 0x00,0x00,0x00,0xE7,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,0x00,
  109. 0x00,0x00,0x00,0xE7,0x42,0x42,0x22,0x24,0x24,0x14,0x14,0x18,0x08,0x08,0x00,0x00,
  110. 0x00,0x00,0x00,0x6B,0x49,0x49,0x49,0x49,0x55,0x55,0x36,0x22,0x22,0x22,0x00,0x00,
  111. 0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x18,0x18,0x18,0x24,0x24,0x42,0xE7,0x00,0x00,
  112. 0x00,0x00,0x00,0x77,0x22,0x22,0x14,0x14,0x08,0x08,0x08,0x08,0x08,0x1C,0x00,0x00,
  113. 0x00,0x00,0x00,0x7E,0x21,0x20,0x10,0x10,0x08,0x04,0x04,0x42,0x42,0x3F,0x00,0x00,
  114. 0x00,0x78,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x78,0x00,
  115. 0x00,0x00,0x02,0x02,0x04,0x04,0x08,0x08,0x08,0x10,0x10,0x20,0x20,0x20,0x40,0x40,
  116. 0x00,0x1E,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1E,0x00,
  117. 0x00,0x38,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  118. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
  119. 0x00,0x06,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  120. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x78,0x44,0x42,0x42,0xFC,0x00,0x00,
  121. 0x00,0x00,0x00,0x03,0x02,0x02,0x02,0x1A,0x26,0x42,0x42,0x42,0x26,0x1A,0x00,0x00,
  122. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x44,0x02,0x02,0x02,0x44,0x38,0x00,0x00,
  123. 0x00,0x00,0x00,0x60,0x40,0x40,0x40,0x78,0x44,0x42,0x42,0x42,0x64,0xD8,0x00,0x00,
  124. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x7E,0x02,0x02,0x42,0x3C,0x00,0x00,
  125. 0x00,0x00,0x00,0xF0,0x88,0x08,0x08,0x7E,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00,
  126. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x22,0x22,0x1C,0x02,0x3C,0x42,0x42,0x3C,
  127. 0x00,0x00,0x00,0x03,0x02,0x02,0x02,0x3A,0x46,0x42,0x42,0x42,0x42,0xE7,0x00,0x00,
  128. 0x00,0x00,0x00,0x0C,0x0C,0x00,0x00,0x0E,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00,
  129. 0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x38,0x20,0x20,0x20,0x20,0x20,0x20,0x22,0x1E,
  130. 0x00,0x00,0x00,0x03,0x02,0x02,0x02,0x72,0x12,0x0A,0x16,0x12,0x22,0x77,0x00,0x00,
  131. 0x00,0x00,0x00,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00,
  132. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x92,0x92,0x92,0x92,0x92,0xB7,0x00,0x00,
  133. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3B,0x46,0x42,0x42,0x42,0x42,0xE7,0x00,0x00,
  134. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,0x00,
  135. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1B,0x26,0x42,0x42,0x42,0x22,0x1E,0x02,0x07,
  136. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x44,0x42,0x42,0x42,0x44,0x78,0x40,0xE0,
  137. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x77,0x4C,0x04,0x04,0x04,0x04,0x1F,0x00,0x00,
  138. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x42,0x02,0x3C,0x40,0x42,0x3E,0x00,0x00,
  139. 0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x3E,0x08,0x08,0x08,0x08,0x08,0x30,0x00,0x00,
  140. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x42,0x42,0x42,0x42,0x62,0xDC,0x00,0x00,
  141. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x14,0x08,0x08,0x00,0x00,
  142. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xEB,0x49,0x49,0x55,0x55,0x22,0x22,0x00,0x00,
  143. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x76,0x24,0x18,0x18,0x18,0x24,0x6E,0x00,0x00,
  144. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x14,0x18,0x08,0x08,0x07,
  145. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x22,0x10,0x08,0x08,0x44,0x7E,0x00,0x00,
  146. 0x00,0xC0,0x20,0x20,0x20,0x20,0x20,0x10,0x20,0x20,0x20,0x20,0x20,0x20,0xC0,0x00,
  147. 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
  148. 0x00,0x06,0x08,0x08,0x08,0x08,0x08,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x06,0x00,
  149. 0x0C,0x32,0xC2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  150. };
  151. u8 Hzk16[]={
  152. 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0xFC,0x1F,0x84,0x10,0x84,0x10,0x84,0x10,
  153. 0x84,0x10,0x84,0x10,0xFC,0x1F,0x84,0x10,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,/*"中",0*/
  154. 0xF8,0x0F,0x08,0x08,0xF8,0x0F,0x08,0x08,0xF8,0x0F,0x80,0x00,0xFF,0x7F,0x00,0x00,
  155. 0xF8,0x0F,0x08,0x08,0x08,0x08,0xF8,0x0F,0x80,0x00,0x84,0x10,0xA2,0x20,0x40,0x00,/*"景",1*/
  156. 0x00,0x00,0xFE,0x3F,0x02,0x20,0xF2,0x27,0x02,0x20,0x02,0x20,0xFA,0x2F,0x22,0x21,
  157. 0x22,0x21,0x22,0x21,0x12,0x29,0x12,0x29,0x0A,0x2E,0x02,0x20,0xFE,0x3F,0x02,0x20,/*"园",2*/
  158. 0x80,0x00,0x80,0x00,0x80,0x00,0xFC,0x1F,0x84,0x10,0x84,0x10,0x84,0x10,0xFC,0x1F,
  159. 0x84,0x10,0x84,0x10,0x84,0x10,0xFC,0x1F,0x84,0x50,0x80,0x40,0x80,0x40,0x00,0x7F,/*"电",3*/
  160. 0x00,0x00,0xFE,0x1F,0x00,0x08,0x00,0x04,0x00,0x02,0x80,0x01,0x80,0x00,0xFF,0x7F,
  161. 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0xA0,0x00,0x40,0x00,/*"子",4*/
  162. 0x10,0x08,0xB8,0x08,0x0F,0x09,0x08,0x09,0x08,0x08,0xBF,0x08,0x08,0x09,0x1C,0x09,
  163. 0x2C,0x08,0x0A,0x78,0xCA,0x0F,0x09,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,/*"科",5*/
  164. 0x08,0x04,0x08,0x04,0x08,0x04,0xC8,0x7F,0x3F,0x04,0x08,0x04,0x08,0x04,0xA8,0x3F,
  165. 0x18,0x21,0x0C,0x11,0x0B,0x12,0x08,0x0A,0x08,0x04,0x08,0x0A,0x8A,0x11,0x64,0x60,/*"技",6*/
  166. };
  167. #endif
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <unistd.h>
  4. #include "cmsis_os2.h"
  5. #include "ohos_init.h"
  6. #include "lcd_st7789.h"
  7. static void show(void)
  8. {
  9. u8 i, m;
  10. float t = 0;
  11. Lcd_Init(); // 初始化OLED
  12. LCD_Clear(WHITE);
  13. BACK_COLOR = WHITE;
  14. while (1)
  15. {
  16. LCD_ShowChinese(10, 0, 0, 32, RED); // 中
  17. LCD_ShowChinese(45, 0, 1, 32, RED); // 景
  18. LCD_ShowChinese(80, 0, 2, 32, RED); // 园
  19. LCD_ShowChinese(115, 0, 3, 32, RED); // 电
  20. LCD_ShowChinese(150, 0, 4, 32, RED); // 子
  21. LCD_ShowChinese(10, 75, 0, 16, RED); // 中
  22. LCD_ShowChinese(45, 75, 1, 16, RED); // 景
  23. LCD_ShowChinese(80, 75, 2, 16, RED); // 园
  24. LCD_ShowChinese(115, 75, 3, 16, RED); // 电
  25. LCD_ShowChinese(150, 75, 4, 16, RED); // 子
  26. LCD_ShowString(10, 35, "2.4 TFT SPI 240*320", RED);
  27. LCD_ShowString(10, 55, "LCD_W:", RED);
  28. LCD_ShowNum(70, 55, LCD_W, 3, RED);
  29. LCD_ShowString(110, 55, "LCD_H:", RED);
  30. LCD_ShowNum(160, 55, LCD_H, 3, RED);
  31. for (i = 0; i < 5; i++)
  32. {
  33. for (m = 0; m < 6; m++)
  34. {
  35. LCD_ShowPicture(0 + m * 40, 120 + i * 40, 39 + m * 40, 159 + i * 40);
  36. }
  37. }
  38. while (1)
  39. {
  40. LCD_ShowNum1(80, 95, t, 5, RED);
  41. t += 0.01;
  42. }
  43. }
  44. }
  45. static void main(void)
  46. {
  47. osThreadAttr_t attr;
  48. attr.name = "st7789";
  49. attr.attr_bits = 0U;
  50. attr.cb_mem = NULL;
  51. attr.cb_size = 0U;
  52. attr.stack_mem = NULL;
  53. attr.stack_size = 1024 * 8;
  54. attr.priority = 25;
  55. // Create the Thread1 task
  56. if (osThreadNew((osThreadFunc_t)show, NULL, &attr) == NULL)
  57. {
  58. printf("Failed to create say hello Thread!\n");
  59. }
  60. }
  61. APP_FEATURE_INIT(main);

OHOS移植LVGL流程

LVGL源码下载

此案例采用lvgl 8.2.0版本,源码下载地址:https://github.com/lvgl/lvgl
首先,切换lvgl版本,如下图所示:
085.png
切换完成后,版本信息不再是master而是v8.2.0,接着就可以下载这个版本了。如下图:
086.png

LVGL子系统构建

来到开发板目录,当前开发板目录为device/board/itcast/genkipi/,我们之前已经在这个开发板中,构建了services子集服务。我们可以把LVGL放到这个子集中去。
构建流程如下:

  1. 在services下新建LVGL文件夹。并且新建BUILD.gn
  2. LVGL目录下新建lvgllvgl_driver目录,并且在每个目录创建BUILD.gn文件
  3. 编辑几个BUILD.gn文件

    1. group("LVGL") {
    2. deps = [
    3. "lvgl",
    4. "lvgl_driver"
    5. ]
    6. }
    1. static_library("lvgl") {
    2. sources = [
    3. ]
    4. include_dirs = [
    5. ]
    6. }
    1. static_library("lvgl_driver") {
    2. sources = [
    3. ]
    4. include_dirs = [
    5. ]
    6. }
    1. group("genkipi_services") {
    2. deps = [
    3. "wifi:genkipi_wifi",
    4. "LVGL"
    5. ]
    6. }

    LVGL源码移植

  4. lvgl-8.2.0源码文件夹下的src,example,lvgl.h,lv_conf_template.h拷贝到services/LVGL/lvgl目录中。

  5. 编辑lvgl/BUILD.gn,将src下的c文件配置到sources中去。 ```c static_library(“lvgl”) { sources = [ “src\core\lv_disp.c”, “src\core\lv_event.c”, “src\core\lv_group.c”, “src\core\lv_indev.c”, “src\core\lv_indev_scroll.c”, “src\core\lv_obj.c”, “src\core\lv_obj_class.c”, “src\core\lv_obj_draw.c”, “src\core\lv_obj_pos.c”, “src\core\lv_obj_scroll.c”, “src\core\lv_obj_style.c”, “src\core\lv_obj_style_gen.c”, “src\core\lv_obj_tree.c”, “src\core\lv_refr.c”, “src\core\lv_theme.c”, “src\draw\lv_draw.c”, “src\draw\lv_draw_arc.c”, “src\draw\lv_draw_img.c”, “src\draw\lv_draw_label.c”, “src\draw\lv_draw_line.c”, “src\draw\lv_draw_mask.c”, “src\draw\lv_draw_rect.c”, “src\draw\lv_draw_triangle.c”, “src\draw\lv_img_buf.c”, “src\draw\lv_img_cache.c”, “src\draw\lv_img_decoder.c”, “src\draw\nxp_pxp\lv_gpu_nxp_pxp.c”, “src\draw\nxp_pxp\lv_gpu_nxp_pxp_osa.c”, “src\draw\nxp_vglite\lv_gpu_nxp_vglite.c”, “src\draw\sdl\lv_draw_sdl.c”, “src\draw\sdl\lv_draw_sdl_arc.c”, “src\draw\sdl\lv_draw_sdl_bg.c”, “src\draw\sdl\lv_draw_sdl_composite.c”, “src\draw\sdl\lv_draw_sdl_img.c”, “src\draw\sdl\lv_draw_sdl_label.c”, “src\draw\sdl\lv_draw_sdl_line.c”, “src\draw\sdl\lv_draw_sdl_mask.c”, “src\draw\sdl\lv_draw_sdl_polygon.c”, “src\draw\sdl\lv_draw_sdl_rect.c”, “src\draw\sdl\lv_draw_sdl_stack_blur.c”, “src\draw\sdl\lv_draw_sdl_texture_cache.c”, “src\draw\sdl\lv_draw_sdl_utils.c”, “src\draw\stm32_dma2d\lv_gpu_stm32_dma2d.c”, “src\draw\sw\lv_draw_sw.c”, “src\draw\sw\lv_draw_sw_arc.c”, “src\draw\sw\lv_draw_sw_blend.c”, “src\draw\sw\lv_draw_sw_dither.c”, “src\draw\sw\lv_draw_sw_gradient.c”, “src\draw\sw\lv_draw_sw_img.c”, “src\draw\sw\lv_draw_sw_letter.c”, “src\draw\sw\lv_draw_sw_line.c”, “src\draw\sw\lv_draw_sw_polygon.c”, “src\draw\sw\lv_draw_sw_rect.c”, “src\extra\layouts\flex\lv_flex.c”, “src\extra\layouts\grid\lv_grid.c”, “src\extra\libs\bmp\lv_bmp.c”, “src\extra\libs\ffmpeg\lv_ffmpeg.c”, “src\extra\libs\freetype\lv_freetype.c”, “src\extra\libs\fsdrv\lv_fs_fatfs.c”, “src\extra\libs\fsdrv\lv_fs_posix.c”, “src\extra\libs\fsdrv\lv_fs_stdio.c”, “src\extra\libs\fsdrv\lv_fs_win32.c”, “src\extra\libs\gif\gifdec.c”, “src\extra\libs\gif\lv_gif.c”, “src\extra\libs\png\lodepng.c”, “src\extra\libs\png\lv_png.c”, “src\extra\libs\qrcode\lv_qrcode.c”, “src\extra\libs\qrcode\qrcodegen.c”, “src\extra\libs\rlottie\lv_rlottie.c”, “src\extra\libs\sjpg\lv_sjpg.c”, “src\extra\libs\sjpg\tjpgd.c”, “src\extra\lv_extra.c”, “src\extra\others\gridnav\lv_gridnav.c”, “src\extra\others\monkey\lv_monkey.c”, “src\extra\others\snapshot\lv_snapshot.c”, “src\extra\themes\basic\lv_theme_basic.c”, “src\extra\themes\default\lv_theme_default.c”, “src\extra\themes\mono\lv_theme_mono.c”, “src\extra\widgets\animimg\lv_animimg.c”, “src\extra\widgets\calendar\lv_calendar.c”, “src\extra\widgets\calendar\lv_calendar_header_arrow.c”, “src\extra\widgets\calendar\lv_calendar_header_dropdown.c”, “src\extra\widgets\chart\lv_chart.c”, “src\extra\widgets\colorwheel\lv_colorwheel.c”, “src\extra\widgets\imgbtn\lv_imgbtn.c”, “src\extra\widgets\keyboard\lv_keyboard.c”, “src\extra\widgets\led\lv_led.c”, “src\extra\widgets\list\lv_list.c”, “src\extra\widgets\menu\lv_menu.c”, “src\extra\widgets\meter\lv_meter.c”, “src\extra\widgets\msgbox\lv_msgbox.c”, “src\extra\widgets\span\lv_span.c”, “src\extra\widgets\spinbox\lv_spinbox.c”, “src\extra\widgets\spinner\lv_spinner.c”, “src\extra\widgets\tabview\lv_tabview.c”, “src\extra\widgets\tileview\lv_tileview.c”, “src\extra\widgets\win\lv_win.c”, “src\font\lv_font.c”, “src\font\lv_font_dejavu_16_persian_hebrew.c”, “src\font\lv_font_fmt_txt.c”, “src\font\lv_font_loader.c”, “src\font\lv_font_montserrat_10.c”, “src\font\lv_font_montserrat_12.c”, “src\font\lv_font_montserrat_12_subpx.c”, “src\font\lv_font_montserrat_14.c”, “src\font\lv_font_montserrat_16.c”, “src\font\lv_font_montserrat_18.c”, “src\font\lv_font_montserrat_20.c”, “src\font\lv_font_montserrat_22.c”, “src\font\lv_font_montserrat_24.c”, “src\font\lv_font_montserrat_26.c”, “src\font\lv_font_montserrat_28.c”, “src\font\lv_font_montserrat_28_compressed.c”, “src\font\lv_font_montserrat_30.c”, “src\font\lv_font_montserrat_32.c”, “src\font\lv_font_montserrat_34.c”, “src\font\lv_font_montserrat_36.c”, “src\font\lv_font_montserrat_38.c”, “src\font\lv_font_montserrat_40.c”, “src\font\lv_font_montserrat_42.c”, “src\font\lv_font_montserrat_44.c”, “src\font\lv_font_montserrat_46.c”, “src\font\lv_font_montserrat_48.c”, “src\font\lv_font_montserrat_8.c”, “src\font\lv_font_simsun_16_cjk.c”, “src\font\lv_font_unscii_16.c”, “src\font\lv_font_unscii_8.c”, “src\hal\lv_hal_disp.c”, “src\hal\lv_hal_indev.c”, “src\hal\lv_hal_tick.c”, “src\misc\lv_anim.c”, “src\misc\lv_anim_timeline.c”, “src\misc\lv_area.c”, “src\misc\lv_async.c”, “src\misc\lv_bidi.c”, “src\misc\lv_color.c”, “src\misc\lv_fs.c”, “src\misc\lv_gc.c”, “src\misc\lv_ll.c”, “src\misc\lv_log.c”, “src\misc\lv_lru.c”, “src\misc\lv_math.c”, “src\misc\lv_mem.c”, “src\misc\lv_printf.c”, “src\misc\lv_style.c”, “src\misc\lv_style_gen.c”, “src\misc\lv_templ.c”, “src\misc\lv_timer.c”, “src\misc\lv_tlsf.c”, “src\misc\lv_txt.c”, “src\misc\lv_txt_ap.c”, “src\misc\lv_utils.c”, “src\widgets\lv_arc.c”, “src\widgets\lv_bar.c”, “src\widgets\lv_btn.c”, “src\widgets\lv_btnmatrix.c”, “src\widgets\lv_canvas.c”, “src\widgets\lv_checkbox.c”, “src\widgets\lv_dropdown.c”, “src\widgets\lv_img.c”, “src\widgets\lv_label.c”, “src\widgets\lv_line.c”, “src\widgets\lv_objx_templ.c”, “src\widgets\lv_roller.c”, “src\widgets\lv_slider.c”, “src\widgets\lv_switch.c”, “src\widgets\lv_table.c”, “src\widgets\lv_textarea.c”, ] include_dirs = [ ] }
  1. 3. 拷贝`lvgl\lv_conf_template.h`文件,放到`LVGL`目录中,并且重命名为`lv_conf.h`
  2. <a name="CWa7B"></a>
  3. #### ST7789驱动移植
  4. <a name="J0Syr"></a>
  5. ##### 裁剪驱动
  6. ST7789驱动(`lcd_st7789.h``lcd_st7789.c`)拷贝到`lvgl_driver`目录下。<br />对驱动进行裁剪,我们在开发过程中,只会用到填充点函数作为LVGL的底层操作,所以,其他绘制函数都可以剔除掉。<br />裁剪的原则:
  7. 1. 剔除不用的函数
  8. 2. 防止函数和文件重名
  9. 裁剪后的代码为:
  10. ```c
  11. #ifndef __LVGL_LCD_ST7789_H__
  12. #define __LVGL_LCD_ST7789_H__
  13. #include "iot_gpio.h"
  14. #include "iot_gpio_ex.h"
  15. #include "iot_spi.h"
  16. #define USE_HORIZONTAL 0 //设置横屏或者竖屏显示 0或1为竖屏 2或3为横屏
  17. #if USE_HORIZONTAL==0||USE_HORIZONTAL==1
  18. #define ST7789_W 240
  19. #define ST7789_H 240
  20. #else
  21. #define ST7789_W 240
  22. #define ST7789_H 240
  23. #endif
  24. #define u8 unsigned char
  25. #define u16 unsigned int
  26. #define u32 unsigned long
  27. #define SDC IOT_IO_NAME_6
  28. #define SDIN IOT_IO_NAME_8
  29. #define RST IOT_IO_NAME_5
  30. #define DC IOT_IO_NAME_7
  31. #define SDC_FUNC IOT_GPIO_FUNC_GPIO_6_SPI0_CK
  32. #define SDIN_FUNC IOT_GPIO_FUNC_GPIO_8_SPI0_TXD
  33. #define RST_FUNC IOT_GPIO_FUNC_GPIO_5_GPIO
  34. #define DC_FUNC IOT_GPIO_FUNC_GPIO_7_GPIO
  35. #define ST7789_PIN_INIT() \
  36. IoTGpioInit(SDC); \
  37. IoTGpioSetFunc(SDC, SDC_FUNC); \
  38. IoTGpioSetDir(SDC, IOT_GPIO_DIR_OUT); \
  39. IoTGpioInit(SDIN); \
  40. IoTGpioSetFunc(SDIN, SDIN_FUNC); \
  41. IoTGpioSetDir(SDIN, IOT_GPIO_DIR_OUT); \
  42. IoTGpioInit(RST); \
  43. IoTGpioSetFunc(RST, RST_FUNC); \
  44. IoTGpioSetDir(RST, IOT_GPIO_DIR_OUT); \
  45. IoTGpioInit(DC); \
  46. IoTGpioSetFunc(DC, DC_FUNC); \
  47. IoTGpioSetDir(DC, IOT_GPIO_DIR_OUT);
  48. #define ST7789_SPI_INIT() \
  49. IoTSpiCfgInitParam param; \
  50. param.isSlave = 0; \
  51. IoTSpiCfgBasicInfo info; \
  52. info.cpol = IOT_SPI_CFG_CLOCK_CPOL_1; \
  53. info.cpha = IOT_SPI_CFG_CLOCK_CPHA_1; \
  54. info.framMode = IOT_SPI_CFG_FRAM_MODE_MOTOROLA; \
  55. info.dataWidth = IOT_SPI_CFG_DATA_WIDTH_E_8BIT; \
  56. info.endian = IOT_SPI_CFG_ENDIAN_LITTLE; \
  57. info.pad = 31; \
  58. info.freq = 40000000; \
  59. IoTSpiInit(0, param, &info);
  60. #define OLED_SCLK_Set() IoTGpioSetOutputVal(SDC, 1)
  61. #define OLED_SCLK_Clr() IoTGpioSetOutputVal(SDC, 0)
  62. #define OLED_SDIN_Set() IoTGpioSetOutputVal(SDIN, 1);
  63. #define OLED_SDIN_Clr() IoTGpioSetOutputVal(SDIN, 0);
  64. #define OLED_RST_Set() IoTGpioSetOutputVal(RST, 1);
  65. #define OLED_RST_Clr() IoTGpioSetOutputVal(RST, 0);
  66. #define OLED_DC_Set() IoTGpioSetOutputVal(DC, 1);
  67. #define OLED_DC_Clr() IoTGpioSetOutputVal(DC, 0);
  68. #define OLED_CMD 0 //写命令
  69. #define OLED_DATA 1 //写数据
  70. // extern u16 BACK_COLOR; //背景色
  71. void ST7789_Writ_Bus(u8 dat);
  72. void ST7789_WR_DATA8(u8 dat);
  73. void ST7789_WR_DATA(u16 dat);
  74. void ST7789_WR_REG(u8 dat);
  75. void ST7789_Address_Set(u16 x1,u16 y1,u16 x2,u16 y2);
  76. void ST7789_Init(void);
  77. void ST7789_Clear(u16 Color);
  78. void ST7789_Fill(u16 xsta,u16 ysta,u16 xend,u16 yend,u16 color);
  79. //画笔颜色
  80. #define WHITE 0xFFFF
  81. #define BLACK 0x0000
  82. #define BLUE 0x001F
  83. #define BRED 0XF81F
  84. #define GRED 0XFFE0
  85. #define GBLUE 0X07FF
  86. #define RED 0xF800
  87. #define MAGENTA 0xF81F
  88. #define GREEN 0x07E0
  89. #define CYAN 0x7FFF
  90. #define YELLOW 0xFFE0
  91. #define BROWN 0XBC40 //棕色
  92. #define BRRED 0XFC07 //棕红色
  93. #define GRAY 0X8430 //灰色
  94. //GUI颜色
  95. #define DARKBLUE 0X01CF //深蓝色
  96. #define LIGHTBLUE 0X7D7C //浅蓝色
  97. #define GRAYBLUE 0X5458 //灰蓝色
  98. //以上三色为PANEL的颜色
  99. #define LIGHTGREEN 0X841F //浅绿色
  100. #define LGRAY 0XC618 //浅灰色(PANNEL),窗体背景色
  101. #define LGRAYBLUE 0XA651 //浅灰蓝色(中间层颜色)
  102. #define LBBLUE 0X2B12 //浅棕蓝色(选择条目的反色)
  103. #endif
  1. #include "lcd_st7789.h"
  2. #include <unistd.h>
  3. // u16 BACK_COLOR; //背景色
  4. /******************************************************************************
  5. 函数说明:LCD串行数据写入函数
  6. 入口数据:dat 要写入的串行数据
  7. 返回值: 无
  8. ******************************************************************************/
  9. void ST7789_Writ_Bus(u8 dat)
  10. {
  11. // u8 i;
  12. // //OLED_CS_Clr();
  13. // for(i=0;i<8;i++)
  14. // {
  15. // OLED_SCLK_Clr();
  16. // if(dat&0x80) {
  17. // OLED_SDIN_Set();
  18. // }
  19. // else {
  20. // OLED_SDIN_Clr();
  21. // }
  22. // OLED_SCLK_Set();
  23. // dat<<=1;
  24. // }
  25. // //OLED_CS_Set();
  26. IoTSpiHostWrite(0, &dat, 1);
  27. }
  28. /******************************************************************************
  29. 函数说明:LCD写入数据
  30. 入口数据:dat 写入的数据
  31. 返回值: 无
  32. ******************************************************************************/
  33. void ST7789_WR_DATA8(u8 dat)
  34. {
  35. OLED_DC_Set();//写数据
  36. ST7789_Writ_Bus(dat);
  37. }
  38. /******************************************************************************
  39. 函数说明:LCD写入数据
  40. 入口数据:dat 写入的数据
  41. 返回值: 无
  42. ******************************************************************************/
  43. void ST7789_WR_DATA(u16 dat)
  44. {
  45. OLED_DC_Set();//写数据
  46. ST7789_Writ_Bus(dat>>8);
  47. ST7789_Writ_Bus(dat);
  48. }
  49. /******************************************************************************
  50. 函数说明:LCD写入命令
  51. 入口数据:dat 写入的命令
  52. 返回值: 无
  53. ******************************************************************************/
  54. void ST7789_WR_REG(u8 dat)
  55. {
  56. OLED_DC_Clr();//写命令
  57. ST7789_Writ_Bus(dat);
  58. }
  59. /******************************************************************************
  60. 函数说明:设置起始和结束地址
  61. 入口数据:x1,x2 设置列的起始和结束地址
  62. y1,y2 设置行的起始和结束地址
  63. 返回值: 无
  64. ******************************************************************************/
  65. void ST7789_Address_Set(u16 x1,u16 y1,u16 x2,u16 y2)
  66. {
  67. if(USE_HORIZONTAL==0)
  68. {
  69. ST7789_WR_REG(0x2a);//列地址设置
  70. ST7789_WR_DATA(x1);
  71. ST7789_WR_DATA(x2);
  72. ST7789_WR_REG(0x2b);//行地址设置
  73. ST7789_WR_DATA(y1);
  74. ST7789_WR_DATA(y2);
  75. ST7789_WR_REG(0x2c);//储存器写
  76. }
  77. else if(USE_HORIZONTAL==1)
  78. {
  79. ST7789_WR_REG(0x2a);//列地址设置
  80. ST7789_WR_DATA(x1);
  81. ST7789_WR_DATA(x2);
  82. ST7789_WR_REG(0x2b);//行地址设置
  83. ST7789_WR_DATA(y1+80);
  84. ST7789_WR_DATA(y2+80);
  85. ST7789_WR_REG(0x2c);//储存器写
  86. }
  87. else if(USE_HORIZONTAL==2)
  88. {
  89. ST7789_WR_REG(0x2a);//列地址设置
  90. ST7789_WR_DATA(x1);
  91. ST7789_WR_DATA(x2);
  92. ST7789_WR_REG(0x2b);//行地址设置
  93. ST7789_WR_DATA(y1);
  94. ST7789_WR_DATA(y2);
  95. ST7789_WR_REG(0x2c);//储存器写
  96. }
  97. else
  98. {
  99. ST7789_WR_REG(0x2a);//列地址设置
  100. ST7789_WR_DATA(x1+80);
  101. ST7789_WR_DATA(x2+80);
  102. ST7789_WR_REG(0x2b);//行地址设置
  103. ST7789_WR_DATA(y1);
  104. ST7789_WR_DATA(y2);
  105. ST7789_WR_REG(0x2c);//储存器写
  106. }
  107. }
  108. /******************************************************************************
  109. 函数说明:LCD初始化函数
  110. 入口数据:无
  111. 返回值: 无
  112. ******************************************************************************/
  113. void ST7789_Init(void)
  114. {
  115. ST7789_PIN_INIT();
  116. ST7789_SPI_INIT();
  117. OLED_RST_Clr();
  118. usleep(20 * 1000);
  119. OLED_RST_Set();
  120. usleep(20 * 1000);
  121. // OLED_BLK_Set();
  122. //************* Start Initial Sequence **********//
  123. ST7789_WR_REG(0x36);
  124. if(USE_HORIZONTAL==0)ST7789_WR_DATA8(0x00);
  125. else if(USE_HORIZONTAL==1)ST7789_WR_DATA8(0xC0);
  126. else if(USE_HORIZONTAL==2)ST7789_WR_DATA8(0x70);
  127. else ST7789_WR_DATA8(0xA0);
  128. ST7789_WR_REG(0x3A);
  129. ST7789_WR_DATA8(0x05);
  130. ST7789_WR_REG(0xB2);
  131. ST7789_WR_DATA8(0x0C);
  132. ST7789_WR_DATA8(0x0C);
  133. ST7789_WR_DATA8(0x00);
  134. ST7789_WR_DATA8(0x33);
  135. ST7789_WR_DATA8(0x33);
  136. ST7789_WR_REG(0xB7);
  137. ST7789_WR_DATA8(0x35);
  138. ST7789_WR_REG(0xBB);
  139. ST7789_WR_DATA8(0x37);
  140. ST7789_WR_REG(0xC0);
  141. ST7789_WR_DATA8(0x2C);
  142. ST7789_WR_REG(0xC2);
  143. ST7789_WR_DATA8(0x01);
  144. ST7789_WR_REG(0xC3);
  145. ST7789_WR_DATA8(0x12);
  146. ST7789_WR_REG(0xC4);
  147. ST7789_WR_DATA8(0x20);
  148. ST7789_WR_REG(0xC6);
  149. ST7789_WR_DATA8(0x0F);
  150. ST7789_WR_REG(0xD0);
  151. ST7789_WR_DATA8(0xA4);
  152. ST7789_WR_DATA8(0xA1);
  153. ST7789_WR_REG(0xE0);
  154. ST7789_WR_DATA8(0xD0);
  155. ST7789_WR_DATA8(0x04);
  156. ST7789_WR_DATA8(0x0D);
  157. ST7789_WR_DATA8(0x11);
  158. ST7789_WR_DATA8(0x13);
  159. ST7789_WR_DATA8(0x2B);
  160. ST7789_WR_DATA8(0x3F);
  161. ST7789_WR_DATA8(0x54);
  162. ST7789_WR_DATA8(0x4C);
  163. ST7789_WR_DATA8(0x18);
  164. ST7789_WR_DATA8(0x0D);
  165. ST7789_WR_DATA8(0x0B);
  166. ST7789_WR_DATA8(0x1F);
  167. ST7789_WR_DATA8(0x23);
  168. ST7789_WR_REG(0xE1);
  169. ST7789_WR_DATA8(0xD0);
  170. ST7789_WR_DATA8(0x04);
  171. ST7789_WR_DATA8(0x0C);
  172. ST7789_WR_DATA8(0x11);
  173. ST7789_WR_DATA8(0x13);
  174. ST7789_WR_DATA8(0x2C);
  175. ST7789_WR_DATA8(0x3F);
  176. ST7789_WR_DATA8(0x44);
  177. ST7789_WR_DATA8(0x51);
  178. ST7789_WR_DATA8(0x2F);
  179. ST7789_WR_DATA8(0x1F);
  180. ST7789_WR_DATA8(0x1F);
  181. ST7789_WR_DATA8(0x20);
  182. ST7789_WR_DATA8(0x23);
  183. ST7789_WR_REG(0x21);
  184. ST7789_WR_REG(0x11);
  185. //Delay (120);
  186. ST7789_WR_REG(0x29);
  187. }
  188. /******************************************************************************
  189. 函数说明:LCD清屏函数
  190. 入口数据:无
  191. 返回值: 无
  192. ******************************************************************************/
  193. void ST7789_Clear(u16 Color)
  194. {
  195. u16 i,j;
  196. ST7789_Address_Set(0,0,ST7789_W-1,ST7789_H-1);
  197. for(i=0;i<ST7789_W;i++)
  198. {
  199. for (j=0;j<ST7789_H;j++)
  200. {
  201. ST7789_WR_DATA(Color);
  202. }
  203. }
  204. }
  205. /******************************************************************************
  206. 函数说明:在指定区域填充颜色
  207. 入口数据:xsta,ysta 起始坐标
  208. xend,yend 终止坐标
  209. 返回值: 无
  210. ******************************************************************************/
  211. void ST7789_Fill(u16 xsta,u16 ysta,u16 xend,u16 yend,u16 color)
  212. {
  213. u16 i,j;
  214. ST7789_Address_Set(xsta,ysta,xend,yend); //设置光标位置
  215. for(i=ysta;i<=yend;i++)
  216. {
  217. for(j=xsta;j<=xend;j++)ST7789_WR_DATA(color);//设置光标位置
  218. }
  219. }

lvgl驱动接口移植

lvgl/examples/porting/lv_port_disp_template.hlvgl/examples/porting/lv_port_disp_template.c这个个模板文件拷贝到lv_driver目录中来,并且重新命名为:lv_port_disp.hlv_port_disp.c
lcd_st7789.clv_port_disp.c配置到BUILD.gn

  1. static_library("lvgl_driver") {
  2. sources = [
  3. "lcd_st7789.c",
  4. "lv_port_disp.c"
  5. ]
  6. include_dirs = [
  7. "//base/iothardware/peripheral/interfaces/inner_api",
  8. "../../../iot_hardware_hals/include",
  9. ]
  10. }

LVGL与ST7789驱动对接

lvgl_driver配置
  1. 开放lv_port_disp.hlv_port_disp.c,lv_conf.h的编译标识

    1. #if 1
  2. 增加引用路径。增加上一级目录。用..表示

    1. include_dirs = [
    2. "..",
    3. ]
  3. 修改lv_port_disp.c引用,将#include "../../lvgl.h"改为如下:

    1. #include "lvgl/lvgl.h"

    lv_port_disp对接

  4. 配置驱动头文件引入,并且定义屏幕大小 ```c

    include “lcd_st7789.h”

/*

  • DEFINES */

    define LV_HOR_RES_MAX (240)

    define LV_VER_RES_MAX (240)

    ```
  1. 修改disp_init函数,初始化st7789屏幕

    1. static void disp_init(void)
    2. {
    3. ST7789_Init();
    4. }
  2. 配置lv_port_disp_init函数,配置一种缓存绘制方式,我们选择 单缓冲: ```c / Example for 1) / static lv_disp_draw_buf_t draw_buf_dsc_1; static lv_color_t draw_buf_1[LV_HOR_RES_MAX 10]; /A buffer for 10 rows/ lv_disp_draw_buf_init(&draw_buf_dsc_1, draw_buf_1, NULL, LV_HOR_RES_MAX 10); /Initialize the display buffer/

// / Example for 2) / // static lv_disp_draw_buf_t draw_buf_dsc_2; // static lv_color_t buf_2_1[MY_DISP_HOR_RES 10]; /A buffer for 10 rows/ // static lv_color_t buf_2_2[MY_DISP_HOR_RES 10]; /An other buffer for 10 rows/ // lv_disp_draw_buf_init(&draw_buf_dsc_2, buf_2_1, buf_2_2, MY_DISP_HOR_RES 10); /Initialize the display buffer*/

// / Example for 3) also set disp_drv.full_refresh = 1 below/ // static lv_disp_draw_buf_t draw_buf_dsc_3; // static lv_color_t buf_3_1[MY_DISP_HOR_RES MY_DISP_VER_RES]; /A screen sized buffer/ // static lv_color_t buf_3_2[MY_DISP_HOR_RES MY_DISP_VER_RES]; /Another screen sized buffer/ // lv_disp_draw_buf_init(&draw_buf_dsc_3, buf_3_1, buf_3_2, MY_DISP_VER_RES LV_VER_RES_MAX); /Initialize the display buffer*/

  1. - 只开启单缓冲
  2. 4. 配置`disp_flush`函数,配置屏幕点颜色填充逻辑:
  3. ```c
  4. static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
  5. {
  6. ST7789_Fill(area->x1, area->y1, area->x2, area->y2, color_p);
  7. /*IMPORTANT!!!
  8. *Inform the graphics library that you are ready with the flushing*/
  9. lv_disp_flush_ready(disp_drv);
  10. }
  1. 修改ST7789_Fill实现

    1. // void ST7789_Fill(u16 xsta,u16 ysta,u16 xend,u16 yend,u16 color);
    2. void ST7789_Fill(u16 xsta, u16 ysta, u16 xend, u16 yend, u16 *color);
    1. void ST7789_Fill(u16 xsta,u16 ysta,u16 xend,u16 yend,uint16_t *color)
    2. {
    3. // u16 i,j;
    4. // ST7789_Address_Set(xsta,ysta,xend,yend); //设置光标位置
    5. // for(i=ysta;i<=yend;i++)
    6. // {
    7. // for(j=xsta;j<=xend;j++)ST7789_WR_DATA(*color);//设置光标位置
    8. // }
    9. uint32_t size = 0;
    10. ST7789_Address_Set(xsta,ysta,xend,yend);
    11. size = ((xend - xsta) + 1) * ((yend - ysta) + 1)*2;
    12. OLED_DC_Set();
    13. IoTSpiHostWrite(0, (uint8_t*) color, size);
    14. }

    完整代码

    ```c /**

    • @file lv_port_disp.h /

    /Copy this file as “lv_port_disp.h” and set this value to “1” to enable content/

    if 1

ifndef LV_PORT_DISP_H

define LV_PORT_DISP_H

ifdef __cplusplus

extern “C” {

endif

/*

  • INCLUDES */

    include “lvgl/lvgl.h”

/*

  • DEFINES */

/**

  • TYPEDEFS **/

/**

  • GLOBAL PROTOTYPES **/ void lv_port_disp_init(void);

/**

  • MACROS **/

ifdef __cplusplus

} /extern “C”/

endif

endif /LV_PORT_DISP_TEMPL_H/

endif /Disable/Enable content/

  1. ```c
  2. /**
  3. * @file lv_port_disp.c
  4. *
  5. */
  6. /*Copy this file as "lv_port_disp.c" and set this value to "1" to enable content*/
  7. #if 1
  8. /*********************
  9. * INCLUDES
  10. *********************/
  11. #include "lv_port_disp.h"
  12. #include "lvgl/lvgl.h"
  13. #include "lcd_st7789.h"
  14. /*********************
  15. * DEFINES
  16. *********************/
  17. #define LV_HOR_RES_MAX (240)
  18. #define LV_VER_RES_MAX (240)
  19. /**********************
  20. * TYPEDEFS
  21. **********************/
  22. /**********************
  23. * STATIC PROTOTYPES
  24. **********************/
  25. static void disp_init(void);
  26. static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p);
  27. //static void gpu_fill(lv_disp_drv_t * disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width,
  28. // const lv_area_t * fill_area, lv_color_t color);
  29. /**********************
  30. * STATIC VARIABLES
  31. **********************/
  32. /**********************
  33. * MACROS
  34. **********************/
  35. /**********************
  36. * GLOBAL FUNCTIONS
  37. **********************/
  38. void lv_port_disp_init(void)
  39. {
  40. /*-------------------------
  41. * Initialize your display
  42. * -----------------------*/
  43. disp_init();
  44. /*-----------------------------
  45. * Create a buffer for drawing
  46. *----------------------------*/
  47. /**
  48. * LVGL requires a buffer where it internally draws the widgets.
  49. * Later this buffer will passed to your display driver's `flush_cb` to copy its content to your display.
  50. * The buffer has to be greater than 1 display row
  51. *
  52. * There are 3 buffering configurations:
  53. * 1. Create ONE buffer:
  54. * LVGL will draw the display's content here and writes it to your display
  55. *
  56. * 2. Create TWO buffer:
  57. * LVGL will draw the display's content to a buffer and writes it your display.
  58. * You should use DMA to write the buffer's content to the display.
  59. * It will enable LVGL to draw the next part of the screen to the other buffer while
  60. * the data is being sent form the first buffer. It makes rendering and flushing parallel.
  61. *
  62. * 3. Double buffering
  63. * Set 2 screens sized buffers and set disp_drv.full_refresh = 1.
  64. * This way LVGL will always provide the whole rendered screen in `flush_cb`
  65. * and you only need to change the frame buffer's address.
  66. */
  67. /* Example for 1) */
  68. static lv_disp_draw_buf_t draw_buf_dsc_1;
  69. static lv_color_t buf_1[LV_HOR_RES_MAX * 10]; /*A buffer for 10 rows*/
  70. lv_disp_draw_buf_init(&draw_buf_dsc_1, buf_1, NULL, LV_HOR_RES_MAX * 10); /*Initialize the display buffer*/
  71. // /* Example for 2) */
  72. // static lv_disp_draw_buf_t draw_buf_dsc_2;
  73. // static lv_color_t buf_2_1[MY_DISP_HOR_RES * 10]; /*A buffer for 10 rows*/
  74. // static lv_color_t buf_2_2[MY_DISP_HOR_RES * 10]; /*An other buffer for 10 rows*/
  75. // lv_disp_draw_buf_init(&draw_buf_dsc_2, buf_2_1, buf_2_2, MY_DISP_HOR_RES * 10); /*Initialize the display buffer*/
  76. // /* Example for 3) also set disp_drv.full_refresh = 1 below*/
  77. // static lv_disp_draw_buf_t draw_buf_dsc_3;
  78. // static lv_color_t buf_3_1[MY_DISP_HOR_RES * MY_DISP_VER_RES]; /*A screen sized buffer*/
  79. // static lv_color_t buf_3_2[MY_DISP_HOR_RES * MY_DISP_VER_RES]; /*Another screen sized buffer*/
  80. // lv_disp_draw_buf_init(&draw_buf_dsc_3, buf_3_1, buf_3_2, MY_DISP_VER_RES * LV_VER_RES_MAX); /*Initialize the display buffer*/
  81. /*-----------------------------------
  82. * Register the display in LVGL
  83. *----------------------------------*/
  84. static lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/
  85. lv_disp_drv_init(&disp_drv); /*Basic initialization*/
  86. /*Set up the functions to access to your display*/
  87. /*Set the resolution of the display*/
  88. disp_drv.hor_res = LV_HOR_RES_MAX;
  89. disp_drv.ver_res = LV_VER_RES_MAX;
  90. /*Used to copy the buffer's content to the display*/
  91. disp_drv.flush_cb = disp_flush;
  92. /*Set a display buffer*/
  93. disp_drv.draw_buf = &draw_buf_dsc_1;
  94. /*Required for Example 3)*/
  95. //disp_drv.full_refresh = 1
  96. /* Fill a memory array with a color if you have GPU.
  97. * Note that, in lv_conf.h you can enable GPUs that has built-in support in LVGL.
  98. * But if you have a different GPU you can use with this callback.*/
  99. //disp_drv.gpu_fill_cb = gpu_fill;
  100. /*Finally register the driver*/
  101. lv_disp_drv_register(&disp_drv);
  102. }
  103. /**********************
  104. * STATIC FUNCTIONS
  105. **********************/
  106. /*Initialize your display and the required peripherals.*/
  107. static void disp_init(void)
  108. {
  109. ST7789_Init();
  110. }
  111. /*Flush the content of the internal buffer the specific area on the display
  112. *You can use DMA or any hardware acceleration to do this operation in the background but
  113. *'lv_disp_flush_ready()' has to be called when finished.*/
  114. static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
  115. {
  116. ST7789_Fill(area->x1, area->y1, area->x2, area->y2, color_p);
  117. // ST7789_LCD_Color_Fill(area->x1,area->y1,area->x2,area->y2,color_p);
  118. // ST7789_LCD_Color_Fill(area->x1,area->y1,area->x2,area->y2,color_565);
  119. /*IMPORTANT!!!
  120. *Inform the graphics library that you are ready with the flushing*/
  121. lv_disp_flush_ready(disp_drv);
  122. }
  123. /*OPTIONAL: GPU INTERFACE*/
  124. /*If your MCU has hardware accelerator (GPU) then you can use it to fill a memory with a color*/
  125. //static void gpu_fill(lv_disp_drv_t * disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width,
  126. // const lv_area_t * fill_area, lv_color_t color)
  127. //{
  128. // /*It's an example code which should be done by your GPU*/
  129. // int32_t x, y;
  130. // dest_buf += dest_width * fill_area->y1; /*Go to the first line*/
  131. //
  132. // for(y = fill_area->y1; y <= fill_area->y2; y++) {
  133. // for(x = fill_area->x1; x <= fill_area->x2; x++) {
  134. // dest_buf[x] = color;
  135. // }
  136. // dest_buf+=dest_width; /*Go to the next line*/
  137. // }
  138. //}
  139. #else /*Enable this file at the top*/
  140. /*This dummy typedef exists purely to silence -Wpedantic.*/
  141. typedef int keep_pedantic_happy;
  142. #endif
  1. #ifndef __LVGL_LCD_ST7789_H__
  2. #define __LVGL_LCD_ST7789_H__
  3. #include "iot_gpio.h"
  4. #include "iot_gpio_ex.h"
  5. #include "iot_spi.h"
  6. #include <stdint.h>
  7. #define USE_HORIZONTAL 0 // 设置横屏或者竖屏显示 0或1为竖屏 2或3为横屏
  8. #if USE_HORIZONTAL == 0 || USE_HORIZONTAL == 1
  9. #define ST7789_W 240
  10. #define ST7789_H 240
  11. #else
  12. #define ST7789_W 240
  13. #define ST7789_H 240
  14. #endif
  15. // #define u8 unsigned char
  16. // #define u16 unsigned int
  17. // #define u32 unsigned long
  18. #define u8 uint8_t
  19. #define u16 uint16_t
  20. #define u32 uint32_t
  21. #define SDC IOT_IO_NAME_6
  22. #define SDIN IOT_IO_NAME_8
  23. #define RST IOT_IO_NAME_5
  24. #define DC IOT_IO_NAME_7
  25. #define SDC_FUNC IOT_GPIO_FUNC_GPIO_6_SPI0_CK
  26. #define SDIN_FUNC IOT_GPIO_FUNC_GPIO_8_SPI0_TXD
  27. #define RST_FUNC IOT_GPIO_FUNC_GPIO_5_GPIO
  28. #define DC_FUNC IOT_GPIO_FUNC_GPIO_7_GPIO
  29. #define ST7789_PIN_INIT() \
  30. IoTGpioInit(SDC); \
  31. IoTGpioSetFunc(SDC, SDC_FUNC); \
  32. IoTGpioSetDir(SDC, IOT_GPIO_DIR_OUT); \
  33. IoTGpioInit(SDIN); \
  34. IoTGpioSetFunc(SDIN, SDIN_FUNC); \
  35. IoTGpioSetDir(SDIN, IOT_GPIO_DIR_OUT); \
  36. IoTGpioInit(RST); \
  37. IoTGpioSetFunc(RST, RST_FUNC); \
  38. IoTGpioSetDir(RST, IOT_GPIO_DIR_OUT); \
  39. IoTGpioInit(DC); \
  40. IoTGpioSetFunc(DC, DC_FUNC); \
  41. IoTGpioSetDir(DC, IOT_GPIO_DIR_OUT);
  42. #define ST7789_SPI_INIT() \
  43. IoTSpiCfgInitParam param; \
  44. param.isSlave = 0; \
  45. IoTSpiCfgBasicInfo info; \
  46. info.cpol = IOT_SPI_CFG_CLOCK_CPOL_1; \
  47. info.cpha = IOT_SPI_CFG_CLOCK_CPHA_1; \
  48. info.framMode = IOT_SPI_CFG_FRAM_MODE_MOTOROLA; \
  49. info.dataWidth = IOT_SPI_CFG_DATA_WIDTH_E_8BIT; \
  50. info.endian = IOT_SPI_CFG_ENDIAN_LITTLE; \
  51. info.pad = 31; \
  52. info.freq = 40000000; \
  53. IoTSpiInit(0, param, &info);
  54. #define OLED_SCLK_Set() IoTGpioSetOutputVal(SDC, 1)
  55. #define OLED_SCLK_Clr() IoTGpioSetOutputVal(SDC, 0)
  56. #define OLED_SDIN_Set() IoTGpioSetOutputVal(SDIN, 1);
  57. #define OLED_SDIN_Clr() IoTGpioSetOutputVal(SDIN, 0);
  58. #define OLED_RST_Set() IoTGpioSetOutputVal(RST, 1);
  59. #define OLED_RST_Clr() IoTGpioSetOutputVal(RST, 0);
  60. #define OLED_DC_Set() IoTGpioSetOutputVal(DC, 1);
  61. #define OLED_DC_Clr() IoTGpioSetOutputVal(DC, 0);
  62. #define OLED_CMD 0 // 写命令
  63. #define OLED_DATA 1 // 写数据
  64. // extern u16 BACK_COLOR; //背景色
  65. void ST7789_Writ_Bus(u8 dat);
  66. void ST7789_WR_DATA8(u8 dat);
  67. void ST7789_WR_DATA(u16 dat);
  68. void ST7789_WR_REG(u8 dat);
  69. void ST7789_Address_Set(u16 x1, u16 y1, u16 x2, u16 y2);
  70. void ST7789_Init(void);
  71. void ST7789_Clear(u16 Color);
  72. // void ST7789_Fill(u16 xsta,u16 ysta,u16 xend,u16 yend,u16 color);
  73. void ST7789_Fill(u16 xsta, u16 ysta, u16 xend, u16 yend, u16 *color);
  74. // 画笔颜色
  75. #define WHITE 0xFFFF
  76. #define BLACK 0x0000
  77. #define BLUE 0x001F
  78. #define BRED 0XF81F
  79. #define GRED 0XFFE0
  80. #define GBLUE 0X07FF
  81. #define RED 0xF800
  82. #define MAGENTA 0xF81F
  83. #define GREEN 0x07E0
  84. #define CYAN 0x7FFF
  85. #define YELLOW 0xFFE0
  86. #define BROWN 0XBC40 // 棕色
  87. #define BRRED 0XFC07 // 棕红色
  88. #define GRAY 0X8430 // 灰色
  89. // GUI颜色
  90. #define DARKBLUE 0X01CF // 深蓝色
  91. #define LIGHTBLUE 0X7D7C // 浅蓝色
  92. #define GRAYBLUE 0X5458 // 灰蓝色
  93. // 以上三色为PANEL的颜色
  94. #define LIGHTGREEN 0X841F // 浅绿色
  95. #define LGRAY 0XC618 // 浅灰色(PANNEL),窗体背景色
  96. #define LGRAYBLUE 0XA651 // 浅灰蓝色(中间层颜色)
  97. #define LBBLUE 0X2B12 // 浅棕蓝色(选择条目的反色)
  98. #endif
  1. #include "lcd_st7789.h"
  2. #include <unistd.h>
  3. // u16 BACK_COLOR; //背景色
  4. /******************************************************************************
  5. 函数说明:LCD串行数据写入函数
  6. 入口数据:dat 要写入的串行数据
  7. 返回值: 无
  8. ******************************************************************************/
  9. void ST7789_Writ_Bus(u8 dat)
  10. {
  11. // u8 i;
  12. // //OLED_CS_Clr();
  13. // for(i=0;i<8;i++)
  14. // {
  15. // OLED_SCLK_Clr();
  16. // if(dat&0x80) {
  17. // OLED_SDIN_Set();
  18. // }
  19. // else {
  20. // OLED_SDIN_Clr();
  21. // }
  22. // OLED_SCLK_Set();
  23. // dat<<=1;
  24. // }
  25. // //OLED_CS_Set();
  26. IoTSpiHostWrite(0, &dat, 1);
  27. }
  28. /******************************************************************************
  29. 函数说明:LCD写入数据
  30. 入口数据:dat 写入的数据
  31. 返回值: 无
  32. ******************************************************************************/
  33. void ST7789_WR_DATA8(u8 dat)
  34. {
  35. OLED_DC_Set();//写数据
  36. ST7789_Writ_Bus(dat);
  37. }
  38. /******************************************************************************
  39. 函数说明:LCD写入数据
  40. 入口数据:dat 写入的数据
  41. 返回值: 无
  42. ******************************************************************************/
  43. void ST7789_WR_DATA(u16 dat)
  44. {
  45. OLED_DC_Set();//写数据
  46. ST7789_Writ_Bus(dat>>8);
  47. ST7789_Writ_Bus(dat);
  48. }
  49. /******************************************************************************
  50. 函数说明:LCD写入命令
  51. 入口数据:dat 写入的命令
  52. 返回值: 无
  53. ******************************************************************************/
  54. void ST7789_WR_REG(u8 dat)
  55. {
  56. OLED_DC_Clr();//写命令
  57. ST7789_Writ_Bus(dat);
  58. }
  59. /******************************************************************************
  60. 函数说明:设置起始和结束地址
  61. 入口数据:x1,x2 设置列的起始和结束地址
  62. y1,y2 设置行的起始和结束地址
  63. 返回值: 无
  64. ******************************************************************************/
  65. void ST7789_Address_Set(u16 x1,u16 y1,u16 x2,u16 y2)
  66. {
  67. if(USE_HORIZONTAL==0)
  68. {
  69. ST7789_WR_REG(0x2a);//列地址设置
  70. ST7789_WR_DATA(x1);
  71. ST7789_WR_DATA(x2);
  72. ST7789_WR_REG(0x2b);//行地址设置
  73. ST7789_WR_DATA(y1);
  74. ST7789_WR_DATA(y2);
  75. ST7789_WR_REG(0x2c);//储存器写
  76. }
  77. else if(USE_HORIZONTAL==1)
  78. {
  79. ST7789_WR_REG(0x2a);//列地址设置
  80. ST7789_WR_DATA(x1);
  81. ST7789_WR_DATA(x2);
  82. ST7789_WR_REG(0x2b);//行地址设置
  83. ST7789_WR_DATA(y1+80);
  84. ST7789_WR_DATA(y2+80);
  85. ST7789_WR_REG(0x2c);//储存器写
  86. }
  87. else if(USE_HORIZONTAL==2)
  88. {
  89. ST7789_WR_REG(0x2a);//列地址设置
  90. ST7789_WR_DATA(x1);
  91. ST7789_WR_DATA(x2);
  92. ST7789_WR_REG(0x2b);//行地址设置
  93. ST7789_WR_DATA(y1);
  94. ST7789_WR_DATA(y2);
  95. ST7789_WR_REG(0x2c);//储存器写
  96. }
  97. else
  98. {
  99. ST7789_WR_REG(0x2a);//列地址设置
  100. ST7789_WR_DATA(x1+80);
  101. ST7789_WR_DATA(x2+80);
  102. ST7789_WR_REG(0x2b);//行地址设置
  103. ST7789_WR_DATA(y1);
  104. ST7789_WR_DATA(y2);
  105. ST7789_WR_REG(0x2c);//储存器写
  106. }
  107. }
  108. /******************************************************************************
  109. 函数说明:LCD初始化函数
  110. 入口数据:无
  111. 返回值: 无
  112. ******************************************************************************/
  113. void ST7789_Init(void)
  114. {
  115. ST7789_PIN_INIT();
  116. ST7789_SPI_INIT();
  117. OLED_RST_Clr();
  118. usleep(20 * 1000);
  119. OLED_RST_Set();
  120. usleep(20 * 1000);
  121. // OLED_BLK_Set();
  122. //************* Start Initial Sequence **********//
  123. ST7789_WR_REG(0x36);
  124. if(USE_HORIZONTAL==0)ST7789_WR_DATA8(0x00);
  125. else if(USE_HORIZONTAL==1)ST7789_WR_DATA8(0xC0);
  126. else if(USE_HORIZONTAL==2)ST7789_WR_DATA8(0x70);
  127. else ST7789_WR_DATA8(0xA0);
  128. ST7789_WR_REG(0x3A);
  129. ST7789_WR_DATA8(0x05);
  130. ST7789_WR_REG(0xB2);
  131. ST7789_WR_DATA8(0x0C);
  132. ST7789_WR_DATA8(0x0C);
  133. ST7789_WR_DATA8(0x00);
  134. ST7789_WR_DATA8(0x33);
  135. ST7789_WR_DATA8(0x33);
  136. ST7789_WR_REG(0xB7);
  137. ST7789_WR_DATA8(0x35);
  138. ST7789_WR_REG(0xBB);
  139. ST7789_WR_DATA8(0x37);
  140. ST7789_WR_REG(0xC0);
  141. ST7789_WR_DATA8(0x2C);
  142. ST7789_WR_REG(0xC2);
  143. ST7789_WR_DATA8(0x01);
  144. ST7789_WR_REG(0xC3);
  145. ST7789_WR_DATA8(0x12);
  146. ST7789_WR_REG(0xC4);
  147. ST7789_WR_DATA8(0x20);
  148. ST7789_WR_REG(0xC6);
  149. ST7789_WR_DATA8(0x0F);
  150. ST7789_WR_REG(0xD0);
  151. ST7789_WR_DATA8(0xA4);
  152. ST7789_WR_DATA8(0xA1);
  153. ST7789_WR_REG(0xE0);
  154. ST7789_WR_DATA8(0xD0);
  155. ST7789_WR_DATA8(0x04);
  156. ST7789_WR_DATA8(0x0D);
  157. ST7789_WR_DATA8(0x11);
  158. ST7789_WR_DATA8(0x13);
  159. ST7789_WR_DATA8(0x2B);
  160. ST7789_WR_DATA8(0x3F);
  161. ST7789_WR_DATA8(0x54);
  162. ST7789_WR_DATA8(0x4C);
  163. ST7789_WR_DATA8(0x18);
  164. ST7789_WR_DATA8(0x0D);
  165. ST7789_WR_DATA8(0x0B);
  166. ST7789_WR_DATA8(0x1F);
  167. ST7789_WR_DATA8(0x23);
  168. ST7789_WR_REG(0xE1);
  169. ST7789_WR_DATA8(0xD0);
  170. ST7789_WR_DATA8(0x04);
  171. ST7789_WR_DATA8(0x0C);
  172. ST7789_WR_DATA8(0x11);
  173. ST7789_WR_DATA8(0x13);
  174. ST7789_WR_DATA8(0x2C);
  175. ST7789_WR_DATA8(0x3F);
  176. ST7789_WR_DATA8(0x44);
  177. ST7789_WR_DATA8(0x51);
  178. ST7789_WR_DATA8(0x2F);
  179. ST7789_WR_DATA8(0x1F);
  180. ST7789_WR_DATA8(0x1F);
  181. ST7789_WR_DATA8(0x20);
  182. ST7789_WR_DATA8(0x23);
  183. ST7789_WR_REG(0x21);
  184. ST7789_WR_REG(0x11);
  185. //Delay (120);
  186. ST7789_WR_REG(0x29);
  187. }
  188. /******************************************************************************
  189. 函数说明:LCD清屏函数
  190. 入口数据:无
  191. 返回值: 无
  192. ******************************************************************************/
  193. void ST7789_Clear(u16 Color)
  194. {
  195. u16 i,j;
  196. ST7789_Address_Set(0,0,ST7789_W-1,ST7789_H-1);
  197. for(i=0;i<ST7789_W;i++)
  198. {
  199. for (j=0;j<ST7789_H;j++)
  200. {
  201. ST7789_WR_DATA(Color);
  202. }
  203. }
  204. }
  205. /******************************************************************************
  206. 函数说明:在指定区域填充颜色
  207. 入口数据:xsta,ysta 起始坐标
  208. xend,yend 终止坐标
  209. 返回值: 无
  210. ******************************************************************************/
  211. void ST7789_Fill(u16 xsta,u16 ysta,u16 xend,u16 yend,uint16_t *color)
  212. {
  213. // u16 i,j;
  214. // ST7789_Address_Set(xsta,ysta,xend,yend); //设置光标位置
  215. // for(i=ysta;i<=yend;i++)
  216. // {
  217. // for(j=xsta;j<=xend;j++)ST7789_WR_DATA(*color);//设置光标位置
  218. // }
  219. uint32_t size = 0;
  220. ST7789_Address_Set(xsta,ysta,xend,yend);
  221. size = ((xend - xsta) + 1) * ((yend - ysta) + 1)*2;
  222. OLED_DC_Set();
  223. IoTSpiHostWrite(0, (uint8_t*) color, size);
  224. }

测试逻辑

最小运行逻辑

  1. #include "lvgl.h"
  2. #include "lv_conf.h"
  3. #include "lv_port_disp.h"
  4. static void first_screen(){
  5. //创建桌面
  6. lv_obj_t * obj = lv_obj_create(lv_scr_act());
  7. }
  8. static void start() {
  9. //lvgl初始化
  10. lv_init();
  11. //lvgl显示接口
  12. lv_port_disp_init();
  13. first_screen();
  14. while(1)
  15. {
  16. usleep(5000);
  17. lv_timer_handler();
  18. }
  19. }

练习题

  • 完成lvgl的移植