#include #include #include #include #include const char* ssid = "tksteti"; const char* password = "ProsimTeNevim"; AsyncWebServer server(80); #define NUM_LEDS 4 #define DATA_PIN 12 CRGB leds[NUM_LEDS]; void handleNastavit(AsyncWebServerRequest *request) { if (request->hasParam("barva",true)) { String barva = request->getParam("barva",true)->value(); long barvaLong = strtol(barva.substring(1,7).c_str(),NULL,16); int r = (barvaLong >> 16) & 0xFF; int g = (barvaLong >> 8) & 0xFF; int b = barvaLong & 0xFF; for (int i = 0; i < NUM_LEDS; i++) { leds[i] = CRGB(r,g,b); } FastLED.show(); request->send(200,"text/plain","OK"); } else { request->send(400,"text/plain","Bad Request"); } } void setup() { Serial.begin(115200); if(!LittleFS.begin(true)){ Serial.println("Chyba při zavádění (mounting) LittleFS"); return; } WiFi.begin(ssid,password); while(WiFi.status() != WL_CONNECTED) { Serial.print("."); delay(50); } Serial.println("Připojeno k WiFi"); FastLED.addLeds(leds,NUM_LEDS); server.on("/",HTTP_GET,[](AsyncWebServerRequest *request){ request ->send(LittleFS,"/index.html","text/html"); }); server.on("/nastavit",HTTP_POST,handleNastavit); server.begin(); } void loop() { }