🎨 refactor(.vscode/tasks.json): 移除CMake配置任务,添加并行编译线程数的输入选项

🐛 fix(demo/oled/test.c): 优化代码可读性
main
JiXieShi 2024-12-15 23:09:55 +08:00
parent 68d2ce3205
commit 58ead967ff
2 changed files with 51 additions and 67 deletions

36
.vscode/tasks.json vendored
View File

@ -19,30 +19,6 @@
]
}
},
{
"label": "CMake Configure",
"type": "shell",
"command": "cmake",
"dependsOn": [
"Create Build Directories"
],
"args": [
"-S",
".",
"-B",
"build",
"-G",
"${input:cmakeGenerator}"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$gcc"
],
"detail": "Configure the project using CMake."
},
{
"label": "CMake Build",
"type": "shell",
@ -54,7 +30,9 @@
"--build",
"build",
"--target",
"all"
"all",
"--",
"-j${input:threadCount}"
],
"group": {
"kind": "build",
@ -63,7 +41,7 @@
"problemMatcher": [
"$gcc"
],
"detail": "Build the project using CMake and Ninja."
"detail": "Build the project using CMake with parallel compilation."
}
],
"inputs": [
@ -78,6 +56,12 @@
],
"default": "Ninja",
"description": "The CMake generator to use."
},
{
"type": "promptString",
"id": "threadCount",
"description": "Number of parallel compilation threads",
"default": "16"
}
]
}

View File

@ -9,33 +9,33 @@
#include "sim_key.h"
#include "page.h"
uint8_t Cmd(uint8_t *data, size_t l) {
// Buf_Print("Cmd", data, l, 16);
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);
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), 128);
void Refresh_Call(OLED_T* dev) {
// LOGT("OLED", "CALL");
// Buf_Print("Buf", dev->buf, dev->width * (dev->height / 8), 128);
SIM_OLED_DrawFromBuffer(dev->buf, dev->width, dev->height / 8);
}
uint8_t oledbuf[8][128] = {0};
void Key_Call_E(Key_t *key) {
void Key_Call_E(Key_t* key) {
switch (key->event) {
case KEY_PRESS_DOWN:
// LOGT("KEY", "ID:%d EVENT:%s", key->key_id, "PressTheEvent");
break;// 按下事件
// LOGT("KEY", "ID:%d EVENT:%s", key->key_id, "PressTheEvent");
break; // 按下事件
case KEY_PRESS_UP:
// LOGT("KEY", "ID:%d EVENT:%s", key->key_id, "BounceIncident");
break;// 弹起事件
// LOGT("KEY", "ID:%d EVENT:%s", key->key_id, "BounceIncident");
break; // 弹起事件
case KEY_PRESS_REPEAT:
LOGT("KEY", "ID:%d EVENT:%s", key->key_id, "RepeatThePressEvent");
break;// 重复按下事件
break; // 重复按下事件
case KEY_SINGLE_CLICK:
LOGT("KEY", "ID:%d EVENT:%s", key->key_id, "ClickEvent");
if (key->key_id == SIM_KEY_UP)cur--;
@ -57,25 +57,25 @@ void Key_Call_E(Key_t *key) {
if (cur == pagesearch(pageid).curmax)pageid = 0;
break;
case 4:
if(cnt_f==1)cnt_f=0;
else cnt_f=1;
if (cnt_f == 1)cnt_f = 0;
else cnt_f = 1;
break;
}
}
break;// 单击事件
break; // 单击事件
case KEY_DOUBLE_CLICK:
LOGT("KEY", "ID:%d EVENT:%s", key->key_id, "DoubleClickTheEvent");
break;// 双击事件
break; // 双击事件
case KEY_LONG_PRESS_START:
// LOGT("KEY", "ID:%d EVENT:%s", key->key_id, "LongPressToStartTheEvent");
break;// 长按开始事件
// LOGT("KEY", "ID:%d EVENT:%s", key->key_id, "LongPressToStartTheEvent");
break; // 长按开始事件
case KEY_LONG_PRESS_HOLD:
LOGT("KEY", "ID:%d EVENT:%s", key->key_id, "LongPressToHoldTheEvent");
break;// 长按保持事件
break; // 长按保持事件
}
}
void Get_Key(void *pVoid) {
void Get_Key(void* pVoid) {
Key_t k1, k2, k3, k4, k5, k6, k7;
key_init(&k1, SIM_KEY_UP, 1, SIM_Key_UP);
key_init(&k2, SIM_KEY_DOWN, 1, SIM_Key_DOWN);
@ -102,16 +102,16 @@ void Get_Key(void *pVoid) {
}
OLED_T oled = {
.height=64,
.width=128,
.state=IDLE,
.buf=oledbuf,
.cmd=Cmd,
.data=Data,
.call=Refresh_Call,
.height = 64,
.width = 128,
.state = IDLE,
.buf = oledbuf,
.cmd = Cmd,
.data = Data,
.call = Refresh_Call,
};
int Test_OLED(void *pVoid) {
int Test_OLED(void* pVoid) {
SIM_OLED_INIT(128, 64, CYAN, 0x0, 5, 0);
OLED_Init(&oled);
@ -125,21 +125,21 @@ int Test_OLED(void *pVoid) {
Sleep(3000);
// extern lv_font_t myFont;
// OLED_DisplayString(&oled, &myFont, "班级", 2, 1);
// extern lv_font_t myFont;
// OLED_DisplayString(&oled, &myFont, "班级", 2, 1);
// OLED_ShowPic(&oled, 0, 0, 64, 64, BMP1);
// OLED_ShowPic(&oled, 0, 0, 64, 64, BMP1);
OLED_Refresh(&oled);
_beginthread(Get_Key, 0, NULL);
// pageinit();
// pageinit();
while (1) {
// if (pageid > 4)pageid = 0;
// item_h = pagesearch(pageid).item_h;
// item_w = pagesearch(pageid).item_w;
//// pagesearch(pageid).page(&oled);
//// sprintf(buf, "DATA:%d", s);
//// OLED_ShowString(&oled, 2, 51, buf, 12);
// OLED_Refresh(&oled);
// if (pageid > 4)pageid = 0;
// item_h = pagesearch(pageid).item_h;
// item_w = pagesearch(pageid).item_w;
//// pagesearch(pageid).page(&oled);
//// sprintf(buf, "DATA:%d", s);
//// OLED_ShowString(&oled, 2, 51, buf, 12);
// OLED_Refresh(&oled);
Sleep(200);
}
SIM_OLED_STOP();