REDAC HybridController
Firmware for LUCIDAC/REDAC Teensy
Loading...
Searching...
No Matches
serial_lines.h
Go to the documentation of this file.
1// Copyright (c) 2024 anabrid GmbH
2// Contact: https://www.anabrid.com/licensing/
3//
4// SPDX-License-Identifier: MIT OR GPL-2.0-or-later
5
6#include <Arduino.h>
7
8namespace utils {
9
11public:
12 static constexpr int serial_buffer_size = 4096;
15
16 bool echo = true;
17
19 if (Serial.available() > 0) {
20 char in = Serial.read();
21
22 if (echo) {
23 Serial.print(in);
24 Serial.flush();
25 }
26
27 if (in == '\n') {
30 return serial_buffer;
31 } else if (serial_buffer_pos < serial_buffer_size - 1) { // Avoid buffer overflow
33 } else {
34 // buffer is full, flush it anyway.
38 return serial_buffer;
39 }
40 }
41 return NULL;
42 }
43};
44
45} // namespace utils
static constexpr int serial_buffer_size
char serial_buffer[serial_buffer_size]
bool echo
whether to give immediate feedback on typing or not.