From dcf1ea57857fecbca178c786946157203a581b65 Mon Sep 17 00:00:00 2001 From: "mr.zhangsan" Date: Sat, 29 Jun 2024 19:38:23 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=E6=B7=BB=E5=8A=A0=E5=BF=83=E7=94=B5?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/.vscode/settings.json | 3 ++- source/app/app_config.c | 3 +++ source/app/app_config.h | 3 +++ source/app/task_btn.c | 10 +++++++++- source/app/task_low_power.c | 38 +++++++++++++++++++++++++++++++++--- source/app/task_low_power.h | 1 + source/app/task_rfid.c | 2 +- 7 files changed, 54 insertions(+), 6 deletions(-) diff --git a/source/.vscode/settings.json b/source/.vscode/settings.json index 5a57a6f..71e333f 100644 --- a/source/.vscode/settings.json +++ b/source/.vscode/settings.json @@ -24,6 +24,7 @@ "rs485.h": "c", "bsp_led.h": "c", "task_nfc_auth.h": "c", - "stc_stc8h.h": "c" + "stc_stc8h.h": "c", + "task.h": "c" } } \ No newline at end of file diff --git a/source/app/app_config.c b/source/app/app_config.c index f313da4..30c7927 100644 --- a/source/app/app_config.c +++ b/source/app/app_config.c @@ -77,6 +77,9 @@ int i; void L3_reg_reset(void) { + //心电模式 + R.xd_mode = 0; + //设置RFID对照表 for(i=0; i=1 && key <=12) { //如果不需要授权 or 需要但已经授权 if(!(R.auth_flag & 0xF0) || (R.auth_flag & 0x0F)) diff --git a/source/app/task_low_power.c b/source/app/task_low_power.c index c122ba3..0e9895d 100644 --- a/source/app/task_low_power.c +++ b/source/app/task_low_power.c @@ -26,22 +26,29 @@ void L3_task_low_power_init(void) } #define D_task_LOW_POWER_SET 0x50 +#define D_task_LOW_POWER_CHANGE 0x51 +#define D_task_XD_CHANGE 0x52 void L3_task_low_power_handler(S_TASK_LOW_POWER *s) { TTSS_Task_init() s->power_mode = R.power_mode; + s->xd_mode = R.xd_mode; L2_task_go(D_task_LOW_POWER_SET); TTSS_Task_step(D_task_LOW_POWER_SET) if(R.power_mode == POWER_LOW) { - //除了功能按键,所有灯全灭 + //低功耗模式除了功能按键,所有灯全灭 L3_led_clear(); - //禁用RFID + //低功耗模式下禁用RFID bsp_rfid_en(RFID_DISABLE); + //低功耗模式下,无法(也不需要)开启心电模式 + R.xd_mode = 0; } - + L2_task_go_Tdelay(D_task_LOW_POWER_CHANGE,0); + + TTSS_Task_step(D_task_LOW_POWER_CHANGE) if(s->power_mode != R.power_mode) { s->power_mode = R.power_mode; @@ -53,6 +60,31 @@ void L3_task_low_power_handler(S_TASK_LOW_POWER *s) bsp_rfid_en(RFID_ENABLE); //重新初始化RFID任务 L3_task_rfid_init(); + //心电进入正常模式 + R.xd_mode = 0; + } + } + L2_task_go_Tdelay(D_task_XD_CHANGE,0); + + TTSS_Task_step(D_task_XD_CHANGE) + //正常功耗模式下,心电模式才有意义 + if(R.power_mode == POWER_NORMAL) + { + if(s->xd_mode != R.xd_mode) + { + s->xd_mode = R.xd_mode; + if(R.xd_mode == 0) + { + //启用rfid + bsp_rfid_en(RFID_ENABLE); + //重新初始化RFID任务 + L3_task_rfid_init(); + } + else + { + //禁用RFID + bsp_rfid_en(RFID_DISABLE); + } } } L2_task_go_Tdelay(D_task_LOW_POWER_SET,D_Tdelay_500ms); diff --git a/source/app/task_low_power.h b/source/app/task_low_power.h index 1cfc556..4ebb28a 100644 --- a/source/app/task_low_power.h +++ b/source/app/task_low_power.h @@ -20,6 +20,7 @@ typedef struct _s_task_low_power { U8 power_mode; + U8 xd_mode; TS_task task; }S_TASK_LOW_POWER; diff --git a/source/app/task_rfid.c b/source/app/task_rfid.c index ffe3fa7..b29803b 100644 --- a/source/app/task_rfid.c +++ b/source/app/task_rfid.c @@ -45,7 +45,7 @@ void L3_task_rfid_handler(S_TASK_RFID *s) L0_uart0_uchex(sizeof(rfidSelCmd) / sizeof(U8)); L0_uart0_uchex(sizeof(rfidLoopRead) / sizeof(U8)); //注意这里加delay,因为rfid_en是强推挽模式,强推挽模式生效有延迟,经测试这里的时间需要>=2s - L2_task_go_Tdelay(D_task_RFID_SET,D_Tdelay_3s); + L2_task_go_Tdelay(D_task_RFID_SET,D_Tdelay_4s); TTSS_Task_step(D_task_RFID_SET) //1.设置天线