#pragma once #include "settings.h" #include "sidetone.h" extern const uint BUZZER_PIN; class Keyer final { public: Keyer() = delete; Keyer(uint8_t wpm, Mode mode); void setMode(Mode mode) { m_mode = mode; } void setSpeed(uint8_t wpm); void run(); void stop(); private: enum class State { Wait, Dit, Dah, DitPause, DahPause, Abort, }; uint8_t m_wpm{18}; Mode m_mode{Mode::IAMBIC_B}; absolute_time_t m_keying_until{0}; absolute_time_t m_pausing_until{0}; Sidetone m_Sidetone{BUZZER_PIN}; State m_state{State::Wait}; State m_previousState{State::Wait}; uint64_t m_elementDuration{0}; bool m_currentlyKeying{false}; bool m_currentlyPausing{false}; bool m_keyNextIambicB{false}; };