Start competition mode
This commit is contained in:
@@ -231,6 +231,43 @@ body {
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
/* Toggle Buttons für Modus-Auswahl */
|
||||
.mode-toggle {
|
||||
display: flex;
|
||||
gap: 0;
|
||||
border: 2px solid #e9ecef;
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
background: white;
|
||||
}
|
||||
|
||||
.mode-button {
|
||||
flex: 1;
|
||||
padding: 15px 25px;
|
||||
border: none;
|
||||
background: white;
|
||||
color: #495057;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.mode-button.active {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.mode-button:not(.active):hover {
|
||||
background: #f8f9fa;
|
||||
color: #667eea;
|
||||
}
|
||||
|
||||
.mode-button:first-child {
|
||||
border-right: 1px solid #e9ecef;
|
||||
}
|
||||
|
||||
.restriction-notice {
|
||||
background: #fff3cd;
|
||||
color: #856404;
|
||||
@@ -306,34 +343,6 @@ body {
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.container {
|
||||
margin: 10px;
|
||||
border-radius: 15px;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.nav-buttons {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.button-group {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.btn {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.time-row {
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.section select {
|
||||
width: 100%;
|
||||
padding: 12px 16px;
|
||||
@@ -372,45 +381,40 @@ body {
|
||||
border-color: #dee2e6;
|
||||
}
|
||||
|
||||
.section select:disabled:hover {
|
||||
border-color: #dee2e6;
|
||||
box-shadow: none;
|
||||
@media (max-width: 600px) {
|
||||
.container {
|
||||
margin: 10px;
|
||||
border-radius: 15px;
|
||||
}
|
||||
|
||||
/* Option Styling */
|
||||
.section select option {
|
||||
padding: 8px;
|
||||
font-size: 16px;
|
||||
background-color: white;
|
||||
color: #333;
|
||||
.content {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.section select option:hover {
|
||||
background-color: #f8f9fa;
|
||||
.nav-buttons {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.section select option:disabled {
|
||||
color: #6c757d;
|
||||
background-color: #f8f9fa;
|
||||
.button-group {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* Form Group für bessere Abstände */
|
||||
.section .form-group {
|
||||
margin-bottom: 20px;
|
||||
.btn {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.section .form-group label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
font-size: 14px;
|
||||
.time-row {
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
/* Responsive Design für kleinere Bildschirme */
|
||||
@media (max-width: 768px) {
|
||||
.section select {
|
||||
font-size: 16px; /* Verhindert Zoom auf iOS */
|
||||
padding: 14px 16px;
|
||||
.mode-toggle {
|
||||
flex-direction: column;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.mode-button:first-child {
|
||||
border-right: none;
|
||||
border-bottom: 1px solid #e9ecef;
|
||||
}
|
||||
}
|
||||
@@ -66,6 +66,30 @@
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Mode Selection Section -->
|
||||
<div class="section">
|
||||
<h2>🎯 Modus</h2>
|
||||
<form id="modeForm">
|
||||
<div class="form-group">
|
||||
<label>Modus auswählen:</label>
|
||||
<div class="mode-toggle">
|
||||
<button type="button" class="mode-button active" data-mode="individual" onclick="selectMode('individual')">
|
||||
👤 Individual
|
||||
</button>
|
||||
<button type="button" class="mode-button" data-mode="wettkampf" onclick="selectMode('wettkampf')">
|
||||
🏆 Wettkampf
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="button-group">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
💾 Modus speichern
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Basic Settings Section -->
|
||||
<div class="section">
|
||||
<h2>🔧 Grundeinstellungen</h2>
|
||||
@@ -464,6 +488,43 @@
|
||||
saveLicence();
|
||||
});
|
||||
|
||||
|
||||
// Mode selection function
|
||||
// Remove active class from all mode buttons
|
||||
function selectMode(mode) {
|
||||
document.querySelectorAll('.mode-button').forEach(button => {
|
||||
button.classList.remove('active');
|
||||
});
|
||||
|
||||
// Add active class to selected button
|
||||
document.querySelector(`[data-mode="${mode}"]`).classList.add('active');
|
||||
}
|
||||
|
||||
// Mode form handler
|
||||
document.getElementById('modeForm').addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const activeButton = document.querySelector('.mode-button.active');
|
||||
const selectedMode = activeButton ? activeButton.getAttribute('data-mode') : 'individual';
|
||||
|
||||
fetch('/api/set-mode', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
body: 'mode=' + encodeURIComponent(selectedMode)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
showMessage('Modus erfolgreich gespeichert!', 'success');
|
||||
} else {
|
||||
showMessage('Fehler beim Speichern des Modus', 'error');
|
||||
}
|
||||
})
|
||||
.catch(error => showMessage('Verbindungsfehler', 'error'));
|
||||
});
|
||||
|
||||
// Einstellungen laden
|
||||
function loadSettings() {
|
||||
fetch("/api/get-settings")
|
||||
|
||||
20
src/gamemodes.h
Normal file
20
src/gamemodes.h
Normal 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
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user