43 lines
No EOL
823 B
C++
43 lines
No EOL
823 B
C++
#ifndef KEYER_H
|
|
#define KEYER_H
|
|
|
|
#include "sidetone.h"
|
|
#include "settings.h"
|
|
|
|
extern const uint BUZZER_PIN;
|
|
|
|
class Keyer final
|
|
{
|
|
public:
|
|
enum class State
|
|
{
|
|
Wait,
|
|
Dit,
|
|
Dah,
|
|
InterCharSpace,
|
|
Abort,
|
|
};
|
|
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:
|
|
State state{State::Wait};
|
|
State m_previousState{State::Wait};
|
|
uint8_t m_wpm{18};
|
|
Mode m_mode{Mode::IAMBIC_B};
|
|
uint64_t m_elementDuration{0};
|
|
bool m_currentlyKeying{false};
|
|
bool m_currentlyPausing{false};
|
|
absolute_time_t m_keying_until{0};
|
|
absolute_time_t m_pausing_until{0};
|
|
Sidetone m_Sidetone{BUZZER_PIN};
|
|
bool m_keyNextIambicB{false};
|
|
};
|
|
|
|
#endif |