From 29202abaa7ffd97b529c58e681a924b1057bf980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=9F=B3=E5=A4=B4X2?= Date: Wed, 1 Mar 2017 00:30:54 +0800 Subject: [PATCH] =?UTF-8?q?=E8=99=9A=E5=87=BD=E6=95=B0=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E4=BD=9C=E4=B8=BA=E4=BA=8B=E4=BB=B6=E5=A4=84=E7=90=86=E5=87=BD?= =?UTF-8?q?=E6=95=B0=EF=BC=8C=E5=8F=96=E5=9C=B0=E5=9D=80=E6=97=B6=E5=8F=AA?= =?UTF-8?q?=E4=BC=9A=E5=BE=97=E5=88=B0=E5=81=8F=E7=A7=BB=E9=87=8F=E8=80=8C?= =?UTF-8?q?=E4=B8=8D=E6=98=AF=E5=87=BD=E6=95=B0=E5=9C=B0=E5=9D=80=EF=BC=8C?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E8=A7=A6=E5=8F=91=E4=BA=8B=E4=BB=B6=E6=97=B6?= =?UTF-8?q?=E8=B7=91=E9=A3=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Button.cpp | 7 ++++++- App/Button.h | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/App/Button.cpp b/App/Button.cpp index 881d504c..013f893e 100644 --- a/App/Button.cpp +++ b/App/Button.cpp @@ -22,7 +22,7 @@ void Button::Set(Pin key, Pin led, Pin relay) void Button::Set(Pin key, Pin led, bool ledInvert, Pin relay, bool relayInvert) { Key.Set(key); - Key.Press.Bind(&Button::OnPress, this); + Key.Press.Bind(&Button::OnKeyPress, this); Key.UsePress(); Key.Open(); @@ -49,6 +49,11 @@ void Button::OnPress(InputPort& port, bool down) } } +void Button::OnKeyPress(Button& btn, InputPort& port, bool down) +{ + btn.OnPress(port, down); +} + bool Button::GetValue() { return _Value; } int Button::OnWrite(byte data) diff --git a/App/Button.h b/App/Button.h index c4f24da2..4a5e143a 100644 --- a/App/Button.h +++ b/App/Button.h @@ -36,10 +36,11 @@ public: String ToString() const; -private: +protected: bool _Value; // 状态 virtual void OnPress(InputPort& port, bool down); + static void OnKeyPress(Button& btn, InputPort& port, bool down); }; #endif