#ifndef _TFT_H #define _TFT_H #if GUI_SELECT typedef void (*tft_init_func)(void); typedef void (*tft_read_id_func)(unsigned char *buf); typedef void (*tft_set_window_func)(unsigned short int x0, unsigned short int y0, unsigned short int x1, unsigned short int y1); typedef struct { unsigned int id; tft_init_func init; tft_read_id_func read_id; tft_set_window_func set_window; } tft_driver_t; #define TFT_COLOR_RED 0xF800 #define TFT_COLOR_GREEN 0x07E0 #define TFT_COLOR_BLUE 0x001F #define TFT_COLOR_BLACK 0x0000 #define TFT_COLOR_WHITE 0xFFFF #define TFT_COLOR_YELLOW 0xFFE0 #define TFT_COLOR_GRAY 0x8410 /* 屏幕背光 */ #if LCD_BL_PE1 #define LCD_BL_EN() \ { \ bsp_pwm_duty_set(GPIO_PE1, 10, 0); \ } #define LCD_BL_DIS() \ { \ bsp_pwm_disable(GPIO_PE1); \ } #elif LCD_BL_PF1 #define LCD_BL_EN() \ { \ bsp_pwm_duty_set(GPIO_PF1, 10, 0); \ } #define LCD_BL_DIS() \ { \ bsp_pwm_disable(GPIO_PF1); \ } #else #define LCD_BL_EN() \ { \ bsp_pwm_duty_set(GPIO_PB4, 10, 0); \ } #define LCD_BL_DIS() \ { \ bsp_pwm_disable(GPIO_PB4); \ } #endif void tft_init(void); void tft_set_window(u16 x0, u16 y0, u16 x1, u16 y1); void tft_write_cmd(u8 cmd); void tft_write_data(u8 data); void tft_write_end(); u8 tft_spi_getbyte(void); void tft_spi_sendbyte(u8 val); void tft_draw_rect(u16 x, u16 y, u16 wid, u16 hei, uint16_t color); void tft_draw_string(u16 x, u16 y, char *text, bool center, uint16_t color, uint16_t bg_color); typedef struct { u16 x; u16 y; u16 wid; u16 hei; u8 progress; } progress_bar_t; void progress_bar_create(progress_bar_t *p_bar, u16 x, u16 y, u16 wid, u16 hei); void progress_bar_update(progress_bar_t *p_bar, u8 progress); #endif #endif