UP tft SIM
This commit is contained in:
@@ -10,7 +10,7 @@ extern "C" {
|
||||
|
||||
#define REFRESH_CALL_ENABLE 1 //使用DMA或者整体刷新函数
|
||||
#define HZK_FONT //使用HZK 12/16 字体 tools下可自由生成
|
||||
#define UTF8_TO_UNICODE //启用UTF8转换显示
|
||||
//#define UTF8_TO_UNICODE //启用UTF8转换显示
|
||||
//#define LVGL_FONT //启用LVGL字体
|
||||
|
||||
/**
|
||||
|
@@ -348,6 +348,17 @@ void TFT_ShowNum(TFT_T *dev, uint16_t x, uint16_t y, uint32_t num, uint16_t len,
|
||||
**/
|
||||
void TFT_ShowPic(TFT_T *dev, uint16_t x0, uint16_t y0, uint16_t w, uint16_t h, TFT_Color_t *bmp);
|
||||
|
||||
/**
|
||||
* @brief 在屏幕上绘制一个十字交叉线
|
||||
* @param dev: [输入] TFT设备指针
|
||||
* @param x: [输入] 十字交叉线中心点x坐标
|
||||
* @param y: [输入] 十字交叉线中心点y坐标
|
||||
* @param r: [输入] 十字交叉线长度的一半(即从中心点到横竖线的长度)
|
||||
* @return void
|
||||
* @example TFT_DrawCross(&tft_dev, 100, 80, 5);
|
||||
**/
|
||||
void TFT_DrawCross(TFT_T *dev, uint16_t x, uint16_t y, uint8_t r);
|
||||
|
||||
/**
|
||||
* @brief 在屏幕上显示进度条
|
||||
* @param dev: [输入] TFT设备指针
|
||||
|
@@ -14,7 +14,7 @@
|
||||
#include "ST7796.h"
|
||||
#endif
|
||||
|
||||
|
||||
const uint8_t initcmd[] = {0};
|
||||
TFT_Color_t POINT_COLOR;
|
||||
TFT_Color_t BACK_COLOR;
|
||||
uint8_t *cmdIndex;
|
||||
@@ -24,6 +24,7 @@ void TFT_Init(TFT_T *dev) {
|
||||
return;
|
||||
}
|
||||
uint8_t count, temp;
|
||||
cmdIndex = (uint8_t *) initcmd;
|
||||
#ifdef TFT_ST7735
|
||||
if (dev->id==ST7735_ID) {
|
||||
cmdIndex= (uint8_t *) st7735initcmd;
|
||||
@@ -440,6 +441,11 @@ void TFT_ShowPic(TFT_T *dev, uint16_t x, uint16_t y, uint16_t width, uint16_t he
|
||||
}
|
||||
}
|
||||
|
||||
void TFT_DrawCross(TFT_T *dev, uint16_t x, uint16_t y, uint8_t r) {
|
||||
TFT_DrawLine(dev, x - r, y, x + r, y);
|
||||
TFT_DrawLine(dev, x, y - r, x, y + r);
|
||||
}
|
||||
|
||||
uint16_t invertRGB565(uint16_t color) {
|
||||
// 分离颜色分量
|
||||
uint8_t r = (color >> 11) & 0x1F; // 取出红色分量
|
||||
@@ -462,13 +468,12 @@ void TFT_ShowBar(TFT_T *dev, uint16_t x, uint16_t y, uint16_t width, uint16_t he
|
||||
if (progress < 1)TFT_Fill(dev, xp, y, width, height, BACK_COLOR);
|
||||
if (height >= 12 && height < 32) {
|
||||
uint8_t tmp[7];
|
||||
uint16_t sp = (width - x) / 2 - 30;
|
||||
uint16_t sp = (width - x) / 2 - 3 * ((height >= 24) ? 24 : (height >= 16) ? 16 : 12) / 2;
|
||||
TFT_Color_t temp = POINT_COLOR;
|
||||
POINT_COLOR.u16 = invertRGB565(POINT_COLOR.u16);
|
||||
sprintf(tmp, "%05.2f%%", progress * 100);
|
||||
sprintf((char *) tmp, "%05.2f%%", progress * 100);
|
||||
if (xp < sp)TFT_ShowString(dev, sp, y, tmp, (height >= 24) ? 24 : (height >= 16) ? 16 : 12, 0);
|
||||
else TFT_ShowString(dev, sp, y, tmp, (height >= 24) ? 24 : (height >= 16) ? 16 : 12, 1);
|
||||
POINT_COLOR = temp;
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user