blob: 7c213a1215c2886aaca307b4ef2ddb6c5b3efb8d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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));
}
}
|