UP BMP脚本

main
JiXieShi 2024-06-25 22:53:45 +08:00
parent e22ddd0bcd
commit 8c8cf20056
5 changed files with 15 additions and 19 deletions

View File

@ -1,13 +1,13 @@
#include "page.h"
#include "list.h"
uint8_t pageid = 0, cur = 1, cnt = 0;
uint8_t pageid = 0, cur = 1, cnt = 0, item_h = 12;
static List_t list;
Page_L_t mainp = {0, 3, 0, 0, mainpage};
Page_L_t ap = {1, 2, 0, 0, pageA};
Page_L_t bp = {2, 2, 0, 0, pageB};
Page_L_t cp = {3, 2, 0, 0, pageC};
Page_L_t mainp = {0, 3, 0, 1, 12, mainpage};
Page_L_t ap = {1, 2, 0, 1, 12, pageA};
Page_L_t bp = {2, 2, 0, 1, 12, pageB};
Page_L_t cp = {3, 2, 0, 1, 12, pageC};
void pageinit() {
list_init(&list);
@ -32,9 +32,7 @@ Page_L_t pagesearch(uint8_t id) {
void pagecur(OLED_T *dev) {
if (cnt % 2) {
if (cur > 0 && cur <= pagesearch(pageid).next)OLED_ShowString(dev, 26, cur * 12, ">", 12);
else
cur = 1;
OLED_ShowString(dev, 26, cur * item_h, ">", item_h);
}
cnt++;
}

View File

@ -5,13 +5,14 @@
typedef void (*Page_t)(OLED_T *dev);
extern uint8_t pageid, cur, cnt;
extern uint8_t pageid, cur, cnt, item_h;
typedef struct Page_L {
uint8_t id;
uint8_t next;
uint8_t curmax: 3;
uint8_t back;
uint8_t enter;
uint8_t curmin: 3;
uint8_t item_h: 4;
Page_t page;
} Page_L_t;

View File

@ -41,6 +41,8 @@ void Key_Call_E(Key_t *key) {
LOGT("KEY", "ID:%d EVENT:%s", key->key_id, "ClickEvent");
if (key->key_id == SIM_KEY_UP)cur--;
if (key->key_id == SIM_KEY_DOWN)cur++;
if (cur < pagesearch(pageid).curmin && pagesearch(pageid).curmin != 0)cur = pagesearch(pageid).curmax;
if (cur > pagesearch(pageid).curmax && pagesearch(pageid).curmax != 0)cur = pagesearch(pageid).curmin;
if (key->key_id == SIM_KEY_LEFT)pageid--;
if (key->key_id == SIM_KEY_RIGHT)pageid++;
if (key->key_id == SIM_KEY_RESET)pageid = pagesearch(pageid).back;
@ -133,6 +135,7 @@ void Test_OLED() {
pageinit();
while (1) {
if (pageid > 3)pageid = 0;
item_h = pagesearch(pageid).item_h;
// pagesearch(pageid).page(&oled);
// sprintf(buf, "DATA:%d", s);
// OLED_ShowString(&oled, 2, 51, buf, 12);

View File

@ -327,18 +327,12 @@ void OLED_ShowPic(OLED_T *dev, uint8_t x0, uint8_t y0, uint8_t w, uint8_t h, uin
uint16_t x = x0, y = y0;
for (index = 0; index < (w * h) / 8; index++) {
OLED_BSet(dev, x, y, bmp[index]);
x++;
if ((x - x0) == w) {
y += 8;
x = x0;
}
}
// uint8_t y = 0;
// if (y % 8 == 0)y = 0;
// else y += 1;
// for (y = y0; y < y1; y++) {
// OLED_SPos(dev, x0, y);
// dev->data(bmp + y * (x1 - x0), x1 - x0);
// }
}
void OLED_Fill(OLED_T *dev, uint8_t data) {

2
main.c
View File

@ -15,7 +15,7 @@
int main() {
srand((unsigned) time(NULL));
int i, j, k = 0;
unsigned char incode[3] = {0x5B, 0x57}; // 要读出的汉字
unsigned char incode[3] = ""; // 要读出的汉字
unsigned char qh, wh;
long offset = 0;
// 占两个字节, 取其区位号