drv_lcd.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 PKG_USING_QRCODE
  16. #include <qrcode.h>
  17. #endif
  18. #define LCD_BASE ((uint32_t)(0x68000000 | 0x0003FFFE)) // A18 link to DCX
  19. #define LCD ((LCD_CONTROLLER_TypeDef *)LCD_BASE)
  20. #define LCD_W 240
  21. #define LCD_H 240
  22. //LCD重要参数集
  23. typedef struct
  24. {
  25. uint16_t width; //LCD 宽度
  26. uint16_t height; //LCD 高度
  27. uint16_t id; //LCD ID
  28. uint8_t dir; //横屏还是竖屏控制:0,竖屏;1,横屏。
  29. uint16_t wramcmd; //开始写gram指令
  30. uint16_t setxcmd; //设置x坐标指令
  31. uint16_t setycmd; //设置y坐标指令
  32. }_lcd_dev;
  33. //LCD参数
  34. extern _lcd_dev lcddev; //管理LCD重要参数
  35. typedef struct
  36. {
  37. volatile uint8_t _u8_REG;
  38. volatile uint8_t RESERVED;
  39. volatile uint8_t _u8_RAM;
  40. volatile uint16_t _u16_RAM;
  41. }LCD_CONTROLLER_TypeDef;
  42. //POINT_COLOR
  43. #define WHITE 0xFFFF
  44. #define BLACK 0x0000
  45. #define BLUE 0x001F
  46. #define BRED 0XF81F
  47. #define GRED 0XFFE0
  48. #define GBLUE 0X07FF
  49. #define RED 0xF800
  50. #define MAGENTA 0xF81F
  51. #define GREEN 0x07E0
  52. #define CYAN 0x7FFF
  53. #define YELLOW 0xFFE0
  54. #define BROWN 0XBC40
  55. #define BRRED 0XFC07
  56. #define GRAY 0X8430
  57. #define GRAY175 0XAD75
  58. #define GRAY151 0X94B2
  59. #define GRAY187 0XBDD7
  60. #define GRAY240 0XF79E
  61. //扫描方向定义
  62. #define L2R_U2D 0 //从左到右,从上到下
  63. #define L2R_D2U 1 //从左到右,从下到上
  64. #define R2L_U2D 2 //从右到左,从上到下
  65. #define R2L_D2U 3 //从右到左,从下到上
  66. #define U2D_L2R 4 //从上到下,从左到右
  67. #define U2D_R2L 5 //从上到下,从右到左
  68. #define D2U_L2R 6 //从下到上,从左到右
  69. #define D2U_R2L 7 //从下到上,从右到左
  70. int drv_lcd_init(void);
  71. void lcd_clear(rt_uint16_t color);
  72. void lcd_address_set(rt_uint16_t x1, rt_uint16_t y1, rt_uint16_t x2, rt_uint16_t y2);
  73. void lcd_set_color(rt_uint16_t back, rt_uint16_t fore);
  74. rt_uint16_t change_byte_order(rt_uint16_t word);
  75. void lcd_draw_point(rt_uint16_t x, rt_uint16_t y);
  76. void lcd_draw_circle(rt_uint16_t x0, rt_uint16_t y0, rt_uint8_t r);
  77. void lcd_draw_line(rt_uint16_t x1, rt_uint16_t y1, rt_uint16_t x2, rt_uint16_t y2);
  78. void lcd_draw_rectangle(rt_uint16_t x1, rt_uint16_t y1, rt_uint16_t x2, rt_uint16_t y2);
  79. void lcd_fill(rt_uint16_t x_start, rt_uint16_t y_start, rt_uint16_t x_end, rt_uint16_t y_end, rt_uint16_t color);
  80. void lcd_address_set(rt_uint16_t x1, rt_uint16_t y1, rt_uint16_t x2, rt_uint16_t y2);
  81. rt_err_t lcd_write_half_word(const rt_uint16_t da);
  82. rt_err_t lcd_write_data_buffer(const void *send_buf, rt_size_t length);
  83. void lcd_show_num(rt_uint16_t x, rt_uint16_t y, rt_uint32_t num, rt_uint8_t len, rt_uint32_t size);
  84. rt_err_t lcd_show_string(rt_uint16_t x, rt_uint16_t y, rt_uint32_t size, const char *fmt, ...);
  85. rt_err_t lcd_show_image(rt_uint16_t x, rt_uint16_t y, rt_uint16_t length, rt_uint16_t wide, const rt_uint8_t *p);
  86. #ifdef PKG_USING_QRCODE
  87. rt_err_t lcd_show_qrcode(rt_uint16_t x, rt_uint16_t y, rt_uint8_t version, rt_uint8_t ecc, const char *data, rt_uint8_t enlargement);
  88. #endif
  89. void lcd_enter_sleep(void);
  90. void lcd_exit_sleep(void);
  91. void lcd_display_on(void);
  92. void lcd_display_off(void);
  93. 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);
  94. #endif