diff options
| author | Jean-François Milants <jf@codingfield.com> | 2021-11-11 09:08:20 (GMT) |
|---|---|---|
| committer | Jean-François Milants <jf@codingfield.com> | 2021-11-11 09:08:20 (GMT) |
| commit | f6d0ec49e6f2669c64729b081eb3342f02151f4a (patch) | |
| tree | 7e21c83726bd3e0d18ec4ebe871274b1dbe2eb38 /src/buttonhandler/ButtonHandler.h | |
| parent | f41aaad6836ae348d1b5b084b4533b636f516b93 (diff) | |
| parent | a57fda6ba4a29866083a1254ffdf92939d00e182 (diff) | |
Merge branch 'develop'
# Conflicts:
# doc/buildAndProgram.md
Diffstat (limited to 'src/buttonhandler/ButtonHandler.h')
| -rw-r--r-- | src/buttonhandler/ButtonHandler.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/buttonhandler/ButtonHandler.h b/src/buttonhandler/ButtonHandler.h new file mode 100644 index 0000000..44b20f1 --- /dev/null +++ b/src/buttonhandler/ButtonHandler.h @@ -0,0 +1,24 @@ +#pragma once + +#include "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; + }; + } +} |
