FastLED 3.9.15
Loading...
Searching...
No Matches
io.h
Go to the documentation of this file.
1#pragma once
2
3#define FL_IO_H_INCLUDED
4
5#ifdef FASTLED_TESTING
6#include "fl/function.h"
7#endif
8
9namespace fl {
10
11// Low-level print functions that avoid printf/sprintf dependencies
12// These use the most efficient output method for each platform
13
14// Print a string without newline
15void print(const char* str);
16
17// Print a string with newline
18#ifndef FL_DBG_PRINTLN_DECLARED
19void println(const char* str);
20#else
21// Declaration already exists from fl/dbg.h
22#endif
23
24// Low-level input functions that provide Serial-style read functionality
25// These use the most efficient input method for each platform
26
27// Returns the number of bytes available to read from input stream
28// Returns 0 if no data is available
29int available();
30
31// Reads the next byte from input stream
32// Returns the byte value (0-255) if data is available
33// Returns -1 if no data is available
34int read();
35
36#ifdef FASTLED_TESTING
37
38// Testing function handler types
39using print_handler_t = fl::function<void(const char*)>;
40using println_handler_t = fl::function<void(const char*)>;
41using available_handler_t = fl::function<int()>;
42using read_handler_t = fl::function<int()>;
43
44// Inject function handlers for testing
45void inject_print_handler(const print_handler_t& handler);
46void inject_println_handler(const println_handler_t& handler);
47void inject_available_handler(const available_handler_t& handler);
48void inject_read_handler(const read_handler_t& handler);
49
50// Clear all injected handlers (restores default behavior)
51void clear_io_handlers();
52
53// Clear individual handlers
54void clear_print_handler();
55void clear_println_handler();
56void clear_available_handler();
57void clear_read_handler();
58
59#endif // FASTLED_TESTING
60
61} // namespace fl
int available()
Definition io.cpp:117
int read()
Definition io.cpp:148
void print(const char *str)
Definition io.cpp:49
void println(const char *str)
Definition io.cpp:83
IMPORTANT!
Definition crgb.h:20