Lane difficulty added
This commit is contained in:
@@ -78,7 +78,7 @@ UserData checkUser(const String &uid) {
|
||||
userData.firstname = responseDoc["firstname"].as<String>();
|
||||
userData.lastname = responseDoc["lastname"].as<String>();
|
||||
userData.alter = responseDoc["alter"] | 0;
|
||||
userData.exists = true;
|
||||
userData.exists = responseDoc["exists"] | true;
|
||||
}
|
||||
} else {
|
||||
Serial.printf("User check failed, HTTP code: %d\n", httpCode);
|
||||
|
||||
@@ -21,6 +21,7 @@ struct TimerData1 {
|
||||
bool isRunning = false;
|
||||
bool isReady = true; // Status für Bahn 1
|
||||
bool isArmed = false; // Status für Bahn 1 (armiert/nicht armiert)
|
||||
char RFIDUID = "";
|
||||
};
|
||||
|
||||
// Timer Struktur für Bahn 2
|
||||
@@ -33,6 +34,7 @@ struct TimerData2 {
|
||||
bool isRunning = false;
|
||||
bool isReady = true; // Status für Bahn 2
|
||||
bool isArmed = false; // Status für Bahn 2 (armiert/nicht armiert)
|
||||
char RFIDUID = "";
|
||||
};
|
||||
|
||||
// Button Konfiguration
|
||||
@@ -66,6 +68,11 @@ String masterlocation;
|
||||
int gamemode; // 0=Individual, 1=Wettkampf
|
||||
bool startCompetition = false; // Flag, ob der Timer gestartet wurde
|
||||
|
||||
// Lane Configuration
|
||||
int laneConfigType = 0; // 0=Identical, 1=Different
|
||||
int lane1DifficultyType = 0; // 0=Light, 1=Heavy (difficulty)
|
||||
int lane2DifficultyType = 0; // 0=Light, 1=Heavy (difficulty)
|
||||
|
||||
// Function Declarations
|
||||
void OnDataRecv(const uint8_t *mac, const uint8_t *incomingData, int len);
|
||||
void handleLearningMode(const uint8_t *mac);
|
||||
|
||||
@@ -42,6 +42,9 @@ void saveSettings() {
|
||||
preferences.putULong("maxTime", maxTimeBeforeReset);
|
||||
preferences.putULong("maxTimeDisplay", maxTimeDisplay);
|
||||
preferences.putUInt("gamemode", gamemode);
|
||||
preferences.putUInt("laneConfigType", laneConfigType);
|
||||
preferences.putUInt("lane1DifficultyType", lane1DifficultyType);
|
||||
preferences.putUInt("lane2DifficultyType", lane2DifficultyType);
|
||||
preferences.end();
|
||||
}
|
||||
|
||||
@@ -50,6 +53,9 @@ void loadSettings() {
|
||||
maxTimeBeforeReset = preferences.getULong("maxTime", 300000);
|
||||
maxTimeDisplay = preferences.getULong("maxTimeDisplay", 20000);
|
||||
gamemode = preferences.getUInt("gamemode", 0);
|
||||
laneConfigType = preferences.getUInt("laneConfigType", 0);
|
||||
lane1DifficultyType = preferences.getUInt("lane1DifficultyType", 0);
|
||||
lane2DifficultyType = preferences.getUInt("lane2DifficultyType", 0);
|
||||
preferences.end();
|
||||
}
|
||||
|
||||
|
||||
@@ -312,6 +312,53 @@ void setupRoutes() {
|
||||
request->send(200, "application/json", result);
|
||||
});
|
||||
|
||||
// Lane Configuration API Routes
|
||||
server.on("/api/set-lane-config", HTTP_POST, [](AsyncWebServerRequest *request) {
|
||||
Serial.println("/api/set-lane-config called");
|
||||
|
||||
String body = request->getBody();
|
||||
DynamicJsonDocument doc(256);
|
||||
deserializeJson(doc, body);
|
||||
|
||||
if (doc.containsKey("type")) {
|
||||
String laneType = doc["type"];
|
||||
laneConfigType = (laneType == "identical") ? 0 : 1;
|
||||
|
||||
if (laneConfigType == 1 && doc.containsKey("lane1Difficulty") && doc.containsKey("lane2Difficulty")) {
|
||||
String lane1Difficulty = doc["lane1Difficulty"];
|
||||
String lane2Difficulty = doc["lane2Difficulty"];
|
||||
lane1DifficultyType = (lane1Difficulty == "light") ? 0 : 1;
|
||||
lane2DifficultyType = (lane2Difficulty == "light") ? 0 : 1;
|
||||
}
|
||||
|
||||
Serial.printf("Lane configuration set - Type: %s, Lane1: %s, Lane2: %s\n",
|
||||
laneType.c_str(),
|
||||
(laneConfigType == 1) ? ((lane1DifficultyType == 0) ? "light" : "heavy") : "identical",
|
||||
(laneConfigType == 1) ? ((lane2DifficultyType == 0) ? "light" : "heavy") : "identical");
|
||||
|
||||
DynamicJsonDocument response(64);
|
||||
response["success"] = true;
|
||||
String result;
|
||||
serializeJson(response, result);
|
||||
request->send(200, "application/json", result);
|
||||
saveSettings();
|
||||
} else {
|
||||
request->send(400, "application/json", "{\"success\":false,\"error\":\"Lane type missing\"}");
|
||||
}
|
||||
});
|
||||
|
||||
server.on("/api/get-lane-config", HTTP_GET, [](AsyncWebServerRequest *request) {
|
||||
DynamicJsonDocument doc(128);
|
||||
doc["type"] = laneConfigType == 0 ? "identical" : "different";
|
||||
if (laneConfigType == 1) {
|
||||
doc["lane1Difficulty"] = lane1DifficultyType == 0 ? "light" : "heavy";
|
||||
doc["lane2Difficulty"] = lane2DifficultyType == 0 ? "light" : "heavy";
|
||||
}
|
||||
String result;
|
||||
serializeJson(doc, result);
|
||||
request->send(200, "application/json", result);
|
||||
});
|
||||
|
||||
// Statische Dateien
|
||||
server.serveStatic("/", SPIFFS, "/");
|
||||
server.begin();
|
||||
|
||||
Reference in New Issue
Block a user