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.
Button.cpp@0:87b7b2ae63c3, 2021-03-03 (annotated)
- Committer:
- Ocky Kristanto
- Date:
- Wed Mar 03 09:01:07 2021 +0100
- Revision:
- 0:87b7b2ae63c3
feat: initial version
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Ocky Kristanto |
0:87b7b2ae63c3 | 1 | #include "Button.h" |
| Ocky Kristanto |
0:87b7b2ae63c3 | 2 | #include "NextionSerial.h" |
| Ocky Kristanto |
0:87b7b2ae63c3 | 3 | |
| Ocky Kristanto |
0:87b7b2ae63c3 | 4 | Button::Button(uint32_t aPage, uint32_t aId, const std::string& aObjectName, NextionSerial& aNextionSerial) : |
| Ocky Kristanto |
0:87b7b2ae63c3 | 5 | NextionUI(aPage, aId, aObjectName, aNextionSerial) |
| Ocky Kristanto |
0:87b7b2ae63c3 | 6 | { |
| Ocky Kristanto |
0:87b7b2ae63c3 | 7 | } |
| Ocky Kristanto |
0:87b7b2ae63c3 | 8 | |
| Ocky Kristanto |
0:87b7b2ae63c3 | 9 | void Button::SetReleaseCallback(std::function<void()> aCallback) |
| Ocky Kristanto |
0:87b7b2ae63c3 | 10 | { |
| Ocky Kristanto |
0:87b7b2ae63c3 | 11 | iReleaseCallback = std::move(aCallback); |
| Ocky Kristanto |
0:87b7b2ae63c3 | 12 | } |
| Ocky Kristanto |
0:87b7b2ae63c3 | 13 | |
| Ocky Kristanto |
0:87b7b2ae63c3 | 14 | void Button::SetPushCallback(std::function<void ()> aPushCallback) |
| Ocky Kristanto |
0:87b7b2ae63c3 | 15 | { |
| Ocky Kristanto |
0:87b7b2ae63c3 | 16 | iPushCallback = std::move(aPushCallback); |
| Ocky Kristanto |
0:87b7b2ae63c3 | 17 | } |
| Ocky Kristanto |
0:87b7b2ae63c3 | 18 | |
| Ocky Kristanto |
0:87b7b2ae63c3 | 19 | void Button::PressReleaseTriggered(TEventType aEventType) |
| Ocky Kristanto |
0:87b7b2ae63c3 | 20 | { |
| Ocky Kristanto |
0:87b7b2ae63c3 | 21 | switch (aEventType) { |
| Ocky Kristanto |
0:87b7b2ae63c3 | 22 | case TEventType::EPress: |
| Ocky Kristanto |
0:87b7b2ae63c3 | 23 | { |
| Ocky Kristanto |
0:87b7b2ae63c3 | 24 | if (iPushCallback != nullptr) { iPushCallback(); } |
| Ocky Kristanto |
0:87b7b2ae63c3 | 25 | break; |
| Ocky Kristanto |
0:87b7b2ae63c3 | 26 | } |
| Ocky Kristanto |
0:87b7b2ae63c3 | 27 | case TEventType::ERelease: |
| Ocky Kristanto |
0:87b7b2ae63c3 | 28 | { |
| Ocky Kristanto |
0:87b7b2ae63c3 | 29 | if (iReleaseCallback != nullptr) { iReleaseCallback(); } |
| Ocky Kristanto |
0:87b7b2ae63c3 | 30 | break; |
| Ocky Kristanto |
0:87b7b2ae63c3 | 31 | } |
| Ocky Kristanto |
0:87b7b2ae63c3 | 32 | default: |
| Ocky Kristanto |
0:87b7b2ae63c3 | 33 | break; |
| Ocky Kristanto |
0:87b7b2ae63c3 | 34 | } |
| Ocky Kristanto |
0:87b7b2ae63c3 | 35 | } |