diff --git a/README.md b/README.md index 71f80cb..61a3aff 100644 --- a/README.md +++ b/README.md @@ -8,11 +8,11 @@ Features (planned/done): - [x] Iambic Paddle - [x] Keying modes: Iambic A, Iambic B -- [ ] Straight key +- [x] Straight key - [x] Sidetone (buzzer) - [x] CW out (straight key input on TRX) +- [ ] Setting speed with rotary knob - [ ] WinKeyer emulation -- [ ] Setting speed with rotary knob (left stop = speed setting from memory) - [ ] LCD Display showing at least: - Current speed - Iambic mode diff --git a/src/keyer.cpp b/src/keyer.cpp index 68395ed..ede379c 100644 --- a/src/keyer.cpp +++ b/src/keyer.cpp @@ -51,6 +51,22 @@ void Keyer::run() { auto timestamp = get_absolute_time(); + // If we are in Straight key mode … + if (m_mode == Mode::Straight) { + if (left_paddle_pressed()) { + gpio_put(LED_PIN, 1); + gpio_put(CW_OUT_PIN, 1); + m_buzzer.on(SIDETONE_FREQ); + } else { + gpio_put(LED_PIN, 0); + gpio_put(CW_OUT_PIN, 0); + m_buzzer.off(); + } + + return; + } + + // If we are in IambicA or IambicB-Mode … switch (m_state) { case State::Wait: if (left_paddle_pressed()) { @@ -60,7 +76,7 @@ void Keyer::run() m_keyNextIambicB = false; m_state = State::Dah; } else { - if (m_mode == Mode::IAMBIC_B && m_keyNextIambicB) { + if (m_mode == Mode::IambicB && m_keyNextIambicB) { if (m_previousState == State::Dit) m_state = State::Dah; else diff --git a/src/keyer.h b/src/keyer.h index 044f916..893a038 100644 --- a/src/keyer.h +++ b/src/keyer.h @@ -26,7 +26,7 @@ class Keyer final }; uint8_t m_wpm {18}; - Mode m_mode {Mode::IAMBIC_B}; + Mode m_mode {Mode::IambicB}; absolute_time_t m_keying_until {0}; absolute_time_t m_pausing_until {0}; diff --git a/src/settings.h b/src/settings.h index b240c2b..cd0f786 100644 --- a/src/settings.h +++ b/src/settings.h @@ -4,14 +4,11 @@ const uint16_t MAGIC_NUMBER = 2; -enum class Mode : uint8_t { - IAMBIC_A = 0, - IAMBIC_B, -}; +enum class Mode : uint8_t { IambicA = 0, IambicB, Straight }; struct Settings { uint16_t magic_number {MAGIC_NUMBER}; // Bytes: 2 - Mode mode {Mode::IAMBIC_B}; // Bytes: 1 + Mode mode {Mode::IambicB}; // Bytes: 1 uint8_t wpm {18}; // Bytes: 1 uint8_t dummy[FLASH_PAGE_SIZE - 4] {0}; // Sum : 4 };