HW_Lib/demo/oled/test.c

42 lines
919 B
C

#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延时
}
}