80 Serial.println(
"HTTP Server Example");
87 Serial.println(
"[GET /] Hello request");
91 .header(
"Content-Type",
"text/plain")
92 .body(
"Hello from FastLED!\n");
99 Serial.println(
"[GET /status] Status request");
103 status.
set(
"brightness",
FastLED.getBrightness());
111 Serial.println(
"[POST /color] Color change request");
118 int r = body[
"r"] | 0;
119 int g = body[
"g"] | 0;
120 int b = body[
"b"] | 0;
124 Serial.print(
"Color set to RGB(");
139 Serial.println(
"Server started on http://localhost:8080/");
142 Serial.println(
"ERROR: Failed to start server");
155 fl::size total_processed = 0;
156 for (
int i = 0; i < 10; ++i) {
157 fl::size processed =
server.update();
158 total_processed += processed;
159 if (processed == 0)
break;
162 if (total_processed > 0) {
163 Serial.print(
"Processed ");
164 Serial.print(
static_cast<int>(total_processed));
165 Serial.println(
" request(s)");
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
const string & body() const
Get request body (for POST/PUT requests)
Response & json(const class json &data)
Set JSON response body with automatic Content-Type header.
static Response ok(const string &body="")
Factory method for 200 OK response.
static Response bad_request(const string &message)
Factory method for 400 Bad Request response.
bool is_null() const FL_NOEXCEPT
void set(const fl::string &key, const json &value) FL_NOEXCEPT
static json parse(const fl::string &txt) FL_NOEXCEPT
static json object() FL_NOEXCEPT
void fill_solid(CRGB *targetArray, int numToFill, const CRGB &color) FL_NOEXCEPT
Fill a range of LEDs with a solid color.
LIB8STATIC u8 beatsin8(accum88 beats_per_minute, u8 lowest=0, u8 highest=255, u32 timebase=0, u8 phase_offset=0) FL_NOEXCEPT
Generates an 8-bit sine wave at a given BPM that oscillates within a given range.
asio::http::Request http_request
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.
asio::http::Response http_response
asio::http::Server HttpServer
Representation of an 8-bit RGB pixel (Red, Green, Blue)