drv_lcd.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #ifdef BSP_USING_TOUCH_CAP
  16. #define LCD_W 800
  17. #define LCD_H 480
  18. #endif // BSP_USING_TOUCH_CAP
  19. #ifdef BSP_USING_TOUCH_RES
  20. #define LCD_W 320
  21. #define LCD_H 480
  22. #endif // BSP_USING_TOUCH_RES
  23. //LCD重要参数集
  24. typedef struct
  25. {
  26. uint16_t width; //LCD 宽度
  27. uint16_t height; //LCD 高度
  28. uint16_t id; //LCD ID
  29. uint8_t dir; //横屏还是竖屏控制:0,竖屏;1,横屏。
  30. uint16_t wramcmd; //开始写gram指令
  31. uint16_t setxcmd; //设置x坐标指令
  32. uint16_t setycmd; //设置y坐标指令
  33. }_lcd_dev;
  34. //LCD参数
  35. extern _lcd_dev lcddev; //管理LCD重要参数
  36. typedef struct
  37. {
  38. __IO uint16_t REG;
  39. __IO uint16_t RAM;
  40. }LCD_CONTROLLER_TypeDef;
  41. //扫描方向定义
  42. #define L2R_U2D 0 //从左到右,从上到下
  43. #define L2R_D2U 1 //从左到右,从下到上
  44. #define R2L_U2D 2 //从右到左,从上到下
  45. #define R2L_D2U 3 //从右到左,从下到上
  46. #define U2D_L2R 4 //从上到下,从左到右
  47. #define U2D_R2L 5 //从上到下,从右到左
  48. #define D2U_L2R 6 //从下到上,从左到右
  49. #define D2U_R2L 7 //从下到上,从右到左
  50. #ifdef BSP_USING_TOUCH_CAP
  51. #define DFT_SCAN_DIR L2R_U2D //电容触摸屏默认的扫描方向
  52. #endif // BSP_USING_TOUCH_CAP
  53. #ifdef BSP_USING_TOUCH_RES
  54. #define DFT_SCAN_DIR D2U_L2R //电阻触摸屏默认的扫描方向
  55. #endif // BSP_USING_TOUCH_RES
  56. //LCD分辨率设置
  57. #define SSD_HOR_RESOLUTION 800 //LCD水平分辨率
  58. #define SSD_VER_RESOLUTION 480 //LCD垂直分辨率
  59. //LCD驱动参数设置
  60. #define SSD_HOR_PULSE_WIDTH 1 //水平脉宽
  61. #define SSD_HOR_BACK_PORCH 46 //水平前廊
  62. #define SSD_HOR_FRONT_PORCH 210 //水平后廊
  63. #define SSD_VER_PULSE_WIDTH 1 //垂直脉宽
  64. #define SSD_VER_BACK_PORCH 23 //垂直前廊
  65. #define SSD_VER_FRONT_PORCH 22 //垂直前廊
  66. //如下几个参数,自动计算
  67. #define SSD_HT (SSD_HOR_RESOLUTION+SSD_HOR_BACK_PORCH+SSD_HOR_FRONT_PORCH)
  68. #define SSD_HPS (SSD_HOR_BACK_PORCH)
  69. #define SSD_VT (SSD_VER_RESOLUTION+SSD_VER_BACK_PORCH+SSD_VER_FRONT_PORCH)
  70. #define SSD_VPS (SSD_VER_BACK_PORCH)
  71. 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);
  72. #endif