raspikeyer/src/keyer.h

36 lines
621 B
C
Raw Normal View History

2024-02-09 12:20:30 +01:00
#ifndef KEYER_H
#define KEYER_H
class Keyer final
{
public:
enum class State
{
2024-02-10 23:51:55 +01:00
Wait,
2024-02-11 16:26:55 +01:00
Dit,
Dah,
2024-02-11 15:45:12 +01:00
InterCharSpace,
2024-02-12 14:14:42 +01:00
// TODO: perhaps new state: Keying
2024-02-09 12:20:30 +01:00
};
2024-02-12 13:48:58 +01:00
Keyer(uint8_t wpm);
2024-02-09 12:20:30 +01:00
void run();
private:
2024-02-12 14:10:04 +01:00
enum class Symbol
{
Dit,
Dah
};
Keyer(){};
2024-02-10 23:51:55 +01:00
State state{State::Wait};
2024-02-12 13:48:58 +01:00
State m_previousState{State::Wait};
uint8_t m_wpm{18};
uint64_t m_elementDuration{0};
2024-02-12 14:10:04 +01:00
bool m_currentlyKeying{false};
2024-02-12 13:48:58 +01:00
absolute_time_t m_keying_until{0};
absolute_time_t m_pausing_until{0};
2024-02-12 14:10:04 +01:00
Symbol m_lastSymbolWas{Symbol::Dit};
2024-02-09 12:20:30 +01:00
};
#endif