Compare commits
No commits in common. "f1d865ab6806d3449884c48de4908f661a8816fd" and "3311e7d79006df6dba98ca2e940446fa8f042506" have entirely different histories.
f1d865ab68
...
3311e7d790
5 changed files with 37 additions and 102 deletions
|
@ -341,8 +341,4 @@ void Keyer::run()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Keyer::stop()
|
void Keyer::stop() { m_paddleKeyingState = State::Abort; }
|
||||||
{
|
|
||||||
m_paddleKeyingState = State::Abort;
|
|
||||||
m_messageKeyingState = MessageState::Abort;
|
|
||||||
}
|
|
|
@ -72,7 +72,7 @@ void core1_main()
|
||||||
break;
|
break;
|
||||||
case KeyerQueueCommand::Stop:
|
case KeyerQueueCommand::Stop:
|
||||||
keyer.stop();
|
keyer.stop();
|
||||||
data.cmd = KeyerQueueCommand::Run;
|
data.cmd = KeyerQueueCommand::Wait;
|
||||||
break;
|
break;
|
||||||
case KeyerQueueCommand::Config:
|
case KeyerQueueCommand::Config:
|
||||||
keyer.setSpeed(data.wpm);
|
keyer.setSpeed(data.wpm);
|
||||||
|
@ -83,6 +83,8 @@ void core1_main()
|
||||||
keyer.sendCharacter(data.message);
|
keyer.sendCharacter(data.message);
|
||||||
data.cmd = KeyerQueueCommand::Run;
|
data.cmd = KeyerQueueCommand::Run;
|
||||||
break;
|
break;
|
||||||
|
case KeyerQueueCommand::Wait:
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ enum class KeyerQueueCommand {
|
||||||
Run,
|
Run,
|
||||||
Stop,
|
Stop,
|
||||||
Config,
|
Config,
|
||||||
|
Wait,
|
||||||
SendMessage,
|
SendMessage,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
102
src/winkeyer.cpp
102
src/winkeyer.cpp
|
@ -8,99 +8,51 @@
|
||||||
void WinKeyer::run(queue_t &queue)
|
void WinKeyer::run(queue_t &queue)
|
||||||
{
|
{
|
||||||
const uint8_t USB_IF = 0;
|
const uint8_t USB_IF = 0;
|
||||||
static uint8_t buf[64] {0};
|
|
||||||
|
|
||||||
if (tud_cdc_n_available(USB_IF)) {
|
if (tud_cdc_n_available(USB_IF)) {
|
||||||
|
uint8_t buf[64];
|
||||||
|
|
||||||
if (m_commandState == CommandState::None) {
|
// printf("AHA!!! %d\n", (int)tud_cdc_n_available(USB_IF));
|
||||||
uint8_t value = tud_cdc_n_read_char(USB_IF);
|
uint32_t count = tud_cdc_n_read(USB_IF, buf, sizeof(buf));
|
||||||
switch (value) {
|
|
||||||
|
if (count > 0) {
|
||||||
|
switch (buf[0]) {
|
||||||
|
case 'a' ... 'z':
|
||||||
|
[[fallthrough]];
|
||||||
|
case 'A' ... 'Z':
|
||||||
|
[[fallthrough]];
|
||||||
|
case '0' ... '9':
|
||||||
|
[[fallthrough]];
|
||||||
case ' ':
|
case ' ':
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case '\"':
|
case '+':
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case '$':
|
case '=':
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case '\'':
|
case '?':
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case '(':
|
case ',':
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case ')':
|
case '.': {
|
||||||
[[fallthrough]];
|
KeyerQueueData keyerQueueData {KeyerQueueCommand::SendMessage, 0, Mode::IambicB, buf[0]};
|
||||||
case '+' ... ']': {
|
|
||||||
if (m_hostOpen) {
|
|
||||||
KeyerQueueData keyerQueueData {KeyerQueueCommand::SendMessage, 0, Mode::IambicB, value};
|
|
||||||
queue_add_blocking(&queue, &keyerQueueData);
|
queue_add_blocking(&queue, &keyerQueueData);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x00: // ADMIN
|
case 0x00: // ADMIN COMMAND
|
||||||
m_commandState = CommandState::Admin;
|
switch (buf[1]) {
|
||||||
break;
|
|
||||||
case 0x07: // GET SPEED POT
|
|
||||||
printf("INFO: Get Speed Pot currently not supported.\n");
|
|
||||||
break;
|
|
||||||
case 0x0A: {
|
|
||||||
// TODO: Implement abort sending message
|
|
||||||
KeyerQueueData keyerQueueData {KeyerQueueCommand::Stop, 0, Mode::IambicB, value};
|
|
||||||
queue_add_blocking(&queue, &keyerQueueData);
|
|
||||||
} break;
|
|
||||||
case 0x0B: // KEY IMMEDIATE
|
|
||||||
m_commandState = CommandState::KeyImmediate;
|
|
||||||
break;
|
|
||||||
case 0x0F: // LOAD DEFAULTS
|
|
||||||
m_commandState = CommandState::LoadDefaults;
|
|
||||||
break;
|
|
||||||
case 0x13: // NOP
|
|
||||||
break;
|
|
||||||
case 0x15: // REQUEST WINKEY STATUS
|
|
||||||
printf("INFO: Request WinKey Status currently not supported.\n");
|
|
||||||
usbSend(USB_IF, 0b11000000);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
printf("Unknown command: %x\n", value);
|
|
||||||
m_commandState = CommandState::None;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else if (m_commandState == CommandState::Admin) {
|
|
||||||
uint8_t value = tud_cdc_n_read_char(USB_IF);
|
|
||||||
switch (value) {
|
|
||||||
case 0x02: // HOST OPEN
|
case 0x02: // HOST OPEN
|
||||||
usbSend(USB_IF, 9); // Send v9 back (Winkeyer 1)
|
usbSend(USB_IF, 9); // Send WK1 (v9) for now (no WinKeyer PTT control)
|
||||||
m_hostOpen = true;
|
|
||||||
m_commandState = CommandState::None;
|
|
||||||
break;
|
break;
|
||||||
case 0x03: // HOST CLOSE
|
case 0x04: // ECHO TEST
|
||||||
m_hostOpen = false;
|
usbSend(USB_IF, &buf[2], 1); // Send the received byte back
|
||||||
break;
|
|
||||||
case 0x04:
|
|
||||||
m_commandState = CommandState::AdminEchoTest;
|
|
||||||
break;
|
|
||||||
case 0x0a: // SET WK1 MODE
|
|
||||||
m_wkMode = WkMode::WK1;
|
|
||||||
m_commandState = CommandState::None;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("Unknown admin command: %x.\n", value);
|
printf("Unknown admin command: %x\n", buf[1]);
|
||||||
m_commandState = CommandState::None;
|
}
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
printf("Unknown command: %d.\n", buf[0]);
|
||||||
}
|
}
|
||||||
} else if (m_commandState == CommandState::AdminEchoTest) {
|
|
||||||
uint8_t value = tud_cdc_n_read_char(USB_IF);
|
|
||||||
usbSend(USB_IF, value); // Send the received byte back
|
|
||||||
m_commandState = CommandState::None;
|
|
||||||
} else if (m_commandState == CommandState::LoadDefaults) {
|
|
||||||
if (tud_cdc_n_available(USB_IF) < 15) {
|
|
||||||
printf("LOAD DEFAULTS: Waiting for remaining bytes ...\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
tud_cdc_n_read(USB_IF, buf, 15);
|
|
||||||
printf("INFO: Loading defaults currently not supported.\n");
|
|
||||||
m_commandState = CommandState::None;
|
|
||||||
} else if (m_commandState == CommandState::KeyImmediate) {
|
|
||||||
tud_cdc_n_read_char(USB_IF); // Silently ignore byte
|
|
||||||
printf("INFO: Tune not supported.\n");
|
|
||||||
m_commandState = CommandState::None;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,20 +8,4 @@ class WinKeyer final
|
||||||
void run(queue_t &queue);
|
void run(queue_t &queue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class CommandState {
|
|
||||||
None,
|
|
||||||
Admin,
|
|
||||||
AdminEchoTest,
|
|
||||||
LoadDefaults,
|
|
||||||
KeyImmediate,
|
|
||||||
};
|
|
||||||
enum class WkMode {
|
|
||||||
WK1,
|
|
||||||
WK2,
|
|
||||||
WK3,
|
|
||||||
};
|
|
||||||
|
|
||||||
CommandState m_commandState {CommandState::None};
|
|
||||||
WkMode m_wkMode {WkMode::WK1};
|
|
||||||
bool m_hostOpen {false};
|
|
||||||
};
|
};
|
Loading…
Reference in a new issue