1 /* 2 * Copyright (c) 2006-2022, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2021-12-28 unknow copy by STemwin 9 */ 10 #ifndef __DRV_LCD_H 11 #define __DRV_LCD_H 12 #include <rtthread.h> 13 #include "rtdevice.h" 14 #include <drv_common.h> 15 16 #ifdef BSP_USING_TOUCH_CAP 17 #define LCD_W 800 18 #define LCD_H 480 19 #endif // BSP_USING_TOUCH_CAP 20 21 #ifdef BSP_USING_TOUCH_RES 22 #define LCD_W 320 23 #define LCD_H 480 24 #endif // BSP_USING_TOUCH_RES 25 26 //LCD重要参数集 27 typedef struct 28 { 29 uint16_t width; //LCD 宽度 30 uint16_t height; //LCD 高度 31 uint16_t id; //LCD ID 32 uint8_t dir; //横屏还是竖屏控制:0,竖屏;1,横屏。 33 uint16_t wramcmd; //开始写gram指令 34 uint16_t setxcmd; //设置x坐标指令 35 uint16_t setycmd; //设置y坐标指令 36 }_lcd_dev; 37 38 //LCD参数 39 extern _lcd_dev lcddev; //管理LCD重要参数 40 41 typedef struct 42 { 43 __IO uint16_t REG; 44 __IO uint16_t RAM; 45 }LCD_CONTROLLER_TypeDef; 46 47 //扫描方向定义 48 #define L2R_U2D 0 //从左到右,从上到下 49 #define L2R_D2U 1 //从左到右,从下到上 50 #define R2L_U2D 2 //从右到左,从上到下 51 #define R2L_D2U 3 //从右到左,从下到上 52 53 #define U2D_L2R 4 //从上到下,从左到右 54 #define U2D_R2L 5 //从上到下,从右到左 55 #define D2U_L2R 6 //从下到上,从左到右 56 #define D2U_R2L 7 //从下到上,从右到左 57 58 #ifdef BSP_USING_TOUCH_CAP 59 #define DFT_SCAN_DIR L2R_U2D //电容触摸屏默认的扫描方向 60 #endif // BSP_USING_TOUCH_CAP 61 62 #ifdef BSP_USING_TOUCH_RES 63 #define DFT_SCAN_DIR D2U_L2R //电阻触摸屏默认的扫描方向 64 #endif // BSP_USING_TOUCH_RES 65 66 //LCD分辨率设置 67 #define SSD_HOR_RESOLUTION 800 //LCD水平分辨率 68 #define SSD_VER_RESOLUTION 480 //LCD垂直分辨率 69 //LCD驱动参数设置 70 #define SSD_HOR_PULSE_WIDTH 1 //水平脉宽 71 #define SSD_HOR_BACK_PORCH 46 //水平前廊 72 #define SSD_HOR_FRONT_PORCH 210 //水平后廊 73 74 #define SSD_VER_PULSE_WIDTH 1 //垂直脉宽 75 #define SSD_VER_BACK_PORCH 23 //垂直前廊 76 #define SSD_VER_FRONT_PORCH 22 //垂直前廊 77 //如下几个参数,自动计算 78 #define SSD_HT (SSD_HOR_RESOLUTION+SSD_HOR_BACK_PORCH+SSD_HOR_FRONT_PORCH) 79 #define SSD_HPS (SSD_HOR_BACK_PORCH) 80 #define SSD_VT (SSD_VER_RESOLUTION+SSD_VER_BACK_PORCH+SSD_VER_FRONT_PORCH) 81 #define SSD_VPS (SSD_VER_BACK_PORCH) 82 83 84 void lcd_fill_array(rt_uint16_t x_start, rt_uint16_t y_start, rt_uint16_t x_end, rt_uint16_t y_end, void *pcolor); 85 86 #endif 87