Compare commits
11 Commits
d93df1d303
...
main
Author | SHA1 | Date | |
---|---|---|---|
|
b8700ac88b | ||
|
3c54795451 | ||
|
6d8133489b | ||
|
040b9be6b9 | ||
|
fd68396b30 | ||
|
23116b7e3d | ||
|
3709d3d284 | ||
|
58ead967ff | ||
|
68d2ce3205 | ||
|
18e6cf26be | ||
|
7dd4268210 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
|||||||
/cmake-build-debug/
|
/cmake-build-debug/
|
||||||
|
/build/
|
||||||
/.idea/
|
/.idea/
|
||||||
/.venv/
|
/.venv/
|
||||||
/lvgl/
|
/lvgl/
|
||||||
|
31
.vscode/launch.json
vendored
Normal file
31
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "(gdb) 启动",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/build/HW_Lib",
|
||||||
|
"args": [],
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"cwd": "${workspaceFolder}/build",
|
||||||
|
"preLaunchTask": "CMake Build",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": false,
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerPath": "",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "为 gdb 启用整齐打印",
|
||||||
|
"text": "-enable-pretty-printing",
|
||||||
|
"ignoreFailures": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "将反汇编风格设置为 Intel",
|
||||||
|
"text": "-gdb-set disassembly-flavor intel",
|
||||||
|
"ignoreFailures": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
13
.vscode/settings.json
vendored
Normal file
13
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"C_Cpp.default.cppStandard": "c++23",
|
||||||
|
"C_Cpp.default.cStandard": "c99",
|
||||||
|
"C_Cpp.default.customConfigurationVariables": {
|
||||||
|
},
|
||||||
|
"C_Cpp.inlayHints.autoDeclarationTypes.enabled": false,
|
||||||
|
"C_Cpp.inlayHints.parameterNames.enabled": true,
|
||||||
|
"files.associations": {
|
||||||
|
"*.dpf": "yaml",
|
||||||
|
"compare": "cpp",
|
||||||
|
"cstdint": "cpp"
|
||||||
|
}
|
||||||
|
}
|
91
.vscode/tasks.json
vendored
Normal file
91
.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "Create Build Directories",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "sh",
|
||||||
|
"args": [
|
||||||
|
"-c",
|
||||||
|
"mkdir -p build"
|
||||||
|
],
|
||||||
|
"problemMatcher": [],
|
||||||
|
"detail": "Create necessary directories for builds.",
|
||||||
|
"windows": {
|
||||||
|
"command": "cmd.exe",
|
||||||
|
"args": [
|
||||||
|
"/C",
|
||||||
|
"if not exist build (mkdir build)"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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",
|
||||||
|
"command": "cmake",
|
||||||
|
"dependsOn": [
|
||||||
|
"CMake Configure"
|
||||||
|
],
|
||||||
|
"args": [
|
||||||
|
"--build",
|
||||||
|
"build",
|
||||||
|
"--target",
|
||||||
|
"all",
|
||||||
|
"--",
|
||||||
|
"-j${input:threadCount}"
|
||||||
|
],
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
},
|
||||||
|
"problemMatcher": [
|
||||||
|
"$gcc"
|
||||||
|
],
|
||||||
|
"detail": "Build the project using CMake with parallel compilation."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"type": "pickString",
|
||||||
|
"id": "cmakeGenerator",
|
||||||
|
"options": [
|
||||||
|
"Ninja",
|
||||||
|
"Unix Makefiles",
|
||||||
|
"MinGW Makefiles",
|
||||||
|
"Xcode"
|
||||||
|
],
|
||||||
|
"default": "Ninja",
|
||||||
|
"description": "The CMake generator to use."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "promptString",
|
||||||
|
"id": "threadCount",
|
||||||
|
"description": "Number of parallel compilation threads",
|
||||||
|
"default": "8"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@@ -19,6 +19,7 @@ foreach (SIM_SUBDIR ${SIM_SUBDIRS})
|
|||||||
endforeach ()
|
endforeach ()
|
||||||
|
|
||||||
set(LVGL_ROOT_DIR lvgl)
|
set(LVGL_ROOT_DIR lvgl)
|
||||||
|
|
||||||
include(lvgl/env_support/cmake/custom.cmake)
|
include(lvgl/env_support/cmake/custom.cmake)
|
||||||
|
|
||||||
include_directories(easyx/include)
|
include_directories(easyx/include)
|
||||||
@@ -31,12 +32,14 @@ add_subdirectory(SDL3 EXCLUDE_FROM_ALL)
|
|||||||
link_libraries(SDL3::SDL3)
|
link_libraries(SDL3::SDL3)
|
||||||
|
|
||||||
link_libraries(libeasyx.a libgdi32.a libole32.a)
|
link_libraries(libeasyx.a libgdi32.a libole32.a)
|
||||||
|
|
||||||
add_executable(HW_Lib main.c ${SOURCES})
|
add_executable(HW_Lib main.c ${SOURCES})
|
||||||
|
|
||||||
#导入库
|
#导入库
|
||||||
add_subdirectory(lib)
|
add_subdirectory(lib)
|
||||||
|
|
||||||
target_link_libraries(HW_Lib HW_LIB_List HW_LIB_Task HW_LIB_Printf HW_LIB_Utils HW_LIB_Iic
|
target_link_libraries(HW_Lib HW_LIB_List HW_LIB_Task HW_LIB_Printf HW_LIB_Utils HW_LIB_Iic
|
||||||
HW_LIB_Spi HW_LIB_Key HW_LIB_Oled HW_LIB_Font HW_LIB_Tft lvgl::lvgl lvgl::examples lvgl::demos
|
HW_LIB_Spi HW_LIB_Key HW_LIB_Oled HW_LIB_Font HW_LIB_Tft lvgl::lvgl HW_LIB_Lui
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_command(TARGET HW_Lib POST_BUILD
|
add_custom_command(TARGET HW_Lib POST_BUILD
|
||||||
|
2
SDL3
2
SDL3
Submodule SDL3 updated: 1266210685...89c6bc5f50
@@ -8,4 +8,6 @@
|
|||||||
extern int Test_List(void *pVoid);
|
extern int Test_List(void *pVoid);
|
||||||
|
|
||||||
extern int Test_Queue(void *pVoid1);
|
extern int Test_Queue(void *pVoid1);
|
||||||
|
|
||||||
|
extern int Test_Hash(void* pVoid);
|
||||||
#endif //HW_LIB_T_LIST_H
|
#endif //HW_LIB_T_LIST_H
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
|
#include "hash_table.h"
|
||||||
|
|
||||||
typedef struct test {
|
typedef struct test {
|
||||||
int val1;
|
int val1;
|
||||||
@@ -100,6 +101,7 @@ int Test_List(void *pVoid) {
|
|||||||
// 测试销毁操作
|
// 测试销毁操作
|
||||||
printf("-----destroy----\n");
|
printf("-----destroy----\n");
|
||||||
list_destroy(&list, NULL); // 销毁链表
|
list_destroy(&list, NULL); // 销毁链表
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Test_Queue(void *pVoid) {
|
int Test_Queue(void *pVoid) {
|
||||||
@@ -141,4 +143,16 @@ int Test_Queue(void *pVoid) {
|
|||||||
printf("Pop value from front: %d\n", *popVal);
|
printf("Pop value from front: %d\n", *popVal);
|
||||||
}
|
}
|
||||||
delQueue_List(deque);
|
delQueue_List(deque);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Test_Hash(void* pVoid) {
|
||||||
|
Hash_Table_t* ht = ht_new();
|
||||||
|
ht_insert(ht, "name", "lydxh");
|
||||||
|
ht_insert(ht, "age", "18");
|
||||||
|
printf("Name:%s\nAge:%s", ht_search(ht, "name"), ht_search(ht, "age"));
|
||||||
|
ht_delete(ht, "name");
|
||||||
|
ht_delete(ht, "age");
|
||||||
|
ht_del_hash_table(ht);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -41,7 +41,7 @@ int Test_lvgl(void *pVoid) {
|
|||||||
// lv_port_indev_init();
|
// lv_port_indev_init();
|
||||||
|
|
||||||
// lv_example_get_started_1();
|
// lv_example_get_started_1();
|
||||||
lv_demo_widgets();
|
// lv_demo_widgets();
|
||||||
// printf("\nTEST Widgets\n");
|
// printf("\nTEST Widgets\n");
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@@ -105,7 +105,7 @@ OLED_T oled = {
|
|||||||
.height = 64,
|
.height = 64,
|
||||||
.width = 128,
|
.width = 128,
|
||||||
.state = IDLE,
|
.state = IDLE,
|
||||||
.buf=oledbuf,
|
.buf = oledbuf[0],
|
||||||
.cmd = Cmd,
|
.cmd = Cmd,
|
||||||
.data = Data,
|
.data = Data,
|
||||||
.call = Refresh_Call,
|
.call = Refresh_Call,
|
||||||
@@ -117,7 +117,7 @@ int Test_OLED(void *pVoid) {
|
|||||||
OLED_Init(&oled);
|
OLED_Init(&oled);
|
||||||
OLED_CLS(&oled);
|
OLED_CLS(&oled);
|
||||||
|
|
||||||
OLED_ShowCHString(&oled, 1, 24, "星海科技机械师");
|
OLED_ShowCHString(&oled, 1, 1, "星海科技机械师");
|
||||||
|
|
||||||
OLED_DrawRect(&oled, 0, 0, 127, 63);
|
OLED_DrawRect(&oled, 0, 0, 127, 63);
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ int Test_OLED(void *pVoid) {
|
|||||||
//// sprintf(buf, "DATA:%d", s);
|
//// sprintf(buf, "DATA:%d", s);
|
||||||
//// OLED_ShowString(&oled, 2, 51, buf, 12);
|
//// OLED_ShowString(&oled, 2, 51, buf, 12);
|
||||||
// OLED_Refresh(&oled);
|
// OLED_Refresh(&oled);
|
||||||
// Sleep(200);
|
Sleep(200);
|
||||||
}
|
}
|
||||||
SIM_OLED_STOP();
|
SIM_OLED_STOP();
|
||||||
}
|
}
|
||||||
|
@@ -11,6 +11,7 @@ set(LIBRARIES
|
|||||||
HW_LIB_Oled oled oled/inc
|
HW_LIB_Oled oled oled/inc
|
||||||
HW_LIB_Tft tft tft/inc
|
HW_LIB_Tft tft tft/inc
|
||||||
HW_LIB_Flash flash flash/inc
|
HW_LIB_Flash flash flash/inc
|
||||||
|
HW_LIB_Lui lui lui/inc
|
||||||
)
|
)
|
||||||
|
|
||||||
# 循环浏览库列表以创建它们
|
# 循环浏览库列表以创建它们
|
||||||
|
@@ -5,6 +5,10 @@
|
|||||||
#ifndef HW_LIB_FLASH_CFG_H
|
#ifndef HW_LIB_FLASH_CFG_H
|
||||||
#define HW_LIB_FLASH_CFG_H
|
#define HW_LIB_FLASH_CFG_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#define FLASH_DEBUG_MODE
|
#define FLASH_DEBUG_MODE
|
||||||
|
|
||||||
#define FLASH_USING_SFDP
|
#define FLASH_USING_SFDP
|
||||||
@@ -19,9 +23,12 @@ enum {
|
|||||||
|
|
||||||
#define FLASH_FLASH_DEVICE_TABLE \
|
#define FLASH_FLASH_DEVICE_TABLE \
|
||||||
{ \
|
{ \
|
||||||
[FLASH_XXXX_DEVICE_INDEX] = {.name = "XXXX", .spi.name = "SPIX"}, \
|
[FLASH_XXXX_DEVICE_INDEX] = {.name = "XXXX", .spi={.name = "SPIX"}, }, \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FLASH_USING_QSPI
|
#define FLASH_USING_QSPI
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#endif //HW_LIB_FLASH_CFG_H
|
#endif //HW_LIB_FLASH_CFG_H
|
||||||
|
@@ -5,66 +5,66 @@
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t unicode[2];
|
uint8_t unicode[2];
|
||||||
uint8_t data[32];
|
uint8_t data[128];
|
||||||
} Chinese_t;
|
} Chinese_t;
|
||||||
|
|
||||||
static uint8_t Hzk_size = 16;
|
static uint8_t Hzk_size=32;
|
||||||
|
|
||||||
static Chinese_t Hzk[] = {
|
static Chinese_t Hzk[] = {
|
||||||
{
|
{
|
||||||
// Original: <20><>
|
// Original: <20><>
|
||||||
{ 0x66, 0x1F },
|
{ 0x66, 0x1F },
|
||||||
{
|
{
|
||||||
0x00, 0x08, 0x3F, 0xFC, 0x20, 0x08, 0x3F, 0xF8, 0x20, 0x08, 0x3F, 0xF8, 0x01, 0x00, 0x21, 0x08,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0xFF, 0xFF, 0xC0, 0x03, 0xFF, 0xFF, 0xC0, 0x03, 0x80, 0x01, 0xC0, 0x03, 0x80, 0x01, 0xC0, 0x03, 0x80, 0x01, 0xC0, 0x01, 0xFF, 0xFF, 0xC0, 0x03, 0x80, 0x01, 0xC0, 0x03, 0x80, 0x01, 0xC0, 0x03, 0x80, 0x01, 0xC0, 0x03, 0xFF, 0xFF, 0xC0, 0x03, 0x80, 0x01, 0xC0, 0x01, 0x01, 0x81, 0x80, 0x01, 0x81, 0xC0, 0x00,
|
||||||
0x3F, 0xFC, 0x21, 0x00, 0x41, 0x10, 0xBF, 0xF8, 0x01, 0x00, 0x01, 0x04, 0xFF, 0xFE, 0x00, 0x00,
|
0x01, 0xC1, 0x80, 0x40, 0x01, 0x81, 0x80, 0xE0, 0x03, 0xFF, 0xFF, 0xF0, 0x03, 0x01, 0x80, 0x00, 0x06, 0x01, 0x80, 0x00, 0x0C, 0x01, 0x80, 0x00, 0x08, 0x01, 0x81, 0x80, 0x11, 0xFF, 0xFF, 0xC0, 0x21, 0x01, 0x80, 0x00, 0x40, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x18, 0x00, 0x01, 0x80, 0x3C, 0x3F, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// Original: <20><>
|
// Original: <20><>
|
||||||
{ 0x6D, 0x77 },
|
{ 0x6D, 0x77 },
|
||||||
{
|
{
|
||||||
0x02, 0x00, 0x42, 0x08, 0x33, 0xFC, 0x14, 0x00, 0x8B, 0xF8, 0x62, 0x88, 0x22, 0x48, 0x0A, 0x08,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x08, 0x07, 0x00, 0x00, 0x0E, 0x06, 0x00, 0x00, 0x07, 0x0E, 0x00, 0x30, 0x07, 0x0F, 0xFF, 0xF8, 0x03, 0x0C, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x40, 0x98, 0x00, 0x80, 0x70, 0xBF, 0xFF, 0xC0, 0x38, 0xAF, 0xFF, 0xC0, 0x19, 0xCC, 0xC1, 0xC0, 0x19, 0x8C, 0x61, 0xC0, 0x09, 0x1C, 0x71, 0xC0, 0x03, 0x1C, 0x31, 0xC0,
|
||||||
0x1F, 0xFE, 0x24, 0x88, 0xE4, 0x48, 0x24, 0x08, 0x27, 0xFC, 0x20, 0x08, 0x20, 0x28, 0x20, 0x10,
|
0x03, 0x1C, 0x01, 0xC8, 0x02, 0xFF, 0xFF, 0xFC, 0x06, 0x18, 0x01, 0x80, 0x06, 0x18, 0xC1, 0x80, 0x06, 0x18, 0x61, 0x80, 0x0C, 0x38, 0x71, 0x80, 0x7C, 0x38, 0x71, 0x80, 0x1C, 0x30, 0x21, 0x88, 0x1C, 0x7F, 0xFF, 0xFC, 0x1C, 0x30, 0x01, 0x80, 0x1C, 0x00, 0x01, 0x80, 0x1C, 0x00, 0x63, 0x80, 0x1C, 0x00, 0x3F, 0x80, 0x1C, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// Original: <20><>
|
// Original: <20><>
|
||||||
{ 0x79, 0xD1 },
|
{ 0x79, 0xD1 },
|
||||||
{
|
{
|
||||||
0x04, 0x10, 0x0E, 0x10, 0xF8, 0x90, 0x08, 0x50, 0x08, 0x10, 0xFE, 0x90, 0x08, 0x50, 0x1C, 0x14,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x00, 0x3C, 0x00, 0xE0, 0x01, 0xFC, 0x00, 0xC0, 0x1F, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x60, 0xC0, 0x00, 0xC0, 0x30, 0xC0, 0x00, 0xC0, 0x38, 0xC0, 0x00, 0xC0, 0x18, 0xC0, 0x00, 0xC4, 0x18, 0xC0, 0x3F, 0xFE, 0x00, 0xC0, 0x3F, 0xFE, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x01, 0xC0, 0xC0, 0xC0, 0x01, 0xE0, 0x70, 0xC0,
|
||||||
0x1A, 0x1E, 0x29, 0xF0, 0x28, 0x10, 0x48, 0x10, 0x88, 0x10, 0x08, 0x10, 0x08, 0x10, 0x08, 0x10,
|
0x03, 0xF8, 0x30, 0xC0, 0x03, 0xDC, 0x30, 0xC8, 0x07, 0xCE, 0x00, 0xDC, 0x06, 0xC6, 0x00, 0xFE, 0x0C, 0xC0, 0x0F, 0xE0, 0x18, 0xC3, 0xF8, 0xC0, 0x10, 0xC7, 0x00, 0xC0, 0x20, 0xC0, 0x00, 0xC0, 0x40, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// Original: <20><>
|
// Original: <20><>
|
||||||
{ 0x62, 0x80 },
|
{ 0x62, 0x80 },
|
||||||
{
|
{
|
||||||
0x10, 0x40, 0x10, 0x40, 0x10, 0x48, 0x13, 0xFC, 0xFC, 0x40, 0x10, 0x40, 0x10, 0x40, 0x13, 0xF8,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x0C, 0x00, 0x01, 0xC0, 0x0E, 0x00, 0x01, 0x80, 0x0C, 0x00, 0x01, 0x80, 0x0C, 0x00, 0x01, 0x80, 0x0C, 0x00, 0x01, 0x80, 0x0C, 0x00, 0x01, 0x88, 0x0C, 0x18, 0x3F, 0xFF, 0xFF, 0xFC, 0x21, 0x80, 0x0C, 0x00, 0x01, 0x80, 0x0C, 0x00, 0x01, 0x80, 0x0C, 0x00, 0x01, 0x80, 0x0C, 0x00, 0x01, 0x8C, 0x0C, 0x20, 0x01, 0xFB, 0xFF, 0xF0,
|
||||||
0x1A, 0x08, 0x31, 0x10, 0xD1, 0x10, 0x10, 0xA0, 0x10, 0x40, 0x10, 0xB0, 0x51, 0x0E, 0x26, 0x04,
|
0x03, 0xE0, 0x80, 0x60, 0x1F, 0x80, 0xC0, 0xE0, 0x3F, 0x80, 0x40, 0xC0, 0x39, 0x80, 0x41, 0xC0, 0x01, 0x80, 0x61, 0xC0, 0x01, 0x80, 0x33, 0x80, 0x01, 0x80, 0x33, 0x00, 0x01, 0x80, 0x1F, 0x00, 0x01, 0x80, 0x1E, 0x00, 0x01, 0x80, 0x1E, 0x00, 0x01, 0x80, 0x3F, 0x00, 0x11, 0x80, 0xE3, 0xC0, 0x1F, 0x83, 0xC1, 0xFC, 0x07, 0x8F, 0x00, 0x7C, 0x03, 0x38, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// Original: <20><>
|
// Original: <20><>
|
||||||
{ 0x67, 0x3A },
|
{ 0x67, 0x3A },
|
||||||
{
|
{
|
||||||
0x10, 0x00, 0x10, 0x10, 0x11, 0xF8, 0x11, 0x10, 0xFD, 0x10, 0x11, 0x10, 0x31, 0x10, 0x39, 0x10,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x03, 0x81, 0x01, 0x80, 0x03, 0x81, 0xFF, 0xC0, 0x03, 0x81, 0x81, 0xC0, 0x03, 0x81, 0x81, 0x80, 0x03, 0x91, 0x81, 0x80, 0x01, 0xB9, 0x81, 0x80, 0x3F, 0xFD, 0x81, 0x80, 0x03, 0x81, 0x81, 0x80, 0x03, 0x81, 0x81, 0x80, 0x03, 0x81, 0x81, 0x80, 0x03, 0xE1, 0x81, 0x80, 0x07, 0xF9, 0x81, 0x80,
|
||||||
0x55, 0x10, 0x51, 0x10, 0x91, 0x10, 0x11, 0x10, 0x11, 0x12, 0x12, 0x12, 0x14, 0x0E, 0x18, 0x00,
|
0x07, 0xBD, 0x81, 0x80, 0x07, 0x9D, 0x81, 0x80, 0x0F, 0x8D, 0x81, 0x80, 0x0F, 0x81, 0x81, 0x80, 0x1B, 0x81, 0x81, 0x80, 0x1B, 0x83, 0x81, 0x80, 0x33, 0x83, 0x01, 0x80, 0x23, 0x83, 0x01, 0x8C, 0x63, 0x83, 0x01, 0x8C, 0x03, 0x86, 0x01, 0x8C, 0x03, 0x86, 0x01, 0x8C, 0x03, 0x8C, 0x01, 0x8E, 0x03, 0x98, 0x01, 0xFE, 0x03, 0xB0, 0x00, 0xFC, 0x03, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// Original: е
|
// Original: е
|
||||||
{ 0x68, 0xB0 },
|
{ 0x68, 0xB0 },
|
||||||
{
|
{
|
||||||
0x10, 0x20, 0x10, 0x28, 0x10, 0x24, 0x17, 0xFE, 0xFC, 0x20, 0x12, 0xA0, 0x32, 0xA0, 0x3A, 0xA4,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x0E, 0x00, 0x03, 0x00, 0x07, 0xC0, 0x03, 0x00, 0x06, 0x70, 0x03, 0x00, 0x06, 0x30, 0x03, 0x00, 0x06, 0x30, 0x03, 0x00, 0x06, 0x00, 0x03, 0x20, 0x06, 0x1C, 0x3F, 0xF7, 0xFF, 0xFC, 0x3F, 0xF0, 0x06, 0x00, 0x07, 0x06, 0xE6, 0x00, 0x07, 0x06, 0xE6, 0x20, 0x07, 0xC6, 0xE6, 0x38, 0x07, 0xE6, 0xE6, 0x38, 0x07, 0x76, 0xE6, 0x30,
|
||||||
0x57, 0xE4, 0x52, 0xA8, 0x92, 0xA8, 0x12, 0x90, 0x14, 0xB0, 0x18, 0x52, 0x10, 0x8A, 0x13, 0x06,
|
0x0F, 0x26, 0xE6, 0x30, 0x0F, 0x3F, 0xFE, 0x70, 0x1B, 0x3F, 0xFE, 0x60, 0x1B, 0x06, 0xE7, 0x60, 0x13, 0x06, 0xE3, 0xC0, 0x33, 0x06, 0xE3, 0xC0, 0x23, 0x0C, 0xE3, 0x80, 0x43, 0x0C, 0xE3, 0x84, 0x03, 0x0C, 0xE3, 0x84, 0x03, 0x18, 0xE7, 0xC4, 0x03, 0x18, 0xEC, 0xEC, 0x03, 0x30, 0xD8, 0x7C, 0x03, 0x20, 0x30, 0x3C, 0x03, 0x40, 0xE0, 0x1C, 0x03, 0x03, 0x80, 0x0E, 0x00, 0x00, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// Original: ʦ
|
// Original: ʦ
|
||||||
{ 0x5E, 0x08 },
|
{ 0x5E, 0x08 },
|
||||||
{
|
{
|
||||||
0x08, 0x04, 0x0B, 0xFE, 0x48, 0x20, 0x48, 0x24, 0x49, 0xFE, 0x49, 0x24, 0x49, 0x24, 0x49, 0x24,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x18, 0x00, 0xEF, 0xFF, 0xFC, 0x00, 0xE6, 0x0C, 0x00, 0x10, 0xE0, 0x0C, 0x00, 0x1C, 0xE0, 0x0C, 0x00, 0x1C, 0xE0, 0x0C, 0x00, 0x1C, 0xE0, 0x0C, 0x10, 0x1C, 0xE7, 0xFF, 0xF8, 0x1C, 0xE7, 0xFF, 0xF8, 0x1C, 0xE6, 0x0C, 0x18, 0x1C, 0xE6, 0x0C, 0x18, 0x1C, 0xC6, 0x0C, 0x18, 0x1C, 0xC6, 0x0C, 0x18,
|
||||||
0x49, 0x24, 0x49, 0x24, 0x49, 0x24, 0x49, 0x24, 0x11, 0x34, 0x11, 0x28, 0x20, 0x20, 0x40, 0x20,
|
0x1C, 0xC6, 0x0C, 0x18, 0x1C, 0xC6, 0x0C, 0x18, 0x1C, 0xC6, 0x0C, 0x18, 0x1C, 0xC6, 0x0C, 0x18, 0x1C, 0xC6, 0x0C, 0x18, 0x1D, 0xC6, 0x0C, 0x18, 0x1D, 0x86, 0x0C, 0x18, 0x19, 0x86, 0x0D, 0xF8, 0x03, 0x86, 0x0C, 0x70, 0x03, 0x06, 0x0C, 0x20, 0x06, 0x00, 0x1C, 0x00, 0x0E, 0x00, 0x1C, 0x00, 0x0C, 0x00, 0x1C, 0x00, 0x10, 0x00, 0x1C, 0x00, 0x20, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@@ -6,7 +6,7 @@ extern "C" {
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#define KEY_TICKS_INTERVAL 5 // 定时器间隔时间,单位为毫秒
|
#define KEY_TICKS_INTERVAL 5 // 定时器间隔时间,单位为毫秒
|
||||||
#define DEBOUNCE_TICKS 0 // 按键去抖动计数阈值,最大为7(0 ~ 7)
|
#define DEBOUNCE_TICKS 0 // 按键去抖动计数阈值,最大为7(0 ~ 7)
|
||||||
#define SHORT_TICKS (300 / KEY_TICKS_INTERVAL) // 短按阈值,单位为定时器间隔的倍数
|
#define SHORT_TICKS (300 / KEY_TICKS_INTERVAL) // 短按阈值,单位为定时器间隔的倍数
|
||||||
|
183
lib/list/hash_table.cpp
Normal file
183
lib/list/hash_table.cpp
Normal file
@@ -0,0 +1,183 @@
|
|||||||
|
#include "hash_table.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
static Hash_Item_t HT_DELETED_ITEM = {NULL, NULL};
|
||||||
|
|
||||||
|
static Hash_Item_t* ht_new_item(const char* k, const char* v) {
|
||||||
|
Hash_Item_t* i = (Hash_Item_t*)malloc(sizeof(Hash_Item_t));
|
||||||
|
i->key = strdup(k);
|
||||||
|
i->value = strdup(v);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ht_hash(const char* s, const int a, const int m) {
|
||||||
|
long hash = 0;
|
||||||
|
const int len_s = strlen(s);
|
||||||
|
for (int i = 0; i < len_s; i++) {
|
||||||
|
hash += (long)pow(a, len_s - (i+1)) * s[i];
|
||||||
|
hash = hash % m;
|
||||||
|
}
|
||||||
|
return (int)hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ht_get_hash(
|
||||||
|
const char* s, const int num_buckets, const int attempt
|
||||||
|
) {
|
||||||
|
const int hash_a = ht_hash(s, HT_PRIME_1, num_buckets);
|
||||||
|
const int hash_b = ht_hash(s, HT_PRIME_2, num_buckets);
|
||||||
|
return (hash_a + (attempt * (hash_b + 1))) % num_buckets;
|
||||||
|
}
|
||||||
|
static void ht_del_item(Hash_Item_t* i) {
|
||||||
|
free(i->key);
|
||||||
|
free(i->value);
|
||||||
|
free(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ht_del_hash_table(Hash_Table_t* ht) {
|
||||||
|
for (int i = 0; i < ht->size; i++) {
|
||||||
|
Hash_Item_t* item = ht->items[i];
|
||||||
|
if (item != NULL) {
|
||||||
|
ht_del_item(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(ht->items);
|
||||||
|
free(ht);
|
||||||
|
}
|
||||||
|
|
||||||
|
int is_prime(const int x) {
|
||||||
|
if (x < 2) { return -1; }
|
||||||
|
if (x < 4) { return 1; }
|
||||||
|
if ((x % 2) == 0) { return 0; }
|
||||||
|
for (int i = 3; i <= floor(sqrt((double) x)); i += 2) {
|
||||||
|
if ((x % i) == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int next_prime(int x) {
|
||||||
|
while (is_prime(x) != 1) {
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Hash_Table_t* ht_new_sized(const int base_size) {
|
||||||
|
Hash_Table_t* ht = (Hash_Table_t*)malloc(sizeof(Hash_Table_t));
|
||||||
|
ht->base_size = base_size;
|
||||||
|
|
||||||
|
ht->size = next_prime(ht->base_size);
|
||||||
|
|
||||||
|
ht->count = 0;
|
||||||
|
ht->items = (Hash_Item_t**) calloc((size_t)ht->size, sizeof(Hash_Item_t*));
|
||||||
|
return ht;
|
||||||
|
}
|
||||||
|
|
||||||
|
Hash_Table_t* ht_new() {
|
||||||
|
return ht_new_sized(HT_INITIAL_BASE_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ht_resize(Hash_Table_t* ht, const int base_size) {
|
||||||
|
if (base_size < HT_INITIAL_BASE_SIZE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Hash_Table_t* new_ht = ht_new_sized(base_size);
|
||||||
|
for (int i = 0; i < ht->size; i++) {
|
||||||
|
Hash_Item_t* item = ht->items[i];
|
||||||
|
if (item != NULL && item != &HT_DELETED_ITEM) {
|
||||||
|
ht_insert(new_ht, item->key, item->value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ht->base_size = new_ht->base_size;
|
||||||
|
ht->count = new_ht->count;
|
||||||
|
|
||||||
|
// To delete new_ht, we give it ht's size and items
|
||||||
|
const int tmp_size = ht->size;
|
||||||
|
ht->size = new_ht->size;
|
||||||
|
new_ht->size = tmp_size;
|
||||||
|
|
||||||
|
Hash_Item_t** tmp_items = ht->items;
|
||||||
|
ht->items = new_ht->items;
|
||||||
|
new_ht->items = tmp_items;
|
||||||
|
|
||||||
|
ht_del_hash_table(new_ht);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ht_resize_up(Hash_Table_t* ht) {
|
||||||
|
const int new_size = ht->base_size * 2;
|
||||||
|
ht_resize(ht, new_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void ht_resize_down(Hash_Table_t* ht) {
|
||||||
|
const int new_size = ht->base_size / 2;
|
||||||
|
ht_resize(ht, new_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ht_insert(Hash_Table_t* ht, const char* key, const char* value) {
|
||||||
|
const int load = ht->count * 100 / ht->size;
|
||||||
|
if (load > 70) {
|
||||||
|
ht_resize_up(ht);
|
||||||
|
}
|
||||||
|
Hash_Item_t* item = ht_new_item(key, value);
|
||||||
|
int index = ht_get_hash(item->key, ht->size, 0);
|
||||||
|
Hash_Item_t* cur_item = ht->items[index];
|
||||||
|
int i = 1;
|
||||||
|
while (cur_item != NULL) {
|
||||||
|
if (cur_item != &HT_DELETED_ITEM) {
|
||||||
|
if (strcmp(cur_item->key, key) == 0) {
|
||||||
|
ht_del_item(cur_item);
|
||||||
|
ht->items[index] = item;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
index = ht_get_hash(item->key, ht->size, i);
|
||||||
|
cur_item = ht->items[index];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
ht->items[index] = item;
|
||||||
|
ht->count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* ht_search(Hash_Table_t* ht, const char* key) {
|
||||||
|
int index = ht_get_hash(key, ht->size, 0);
|
||||||
|
Hash_Item_t* item = ht->items[index];
|
||||||
|
int i = 1;
|
||||||
|
while (item != NULL) {
|
||||||
|
if (item != &HT_DELETED_ITEM) {
|
||||||
|
if (strcmp(item->key, key) == 0) {
|
||||||
|
return item->value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
index = ht_get_hash(key, ht->size, i);
|
||||||
|
item = ht->items[index];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ht_delete(Hash_Table_t* ht, const char* key) {
|
||||||
|
const int load = ht->count * 100 / ht->size;
|
||||||
|
if (load < 10) {
|
||||||
|
ht_resize_down(ht);
|
||||||
|
}
|
||||||
|
int index = ht_get_hash(key, ht->size, 0);
|
||||||
|
Hash_Item_t* item = ht->items[index];
|
||||||
|
int i = 1;
|
||||||
|
while (item != NULL) {
|
||||||
|
if (item != &HT_DELETED_ITEM) {
|
||||||
|
if (strcmp(item->key, key) == 0) {
|
||||||
|
ht_del_item(item);
|
||||||
|
ht->items[index] = &HT_DELETED_ITEM;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
index = ht_get_hash(key, ht->size, i);
|
||||||
|
item = ht->items[index];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
ht->count--;
|
||||||
|
}
|
36
lib/list/inc/hash_table.h
Normal file
36
lib/list/inc/hash_table.h
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#pragma once
|
||||||
|
#ifndef HW_LIB_HASH_TABLE_H
|
||||||
|
#define HW_LIB_HASH_TABLE_H
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define HT_PRIME_1 151
|
||||||
|
#define HT_PRIME_2 163
|
||||||
|
#define HT_INITIAL_BASE_SIZE 53
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct Hash_Item
|
||||||
|
{
|
||||||
|
char* key;
|
||||||
|
char* value;
|
||||||
|
} Hash_Item_t;
|
||||||
|
|
||||||
|
typedef struct Hash_Table
|
||||||
|
{
|
||||||
|
int base_size;
|
||||||
|
int size;
|
||||||
|
int count;
|
||||||
|
Hash_Item_t** items;
|
||||||
|
} Hash_Table_t;
|
||||||
|
|
||||||
|
Hash_Table_t* ht_new();
|
||||||
|
void ht_del_hash_table(Hash_Table_t* ht);
|
||||||
|
void ht_insert(Hash_Table_t* ht, const char* key, const char* value);
|
||||||
|
char* ht_search(Hash_Table_t* ht, const char* key);
|
||||||
|
void ht_delete(Hash_Table_t* h, const char* key);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif //HW_LIB_HASH_TABLE_H
|
3948
lib/lui/inc/lame_ui.h
Normal file
3948
lib/lui/inc/lame_ui.h
Normal file
File diff suppressed because it is too large
Load Diff
6376
lib/lui/lame_ui.c
Normal file
6376
lib/lui/lame_ui.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
#include "stdbool.h"
|
||||||
#include "stdint.h"
|
#include "stdint.h"
|
||||||
|
|
||||||
|
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
#include "stdbool.h"
|
||||||
typedef char OptId;
|
typedef char OptId;
|
||||||
|
|
||||||
typedef struct Option {
|
typedef struct Option {
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <syncstream>
|
|
||||||
#include "tool.h"
|
#include "tool.h"
|
||||||
|
|
||||||
float Mapping(float val, float I_Min, float I_Max, float O_Min, float O_Max) {
|
float Mapping(float val, float I_Min, float I_Max, float O_Min, float O_Max) {
|
||||||
|
12
main.c
12
main.c
@@ -12,7 +12,7 @@
|
|||||||
#include "t_tft.h"
|
#include "t_tft.h"
|
||||||
#include "tool.h"
|
#include "tool.h"
|
||||||
#include "sim_test.h"
|
#include "sim_test.h"
|
||||||
#include "sim_sdl.h"
|
#include "t_lui.h"
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
@@ -30,12 +30,6 @@ static SDL_Point points[POINTS_COUNT] = {
|
|||||||
|
|
||||||
static SDL_Rect bigrect = {0, 0, 540, 380};
|
static SDL_Rect bigrect = {0, 0, 540, 380};
|
||||||
|
|
||||||
static SIM_SDL3_t sdl1;
|
|
||||||
static SIM_SDL3_t sdl2;
|
|
||||||
static SIM_SDL3_t sdl3;
|
|
||||||
|
|
||||||
static SIM_SDL3_t sdls[3];
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
srand((unsigned) time(NULL));
|
srand((unsigned) time(NULL));
|
||||||
|
|
||||||
@@ -166,9 +160,11 @@ int main(int argc, char *argv[]) {
|
|||||||
// Test_Run("List", Test_List,NULL);
|
// Test_Run("List", Test_List,NULL);
|
||||||
// Test_RunTime("Key", Test_Key);
|
// Test_RunTime("Key", Test_Key);
|
||||||
// Test_RunTime("Queue", Test_Queue);
|
// Test_RunTime("Queue", Test_Queue);
|
||||||
Test_RunTime("Task", Test_task);
|
// Test_RunTime("Hash", Test_Hash);
|
||||||
|
// Test_RunTime("Task", Test_task);
|
||||||
// Test_RunTime("OLED", Test_OLED);
|
// Test_RunTime("OLED", Test_OLED);
|
||||||
// Test_RunTime("LVGL", Test_lvgl);
|
// Test_RunTime("LVGL", Test_lvgl);
|
||||||
// Test_RunTime("TFT", Test_tft);
|
// Test_RunTime("TFT", Test_tft);
|
||||||
|
Test_RunTime("LUI", Test_lui);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <syncstream>
|
|
||||||
#include "sim_test.h"
|
#include "sim_test.h"
|
||||||
|
|
||||||
void Test_RunTime(char *name, int (*pFunction)(void *)) {
|
void Test_RunTime(char *name, int (*pFunction)(void *)) {
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
#include "sim_display.h"
|
#include "sim_display.h"
|
||||||
#include "graphics.h"
|
|
||||||
#include <conio.h>
|
|
||||||
|
|
||||||
#define GET_BIT(x, bit) ((x & (1 << bit)) >> bit)
|
#define GET_BIT(x, bit) ((x & (1 << bit)) >> bit)
|
||||||
|
|
||||||
@@ -20,6 +19,10 @@ uint32_t RGB565_to_ARGB8888(uint16_t rgb565, bool isBGR) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifndef USER_SDL3
|
#ifndef USER_SDL3
|
||||||
|
|
||||||
|
#include "graphics.h"
|
||||||
|
#include <conio.h>
|
||||||
|
|
||||||
static uint32_t pixelColor, backgroundColor;
|
static uint32_t pixelColor, backgroundColor;
|
||||||
static int scaleFactor, w, h;
|
static int scaleFactor, w, h;
|
||||||
uint8_t border;
|
uint8_t border;
|
||||||
|
113
sim/key/key.cpp
113
sim/key/key.cpp
@@ -108,4 +108,117 @@ uint8_t SIM_Key_Scan() {
|
|||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t SIM_Key_UP(uint8_t) {
|
||||||
|
SDL_Event event;
|
||||||
|
uint8_t key = 0;
|
||||||
|
SDL_PollEvent(&event);
|
||||||
|
switch (event.type) {
|
||||||
|
case SDL_EVENT_QUIT:
|
||||||
|
return 0;
|
||||||
|
case SDL_EVENT_KEY_DOWN:
|
||||||
|
if (event.key.key == SDLK_UP || event.key.key == SDLK_W)key = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t SIM_Key_DOWN(uint8_t l) {
|
||||||
|
SDL_Event event;
|
||||||
|
uint8_t key = 0;
|
||||||
|
SDL_PollEvent(&event);
|
||||||
|
switch (event.type) {
|
||||||
|
case SDL_EVENT_QUIT:
|
||||||
|
return 0;
|
||||||
|
case SDL_EVENT_KEY_DOWN:
|
||||||
|
if (event.key.key == SDLK_DOWN || event.key.key == SDLK_S)key = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t SIM_Key_LEFT(uint8_t) {
|
||||||
|
SDL_Event event;
|
||||||
|
uint8_t key = 0;
|
||||||
|
SDL_PollEvent(&event);
|
||||||
|
switch (event.type) {
|
||||||
|
case SDL_EVENT_QUIT:
|
||||||
|
return 0;
|
||||||
|
case SDL_EVENT_KEY_DOWN:
|
||||||
|
if (event.key.key == SDLK_LEFT || event.key.key == SDLK_A)key = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t SIM_Key_RIGHT(uint8_t) {
|
||||||
|
SDL_Event event;
|
||||||
|
uint8_t key = 0;
|
||||||
|
SDL_PollEvent(&event);
|
||||||
|
switch (event.type) {
|
||||||
|
case SDL_EVENT_QUIT:
|
||||||
|
return 0;
|
||||||
|
case SDL_EVENT_KEY_DOWN:
|
||||||
|
if (event.key.key == SDLK_RIGHT || event.key.key == SDLK_D)key = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t SIM_Key_ENABLE(uint8_t) {
|
||||||
|
SDL_Event event;
|
||||||
|
uint8_t key = 0;
|
||||||
|
SDL_PollEvent(&event);
|
||||||
|
switch (event.type) {
|
||||||
|
case SDL_EVENT_QUIT:
|
||||||
|
return 0;
|
||||||
|
case SDL_EVENT_KEY_DOWN:
|
||||||
|
if (event.key.key == SDLK_KP_ENTER || event.key.key == SDLK_E)key = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t SIM_Key_SET(uint8_t) {
|
||||||
|
SDL_Event event;
|
||||||
|
uint8_t key = 0;
|
||||||
|
SDL_PollEvent(&event);
|
||||||
|
switch (event.type) {
|
||||||
|
case SDL_EVENT_QUIT:
|
||||||
|
return 0;
|
||||||
|
case SDL_EVENT_KEY_DOWN:
|
||||||
|
if (event.key.key == SDLK_Q)key = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t SIM_Key_RESET(uint8_t) {
|
||||||
|
SDL_Event event;
|
||||||
|
uint8_t key = 0;
|
||||||
|
SDL_PollEvent(&event);
|
||||||
|
switch (event.type) {
|
||||||
|
case SDL_EVENT_QUIT:
|
||||||
|
return 0;
|
||||||
|
case SDL_EVENT_KEY_DOWN:
|
||||||
|
if (event.key.key == SDLK_R)key = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -12,8 +12,6 @@
|
|||||||
*********************/
|
*********************/
|
||||||
#include "lv_port_indev.h"
|
#include "lv_port_indev.h"
|
||||||
#include "lvgl.h"
|
#include "lvgl.h"
|
||||||
#include "graphics.h"
|
|
||||||
#include <easyx.h>
|
|
||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
@@ -253,8 +251,8 @@ static void mouse_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
|
|||||||
static bool mouse_is_pressed(void)
|
static bool mouse_is_pressed(void)
|
||||||
{
|
{
|
||||||
/*Your code comes here*/
|
/*Your code comes here*/
|
||||||
ExMessage msg;peekmessage(&msg, EM_MOUSE);
|
// ExMessage msg;peekmessage(&msg, EM_MOUSE);
|
||||||
if(msg.message==WM_LBUTTONDOWN) return true;
|
// if(msg.message==WM_LBUTTONDOWN) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,13 +260,13 @@ static bool mouse_is_pressed(void)
|
|||||||
static void mouse_get_xy(lv_coord_t * x, lv_coord_t * y)
|
static void mouse_get_xy(lv_coord_t * x, lv_coord_t * y)
|
||||||
{
|
{
|
||||||
/*Your code comes here*/
|
/*Your code comes here*/
|
||||||
ExMessage msg;
|
// ExMessage msg;
|
||||||
if(peekmessage(&msg, EM_MOUSE))
|
// if(peekmessage(&msg, EM_MOUSE))
|
||||||
{
|
// {
|
||||||
(*x) = msg.x;
|
// (*x) = msg.x;
|
||||||
(*y) = msg.y;
|
// (*y) = msg.y;
|
||||||
printf("\nX:%d,Y:%d",*x,*y);
|
// printf("\nX:%d,Y:%d",*x,*y);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------
|
/*------------------
|
||||||
|
@@ -1,6 +1,4 @@
|
|||||||
#include "sim_oled.h"
|
#include "sim_oled.h"
|
||||||
#include "graphics.h"
|
|
||||||
#include <conio.h>
|
|
||||||
|
|
||||||
static SIM_Display_t oled_display;
|
static SIM_Display_t oled_display;
|
||||||
void SIM_OLED_INIT(int width, int height, uint32_t pixcolor, uint32_t backcolor, int scale, uint8_t b) {
|
void SIM_OLED_INIT(int width, int height, uint32_t pixcolor, uint32_t backcolor, int scale, uint8_t b) {
|
||||||
|
Reference in New Issue
Block a user