FastLED 3.9.15
Loading...
Searching...
No Matches
fl::SerialPort Class Reference

Detailed Description

Arduino-compatible Serial class for cross-platform serial I/O.

This class provides the familiar Arduino Serial API for all FastLED platforms. It delegates to platform-specific implementations under the hood.

USAGE:

fl::Serial.begin(115200);
fl::Serial.println("Hello, FastLED!");
if (fl::Serial.available()) {
char c = fl::Serial.read();
fl::Serial.print("Received: ");
fl::Serial.println(c);
}
int available()
Check how many bytes are available to read.

COMPATIBILITY:

  • Compatible with Arduino Serial API
  • Works on all FastLED platforms (AVR, ESP32, STM32, host, etc.)
  • Zero overhead - compiles to direct platform calls

Definition at line 38 of file serial.h.

#include <serial.h>

Public Member Functions

int available ()
 Check how many bytes are available to read.
 
void begin (u32 baudRate=115200)
 Initialize serial communication.
 
void end ()
 Close serial communication.
 
bool flush (u32 timeoutMs=1000)
 Wait for serial output to complete.
 
 operator bool () const
 Check if serial port is ready for I/O.
 
float parseFloat ()
 Parse floating-point number from serial input.
 
long parseInt ()
 Parse integer from serial input.
 
int peek ()
 Peek at next byte without removing it from buffer.
 
size_t print (const char *str)
 Print string to serial output.
 
size_t print (int value)
 Print integer to serial output.
 
size_t print (long value)
 Print long integer to serial output.
 
template<typename T>
fl::enable_if< fl::is_multi_byte_integer< T >::value &&!fl::is_signed< T >::value, size_t >::type print (T value)
 Print generic unsigned integer via SFINAE template Handles u32, unsigned long, and other unsigned multi-byte integers Uses enable_if to avoid duplicate overload issues on platforms where unsigned long == u32.
 
template<typename... Args>
size_t printf (const char *format, Args... args)
 Print formatted string to serial output (printf-style)
 
size_t println ()
 Print newline only.
 
size_t println (const char *str)
 Print string with newline to serial output.
 
size_t println (int value)
 Print integer with newline to serial output.
 
size_t println (long value)
 Print long integer with newline to serial output.
 
template<typename T>
fl::enable_if< fl::is_multi_byte_integer< T >::value &&!fl::is_signed< T >::value, size_t >::type println (T value)
 Print generic unsigned integer with newline via SFINAE template Handles u32, unsigned long, and other unsigned multi-byte integers Uses enable_if to avoid duplicate overload issues on platforms where unsigned long == u32.
 
int read ()
 Read next byte from serial input.
 
size_t readBytes (u8 *buffer, size_t length)
 Read fixed number of bytes into buffer.
 
size_t readBytesUntil (char delimiter, u8 *buffer, size_t length)
 Read bytes until delimiter is found.
 
fl::string readString ()
 Read all available bytes into a string.
 
fl::string readStringUntil (char delimiter)
 Read characters until delimiter is found.
 
void setTimeout (u32 timeoutMs)
 Set timeout for read operations.
 
size_t write (const u8 *buffer, size_t size)
 Write buffer to serial output.
 
size_t write (u8 byte)
 Write single byte to serial output.
 

Private Attributes

u32 mTimeoutMs = 1000
 

The documentation for this class was generated from the following files: