UP 通用OLED

This commit is contained in:
JiXieShi
2024-06-22 15:21:15 +08:00
parent 8b0426a9e0
commit a1624f0682
6 changed files with 77 additions and 9 deletions

6
demo/oled/t_oled.h Normal file
View File

@@ -0,0 +1,6 @@
#ifndef HW_LIB_T_OLED_H
#define HW_LIB_T_OLED_H
void Test_OLED();
#endif //HW_LIB_T_OLED_H

42
demo/oled/test.c Normal file
View File

@@ -0,0 +1,42 @@
#include <stdio.h>
#include "oled.h"
#include "log.h"
#include "tool.h"
#include "t_oled.h"
#include <windows.h>
uint8_t Cmd(uint8_t *data, size_t l) {
Buf_Print("Cmd", data, l, 16);
}
uint8_t Data(uint8_t *data, size_t l) {
Buf_Print("Data", data, l, 16);
}
void Refresh_Call(OLED_T *dev) {
LOGT("OLED", "CALL");
Buf_Print("Buf", dev->buf, dev->width * (dev->height / 8), 16);
}
uint8_t oledbuf[8][128];
void Test_OLED() {
OLED_T oled = {
.height=64,
.width=128,
.state=IDLE,
.buf=oledbuf,
.call=Refresh_Call,
.cmd=Cmd,
.data=Data
};
OLED_Init(&oled);
Sleep(150);
OLED_CLS(&oled);
OLED_ShowString(&oled, 0, 0, "sss", 4);
while (1) {
// 每5ms调用一次key_ticks函数
OLED_Refresh(&oled);
Sleep(5); // 使用Windows平台的Sleep函数进行5ms延时
}
}