UP 准备加入彩屏支持
This commit is contained in:
@@ -2,53 +2,20 @@
|
||||
#include "graphics.h"
|
||||
#include <conio.h>
|
||||
|
||||
static uint32_t pixelColor, backgroundColor;
|
||||
static int scaleFactor, w, h;
|
||||
uint8_t border;
|
||||
|
||||
#define GET_BIT(x, bit) ((x & (1 << bit)) >> bit)
|
||||
|
||||
void SIM_OLED_INIT(int width, int height, uint32_t pixcolor, uint32_t backcolor, int scale, uint8_t b) {
|
||||
w = width * scale;
|
||||
h = height * scale;
|
||||
pixelColor = pixcolor;
|
||||
backgroundColor = backcolor;
|
||||
scaleFactor = scale;
|
||||
border = b;
|
||||
SIM_Display_INIT(width,height,pixcolor,backcolor,scale,b);
|
||||
}
|
||||
|
||||
void SIM_OLED_START() {
|
||||
initgraph(w, h);
|
||||
setbkcolor(backgroundColor);
|
||||
setfillcolor(pixelColor);
|
||||
cleardevice();
|
||||
SIM_Display_START();
|
||||
}
|
||||
|
||||
void SIM_OLED_STOP() {
|
||||
closegraph();
|
||||
SIM_Display_STOP();
|
||||
}
|
||||
|
||||
void drawOledPixel(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);
|
||||
else solidrectangle(startX, startY, startX + scaleFactor, startY + scaleFactor);
|
||||
}
|
||||
|
||||
|
||||
void SIM_OLED_DrawFromBuffer(uint8_t *buf, uint8_t width, uint8_t height) {
|
||||
BeginBatchDraw();
|
||||
cleardevice();
|
||||
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++) {
|
||||
uint8_t bit = GET_BIT(byteData, i);
|
||||
if (bit)drawOledPixel(x, y * 8 + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
EndBatchDraw();
|
||||
SIM_OneColor_DrawFromBuffer(buf,width,height);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -4,27 +4,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
/**
|
||||
* @brief 定义颜色常量值,用于模拟 OLED 显示
|
||||
*/
|
||||
#define BLACK 0 // 黑色
|
||||
#define BLUE 0xAA0000 // 蓝色
|
||||
#define GREEN 0x00AA00 // 绿色
|
||||
#define CYAN 0xAAAA00 // 青色
|
||||
#define RED 0x0000AA // 红色
|
||||
#define MAGENTA 0xAA00AA // 品红
|
||||
#define BROWN 0x0055AA // 棕色
|
||||
#define LIGHTGRAY 0xAAAAAA // 亮灰色
|
||||
#define DARKGRAY 0x555555 // 暗灰色
|
||||
#define LIGHTBLUE 0xFF5555 // 亮蓝色
|
||||
#define LIGHTGREEN 0x55FF55 // 亮绿色
|
||||
#define LIGHTCYAN 0xFFFF55 // 亮青色
|
||||
#define LIGHTRED 0x5555FF // 亮红色
|
||||
#define LIGHTMAGENTA 0xFF55FF // 亮品红
|
||||
#define YELLOW 0x55FFFF // 黄色
|
||||
#define WHITE 0xFFFFFF // 白色
|
||||
#include "sim_display.h"
|
||||
|
||||
/**
|
||||
* @brief 初始化模拟 OLED 显示
|
||||
|
Reference in New Issue
Block a user