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