ref: fc5424cb72e477c5f1bbfaeddb5c50b851a965ae
src/buttonhandler/ButtonHandler.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
#pragma once #include "buttonhandler/ButtonActions.h" #include "systemtask/SystemTask.h" #include <FreeRTOS.h> #include <timers.h> namespace Pinetime { namespace Controllers { class ButtonHandler { public: enum class Events : uint8_t { Press, Release, Timer }; void Init(Pinetime::System::SystemTask* systemTask); ButtonActions HandleEvent(Events event); private: enum class States : uint8_t { Idle, Pressed, Holding, LongHeld }; TickType_t releaseTime = 0; TimerHandle_t buttonTimer; bool buttonPressed = false; States state = States::Idle; }; } } |