audio out added

This commit is contained in:
Martin Brodbeck 2024-02-18 17:14:47 +01:00
parent ac52f4cc23
commit b2dd1e28a1
4 changed files with 20 additions and 10 deletions

View file

@ -8,7 +8,9 @@
extern const uint LED_PIN;
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;
const uint SIDETONE_FREQ = 622;
@ -34,7 +36,10 @@ uint64_t calcElementDurationUs(uint8_t wpm)
return duration;
}
Keyer::Keyer(uint8_t wpm, Mode mode) : m_wpm(wpm), m_mode(mode) { m_elementDuration = calcElementDurationUs(m_wpm); }
Keyer::Keyer(uint8_t wpm, Mode mode) : m_wpm(wpm), m_mode(mode), m_buzzer(BUZZER_PIN), m_audioOut(AUDIO_OUT_PIN)
{
m_elementDuration = calcElementDurationUs(m_wpm);
}
void Keyer::setSpeed(uint8_t wpm)
{
@ -71,7 +76,8 @@ void Keyer::run()
m_keying_until = make_timeout_time_us(m_elementDuration);
gpio_put(LED_PIN, 1);
gpio_put(CW_OUT_PIN, 1);
m_Sidetone.on(SIDETONE_FREQ);
m_buzzer.on(SIDETONE_FREQ);
m_audioOut.on(SIDETONE_FREQ);
} else {
// If right paddle üressed -> note for Iambic B
if (right_paddle_pressed() && !m_keyNextIambicB) {
@ -83,7 +89,8 @@ void Keyer::run()
m_currentlyKeying = false;
gpio_put(LED_PIN, 0);
gpio_put(CW_OUT_PIN, 0);
m_Sidetone.off();
m_buzzer.off();
m_audioOut.off();
m_previousState = State::Dit;
m_state = State::DitPause;
}
@ -95,7 +102,8 @@ void Keyer::run()
m_keying_until = make_timeout_time_us(m_elementDuration * 3);
gpio_put(LED_PIN, 1);
gpio_put(CW_OUT_PIN, 1);
m_Sidetone.on(SIDETONE_FREQ);
m_buzzer.on(SIDETONE_FREQ);
m_audioOut.on(SIDETONE_FREQ);
} else {
// If left paddle pressed -> Note for Iambic B
if (left_paddle_pressed() && !m_keyNextIambicB) {
@ -107,7 +115,8 @@ void Keyer::run()
m_currentlyKeying = false;
gpio_put(LED_PIN, 0);
gpio_put(CW_OUT_PIN, 0);
m_Sidetone.off();
m_buzzer.off();
m_audioOut.off();
m_previousState = State::Dah;
m_state = State::DahPause;
}
@ -156,7 +165,8 @@ void Keyer::run()
case State::Abort:
gpio_put(LED_PIN, 0);
gpio_put(CW_OUT_PIN, 0);
m_Sidetone.off();
m_buzzer.off();
m_audioOut.off();
m_keyNextIambicB = false;
m_currentlyPausing = false;
m_currentlyKeying = false;

View file

@ -3,8 +3,6 @@
#include "settings.h"
#include "sidetone.h"
extern const uint BUZZER_PIN;
class Keyer final
{
public:
@ -33,7 +31,8 @@ class Keyer final
absolute_time_t m_keying_until{0};
absolute_time_t m_pausing_until{0};
Sidetone m_Sidetone{BUZZER_PIN};
Sidetone m_buzzer;
Sidetone m_audioOut;
State m_state{State::Wait};
State m_previousState{State::Wait};

View file

@ -17,6 +17,7 @@ extern const uint LEFT_PADDLE_PIN = 14;
extern const uint RIGHT_PADDLE_PIN = 15;
extern const uint BUZZER_PIN = 18;
extern const uint CW_OUT_PIN = 17;
extern const uint AUDIO_OUT_PIN = 16;
// Stuff for communicating between cores
enum class KeyerQueueCommand {

View file

@ -3,11 +3,11 @@
class Sidetone
{
public:
Sidetone() = delete;
Sidetone(uint gpio);
void on(uint freq);
void off();
private:
Sidetone(){};
uint m_gpio{0};
};