diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2026-06-20 22:23:48 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2026-06-20 22:44:43 +0200 |
| commit | d7c2a8029c4aefc295719174a863129645d6ab99 (patch) | |
| tree | d2f36ab8721dd32235dc63a60218378eb35922c8 /throttle-quadrant.ino | |
| download | throttle-quadrant-master.tar.xz throttle-quadrant-master.zip | |
Diffstat (limited to 'throttle-quadrant.ino')
| -rw-r--r-- | throttle-quadrant.ino | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/throttle-quadrant.ino b/throttle-quadrant.ino new file mode 100644 index 0000000..7c213a1 --- /dev/null +++ b/throttle-quadrant.ino @@ -0,0 +1,32 @@ +#include "protocol.hpp" + +//! Set up any global state. +//! +//! This function is executed once during the start of the firmware. +auto setup() -> void { + // Initialize the protocol subsystem. + tq::protocol::init(); + + // Initialize the serial output stream. + Serial.begin(9600); +} + +//! Perform one iteration through the firmare logic. +//! +//! This function is called in an endless loop after the firmware has started. +auto loop() -> void { + // Always try to start a new transfer. + tq::protocol::start(); + + // Receive a new message if one is available. + auto maybe_message = tq::protocol::perform_transfer(); + + if (maybe_message.has_value()) { + // Extract the received message. + auto const& message = maybe_message.value(); + + Serial.write("new message: "); + Serial.write("throttle == "); + Serial.print(static_cast<int>(message.throttle)); + } +}
\ No newline at end of file |
