78 {
80 Serial.println(
"HTTP Server Example");
81
84
85
87 Serial.println(
"[GET /] Hello request");
88
91 .header("Content-Type", "text/plain")
92 .body("Hello from FastLED!\n");
93
95 });
96
97
99 Serial.println(
"[GET /status] Status request");
100
103 status.
set(
"brightness",
FastLED.getBrightness());
105
107 });
108
109
111 Serial.println(
"[POST /color] Color change request");
112
116 }
117
118 int r = body["r"] | 0;
119 int g = body["g"] | 0;
120 int b = body["b"] | 0;
121
123
124 Serial.print(
"Color set to RGB(");
128
130 });
131
132
135 });
136
137
139 Serial.println(
"Server started on http://localhost:8080/");
141 } else {
142 Serial.println(
"ERROR: Failed to start server");
146 }
147
150}
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.
asio::http::Request http_request
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.
asio::http::Response http_response
Representation of an 8-bit RGB pixel (Red, Green, Blue)