2024-02-10 23:51:55 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "pico/stdlib.h"
|
|
|
|
|
2024-02-09 12:20:30 +01:00
|
|
|
#include "keyer.h"
|
|
|
|
|
2024-02-10 23:51:55 +01:00
|
|
|
extern const uint LEFT_PADDLE_PIN;
|
|
|
|
|
|
|
|
bool left_paddle_pressed()
|
|
|
|
{
|
2024-02-11 15:45:12 +01:00
|
|
|
if (!gpio_get(LEFT_PADDLE_PIN))
|
2024-02-10 23:51:55 +01:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-02-09 12:20:30 +01:00
|
|
|
void Keyer::run()
|
|
|
|
{
|
|
|
|
switch (state)
|
|
|
|
{
|
2024-02-10 23:51:55 +01:00
|
|
|
case State::Wait:
|
|
|
|
if (left_paddle_pressed())
|
|
|
|
state = State::LeftPaddlePressed;
|
|
|
|
break;
|
|
|
|
case State::LeftPaddlePressed:
|
|
|
|
printf(".");
|
2024-02-11 15:45:12 +01:00
|
|
|
|
|
|
|
if (left_paddle_pressed())
|
|
|
|
state = State::InterCharSpace;
|
|
|
|
else
|
|
|
|
state = State::Wait;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case State::InterCharSpace:
|
|
|
|
printf("(.)");
|
|
|
|
|
|
|
|
if (left_paddle_pressed())
|
|
|
|
state = State::LeftPaddlePressed;
|
|
|
|
else
|
|
|
|
state = State::Wait;
|
2024-02-09 12:20:30 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|