43 lines
No EOL
805 B
C++
43 lines
No EOL
805 B
C++
#pragma once
|
|
|
|
#include "settings.h"
|
|
#include "sidetone.h"
|
|
|
|
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::IambicB};
|
|
|
|
absolute_time_t m_keying_until {0};
|
|
absolute_time_t m_pausing_until {0};
|
|
|
|
Sidetone m_buzzer;
|
|
//Sidetone m_audioOut;
|
|
|
|
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};
|
|
}; |