code beautifying

This commit is contained in:
Martin Brodbeck 2024-02-16 20:56:03 +01:00
parent 9a07c24d8f
commit 08885a3aac
8 changed files with 292 additions and 113 deletions

View file

@ -1,11 +1,11 @@
#include <stdio.h>
#include "pico/stdlib.h"
#include "pico/multicore.h"
#include "pico/stdlib.h"
#include "pico/util/queue.h"
#include "settings.h"
#include "keyer.h"
#include "settings.h"
namespace
{
@ -18,15 +18,13 @@ extern const uint RIGHT_PADDLE_PIN = 15;
extern const uint BUZZER_PIN = 18;
// Stuff for communicating between cores
enum class KeyerQueueCommand
{
enum class KeyerQueueCommand {
Run,
Stop,
Config,
Wait,
};
struct KeyerQueueData
{
struct KeyerQueueData {
KeyerQueueCommand cmd;
uint8_t wpm;
Mode mode;
@ -49,7 +47,7 @@ void setup()
gpio_set_dir(RIGHT_PADDLE_PIN, GPIO_IN);
gpio_pull_up(RIGHT_PADDLE_PIN);
//sleep_ms(1000);
// sleep_ms(1000);
}
/* Let's do all the keying stuff in the second core, so there are no timing problems. */
@ -61,12 +59,10 @@ void core1_main()
Keyer keyer(data.wpm, data.mode);
while (true)
{
while (true) {
queue_try_remove(&keyerQueue, &data);
switch (data.cmd)
{
switch (data.cmd) {
case KeyerQueueCommand::Run:
keyer.run();
break;
@ -89,8 +85,8 @@ void core1_main()
int main()
{
//timer_hw->dbgpause = 2; // workaround for problem with debug and sleep_ms
// https://github.com/raspberrypi/pico-sdk/issues/1152#issuecomment-1418248639
// timer_hw->dbgpause = 2; // workaround for problem with debug and sleep_ms
// https://github.com/raspberrypi/pico-sdk/issues/1152#issuecomment-1418248639
setup();
@ -106,8 +102,7 @@ int main()
KeyerQueueData keyerQueueData{KeyerQueueCommand::Run, settings.wpm, settings.mode};
queue_add_blocking(&keyerQueue, &keyerQueueData);
while (true)
{
while (true) {
// Currently there's nothing to do on core0
sleep_ms(1000);
}