UP 通用OLED

main
JiXieShi 2024-06-22 16:41:48 +08:00
parent a1624f0682
commit c784f3ca96
3 changed files with 13 additions and 20 deletions

View File

@ -3,40 +3,34 @@
#include "log.h"
#include "tool.h"
#include "t_oled.h"
#include <windows.h>
uint8_t Cmd(uint8_t *data, size_t l) {
void Cmd(uint8_t *data, size_t l) {
Buf_Print("Cmd", data, l, 16);
}
uint8_t Data(uint8_t *data, size_t l) {
void 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);
BufPrint("Buf", dev->buf, T_U8, dev->width * (dev->height / 8), 16);
}
uint8_t oledbuf[8][128];
uint8_t oledbuf[8][128] = {0};
void Test_OLED() {
OLED_T oled = {
.height=64,
.height=(uint8_t) 64,
.width=128,
.state=IDLE,
.buf=oledbuf,
.call=Refresh_Call,
.cmd=Cmd,
.data=Data
.data=Data,
.call=Refresh_Call,
};
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延时
}
OLED_ShowString(&oled, 0, 0, "Hello", 12);
OLED_Refresh(&oled);
}

View File

@ -52,9 +52,9 @@ typedef enum {
*/
struct OLED_Dev {
uint8_t *buf; /**< 显示缓冲区指针 */
uint8_t width: 3; /**< 显示宽度 */
uint8_t height: 3; /**< 显示高度 */
OLED_STATE_T state: 2; /**< OLED状态 */
uint8_t width; /**< 显示宽度 */
uint8_t height; /**< 显示高度 */
OLED_STATE_T state; /**< OLED状态 */
OLED_CMD_t cmd; /**< OLED命令处理函数指针 */
OLED_DATA_t data; /**< OLED数据处理函数指针 */
#if REFRESH_CALL_ENABLE

View File

@ -44,7 +44,6 @@ void OLED_Turn(OLED_T *dev, bool e) {
}
void OLED_Refresh(OLED_T *dev) {
#if REFRESH_CALL_ENABLE
dev->call(dev);
#else
@ -56,7 +55,7 @@ void OLED_Refresh(OLED_T *dev) {
dev->cmd(cmd, 3);
dev->data(dev->buf + (i * dev->width), dev->width);
}
dev->state=IDLE;
dev->state = IDLE;
}
#endif
}