This commit is contained in:
Martin Brodbeck 2024-02-10 23:51:55 +01:00
parent 49e3a19f1f
commit 706e514ba4
3 changed files with 29 additions and 6 deletions

View file

@ -1,11 +1,31 @@
#include <stdio.h>
#include "pico/stdlib.h"
#include "keyer.h" #include "keyer.h"
extern const uint LEFT_PADDLE_PIN;
bool left_paddle_pressed()
{
if (gpio_get(LEFT_PADDLE_PIN))
{
return true;
}
return false;
}
void Keyer::run() void Keyer::run()
{ {
switch (state) switch (state)
{ {
case State::WAIT: case State::Wait:
// do nothing if (left_paddle_pressed())
state = State::LeftPaddlePressed;
break;
case State::LeftPaddlePressed:
printf(".");
state = State::Wait;
break; break;
default: default:

View file

@ -6,13 +6,15 @@ class Keyer final
public: public:
enum class State enum class State
{ {
WAIT Wait,
LeftPaddlePressed,
}; };
void run(); void run();
private: private:
State state{State::WAIT}; State state{State::Wait};
}; };
#endif #endif

View file

@ -8,9 +8,10 @@
namespace namespace
{ {
const uint LED_PIN = PICO_DEFAULT_LED_PIN; const uint LED_PIN = PICO_DEFAULT_LED_PIN;
const uint LEFT_PADDLE_PIN = 14;
const uint RIGHT_PADDLE_PIN = 15; const uint RIGHT_PADDLE_PIN = 15;
} }
extern const uint LEFT_PADDLE_PIN = 14;
void setup() void setup()
{ {
@ -45,7 +46,7 @@ int main()
while (true) while (true)
{ {
sleep_ms(10); sleep_ms(1.2 * settings.wpm);
keyer.run(); keyer.run();
} }