set mode/speed added

This commit is contained in:
Martin Brodbeck 2024-02-14 11:05:33 +01:00
parent 60e9da0877
commit be9ac6b074
2 changed files with 10 additions and 1 deletions

View file

@ -40,6 +40,12 @@ Keyer::Keyer(uint8_t wpm, Mode mode) : m_wpm(wpm), m_mode(mode)
m_elementDuration = calcElementDurationUs(m_wpm); m_elementDuration = calcElementDurationUs(m_wpm);
} }
void Keyer::setSpeed(uint8_t wpm)
{
m_wpm = wpm;
m_elementDuration = calcElementDurationUs(wpm);
}
void Keyer::run() void Keyer::run()
{ {
auto timestamp = get_absolute_time(); auto timestamp = get_absolute_time();

View file

@ -16,12 +16,15 @@ public:
Dah, Dah,
InterCharSpace, InterCharSpace,
}; };
Keyer() = delete;
Keyer(uint8_t wpm, Mode mode); Keyer(uint8_t wpm, Mode mode);
void setMode(Mode mode) { m_mode = mode; }
void setSpeed(uint8_t wpm);
void run(); void run();
private: private:
Keyer(){};
State state{State::Wait}; State state{State::Wait};
State m_previousState{State::Wait}; State m_previousState{State::Wait};
uint8_t m_wpm{18}; uint8_t m_wpm{18};