UP tft SIM
This commit is contained in:
@@ -9,6 +9,23 @@ uint8_t border;
|
||||
|
||||
#define GET_BIT(x, bit) ((x & (1 << bit)) >> bit)
|
||||
|
||||
uint32_t RGB565_to_RGB888(uint16_t rgb565, bool isBGR) {
|
||||
uint8_t r5 = (rgb565 >> 11) & 0x1F;
|
||||
uint8_t g6 = (rgb565 >> 5) & 0x3F;
|
||||
uint8_t b5 = rgb565 & 0x1F;
|
||||
|
||||
uint8_t r8 = (r5 * 527 + 23) >> 6;
|
||||
uint8_t g8 = (g6 * 259 + 33) >> 6;
|
||||
uint8_t b8 = (b5 * 527 + 23) >> 6;
|
||||
|
||||
if (isBGR) {
|
||||
return (b8 << 16) | (g8 << 8) | r8;
|
||||
} else {
|
||||
return (r8 << 16) | (g8 << 8) | b8;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SIM_Display_INIT(int width, int height, uint32_t pixcolor, uint32_t backcolor, int scale, uint8_t b)
|
||||
{
|
||||
w = width * scale;
|
||||
@@ -60,6 +77,25 @@ void SIM_OneColor_DrawFromBuffer(uint8_t* buf, uint16_t width, uint16_t height)
|
||||
EndBatchDraw();
|
||||
}
|
||||
|
||||
void SIM_Color_DrawPiexl(uint32_t buf, uint16_t x, uint16_t y) {
|
||||
BeginBatchDraw();
|
||||
// cleardevice();
|
||||
setfillcolor(buf);
|
||||
drawPixel(x, y);
|
||||
EndBatchDraw();
|
||||
}
|
||||
|
||||
void SIM_Color_DrawHLineBuffer(uint32_t *buf, uint16_t x, uint16_t y, uint16_t width) {
|
||||
BeginBatchDraw();
|
||||
// cleardevice();
|
||||
for (int x_ = 0; x_ < width; x_++) {
|
||||
setfillcolor(*buf);
|
||||
drawPixel(x + x_, y);
|
||||
buf++;
|
||||
}
|
||||
EndBatchDraw();
|
||||
}
|
||||
|
||||
void SIM_Color_DrawFromBuffer(uint32_t* buf, uint16_t width, uint16_t height)
|
||||
{
|
||||
BeginBatchDraw();
|
||||
@@ -79,7 +115,7 @@ void SIM_Color_DrawFromBuffer(uint32_t* buf, uint16_t width, uint16_t height)
|
||||
void SIM_Color_ImgFromBuffer(uint32_t* buf, uint16_t x, uint16_t y, uint16_t width, uint16_t height)
|
||||
{
|
||||
BeginBatchDraw();
|
||||
cleardevice();
|
||||
// cleardevice();
|
||||
for (int y_i = 0; y_i < height; y_i++)
|
||||
{
|
||||
for (int x_i = 0; x_i < width; x_i++)
|
||||
@@ -95,7 +131,7 @@ void SIM_Color_ImgFromBuffer(uint32_t* buf, uint16_t x, uint16_t y, uint16_t wid
|
||||
void SIM_Color_FillFromBuffer(uint32_t* buf, uint16_t xs, uint16_t ys, uint16_t xe, uint16_t ye)
|
||||
{
|
||||
BeginBatchDraw();
|
||||
cleardevice();
|
||||
// cleardevice();
|
||||
for (int y_i = ys; y_i < ye; y_i++)
|
||||
{
|
||||
for (int x_i = xs; x_i < xe; x_i++)
|
||||
|
@@ -68,6 +68,16 @@ void SIM_Display_STOP();
|
||||
**/
|
||||
void SIM_OneColor_DrawFromBuffer(uint8_t *buf, uint16_t width, uint16_t height);
|
||||
|
||||
/**
|
||||
* @brief 在指定的坐标位置绘制一个像素点
|
||||
* @param color 颜色
|
||||
* @param x x坐标
|
||||
* @param y y坐标
|
||||
*/
|
||||
void SIM_Color_DrawPiexl(uint32_t color, uint16_t x, uint16_t y);
|
||||
|
||||
void SIM_Color_DrawHLineBuffer(uint32_t *buf, uint16_t x, uint16_t y, uint16_t width);
|
||||
|
||||
/**
|
||||
* @brief 从缓冲区绘制到显示
|
||||
* @param buf: [输入] 缓冲区指针
|
||||
@@ -102,6 +112,8 @@ void SIM_Color_ImgFromBuffer(uint32_t* buf, uint16_t x, uint16_t y, uint16_t wid
|
||||
**/
|
||||
void SIM_Color_FillFromBuffer(uint32_t* buf, uint16_t xs, uint16_t ys, uint16_t xe, uint16_t ye);
|
||||
|
||||
uint32_t RGB565_to_RGB888(uint16_t rgb565, bool isBGR);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user