diff --git a/src/keyer.cpp b/src/keyer.cpp index 83f631d..b4389dc 100644 --- a/src/keyer.cpp +++ b/src/keyer.cpp @@ -1,11 +1,31 @@ +#include + +#include "pico/stdlib.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() { switch (state) { - case State::WAIT: - // do nothing + case State::Wait: + if (left_paddle_pressed()) + state = State::LeftPaddlePressed; + break; + case State::LeftPaddlePressed: + printf("."); + state = State::Wait; break; default: diff --git a/src/keyer.h b/src/keyer.h index 96abae0..98b7c7f 100644 --- a/src/keyer.h +++ b/src/keyer.h @@ -6,13 +6,15 @@ class Keyer final public: enum class State { - WAIT + Wait, + LeftPaddlePressed, + }; void run(); private: - State state{State::WAIT}; + State state{State::Wait}; }; #endif \ No newline at end of file diff --git a/src/pico_keyer.cpp b/src/pico_keyer.cpp index 095acac..d29cf40 100644 --- a/src/pico_keyer.cpp +++ b/src/pico_keyer.cpp @@ -8,9 +8,10 @@ namespace { const uint LED_PIN = PICO_DEFAULT_LED_PIN; - const uint LEFT_PADDLE_PIN = 14; + const uint RIGHT_PADDLE_PIN = 15; } +extern const uint LEFT_PADDLE_PIN = 14; void setup() { @@ -45,7 +46,7 @@ int main() while (true) { - sleep_ms(10); + sleep_ms(1.2 * settings.wpm); keyer.run(); }