audio out added
This commit is contained in:
parent
ac52f4cc23
commit
b2dd1e28a1
4 changed files with 20 additions and 10 deletions
|
@ -8,7 +8,9 @@
|
||||||
extern const uint LED_PIN;
|
extern const uint LED_PIN;
|
||||||
extern const uint LEFT_PADDLE_PIN;
|
extern const uint LEFT_PADDLE_PIN;
|
||||||
extern const uint RIGHT_PADDLE_PIN;
|
extern const uint RIGHT_PADDLE_PIN;
|
||||||
|
extern const uint BUZZER_PIN;
|
||||||
extern const uint CW_OUT_PIN;
|
extern const uint CW_OUT_PIN;
|
||||||
|
extern const uint AUDIO_OUT_PIN;
|
||||||
|
|
||||||
const uint SIDETONE_FREQ = 622;
|
const uint SIDETONE_FREQ = 622;
|
||||||
|
|
||||||
|
@ -34,7 +36,10 @@ uint64_t calcElementDurationUs(uint8_t wpm)
|
||||||
return duration;
|
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)
|
void Keyer::setSpeed(uint8_t wpm)
|
||||||
{
|
{
|
||||||
|
@ -71,7 +76,8 @@ void Keyer::run()
|
||||||
m_keying_until = make_timeout_time_us(m_elementDuration);
|
m_keying_until = make_timeout_time_us(m_elementDuration);
|
||||||
gpio_put(LED_PIN, 1);
|
gpio_put(LED_PIN, 1);
|
||||||
gpio_put(CW_OUT_PIN, 1);
|
gpio_put(CW_OUT_PIN, 1);
|
||||||
m_Sidetone.on(SIDETONE_FREQ);
|
m_buzzer.on(SIDETONE_FREQ);
|
||||||
|
m_audioOut.on(SIDETONE_FREQ);
|
||||||
} else {
|
} else {
|
||||||
// If right paddle üressed -> note for Iambic B
|
// If right paddle üressed -> note for Iambic B
|
||||||
if (right_paddle_pressed() && !m_keyNextIambicB) {
|
if (right_paddle_pressed() && !m_keyNextIambicB) {
|
||||||
|
@ -83,7 +89,8 @@ void Keyer::run()
|
||||||
m_currentlyKeying = false;
|
m_currentlyKeying = false;
|
||||||
gpio_put(LED_PIN, 0);
|
gpio_put(LED_PIN, 0);
|
||||||
gpio_put(CW_OUT_PIN, 0);
|
gpio_put(CW_OUT_PIN, 0);
|
||||||
m_Sidetone.off();
|
m_buzzer.off();
|
||||||
|
m_audioOut.off();
|
||||||
m_previousState = State::Dit;
|
m_previousState = State::Dit;
|
||||||
m_state = State::DitPause;
|
m_state = State::DitPause;
|
||||||
}
|
}
|
||||||
|
@ -95,7 +102,8 @@ void Keyer::run()
|
||||||
m_keying_until = make_timeout_time_us(m_elementDuration * 3);
|
m_keying_until = make_timeout_time_us(m_elementDuration * 3);
|
||||||
gpio_put(LED_PIN, 1);
|
gpio_put(LED_PIN, 1);
|
||||||
gpio_put(CW_OUT_PIN, 1);
|
gpio_put(CW_OUT_PIN, 1);
|
||||||
m_Sidetone.on(SIDETONE_FREQ);
|
m_buzzer.on(SIDETONE_FREQ);
|
||||||
|
m_audioOut.on(SIDETONE_FREQ);
|
||||||
} else {
|
} else {
|
||||||
// If left paddle pressed -> Note for Iambic B
|
// If left paddle pressed -> Note for Iambic B
|
||||||
if (left_paddle_pressed() && !m_keyNextIambicB) {
|
if (left_paddle_pressed() && !m_keyNextIambicB) {
|
||||||
|
@ -107,7 +115,8 @@ void Keyer::run()
|
||||||
m_currentlyKeying = false;
|
m_currentlyKeying = false;
|
||||||
gpio_put(LED_PIN, 0);
|
gpio_put(LED_PIN, 0);
|
||||||
gpio_put(CW_OUT_PIN, 0);
|
gpio_put(CW_OUT_PIN, 0);
|
||||||
m_Sidetone.off();
|
m_buzzer.off();
|
||||||
|
m_audioOut.off();
|
||||||
m_previousState = State::Dah;
|
m_previousState = State::Dah;
|
||||||
m_state = State::DahPause;
|
m_state = State::DahPause;
|
||||||
}
|
}
|
||||||
|
@ -156,7 +165,8 @@ void Keyer::run()
|
||||||
case State::Abort:
|
case State::Abort:
|
||||||
gpio_put(LED_PIN, 0);
|
gpio_put(LED_PIN, 0);
|
||||||
gpio_put(CW_OUT_PIN, 0);
|
gpio_put(CW_OUT_PIN, 0);
|
||||||
m_Sidetone.off();
|
m_buzzer.off();
|
||||||
|
m_audioOut.off();
|
||||||
m_keyNextIambicB = false;
|
m_keyNextIambicB = false;
|
||||||
m_currentlyPausing = false;
|
m_currentlyPausing = false;
|
||||||
m_currentlyKeying = false;
|
m_currentlyKeying = false;
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "sidetone.h"
|
#include "sidetone.h"
|
||||||
|
|
||||||
extern const uint BUZZER_PIN;
|
|
||||||
|
|
||||||
class Keyer final
|
class Keyer final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -33,7 +31,8 @@ class Keyer final
|
||||||
absolute_time_t m_keying_until{0};
|
absolute_time_t m_keying_until{0};
|
||||||
absolute_time_t m_pausing_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_state{State::Wait};
|
||||||
State m_previousState{State::Wait};
|
State m_previousState{State::Wait};
|
||||||
|
|
|
@ -17,6 +17,7 @@ extern const uint LEFT_PADDLE_PIN = 14;
|
||||||
extern const uint RIGHT_PADDLE_PIN = 15;
|
extern const uint RIGHT_PADDLE_PIN = 15;
|
||||||
extern const uint BUZZER_PIN = 18;
|
extern const uint BUZZER_PIN = 18;
|
||||||
extern const uint CW_OUT_PIN = 17;
|
extern const uint CW_OUT_PIN = 17;
|
||||||
|
extern const uint AUDIO_OUT_PIN = 16;
|
||||||
|
|
||||||
// Stuff for communicating between cores
|
// Stuff for communicating between cores
|
||||||
enum class KeyerQueueCommand {
|
enum class KeyerQueueCommand {
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
class Sidetone
|
class Sidetone
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Sidetone() = delete;
|
||||||
Sidetone(uint gpio);
|
Sidetone(uint gpio);
|
||||||
void on(uint freq);
|
void on(uint freq);
|
||||||
void off();
|
void off();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Sidetone(){};
|
|
||||||
uint m_gpio{0};
|
uint m_gpio{0};
|
||||||
};
|
};
|
Loading…
Reference in a new issue