up lvgl
This commit is contained in:
@@ -9,7 +9,8 @@ uint8_t border;
|
||||
|
||||
#define GET_BIT(x, bit) ((x & (1 << bit)) >> bit)
|
||||
|
||||
void SIM_Display_INIT(int width, int height, uint32_t pixcolor, uint32_t backcolor, int scale, uint8_t b) {
|
||||
void SIM_Display_INIT(int width, int height, uint32_t pixcolor, uint32_t backcolor, int scale, uint8_t b)
|
||||
{
|
||||
w = width * scale;
|
||||
h = height * scale;
|
||||
pixelColor = pixcolor;
|
||||
@@ -18,18 +19,21 @@ void SIM_Display_INIT(int width, int height, uint32_t pixcolor, uint32_t backcol
|
||||
border = b;
|
||||
}
|
||||
|
||||
void SIM_Display_START() {
|
||||
void SIM_Display_START()
|
||||
{
|
||||
initgraph(w, h);
|
||||
setbkcolor(backgroundColor);
|
||||
setfillcolor(pixelColor);
|
||||
cleardevice();
|
||||
}
|
||||
|
||||
void SIM_Display_STOP() {
|
||||
void SIM_Display_STOP()
|
||||
{
|
||||
closegraph();
|
||||
}
|
||||
|
||||
void drawPixel(int oledX, int oledY) {
|
||||
void drawPixel(int oledX, int oledY)
|
||||
{
|
||||
int startX = oledX * scaleFactor;
|
||||
int startY = oledY * scaleFactor;
|
||||
if (border) fillrectangle(startX + 1, startY + 1, startX + scaleFactor - 1, startY + scaleFactor - 1);
|
||||
@@ -37,13 +41,17 @@ void drawPixel(int oledX, int oledY) {
|
||||
}
|
||||
|
||||
|
||||
void SIM_OneColor_DrawFromBuffer(uint8_t *buf, uint16_t width, uint16_t height) {
|
||||
void SIM_OneColor_DrawFromBuffer(uint8_t* buf, uint16_t width, uint16_t height)
|
||||
{
|
||||
BeginBatchDraw();
|
||||
cleardevice();
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
uint8_t byteData = buf[y * width + x];
|
||||
for (int i = 0; i < 8; i++) {
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
uint8_t bit = GET_BIT(byteData, i);
|
||||
if (bit)drawPixel(x, y * 8 + i);
|
||||
}
|
||||
@@ -52,11 +60,14 @@ void SIM_OneColor_DrawFromBuffer(uint8_t *buf, uint16_t width, uint16_t height)
|
||||
EndBatchDraw();
|
||||
}
|
||||
|
||||
void SIM_Color_DrawFromBuffer(uint32_t *buf, uint16_t width, uint16_t height){
|
||||
void SIM_Color_DrawFromBuffer(uint32_t* buf, uint16_t width, uint16_t height)
|
||||
{
|
||||
BeginBatchDraw();
|
||||
cleardevice();
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
setfillcolor(*buf);
|
||||
drawPixel(x, y);
|
||||
buf++;
|
||||
@@ -64,3 +75,35 @@ void SIM_Color_DrawFromBuffer(uint32_t *buf, uint16_t width, uint16_t height){
|
||||
}
|
||||
EndBatchDraw();
|
||||
}
|
||||
|
||||
void SIM_Color_ImgFromBuffer(uint32_t* buf, uint16_t x, uint16_t y, uint16_t width, uint16_t height)
|
||||
{
|
||||
BeginBatchDraw();
|
||||
cleardevice();
|
||||
for (int y_i = 0; y_i < height; y_i++)
|
||||
{
|
||||
for (int x_i = 0; x_i < width; x_i++)
|
||||
{
|
||||
setfillcolor(*buf);
|
||||
drawPixel(x + x_i, y + y_i);
|
||||
buf++;
|
||||
}
|
||||
}
|
||||
EndBatchDraw();
|
||||
}
|
||||
|
||||
void SIM_Color_FillFromBuffer(uint32_t* buf, uint16_t xs, uint16_t ys, uint16_t xe, uint16_t ye)
|
||||
{
|
||||
BeginBatchDraw();
|
||||
cleardevice();
|
||||
for (int y_i = ys; y_i < ye; y_i++)
|
||||
{
|
||||
for (int x_i = xs; x_i < xe; x_i++)
|
||||
{
|
||||
setfillcolor(*buf);
|
||||
drawPixel(x_i, y_i);
|
||||
buf++;
|
||||
}
|
||||
}
|
||||
EndBatchDraw();
|
||||
}
|
||||
|
@@ -78,6 +78,30 @@ void SIM_OneColor_DrawFromBuffer(uint8_t *buf, uint16_t width, uint16_t height);
|
||||
**/
|
||||
void SIM_Color_DrawFromBuffer(uint32_t *buf, uint16_t width, uint16_t height);
|
||||
|
||||
/**
|
||||
* @brief 从缓冲区中填充图像
|
||||
* @param buf: [输入] 缓冲区指针
|
||||
* @param x: [输入] 图像起始横坐标
|
||||
* @param y: [输入] 图像起始纵坐标
|
||||
* @param width: [输入] 图像宽度
|
||||
* @param height: [输入] 图像高度
|
||||
* @return void
|
||||
* @example SIM_Color_ImgFromBuffer(buf, 100, 50, 320, 240);
|
||||
**/
|
||||
void SIM_Color_ImgFromBuffer(uint32_t* buf, uint16_t x, uint16_t y, uint16_t width, uint16_t height);
|
||||
|
||||
/**
|
||||
* @brief 从缓冲区中填充颜色
|
||||
* @param buf: [输入] 缓冲区指针
|
||||
* @param xs: [输入] 填充区域起始横坐标
|
||||
* @param ys: [输入] 填充区域起始纵坐标
|
||||
* @param xe: [输入] 填充区域结束横坐标
|
||||
* @param ye: [输入] 填充区域结束纵坐标
|
||||
* @return void
|
||||
* @example SIM_Color_FillFromBuffer(buf, 50, 30, 150, 100);
|
||||
**/
|
||||
void SIM_Color_FillFromBuffer(uint32_t* buf, uint16_t xs, uint16_t ys, uint16_t xe, uint16_t ye);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user