#ifndef KEYER_H #define KEYER_H #include "sidetone.h" extern const uint BUZZER_PIN; class Keyer final { public: enum class State { Wait, Dit, Dah, InterCharSpace, // TODO: perhaps new state: Keying }; Keyer(uint8_t wpm); void run(); private: enum class Symbol { Dit, Dah }; Keyer(){}; State state{State::Wait}; State m_previousState{State::Wait}; uint8_t m_wpm{18}; uint64_t m_elementDuration{0}; bool m_currentlyKeying{false}; absolute_time_t m_keying_until{0}; absolute_time_t m_pausing_until{0}; Symbol m_lastSymbolWas{Symbol::Dit}; Sidetone m_Sidetone{BUZZER_PIN}; }; #endif