Start competition mode

This commit is contained in:
Carsten Graf
2025-08-02 20:36:19 +02:00
parent 0166e1a695
commit a1c68791bf
5 changed files with 467 additions and 356 deletions

20
src/gamemodes.h Normal file
View File

@@ -0,0 +1,20 @@
#pragma once
#include <Arduino.h>
#include <ArduinoJson.h>
#include <ESPAsyncWebServer.h>
void IndividualMode();
void CompetitionMode();
void IndividualMode(const char *action, int lane, int timestamp = 0) {
Serial.printf("Individual Mode Action: %s on Lane %d at %d\n", action, lane,
timestamp);
// Implement individual mode logic here
}
void CompetitionMode(const char *action, int lane, int timestamp = 0) {
Serial.printf("Competition Mode Action: %s on Lane %d at %d\n", action, lane,
timestamp);
// Implement competition mode logic here
}

View File

@@ -56,6 +56,7 @@ unsigned long maxTimeBeforeReset = 300000; // 5 Minuten default
unsigned long maxTimeDisplay = 20000; // 20 Sekunden Standard (in ms)
bool wifimodeAP = false; // AP-Modus deaktiviert
String masterlocation;
int operationalMode = 0; // 0=Individual, 1=Wettkampf
// Function Declarations
void OnDataRecv(const uint8_t *mac, const uint8_t *incomingData, int len);

View File

@@ -280,6 +280,31 @@ void setupRoutes() {
request->send(200, "application/json", "{\"success\":true}");
});
server.on("/api/set-mode", HTTP_POST, [](AsyncWebServerRequest *request) {
Serial.println("/api/set-mode called");
String mode;
if (request->hasParam("mode", true)) {
mode = request->getParam("mode", true)->value();
}
if (mode.length() > 0) {
// Speichere den Modus
operationalMode = mode == "individual" ? 1 : 0;
Serial.printf("Operational mode set to: %s\n",
operationalMode == 1 ? "Individual" : "Wettkampf");
// Rückmeldung
DynamicJsonDocument doc(64);
doc["success"] = true;
String result;
serializeJson(doc, result);
request->send(200, "application/json", result);
} else {
request->send(400, "application/json",
"{\"success\":false,\"error\":\"Modus fehlt\"}");
}
});
// Statische Dateien
server.serveStatic("/", SPIFFS, "/");
server.begin();