Browse Source

feature:1.增加长时间无操作自关机功能

temp-branch
Zhangwen 3 months ago
parent
commit
ee098499a5
  1. 2
      source/app/app_config.c
  2. 2
      source/app/app_config.h
  3. 1
      source/app/main.c
  4. 28
      source/app/task_appstatus.c
  5. 2
      source/app/task_appstatus.h
  6. 7
      source/app/task_keystatus.c
  7. 4
      source/bsp/bsp_oid.c

2
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;

2
source/app/app_config.h

@ -87,6 +87,8 @@ typedef struct global_register
APP_STATUS app_status;
vU32 Operation_time;
}GlobalRegister;
extern GlobalRegister R;

1
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);

28
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_");
}
}

2
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

7
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;

4
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;

Loading…
Cancel
Save