From fa81dd2631ac4f968b90fe3e1197e93d85a12a99 Mon Sep 17 00:00:00 2001 From: wangzhiming <1250853412@qq.com> Date: Thu, 20 Jul 2023 08:05:58 +0800 Subject: [PATCH 1/4] =?UTF-8?q?apps:=20=E6=96=B0=E5=A2=9E=E6=8C=89?= =?UTF-8?q?=E9=94=AE=E9=A9=B1=E5=8A=A8=E6=B5=8B=E8=AF=95=E6=A1=88=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/Makefile | 3 ++- apps/install.mk | 3 ++- apps/key_test/Makefile | 9 +++++++++ apps/key_test/key_test.c | 28 ++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 apps/key_test/Makefile create mode 100644 apps/key_test/key_test.c diff --git a/apps/Makefile b/apps/Makefile index 1d81d74..c59cd12 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -19,7 +19,7 @@ $(error unsupported arch!) endif -X_CFLAGS := $(MCFLAGS) -fno-builtin -fno-stack-protector +X_CFLAGS := $(MCFLAGS) -fno-builtin -fno-stack-protector X_CFLAGS += -nostdlib -nostdinc -Wall -O3 -ffunction-sections -fdata-sections -ffreestanding -std=gnu99 X_CFLAGS += -DNXOS -D__NXOS__ -D__nxos__ @@ -56,3 +56,4 @@ MODULE += gnuboy MODULE += showimage MODULE += showfont MODULE += sdl_audio +MODULE += key_test diff --git a/apps/install.mk b/apps/install.mk index 50d92a9..6a07f7f 100644 --- a/apps/install.mk +++ b/apps/install.mk @@ -17,9 +17,10 @@ apps: cp build/gnuboy/gnuboy.xapp $(APP_DIR) cp build/showimage/showimage.xapp $(APP_DIR) cp build/showfont/showfont.xapp $(APP_DIR) + cp build/key_test/key_test.xapp $(APP_DIR) tests: cp build/LVGL_Demo/LVGL_Demo.xapp $(APP_DIR) cp build/WinTest/WinTest.xapp $(APP_DIR) cp build/SDL_Demo/SDL_Demo.xapp $(APP_DIR) - cp build/sdl_audio/sdl_audio.xapp $(APP_DIR) \ No newline at end of file + cp build/sdl_audio/sdl_audio.xapp $(APP_DIR) diff --git a/apps/key_test/Makefile b/apps/key_test/Makefile new file mode 100644 index 0000000..3db5068 --- /dev/null +++ b/apps/key_test/Makefile @@ -0,0 +1,9 @@ +NAME := key_test.xapp +SRC += *.c + +define CUSTOM_TARGET_CMD +echo [APP] $@; \ +$(LD) $(X_LDFLAGS) $(X_OBJS) -o $@ $(patsubst %, -L%, $(X_LIBDIRS)) \ + --start-group $(patsubst %, -l:%, $(X_LIBS)) --end-group; \ +$(OD) -D -S $@ > $@.dump.S +endef diff --git a/apps/key_test/key_test.c b/apps/key_test/key_test.c new file mode 100644 index 0000000..d4add8c --- /dev/null +++ b/apps/key_test/key_test.c @@ -0,0 +1,28 @@ +#include + +NX_Error NX_Main(char *cmdline, char *envline) +{ + NX_ThreadSleep(2000); + NX_Printf("[%s %d] APP Start!\n", __func__, __LINE__); + + NX_Solt key0 = NX_DeviceOpen("KeyBoard_DRV", 0); + if (key0 < 0) { + NX_Printf("open KeyBoard_DRV device failed!\n"); + return NX_ENOSRCH; + } + + NX_U32 info; + // 校准键盘测试 + if (NX_DeviceControl(key0, NX_INPUT_EVENT_CMD_CALIBRATE, &info) != NX_EOK) + { + NX_Printf("get fb info failed!\n"); + NX_SoltClose(key0); + return NX_EPERM; + } + + NX_Printf("info:%d\n", info); + + while (1) { + + } +} \ No newline at end of file -- Gitee From 4884460dfd335b23d729067b6dd7e366d38bfb73 Mon Sep 17 00:00:00 2001 From: wangzhiming <1250853412@qq.com> Date: Thu, 20 Jul 2023 22:35:00 +0800 Subject: [PATCH 2/4] =?UTF-8?q?apps:=20key=5Ftest:=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E4=BA=86=E9=83=A8=E5=88=86=E6=8C=89=E9=94=AE=E9=A9=B1=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/key_test/key_test.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/apps/key_test/key_test.c b/apps/key_test/key_test.c index d4add8c..80c7659 100644 --- a/apps/key_test/key_test.c +++ b/apps/key_test/key_test.c @@ -2,7 +2,7 @@ NX_Error NX_Main(char *cmdline, char *envline) { - NX_ThreadSleep(2000); + // NX_ThreadSleep(2000); NX_Printf("[%s %d] APP Start!\n", __func__, __LINE__); NX_Solt key0 = NX_DeviceOpen("KeyBoard_DRV", 0); @@ -11,18 +11,20 @@ NX_Error NX_Main(char *cmdline, char *envline) return NX_ENOSRCH; } - NX_U32 info; + // NX_U32 info; // 校准键盘测试 - if (NX_DeviceControl(key0, NX_INPUT_EVENT_CMD_CALIBRATE, &info) != NX_EOK) - { - NX_Printf("get fb info failed!\n"); - NX_SoltClose(key0); - return NX_EPERM; - } + // if (NX_DeviceControl(key0, NX_INPUT_EVENT_CMD_CALIBRATE, &info) != NX_EOK) + // { + // NX_Printf("get fb info failed!\n"); + // NX_SoltClose(key0); + // return NX_EPERM; + // } - NX_Printf("info:%d\n", info); + // NX_Printf("info:%d\n", info); + NX_ThreadSleep(2000); + NX_SoltClose(key0); while (1) { - + NX_ThreadSleep(200); } } \ No newline at end of file -- Gitee From f1ee3224e2be6483c1439452ed46555e348f5bd0 Mon Sep 17 00:00:00 2001 From: wangzhiming <1250853412@qq.com> Date: Fri, 21 Jul 2023 07:49:56 +0800 Subject: [PATCH 3/4] =?UTF-8?q?apps:=20key=5Ftest:=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=8C=89=E9=94=AE=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/key_test/key_test.c | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/apps/key_test/key_test.c b/apps/key_test/key_test.c index 80c7659..05ff29c 100644 --- a/apps/key_test/key_test.c +++ b/apps/key_test/key_test.c @@ -1,8 +1,12 @@ #include +#define calibrate 0 + NX_Error NX_Main(char *cmdline, char *envline) { - // NX_ThreadSleep(2000); + NX_ThreadSleep(2000); // 避免该应用的log被shell打印打乱 + NX_InputEvent e; + NX_Printf("[%s %d] APP Start!\n", __func__, __LINE__); NX_Solt key0 = NX_DeviceOpen("KeyBoard_DRV", 0); @@ -11,20 +15,28 @@ NX_Error NX_Main(char *cmdline, char *envline) return NX_ENOSRCH; } - // NX_U32 info; - // 校准键盘测试 - // if (NX_DeviceControl(key0, NX_INPUT_EVENT_CMD_CALIBRATE, &info) != NX_EOK) - // { - // NX_Printf("get fb info failed!\n"); - // NX_SoltClose(key0); - // return NX_EPERM; - // } - // NX_Printf("info:%d\n", info); +#if calibrate + NX_U32 info; + // 校准键盘测试 + if (NX_DeviceControl(key0, NX_INPUT_EVENT_CMD_CALIBRATE, &info) != NX_EOK) + { + NX_Printf("get fb info failed!\n"); + NX_SoltClose(key0); + return NX_EPERM; + } + NX_Printf("info:%d\n", info); +#endif - NX_ThreadSleep(2000); - NX_SoltClose(key0); while (1) { - NX_ThreadSleep(200); + if (NX_DeviceRead(key0, &e, 0, sizeof(e)) > 0) { + if (e.type == NX_EV_KEY) { + if ((e.value & 0xffff) == 0) { + NX_Printf("keydown: %x/%c\n", e.code, e.code); + } + } + } + NX_ThreadSleep(10); } + NX_SoltClose(key0); } \ No newline at end of file -- Gitee From 648c7d5a7ba7d78ca3b1a76d6354f9b5993f06d2 Mon Sep 17 00:00:00 2001 From: wangzhiming <1250853412@qq.com> Date: Fri, 21 Jul 2023 23:48:17 +0800 Subject: [PATCH 4/4] =?UTF-8?q?apps:=20key=5Ftest:=20=E5=AE=8C=E6=88=90key?= =?UTF-8?q?=E9=A9=B1=E5=8A=A8=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/key_test/key_test.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/key_test/key_test.c b/apps/key_test/key_test.c index 05ff29c..0fb166e 100644 --- a/apps/key_test/key_test.c +++ b/apps/key_test/key_test.c @@ -6,6 +6,7 @@ NX_Error NX_Main(char *cmdline, char *envline) { NX_ThreadSleep(2000); // 避免该应用的log被shell打印打乱 NX_InputEvent e; + NX_U32 i = 0; NX_Printf("[%s %d] APP Start!\n", __func__, __LINE__); @@ -15,7 +16,6 @@ NX_Error NX_Main(char *cmdline, char *envline) return NX_ENOSRCH; } - #if calibrate NX_U32 info; // 校准键盘测试 @@ -28,7 +28,8 @@ NX_Error NX_Main(char *cmdline, char *envline) NX_Printf("info:%d\n", info); #endif - while (1) { + NX_U32 run = 1; + while (run) { if (NX_DeviceRead(key0, &e, 0, sizeof(e)) > 0) { if (e.type == NX_EV_KEY) { if ((e.value & 0xffff) == 0) { @@ -36,7 +37,12 @@ NX_Error NX_Main(char *cmdline, char *envline) } } } + if (i++ > 1000) + run = 0; NX_ThreadSleep(10); } NX_SoltClose(key0); + + NX_Printf("[%s %d] APP Run finish!\n", __func__, __LINE__); + return 0; } \ No newline at end of file -- Gitee