From c57f9251c26dbd3fb29adbf62502a20953790389 Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Fri, 23 Feb 2024 09:18:02 +0100 Subject: [PATCH] prepare for sending messages --- src/keyer.cpp | 17 +++++++++++------ src/keyer.h | 7 ++++++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/keyer.cpp b/src/keyer.cpp index e30f0a5..ecf9d1e 100644 --- a/src/keyer.cpp +++ b/src/keyer.cpp @@ -10,7 +10,7 @@ extern const uint LEFT_PADDLE_PIN; extern const uint RIGHT_PADDLE_PIN; extern const uint BUZZER_PIN; extern const uint CW_OUT_PIN; -//extern const uint AUDIO_OUT_PIN; +// extern const uint AUDIO_OUT_PIN; const uint SIDETONE_FREQ = 622; @@ -51,6 +51,11 @@ void Keyer::run() { auto timestamp = get_absolute_time(); + // If there is something to send … + if (!m_messageQueue.empty()) { + // TODO + } + // If we are in Straight key mode … if (m_mode == Mode::Straight) { if (left_paddle_pressed()) { @@ -93,7 +98,7 @@ void Keyer::run() gpio_put(LED_PIN, 1); gpio_put(CW_OUT_PIN, 1); m_buzzer.on(SIDETONE_FREQ); - //m_audioOut.on(SIDETONE_FREQ); + // m_audioOut.on(SIDETONE_FREQ); } else { // If right paddle üressed -> note for Iambic B if (right_paddle_pressed() && !m_keyNextIambicB) { @@ -105,7 +110,7 @@ void Keyer::run() gpio_put(LED_PIN, 0); gpio_put(CW_OUT_PIN, 0); m_buzzer.off(); - //m_audioOut.off(); + // m_audioOut.off(); m_previousState = State::Dit; m_state = State::DitPause; } @@ -118,7 +123,7 @@ void Keyer::run() gpio_put(LED_PIN, 1); gpio_put(CW_OUT_PIN, 1); m_buzzer.on(SIDETONE_FREQ); - //m_audioOut.on(SIDETONE_FREQ); + // m_audioOut.on(SIDETONE_FREQ); } else { // If left paddle pressed -> Note for Iambic B if (left_paddle_pressed() && !m_keyNextIambicB) { @@ -130,7 +135,7 @@ void Keyer::run() gpio_put(LED_PIN, 0); gpio_put(CW_OUT_PIN, 0); m_buzzer.off(); - //m_audioOut.off(); + // m_audioOut.off(); m_previousState = State::Dah; m_state = State::DahPause; } @@ -180,7 +185,7 @@ void Keyer::run() gpio_put(LED_PIN, 0); gpio_put(CW_OUT_PIN, 0); m_buzzer.off(); - //m_audioOut.off(); + // m_audioOut.off(); m_keyNextIambicB = false; m_currentlyPausing = false; m_currentlyKeying = false; diff --git a/src/keyer.h b/src/keyer.h index 1db70ac..6bb6726 100644 --- a/src/keyer.h +++ b/src/keyer.h @@ -1,5 +1,8 @@ #pragma once +#include +#include + #include "settings.h" #include "sidetone.h" @@ -32,7 +35,7 @@ class Keyer final absolute_time_t m_pausing_until {0}; Sidetone m_buzzer; - //Sidetone m_audioOut; + // Sidetone m_audioOut; State m_state {State::Wait}; State m_previousState {State::Wait}; @@ -40,4 +43,6 @@ class Keyer final bool m_currentlyKeying {false}; bool m_currentlyPausing {false}; bool m_keyNextIambicB {false}; + + std::queue m_messageQueue; }; \ No newline at end of file