From 39e3b045d3bcbd9d302d7ee8c6905881804f46e9 Mon Sep 17 00:00:00 2001 From: cdyong <273797002@qq.com> Date: Mon, 31 Oct 2016 08:01:55 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E4=BB=BB=E5=8A=A1=E5=81=9A?= =?UTF-8?q?=E5=A4=96=E9=83=A8=E4=BA=8B=E4=BB=B6=EF=BC=8C=E9=81=BF=E5=85=8D?= =?UTF-8?q?=E5=A4=96=E9=83=A8=E4=B8=9A=E5=8A=A1=E6=89=A7=E8=A1=8C=E8=BF=87?= =?UTF-8?q?=E9=95=BF=EF=BC=8C=E5=BD=B1=E5=93=8D=E8=A7=A6=E6=91=B8=E5=BC=80?= =?UTF-8?q?=E5=85=B3=E7=9A=84=E7=BB=A7=E7=94=B5=E5=99=A8=E5=8A=A8=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Button_GrayLevel.cpp | 23 ++++++++++++++++++----- App/Button_GrayLevel.h | 5 +++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/App/Button_GrayLevel.cpp b/App/Button_GrayLevel.cpp index e2cc1796..dde0c237 100644 --- a/App/Button_GrayLevel.cpp +++ b/App/Button_GrayLevel.cpp @@ -55,6 +55,11 @@ void Button_GrayLevel::Set(Pin key, Pin relay, bool relayInvert) Key.UsePress(); Key.Open(); + //面板事件 + if (!_task3) + { + _task3 = Sys.AddTask(&Button_GrayLevel::ReportPress, this, -1, -1, "面板事件"); + } if (relay != P0) Relay.Init(relay, relayInvert).Open(); } @@ -119,14 +124,14 @@ void Button_GrayLevel::OnPress(InputPort& port, bool down) if (time > 1500) { debug_printf("DelayClose "); - if (time >= 3800 && time < 6500) + if (time >= 3800 && time < 6500) { debug_printf("60s\r\n"); DelayClose2(60 * 1000); port.PressTime = 0; // 保险一下,以免在延时关闭更新状态的时候误判造成重启 return; } - if(time < 3800) + if (time < 3800) { debug_printf("15s\r\n"); DelayClose2(15 * 1000); @@ -147,10 +152,18 @@ void Button_GrayLevel::OnPress(InputPort& port, bool down) } } // if (_Handler) _Handler(this, _Param); - Press(*this); + if (_task3) + Sys.SetTask(_task3, true, 0); + else + Press(*this); } } +void Button_GrayLevel::ReportPress() +{ + Press(*this); +} + void Close2Task(void * param) { auto bt = (Button_GrayLevel *)param; @@ -163,7 +176,7 @@ void Close2Task(void * param) else { bt->delaytime = 0; - debug_printf("延时关闭已完成 删除任务 0x%08X\r\n",bt->_task2); + debug_printf("延时关闭已完成 删除任务 0x%08X\r\n", bt->_task2); Sys.RemoveTask(bt->_task2); bt->_task2 = 0; bt->SetValue(false); @@ -300,7 +313,7 @@ void Button_GrayLevel::Init(TIMER tim, byte count, Button_GrayLevel* btns, TActi btns[i].Name = names[i]; #endif //btns[i].Register(onpress); - btns[i].Press = onpress; + btns[i].Press = onpress; // 灰度 LED 绑定到 Button btns[i].Set(&LedPWM, pins[i].PwmIndex); diff --git a/App/Button_GrayLevel.h b/App/Button_GrayLevel.h index fca33b00..d2d70668 100644 --- a/App/Button_GrayLevel.h +++ b/App/Button_GrayLevel.h @@ -81,6 +81,11 @@ public: void DelayClose2(int ms); // 自定义延时关闭 int delaytime = 0; uint _task2 = 0; + + //上报状态变化 + uint _task3 = 0; + + void ReportPress(); // 过零检测 private: static int ACZeroAdjTime; // 过零检测时间补偿 默认 2300us