tft lvgl test ok

This commit is contained in:
TuxMonkey
2026-07-20 21:59:16 +08:00
parent 8928b7c7db
commit b2169513e1
766 changed files with 443311 additions and 22 deletions

View File

@@ -35,7 +35,7 @@ static const uint8_t tft_font5x7[][TFT_FONT_H] = {
{0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C}, /* . */
{0x00, 0x0C, 0x0C, 0x00, 0x0C, 0x0C, 0x00}, /* : */
{0x0E, 0x11, 0x13, 0x15, 0x19, 0x11, 0x0E}, /* 0 */
{0x04, 0x0C, 0x04, 0x04, 0x04, 0x04, 0x0E}, /* 1 */
{0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x0E}, /* 1 */
{0x0E, 0x11, 0x10, 0x08, 0x04, 0x02, 0x1F}, /* 2 */
{0x1F, 0x08, 0x04, 0x08, 0x10, 0x11, 0x0E}, /* 3 */
{0x08, 0x0C, 0x0A, 0x09, 0x1F, 0x08, 0x08}, /* 4 */
@@ -188,6 +188,25 @@ static void tft_write_bytes(const uint8_t *data, uint32_t len)
#endif
}
static void tft_write_bytes_continuous(const uint8_t *data, uint32_t len)
{
#if TFT_USE_SOFT_SPI
tft_write_bytes(data, len);
#else
while (len > 0U)
{
uint16_t chunk = len > UINT16_MAX ? UINT16_MAX : (uint16_t) len;
if (HAL_SPI_Transmit(&TFT_SPI_UNIT, (uint8_t *) data, chunk, TFT_SPI_TIMEOUT_MS) != HAL_OK)
{
tft_transfer_ok = false;
return;
}
data += chunk;
len -= chunk;
}
#endif
}
static void lcd_write_reg(uint8_t reg)
{
tft_cs_low();
@@ -237,6 +256,28 @@ static void tft_write_color_block(uint16_t color, uint32_t count)
tft_cs_high();
}
void TFT_WriteColorData(const uint8_t *data, uint32_t len)
{
if (data == NULL || len == 0U)
{
return;
}
tft_cs_low();
tft_dc_data();
#if TFT_HW_SPI_STREAM_COLOR
tft_write_bytes_continuous(data, len);
#else
tft_write_bytes(data, len);
#endif
tft_cs_high();
}
bool TFT_IsReady(void)
{
return tft_initialized && tft_transfer_ok;
}
void LCD_Address_Set(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2)
{
uint16_t xs = x1 + TFT_X_OFFSET;

View File

@@ -4,6 +4,7 @@
#include "main.h"
#include "robot_def.h"
#include "spi.h"
#include <stdbool.h>
#include <stdint.h>
#ifdef __cplusplus
@@ -14,6 +15,7 @@ extern "C" {
#define TFT_USE_SOFT_SPI 0U
#define TFT_HW_SPI_BYTE_MODE 1U
#define TFT_HW_SPI_PULSE_CS 1U
#define TFT_HW_SPI_STREAM_COLOR 1U
#if (TFT_USE_HORIZONTAL == 0U) || (TFT_USE_HORIZONTAL == 1U)
#define TFT_LCD_W 240U
@@ -87,6 +89,8 @@ void TFT_FillRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint1
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);
bool TFT_IsReady(void);
void TFT_WriteColorData(const uint8_t *data, uint32_t len);
const char *TFT_RobotModeText(RobotMode_t mode);
void LCD_Init(void);