st7789.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright (c) 2006-2023, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2023-03-23 Vandoul First version
  9. */
  10. #ifndef __ST7789_H__
  11. #define __ST7789_H__
  12. #ifdef __cplusplus
  13. extern "C"
  14. {
  15. #endif
  16. #include <stdint.h>
  17. #include <rtthread.h>
  18. #include <rtdevice.h>
  19. #include "drivers/spi.h"
  20. #include "lcd.h"
  21. /* 0-0 angle|1-90 angle|2-180 angle|-270 angle */
  22. #define USE_DIRECTION 0
  23. /* lcd size */
  24. #define LCD_W 240
  25. #define LCD_H 240
  26. #define CS_PIN GET_PIN(B, 12)
  27. #define BK_PIN GET_PIN(D, 9) //PD9
  28. #define DC_PIN GET_PIN(D, 8) //PD8
  29. #define RST_PIN GET_PIN(B, 14) //PB14
  30. #define LCD_DC_CLR rt_pin_write(DC_PIN, PIN_LOW)
  31. #define LCD_DC_SET rt_pin_write(DC_PIN, PIN_HIGH)
  32. #define LCD_RES_CLR rt_pin_write(RST_PIN, PIN_LOW)
  33. #define LCD_RES_SET rt_pin_write(RST_PIN, PIN_HIGH)
  34. #define LCD_BLK_CLR rt_pin_write(BK_PIN, PIN_HIGH)
  35. #define DELAY rt_thread_mdelay
  36. #define WHITE 0xFFFF
  37. #define BLACK 0x0000
  38. #define BLUE 0x001F
  39. #define BRED 0XF81F
  40. #define GRED 0XFFE0
  41. #define GBLUE 0X07FF
  42. #define RED 0xF800
  43. #define MAGENTA 0xF81F
  44. #define GREEN 0x07E0
  45. #define CYAN 0x7FFF
  46. #define YELLOW 0xFFE0
  47. #define BROWN 0XBC40
  48. #define BRRED 0XFC07
  49. #define GRAY 0X8430
  50. void LCD_Clear(uint16_t Color);
  51. void LCD_direction(uint8_t direction);
  52. void LCD_SetCursor(uint16_t Xpos, uint16_t Ypos);
  53. void LCD_SetWindows(uint16_t xStar, uint16_t yStar, uint16_t xEnd, uint16_t yEnd);
  54. void LCD_Fill(uint16_t xsta, uint16_t ysta, uint16_t xend, uint16_t yend, uint16_t color);
  55. void lcd_fill_array_spi(uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end, uint16_t *pcolor);
  56. rt_err_t spi_lcd_init(uint32_t freq);
  57. #ifdef __cplusplus
  58. }
  59. #endif
  60. #endif