Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: Button.cpp
- Revision:
- 0:87b7b2ae63c3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Button.cpp	Wed Mar 03 09:01:07 2021 +0100
@@ -0,0 +1,35 @@
+#include "Button.h"
+#include "NextionSerial.h"
+
+Button::Button(uint32_t aPage, uint32_t aId, const std::string& aObjectName, NextionSerial& aNextionSerial) : 
+  NextionUI(aPage, aId, aObjectName, aNextionSerial)
+{
+}
+
+void Button::SetReleaseCallback(std::function<void()> aCallback)
+{
+    iReleaseCallback = std::move(aCallback);
+}
+
+void Button::SetPushCallback(std::function<void ()> aPushCallback)
+{
+    iPushCallback = std::move(aPushCallback);
+}
+
+void Button::PressReleaseTriggered(TEventType aEventType)
+{
+    switch (aEventType) {
+        case TEventType::EPress:
+        {
+            if (iPushCallback != nullptr) { iPushCallback(); }
+            break;
+        }    
+        case TEventType::ERelease:
+        {
+            if (iReleaseCallback != nullptr) { iReleaseCallback(); }
+            break;
+        }
+        default:
+            break;
+    }
+}
\ No newline at end of file