mirror of
https://gitee.com/dlmu-cone/tronone-h7-scaffold
synced 2026-07-24 03:27:45 +08:00
101 lines
2.6 KiB
C
101 lines
2.6 KiB
C
#ifndef TFT_H
|
|
#define TFT_H
|
|
|
|
#include "main.h"
|
|
#include "robot_def.h"
|
|
#include "spi.h"
|
|
#include <stdint.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define TFT_USE_HORIZONTAL 2U
|
|
#define TFT_USE_SOFT_SPI 0U
|
|
#define TFT_HW_SPI_BYTE_MODE 1U
|
|
#define TFT_HW_SPI_PULSE_CS 1U
|
|
|
|
#if (TFT_USE_HORIZONTAL == 0U) || (TFT_USE_HORIZONTAL == 1U)
|
|
#define TFT_LCD_W 240U
|
|
#define TFT_LCD_H 280U
|
|
#else
|
|
#define TFT_LCD_W 280U
|
|
#define TFT_LCD_H 240U
|
|
#endif
|
|
|
|
#ifndef TFT_SPI_UNIT
|
|
#define TFT_SPI_UNIT hspi1
|
|
#endif
|
|
|
|
#ifndef TFT_SCK_GPIO_Port
|
|
#define TFT_SCK_GPIO_Port GPIOB
|
|
#define TFT_SCK_Pin GPIO_PIN_3
|
|
#endif
|
|
|
|
#ifndef TFT_MOSI_GPIO_Port
|
|
#define TFT_MOSI_GPIO_Port GPIOD
|
|
#define TFT_MOSI_Pin GPIO_PIN_7
|
|
#endif
|
|
|
|
#if defined(LCD_CS_GPIO_Port) && defined(LCD_CS_Pin)
|
|
#define TFT_CS_GPIO_Port LCD_CS_GPIO_Port
|
|
#define TFT_CS_Pin LCD_CS_Pin
|
|
#else
|
|
#define TFT_CS_GPIO_Port cs2_GPIO_Port
|
|
#define TFT_CS_Pin cs2_Pin
|
|
#endif
|
|
|
|
#if defined(LCD_BLK_GPIO_Port) && defined(LCD_BLK_Pin)
|
|
#define TFT_BLK_GPIO_Port LCD_BLK_GPIO_Port
|
|
#define TFT_BLK_Pin LCD_BLK_Pin
|
|
#else
|
|
#define TFT_BLK_GPIO_Port cs1_GPIO_Port
|
|
#define TFT_BLK_Pin cs1_Pin
|
|
#endif
|
|
|
|
#if defined(LCD_RES_GPIO_Port) && defined(LCD_RES_Pin)
|
|
#define TFT_RES_GPIO_Port LCD_RES_GPIO_Port
|
|
#define TFT_RES_Pin LCD_RES_Pin
|
|
#else
|
|
#define TFT_RES_GPIO_Port cs4_GPIO_Port
|
|
#define TFT_RES_Pin cs4_Pin
|
|
#endif
|
|
|
|
#if defined(LCD_DC_GPIO_Port) && defined(LCD_DC_Pin)
|
|
#define TFT_DC_GPIO_Port LCD_DC_GPIO_Port
|
|
#define TFT_DC_Pin LCD_DC_Pin
|
|
#else
|
|
#define TFT_DC_GPIO_Port cs3_GPIO_Port
|
|
#define TFT_DC_Pin cs3_Pin
|
|
#endif
|
|
|
|
#define TFT_COLOR_WHITE 0xFFFFU
|
|
#define TFT_COLOR_BLACK 0x0000U
|
|
#define TFT_COLOR_BLUE 0x001FU
|
|
#define TFT_COLOR_RED 0xF800U
|
|
#define TFT_COLOR_GREEN 0x07E0U
|
|
#define TFT_COLOR_CYAN 0x7FFFU
|
|
#define TFT_COLOR_YELLOW 0xFFE0U
|
|
#define TFT_COLOR_MAGENTA 0xF81FU
|
|
#define TFT_COLOR_DARK_GRAY 0x4208U
|
|
#define TFT_COLOR_LIGHT_GRAY 0xC618U
|
|
|
|
void TFT_Init(void);
|
|
void TFT_ShowBootScreen(void);
|
|
void TFT_Clear(uint16_t color);
|
|
void TFT_FillRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color);
|
|
void TFT_DrawPoint(uint16_t x, uint16_t y, uint16_t color);
|
|
void TFT_DrawString(uint16_t x, uint16_t y, const char *text, uint16_t fc, uint16_t bc, uint8_t scale);
|
|
void TFT_ShowStatus(float temperature_c, RobotMode_t mode);
|
|
const char *TFT_RobotModeText(RobotMode_t mode);
|
|
|
|
void LCD_Init(void);
|
|
void LCD_Address_Set(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
|
|
void LCD_Fill(uint16_t xsta, uint16_t ysta, uint16_t xend, uint16_t yend, uint16_t color);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|