9#include "platforms/io.h"
47static print_handler_t& get_print_handler()
FL_NO_EXCEPT {
48 static print_handler_t handler;
52static println_handler_t& get_println_handler()
FL_NO_EXCEPT {
53 static println_handler_t handler;
57static available_handler_t& get_available_handler()
FL_NO_EXCEPT {
58 static available_handler_t handler;
63 static read_handler_t handler;
67static flush_handler_t& get_flush_handler()
FL_NO_EXCEPT {
68 static flush_handler_t handler;
72static write_bytes_handler_t& get_write_bytes_handler()
FL_NO_EXCEPT {
73 static write_bytes_handler_t handler;
85 if (get_print_handler()) {
86 get_print_handler()(str);
92 platforms::print(str);
100#ifdef FASTLED_TESTING
102 if (get_println_handler()) {
103 get_println_handler()(str);
109 platforms::println(str);
113#ifdef FASTLED_TESTING
115 if (get_available_handler()) {
116 return get_available_handler()();
121 return platforms::available();
125 return platforms::peek();
129#ifdef FASTLED_TESTING
131 if (get_read_handler()) {
132 return get_read_handler()();
137 return platforms::read();
147 if (timeoutMs.has_value()) {
148 if (
fl::millis() - startTime >= timeoutMs.value()) {
169 if (c == delimiter) {
179 out << static_cast<char>(c);
192 int nativeLen = platforms::readLineNative(delimiter, nativeBuf,
sizeof(nativeBuf));
193 if (nativeLen >= 0) {
210#ifdef FASTLED_TESTING
211 if (get_flush_handler()) {
212 return get_flush_handler()(timeoutMs);
215 return platforms::flush(timeoutMs);
219 if (!buffer || size == 0)
return 0;
220#ifdef FASTLED_TESTING
221 if (get_write_bytes_handler()) {
222 return get_write_bytes_handler()(buffer, size);
225 return platforms::write_bytes(buffer, size);
228#if !FL_SERIAL_BEGIN_INLINE
230 platforms::begin(baudRate);
235 return platforms::serial_ready();
244#ifdef FASTLED_TESTING
247void inject_print_handler(
const print_handler_t& handler)
FL_NO_EXCEPT {
248 get_print_handler() = handler;
251void inject_println_handler(
const println_handler_t& handler)
FL_NO_EXCEPT {
252 get_println_handler() = handler;
255void inject_available_handler(
const available_handler_t& handler)
FL_NO_EXCEPT {
256 get_available_handler() = handler;
259void inject_read_handler(
const read_handler_t& handler)
FL_NO_EXCEPT {
260 get_read_handler() = handler;
263void inject_flush_handler(
const flush_handler_t& handler)
FL_NO_EXCEPT {
264 get_flush_handler() = handler;
267void inject_write_bytes_handler(
const write_bytes_handler_t& handler)
FL_NO_EXCEPT {
268 get_write_bytes_handler() = handler;
273 get_print_handler() = print_handler_t{};
274 get_println_handler() = println_handler_t{};
275 get_available_handler() = available_handler_t{};
276 get_read_handler() = read_handler_t{};
277 get_flush_handler() = flush_handler_t{};
278 get_write_bytes_handler() = write_bytes_handler_t{};
283 get_print_handler() = print_handler_t{};
287 get_println_handler() = println_handler_t{};
291 get_available_handler() = available_handler_t{};
295 get_read_handler() = read_handler_t{};
299 get_flush_handler() = flush_handler_t{};
303 get_write_bytes_handler() = write_bytes_handler_t{};
310namespace cstdio_init {
313 (void)get_print_handler();
314 (void)get_println_handler();
315 (void)get_available_handler();
316 (void)get_read_handler();
317 (void)get_flush_handler();
318 (void)get_write_bytes_handler();
322FL_INIT(cstdio_init_wrapper, cstdio_init::init_io_handlers)
string str() const FL_NO_EXCEPT
void delay_impl(u32 ms, bool run_async) FL_NO_EXCEPT
Internal delay implementation used by the public fl::delay wrapper.
Compile-time linker keep-alive hook for a single fl::Bus.
u8 getLogLevel() FL_NO_EXCEPT
Get the current global log level.
u8 u8 fract8 blur_amount FL_NO_EXCEPT
void print(const char *str) FL_NO_EXCEPT
bool readStringUntil(sstream &out, char delimiter, char skipChar, fl::optional< u32 > timeoutMs) FL_NO_EXCEPT
bool serial_ready() FL_NO_EXCEPT
void setLogLevel(u8 level) FL_NO_EXCEPT
Set the global log level.
fl::optional< fl::string > readLine(char delimiter, char skipChar, fl::optional< u32 > timeoutMs) FL_NO_EXCEPT
fl::u32 millis() FL_NO_EXCEPT
Universal millisecond timer - returns milliseconds since system startup.
size_t write_bytes(const u8 *buffer, size_t size) FL_NO_EXCEPT
void serial_begin(u32 baudRate) FL_NO_EXCEPT
@ FL_LOG_LEVEL_DEBUG
All logging including debug (default)
@ FL_LOG_LEVEL_NONE
No logging (completely silent)
bool flush(u32 timeoutMs) FL_NO_EXCEPT
expected< T, E > result
Alias for expected (Rust-style naming)
constexpr nullopt_t nullopt
void println(const char *str) FL_NO_EXCEPT
int available() FL_NO_EXCEPT
void delayMicroseconds(u32 us) FL_NO_EXCEPT
Delay for a given number of microseconds.
Base definition for an LED controller.