refacturing compiles
This commit is contained in:
parent
6f51f5e962
commit
e4bc705f04
6 changed files with 149 additions and 110 deletions
58
src/winkeyer.cpp
Normal file
58
src/winkeyer.cpp
Normal file
|
@ -0,0 +1,58 @@
|
|||
#include "pico/stdlib.h"
|
||||
#include "tusb.h"
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#include "winkeyer.h"
|
||||
|
||||
void WinKeyer::run(queue_t &queue)
|
||||
{
|
||||
const uint8_t USB_IF = 0;
|
||||
|
||||
if (tud_cdc_n_available(USB_IF)) {
|
||||
uint8_t buf[64];
|
||||
|
||||
// printf("AHA!!! %d\n", (int)tud_cdc_n_available(USB_IF));
|
||||
uint32_t count = tud_cdc_n_read(USB_IF, buf, sizeof(buf));
|
||||
|
||||
if (count > 0) {
|
||||
switch (buf[0]) {
|
||||
case 'a' ... 'z':
|
||||
[[fallthrough]];
|
||||
case 'A' ... 'Z':
|
||||
[[fallthrough]];
|
||||
case '0' ... '9':
|
||||
[[fallthrough]];
|
||||
case ' ':
|
||||
[[fallthrough]];
|
||||
case '+':
|
||||
[[fallthrough]];
|
||||
case '=':
|
||||
[[fallthrough]];
|
||||
case '?':
|
||||
[[fallthrough]];
|
||||
case ',':
|
||||
[[fallthrough]];
|
||||
case '.': {
|
||||
KeyerQueueData keyerQueueData {KeyerQueueCommand::SendMessage, 0, Mode::IambicB, buf[0]};
|
||||
queue_add_blocking(&queue, &keyerQueueData);
|
||||
break;
|
||||
}
|
||||
case 0x00: // ADMIN COMMAND
|
||||
switch (buf[1]) {
|
||||
case 0x02: // HOST OPEN
|
||||
usbSend(USB_IF, 9); // Send WK1 (v9) for now (no WinKeyer PTT control)
|
||||
break;
|
||||
case 0x04: // ECHO TEST
|
||||
usbSend(USB_IF, &buf[2], 1); // Send the received byte back
|
||||
break;
|
||||
default:
|
||||
printf("Unknown admin command: %x\n", buf[1]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
printf("Unknown command: %d.\n", buf[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue