diff --git a/src/keyer.cpp b/src/keyer.cpp index 327f9b2..3c90c8f 100644 --- a/src/keyer.cpp +++ b/src/keyer.cpp @@ -58,10 +58,10 @@ void Keyer::run() { auto timestamp = get_absolute_time(); - // If there is something to send … + // If there is some message to send … if (!m_messageQueue.empty() || m_messageKeyingState != MessageState::Wait) { // Stop all paddle keying, if necessary - if (m_PaddleKeyingState != State::Wait) { + if (m_paddleKeyingState != State::Wait) { gpio_put(LED_PIN, 0); gpio_put(CW_OUT_PIN, 0); m_buzzer.off(); @@ -69,12 +69,13 @@ void Keyer::run() m_currentlyPausing = false; m_currentlyKeying = false; m_previousState = State::Abort; - m_PaddleKeyingState = State::Wait; + m_paddleKeyingState = State::Wait; } switch (m_messageKeyingState) { case MessageState::Wait: m_messageChar = m_messageQueue.front(); + m_messageQueue.pop(); switch (m_messageChar) { case '.': @@ -181,6 +182,7 @@ void Keyer::run() m_currentlyKeying = false; std::queue emptyQueue; std::swap(m_messageQueue, emptyQueue); + m_messageKeyingState = MessageState::Wait; break; } default: @@ -206,20 +208,20 @@ void Keyer::run() } // If we are in IambicA or IambicB-Mode … - switch (m_PaddleKeyingState) { + switch (m_paddleKeyingState) { case State::Wait: if (left_paddle_pressed()) { m_keyNextIambicB = false; - m_PaddleKeyingState = State::Dit; + m_paddleKeyingState = State::Dit; } else if (right_paddle_pressed()) { m_keyNextIambicB = false; - m_PaddleKeyingState = State::Dah; + m_paddleKeyingState = State::Dah; } else { if (m_mode == Mode::IambicB && m_keyNextIambicB) { if (m_previousState == State::Dit) - m_PaddleKeyingState = State::Dah; + m_paddleKeyingState = State::Dah; else - m_PaddleKeyingState = State::Dit; + m_paddleKeyingState = State::Dit; m_keyNextIambicB = false; } @@ -246,7 +248,7 @@ void Keyer::run() m_buzzer.off(); // m_audioOut.off(); m_previousState = State::Dit; - m_PaddleKeyingState = State::DitPause; + m_paddleKeyingState = State::DitPause; } } break; @@ -271,7 +273,7 @@ void Keyer::run() m_buzzer.off(); // m_audioOut.off(); m_previousState = State::Dah; - m_PaddleKeyingState = State::DahPause; + m_paddleKeyingState = State::DahPause; } } break; @@ -284,13 +286,13 @@ void Keyer::run() m_currentlyPausing = false; if (right_paddle_pressed()) { - m_PaddleKeyingState = State::Dah; + m_paddleKeyingState = State::Dah; m_keyNextIambicB = false; } else if (left_paddle_pressed()) { - m_PaddleKeyingState = State::Dit; + m_paddleKeyingState = State::Dit; m_keyNextIambicB = false; } else { - m_PaddleKeyingState = State::Wait; + m_paddleKeyingState = State::Wait; } } } @@ -304,13 +306,13 @@ void Keyer::run() m_currentlyPausing = false; if (left_paddle_pressed()) { - m_PaddleKeyingState = State::Dit; + m_paddleKeyingState = State::Dit; m_keyNextIambicB = false; } else if (right_paddle_pressed()) { - m_PaddleKeyingState = State::Dah; + m_paddleKeyingState = State::Dah; m_keyNextIambicB = false; } else { - m_PaddleKeyingState = State::Wait; + m_paddleKeyingState = State::Wait; } } } @@ -324,11 +326,11 @@ void Keyer::run() m_currentlyPausing = false; m_currentlyKeying = false; m_previousState = State::Abort; - m_PaddleKeyingState = State::Wait; + m_paddleKeyingState = State::Wait; break; default: break; } } -void Keyer::stop() { m_PaddleKeyingState = State::Abort; } \ No newline at end of file +void Keyer::stop() { m_paddleKeyingState = State::Abort; } \ No newline at end of file diff --git a/src/keyer.h b/src/keyer.h index 90cf00d..333a94a 100644 --- a/src/keyer.h +++ b/src/keyer.h @@ -48,7 +48,7 @@ class Keyer final Sidetone m_buzzer; // Sidetone m_audioOut; - State m_PaddleKeyingState {State::Wait}; + State m_paddleKeyingState {State::Wait}; State m_previousState {State::Wait}; std::queue m_messageQueue;