Ocky Kristanto / NextionSerial
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Button.cpp Source File

Button.cpp

00001 #include "Button.h"
00002 #include "NextionSerial.h"
00003 
00004 Button::Button(uint32_t aPage, uint32_t aId, const std::string& aObjectName, NextionSerial& aNextionSerial) : 
00005   NextionUI(aPage, aId, aObjectName, aNextionSerial)
00006 {
00007 }
00008 
00009 void Button::SetReleaseCallback(std::function<void()> aCallback)
00010 {
00011     iReleaseCallback = std::move(aCallback);
00012 }
00013 
00014 void Button::SetPushCallback(std::function<void ()> aPushCallback)
00015 {
00016     iPushCallback = std::move(aPushCallback);
00017 }
00018 
00019 void Button::PressReleaseTriggered(TEventType aEventType)
00020 {
00021     switch (aEventType) {
00022         case TEventType::EPress:
00023         {
00024             if (iPushCallback != nullptr) { iPushCallback(); }
00025             break;
00026         }    
00027         case TEventType::ERelease:
00028         {
00029             if (iReleaseCallback != nullptr) { iReleaseCallback(); }
00030             break;
00031         }
00032         default:
00033             break;
00034     }
00035 }