Keyer should now run on core1
This commit is contained in:
parent
6ea69df2fa
commit
60e9da0877
1 changed files with 39 additions and 10 deletions
|
@ -17,6 +17,20 @@ extern const uint LEFT_PADDLE_PIN = 14;
|
|||
extern const uint RIGHT_PADDLE_PIN = 15;
|
||||
extern const uint BUZZER_PIN = 13;
|
||||
|
||||
// Stuff for communicating between cores
|
||||
enum class KeyerQueueCommand
|
||||
{
|
||||
Run,
|
||||
Stop,
|
||||
Config,
|
||||
};
|
||||
struct KeyerQueueData
|
||||
{
|
||||
KeyerQueueCommand cmd;
|
||||
uint8_t wpm;
|
||||
Mode mode;
|
||||
};
|
||||
|
||||
queue_t keyerQueue;
|
||||
|
||||
void setup()
|
||||
|
@ -37,18 +51,33 @@ void setup()
|
|||
sleep_ms(1000);
|
||||
}
|
||||
|
||||
/* Let's do all the keying stuff in the second core, so there are no timing problems. */
|
||||
void core1_main()
|
||||
{
|
||||
Settings settings;
|
||||
queue_remove_blocking(&keyerQueue, &settings);
|
||||
KeyerQueueData data;
|
||||
queue_remove_blocking(&keyerQueue, &data);
|
||||
|
||||
Keyer keyer(settings.wpm, settings.mode);
|
||||
Keyer keyer(data.wpm, data.mode);
|
||||
|
||||
while (true)
|
||||
{
|
||||
keyer.run();
|
||||
}
|
||||
queue_try_remove(&keyerQueue, &data);
|
||||
|
||||
switch (data.cmd)
|
||||
{
|
||||
case KeyerQueueCommand::Run:
|
||||
keyer.run();
|
||||
break;
|
||||
case KeyerQueueCommand::Stop:
|
||||
break;
|
||||
case KeyerQueueCommand::Config:
|
||||
// set speed and wpm
|
||||
data.cmd = KeyerQueueCommand::Run;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@ -60,13 +89,13 @@ int main()
|
|||
|
||||
Settings settings{read_settings()};
|
||||
|
||||
/*Keyer keyer(settings.wpm, settings.mode);*/
|
||||
|
||||
queue_add_blocking(&keyerQueue, &settings);
|
||||
KeyerQueueData keyerQueueData{KeyerQueueCommand::Run, settings.wpm, settings.mode};
|
||||
queue_add_blocking(&keyerQueue, &keyerQueueData);
|
||||
|
||||
while (true)
|
||||
{
|
||||
sleep_ms(100);
|
||||
// Currently there's nothing to do on core0
|
||||
sleep_ms(1000);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue