Handle the case when the other paddle is pressed during the inter character space

This commit is contained in:
Martin Brodbeck 2024-02-15 10:03:29 +01:00
parent aee58bf274
commit 026b1d0406
2 changed files with 33 additions and 5 deletions

View file

@ -56,7 +56,7 @@ void Keyer::run()
if (left_paddle_pressed() && right_paddle_pressed())
{
m_keyNextIambicB = false;
if (m_previousState == State::Dit)
{
state = State::Dah;
@ -141,11 +141,37 @@ void Keyer::run()
m_pausing_until = make_timeout_time_us(m_elementDuration);
m_currentlyPausing = true;
}
if (absolute_time_diff_us(timestamp, m_pausing_until) <= 0)
// Handle the case when the other paddle is pressed during the inter character space
else if (absolute_time_diff_us(timestamp, m_pausing_until) > 0)
{
m_currentlyPausing = false;
state = State::Wait;
if (left_paddle_pressed() && m_previousState == State::Dah && m_nextState == State::Wait)
{
printf("--- Pause --- Next state is Dit!\n");
m_nextState = State::Dit;
m_keyNextIambicB = right_paddle_pressed() ? true : false;
}
else if (right_paddle_pressed() && m_previousState == State::Dit && m_nextState == State::Wait)
{
printf("--- Pause --- Next state is Dah!\n");
m_nextState = State::Dah;
m_keyNextIambicB = left_paddle_pressed() ? true : false;
}
else if (m_previousState == State::Wait)
{
m_nextState = State::Wait;
}
}
else
{
if (absolute_time_diff_us(timestamp, m_pausing_until) <= 0)
{
m_currentlyPausing = false;
state = m_nextState;
m_nextState = State::Wait;
}
}
break;
@ -156,6 +182,7 @@ void Keyer::run()
m_currentlyPausing = false;
m_currentlyKeying = false;
m_previousState = State::Abort;
m_nextState = State::Wait;
state = State::Wait;
break;
default:

View file

@ -29,6 +29,7 @@ public:
private:
State state{State::Wait};
State m_previousState{State::Wait};
State m_nextState{State::Wait};
uint8_t m_wpm{18};
Mode m_mode{Mode::IAMBIC_B};
uint64_t m_elementDuration{0};