| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- #ifndef __LCD_Hx__
- #define __LCD_Hx__
- #include <rtthread.h>
- #include <rtdevice.h>
- #include "gpio.h"
- #include "drv_spi.h"
- #include "font.h"
- enum {
- COLOR_ID_WHITE=0,
- COLOR_ID_BLACK,
- COLOR_ID_BLUE,
- COLOR_ID_BRED,
- COLOR_ID_GRED,
- COLOR_ID_GBLUE,
- COLOR_ID_RED,
- COLOR_ID_MAGENTA,
- COLOR_ID_GREEN,
- COLOR_ID_CYAN,
- COLOR_ID_YELLOW,
- COLOR_ID_BROWN,
- COLOR_ID_BRRED,
- COLOR_ID_GRAY,
-
- COLOR_ID_MAX,
- };
- #define CS_PIN GET_PIN(B, 12)
- #define BK_PIN GET_PIN(D, 9) //PD9
- #define DC_PIN GET_PIN(D, 8) //PD8
- #define RST_PIN GET_PIN(B, 14) //PB14
- #define LCD_COLOR COLOR_RGB565
- #if 0
- #define LCD_WIDTH 128
- #define LCD_HEIGHT 64
- #else
- #define LCD_WIDTH 240
- #define LCD_HEIGHT 240
- #endif
- /* 颜色 */
- #if 1
- #define COLOR_WHITE 0xFFFF
- #define COLOR_BLACK 0x0000
- #define COLOR_BLUE 0x001F
- #define COLOR_BRED 0XF81F
- #define COLOR_GRED 0XFFE0
- #define COLOR_GBLUE 0X07FF
- #define COLOR_RED 0xF800
- #define COLOR_MAGENTA 0xF81F
- #define COLOR_GREEN 0x07E0
- #define COLOR_CYAN 0x7FFF
- #define COLOR_YELLOW 0xFFE0
- #define COLOR_BROWN 0XBC40
- #define COLOR_BRRED 0XFC07
- #define COLOR_GRAY 0X8430
- #elif (LCD_COLOR==COLOR_RGB666)
-
- #elif (LCD_COLOR==COLOR_RGB888)
- #else
- #endif
- enum {
- HORIZONTAL_LEFT=0,
- HORIZONTAL_CENTER,
- HORIZONTAL_RIGHT,
- };
- enum {
- VERTICAL_TOP=0,
- VERTICAL_CENTER,
- VERTICAL_BOTTOM,
- };
- enum {
- COLOR_WB=0,
- COLOR_RGB8,
- COLOR_RGB565,
- COLOR_RGB666,
- COLOR_RGB888,
- COLOR_RGBA,
- };
- typedef struct {
- int width;
- int height;
- int color;
- int rotate;
- struct rt_spi_device *dev;
- uint16_t *buf;
- int buflen;
- }lcd_handle_t;
- void lcd_init(int width, int height, uint32_t color);
- void lcd_deinit(void);
- void lcd_rotate(int angle);
- int lcd_get_rotate(void);
- void lcd_set_backlight(int on);
- void lcd_fill(uint32_t color);
- void lcd_draw_line(int x1, int y1, int x2, int y2, uint32_t color);
- void lcd_draw_rect(int x1, int y1, int w, int h, uint32_t color);
- void lcd_fill_rect(int x1, int y1, int w, int h, uint32_t color);
- void lcd_draw_string(int x, int y, int width, int height, char *str, int font, uint32_t color, uint32_t bgcolor, int hori, int vert);
- void lcd_refresh(void);
- #endif
|