diff --git a/source/app/app_config.c b/source/app/app_config.c index 08334ff..2c1ec7e 100644 --- a/source/app/app_config.c +++ b/source/app/app_config.c @@ -116,6 +116,8 @@ void L3_reg_reset(void) { U8 i = 0; + R.Operation_time = D_sys_now; + R.app_status = POW_OFF; R.pen_sta = 0; diff --git a/source/app/app_config.h b/source/app/app_config.h index 2cf7b03..1172c5d 100644 --- a/source/app/app_config.h +++ b/source/app/app_config.h @@ -87,6 +87,8 @@ typedef struct global_register APP_STATUS app_status; + vU32 Operation_time; + }GlobalRegister; extern GlobalRegister R; diff --git a/source/app/main.c b/source/app/main.c index eecb14e..7b910a0 100644 --- a/source/app/main.c +++ b/source/app/main.c @@ -106,6 +106,7 @@ void main(void) // WIFI任务 if (R.app_status >= POW_ON) { + Power_Off_judge(); // WIFI数据解析 L3_uart2_wifi_parse(); L2_task_W600_flow_handle(&_s_task_w600_para); diff --git a/source/app/task_appstatus.c b/source/app/task_appstatus.c index 1e2f8cf..b836d43 100644 --- a/source/app/task_appstatus.c +++ b/source/app/task_appstatus.c @@ -26,6 +26,7 @@ S_TASK_APPSTATUS _s_task_appstatus; + void L3_task_AppStatus_init(void) { L1_task_init(&_s_task_appstatus.task); @@ -47,6 +48,7 @@ void L3_task_appstatus_handler(S_TASK_APPSTATUS *s) L2_task_go(D_task_DETECTCHANGE); TTSS_Task_step(D_task_DETECTCHANGE) + if(s->status != R.app_status) { s->status = R.app_status; @@ -143,4 +145,30 @@ void L3_task_appstatus_handler(S_TASK_APPSTATUS *s) L2_task_go_Tdelay(D_task_DETECTCHANGE,D_Tdelay_500ms); TTSS_Task_end(); +} + +// 180s无操作判定函数 +void Power_Off_judge() +{ + vU32 Nowtime = D_sys_now; + vU32 diff = Nowtime - R.Operation_time; + L0_uart0_0d0a(); + L0_uart0_sendstr(" R.Operation_time = "); + L0_uart0_ulhex(R.Operation_time); + L0_uart0_0d0a(); + L0_uart0_0d0a(); + L0_uart0_sendstr(" R.Nowtime = "); + L0_uart0_ulhex(Nowtime); + L0_uart0_0d0a(); + + L0_uart0_0d0a(); + L0_uart0_sendstr(" diff = "); + L0_uart0_ulhex(diff); + L0_uart0_0d0a(); + if (diff > 6000) //180000 180秒 30000 30秒 60000 60秒 + { + R.app_status = POW_OFF; + L0_uart0_0d0a(); + L0_uart0_sendstr(" _judge_Power_Off_"); + } } \ No newline at end of file diff --git a/source/app/task_appstatus.h b/source/app/task_appstatus.h index b72c1c3..c1949ce 100644 --- a/source/app/task_appstatus.h +++ b/source/app/task_appstatus.h @@ -25,7 +25,9 @@ typedef struct _s_task_appstatus }S_TASK_APPSTATUS; extern S_TASK_APPSTATUS _s_task_appstatus; +extern vU32 Nowtime ; extern void L3_task_AppStatus_init(void); extern void L3_task_appstatus_handler(S_TASK_APPSTATUS *s); +extern void Power_Off_judge(); #endif // #ifndef diff --git a/source/app/task_keystatus.c b/source/app/task_keystatus.c index 40c85e8..7bee402 100644 --- a/source/app/task_keystatus.c +++ b/source/app/task_keystatus.c @@ -11,6 +11,7 @@ ////////////////////////////////////////////////////////////////////////////// #include "../app/task_keystatus.h" +#include "../app/task_appstatus.h" #include "../app/app_config.h" #include "../app/task_w600.h" #include "../bsp/bsp_key.h" @@ -44,6 +45,8 @@ void L3_task_keystatus_handler(S_TASK_KEYSTATUS *s) TTSS_Task_step(D_task_KEY_DETECT) if(L2_ReadKey3() == Key_Down) { + R.Operation_time = D_sys_now; + if (s->Key3_Down_Begin_Time == 0) { s->Key3_Down_Begin_Time = D_sys_now; @@ -82,6 +85,8 @@ void L3_task_keystatus_handler(S_TASK_KEYSTATUS *s) } else if (L2_ReadKey1() == Key_Down) { + R.Operation_time = D_sys_now; + if (s->Key1_handled == 0 && R.app_status != POW_OFF) { s->Key1_handled = 1; @@ -91,6 +96,8 @@ void L3_task_keystatus_handler(S_TASK_KEYSTATUS *s) } else if (L2_ReadKey2() == Key_Down) { + R.Operation_time = D_sys_now; + if (s->Key2_handled == 0 && R.app_status != POW_OFF) { s->Key2_handled = 1; diff --git a/source/bsp/bsp_oid.c b/source/bsp/bsp_oid.c index 6b6fec9..26d1c04 100644 --- a/source/bsp/bsp_oid.c +++ b/source/bsp/bsp_oid.c @@ -8,6 +8,8 @@ #include "../app/app_task_speech.h" #include "../bsp/bsp_WT2605B.h" #include "../bsp/bsp_wifi.h" +#include "../app/task_appstatus.h" + /****************************************************************************************************** 变量定义 @@ -472,6 +474,8 @@ void L1_Oid_readoid(void) { if(!OID_DET) { + R.Operation_time = D_sys_now; + // L2_WT2605B_Broadcast(&audio_game_correct); ts_oid.pre_x = ts_oid.X100; ts_oid.pre_y = ts_oid.Y100;