raspikeyer/src/keyer.h

28 lines
426 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,
LeftPaddlePressed,
2024-02-11 15:45:12 +01:00
InterCharSpace,
2024-02-10 23:51:55 +01:00
2024-02-09 12:20:30 +01:00
};
void run();
private:
2024-02-10 23:51:55 +01:00
State state{State::Wait};
2024-02-11 15:45:12 +01:00
uint8_t numElements{0};
2024-02-09 12:20:30 +01:00
};
2024-02-11 15:45:12 +01:00
inline uint64_t element_duration_us(uint8_t wpm)
{
uint64_t duration = static_cast<uint64_t>(1.2 / static_cast<uint64_t>(wpm) * 1000 * 1000);
return duration;
}
2024-02-09 12:20:30 +01:00
#endif