UP 模拟器

main
JiXieShi 2024-06-22 19:32:13 +08:00
parent 678c8067b8
commit 2a5c81891a
3 changed files with 22 additions and 8 deletions

View File

@ -23,7 +23,7 @@ void Refresh_Call(OLED_T *dev) {
uint8_t oledbuf[8][128] = {0}; uint8_t oledbuf[8][128] = {0};
void Test_OLED() { void Test_OLED() {
SIM_OLED_INIT(128, 64, 0xFFFFFF, 0x0, 10, 1); SIM_OLED_INIT(128, 64, BLUE, 0x0, 5, 1);
OLED_T oled = { OLED_T oled = {
.height=64, .height=64,
.width=128, .width=128,

View File

@ -6,6 +6,8 @@ static uint32_t pixelColor, backgroundColor;
static int scaleFactor, w, h; static int scaleFactor, w, h;
uint8_t border; 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) { void SIM_OLED_INIT(int width, int height, uint32_t pixcolor, uint32_t backcolor, int scale, uint8_t b) {
w = width * scale; w = width * scale;
h = height * scale; h = height * scale;
@ -34,7 +36,6 @@ void drawOledPixel(int oledX, int oledY) {
else solidrectangle(startX, startY, startX + scaleFactor, startY + scaleFactor); else solidrectangle(startX, startY, startX + scaleFactor, startY + scaleFactor);
} }
#define GET_BIT(x, bit) ((x & (1 << bit)) >> bit)
void SIM_OLED_DrawFromBuffer(uint8_t *buf, uint8_t width, uint8_t height) { void SIM_OLED_DrawFromBuffer(uint8_t *buf, uint8_t width, uint8_t height) {
cleardevice(); cleardevice();
@ -43,8 +44,7 @@ void SIM_OLED_DrawFromBuffer(uint8_t *buf, uint8_t width, uint8_t height) {
uint8_t byteData = buf[y * 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); uint8_t bit = GET_BIT(byteData, i);
if (bit) if (bit)drawOledPixel(x, y * 8 + (i));
drawOledPixel(x, y * 8 + (i));
} }
} }
} }

View File

@ -6,8 +6,22 @@ extern "C" {
#include "stdint.h" #include "stdint.h"
#define WIDTH 1280 #define BLACK 0
#define HEIGHT 640 #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
/** /**
* @brief OLED * @brief OLED
@ -16,11 +30,11 @@ extern "C" {
* @param pixcolor: [] * @param pixcolor: []
* @param backcolor: [] * @param backcolor: []
* @param scale: [] * @param scale: []
* @param b: [] * @param border: []
* @return void * @return void
* @example SIM_OLED_INIT(128, 64, 0xFFFF00, 0x000000, 10, 1); * @example SIM_OLED_INIT(128, 64, 0xFFFF00, 0x000000, 10, 1);
**/ **/
void SIM_OLED_INIT(int width, int height, uint32_t pixcolor, uint32_t backcolor, int scale, uint8_t b); void SIM_OLED_INIT(int width, int height, uint32_t pixcolor, uint32_t backcolor, int scale, uint8_t border);
/** /**
* @brief OLED * @brief OLED