Compare commits
No commits in common. "701bf8f6b4db8ea18833ba8f54c012634d78dd4d" and "e420930ce6c4fbfda69352768327ff404cca3341" have entirely different histories.
701bf8f6b4
...
e420930ce6
4 changed files with 22 additions and 67 deletions
|
@ -50,10 +50,9 @@ void Keyer::setSpeed(uint8_t wpm)
|
||||||
|
|
||||||
void Keyer::sendMessage(std::string msg)
|
void Keyer::sendMessage(std::string msg)
|
||||||
{
|
{
|
||||||
printf("Queue size: %d\n", m_messageQueue.size());
|
|
||||||
std::string morse = messageToMorse(msg);
|
std::string morse = messageToMorse(msg);
|
||||||
|
|
||||||
for (char c : morse) {
|
for (unsigned char c : morse) {
|
||||||
m_messageQueue.push(c);
|
m_messageQueue.push(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,18 +62,17 @@ void Keyer::run()
|
||||||
auto timestamp = get_absolute_time();
|
auto timestamp = get_absolute_time();
|
||||||
|
|
||||||
// If there is some message to send …
|
// If there is some message to send …
|
||||||
//if (!m_messageQueue.empty() || m_messageKeyingState != MessageState::Wait) {
|
if (!m_messageQueue.empty() || m_messageKeyingState != MessageState::Wait) {
|
||||||
if (!m_messageQueue.empty()) {
|
|
||||||
// Stop all paddle keying, if necessary
|
// Stop all paddle keying, if necessary
|
||||||
if (m_paddleKeyingState != State::Wait) {
|
if (m_paddleKeyingState != State::Wait) {
|
||||||
//gpio_put(LED_PIN, 0);
|
gpio_put(LED_PIN, 0);
|
||||||
//gpio_put(CW_OUT_PIN, 0);
|
gpio_put(CW_OUT_PIN, 0);
|
||||||
//m_buzzer.off();
|
m_buzzer.off();
|
||||||
//m_keyNextIambicB = false;
|
m_keyNextIambicB = false;
|
||||||
//m_currentlyPausing = false;
|
m_currentlyPausing = false;
|
||||||
//m_currentlyKeying = false;
|
m_currentlyKeying = false;
|
||||||
//m_previousState = State::Abort;
|
m_previousState = State::Abort;
|
||||||
//m_paddleKeyingState = State::Wait;
|
m_paddleKeyingState = State::Wait;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (m_messageKeyingState) {
|
switch (m_messageKeyingState) {
|
||||||
|
|
|
@ -78,32 +78,8 @@ std::string messageToMorse(std::string &msg)
|
||||||
|
|
||||||
// Append word space if last char was not a blank
|
// Append word space if last char was not a blank
|
||||||
if (msg.back() != ' ') {
|
if (msg.back() != ' ') {
|
||||||
//morseString.push_back('w');
|
|
||||||
}
|
|
||||||
|
|
||||||
return morseString;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string charToMorse(char ch) {
|
|
||||||
std::string morseString {};
|
|
||||||
|
|
||||||
if (ch == ' ') {
|
|
||||||
morseString.push_back('w');
|
morseString.push_back('w');
|
||||||
return morseString;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int j = 0; j < morseCode[ch].length(); j++) {
|
|
||||||
char m = morseCode[ch][j];
|
|
||||||
|
|
||||||
morseString += m;
|
|
||||||
|
|
||||||
if (j < morseCode[ch].length() - 1) {
|
|
||||||
morseString.push_back('i');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//morseString.push_back('c');
|
|
||||||
|
|
||||||
return morseString;
|
return morseString;
|
||||||
|
|
||||||
}
|
}
|
|
@ -3,4 +3,3 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
std::string messageToMorse(std::string &msg);
|
std::string messageToMorse(std::string &msg);
|
||||||
std::string charToMorse(char ch);
|
|
|
@ -93,7 +93,6 @@ void core1_main()
|
||||||
data.cmd = KeyerQueueCommand::Run;
|
data.cmd = KeyerQueueCommand::Run;
|
||||||
break;
|
break;
|
||||||
case KeyerQueueCommand::SendMessage:
|
case KeyerQueueCommand::SendMessage:
|
||||||
printf("Sending: %s\n", data.message.c_str());
|
|
||||||
keyer.sendMessage(data.message);
|
keyer.sendMessage(data.message);
|
||||||
data.cmd = KeyerQueueCommand::Run;
|
data.cmd = KeyerQueueCommand::Run;
|
||||||
break;
|
break;
|
||||||
|
@ -127,42 +126,25 @@ void cdc_task()
|
||||||
if (tud_cdc_n_available(USB_IF)) {
|
if (tud_cdc_n_available(USB_IF)) {
|
||||||
uint8_t buf[64];
|
uint8_t buf[64];
|
||||||
|
|
||||||
//printf("AHA!!! %d\n", (int)tud_cdc_n_available(USB_IF));
|
// printf("AHA!!! %d\n", (int)tud_cdc_n_available(USB_IF));
|
||||||
uint32_t count = tud_cdc_n_read(USB_IF, buf, sizeof(buf));
|
uint32_t count = tud_cdc_n_read(USB_IF, buf, sizeof(buf));
|
||||||
|
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
switch (buf[0]) {
|
switch (buf[0]) {
|
||||||
case 'a' ... 'z':
|
case 'a' ... 'z':
|
||||||
[[fallthrough]];
|
|
||||||
case 'A' ... 'Z':
|
case 'A' ... 'Z':
|
||||||
[[fallthrough]];
|
|
||||||
case '0' ... '9':
|
case '0' ... '9':
|
||||||
[[fallthrough]];
|
printf("TODO: Send it!\n");
|
||||||
case ' ':
|
|
||||||
[[fallthrough]];
|
|
||||||
case '+':
|
|
||||||
[[fallthrough]];
|
|
||||||
case '=':
|
|
||||||
[[fallthrough]];
|
|
||||||
case '?':
|
|
||||||
[[fallthrough]];
|
|
||||||
case ',':
|
|
||||||
[[fallthrough]];
|
|
||||||
case '.':
|
|
||||||
{
|
|
||||||
printf("TODO: Send it: %c\n", buf[0]);
|
|
||||||
std::string msg(1, buf[0]);
|
|
||||||
KeyerQueueData keyerQueueData {KeyerQueueCommand::SendMessage, 0, Mode::IambicB, msg};
|
|
||||||
queue_add_blocking(&keyerQueue, &keyerQueueData);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case 0x00: // ADMIN COMMAND
|
case 0x00: // ADMIN COMMAND
|
||||||
switch (buf[1]) {
|
switch (buf[1]) {
|
||||||
case 0x02: // HOST OPEN
|
case 0x02: // Host open
|
||||||
usbSend(USB_IF, 9); // Send WK1 (v9) for now (no WinKeyer PTT control)
|
usbSend(USB_IF, 9); // Send WK1 (v9) for now (no WinKeyer PTT control)
|
||||||
break;
|
break;
|
||||||
case 0x04: // ECHO TEST
|
case 0x04: // Echo test
|
||||||
usbSend(USB_IF, &buf[2], 1); // Send the received byte back
|
printf("Echo test: %x\n", buf[2]);
|
||||||
|
printf("buf address: %p\n", &buf[2]);
|
||||||
|
usbSend(USB_IF, &buf[2], 1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("Unknown admin command: %x\n", buf[1]);
|
printf("Unknown admin command: %x\n", buf[1]);
|
||||||
|
@ -227,6 +209,9 @@ int main()
|
||||||
static bool used = false;
|
static bool used = false;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
tud_task();
|
||||||
|
cdc_task();
|
||||||
|
|
||||||
currentWpm = calcWPM(potiRead(), settings.wpmPotiMin, settings.wpmPotiMax);
|
currentWpm = calcWPM(potiRead(), settings.wpmPotiMin, settings.wpmPotiMax);
|
||||||
|
|
||||||
// If WPM in settings is set to 0 -> take speed from poti
|
// If WPM in settings is set to 0 -> take speed from poti
|
||||||
|
@ -243,9 +228,6 @@ int main()
|
||||||
// pse k"}; queue_add_blocking(&keyerQueue, &keyerQueueData);
|
// pse k"}; queue_add_blocking(&keyerQueue, &keyerQueueData);
|
||||||
used = true;
|
used = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
tud_task();
|
|
||||||
cdc_task();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue