Start competition mode
This commit is contained in:
@@ -231,6 +231,43 @@ body {
|
|||||||
box-shadow: none !important;
|
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 {
|
.restriction-notice {
|
||||||
background: #fff3cd;
|
background: #fff3cd;
|
||||||
color: #856404;
|
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 {
|
.section select {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 12px 16px;
|
padding: 12px 16px;
|
||||||
@@ -372,45 +381,40 @@ body {
|
|||||||
border-color: #dee2e6;
|
border-color: #dee2e6;
|
||||||
}
|
}
|
||||||
|
|
||||||
.section select:disabled:hover {
|
@media (max-width: 600px) {
|
||||||
border-color: #dee2e6;
|
.container {
|
||||||
box-shadow: none;
|
margin: 10px;
|
||||||
|
border-radius: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Option Styling */
|
.content {
|
||||||
.section select option {
|
padding: 20px;
|
||||||
padding: 8px;
|
|
||||||
font-size: 16px;
|
|
||||||
background-color: white;
|
|
||||||
color: #333;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.section select option:hover {
|
.nav-buttons {
|
||||||
background-color: #f8f9fa;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
.section select option:disabled {
|
.button-group {
|
||||||
color: #6c757d;
|
flex-direction: column;
|
||||||
background-color: #f8f9fa;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Form Group für bessere Abstände */
|
.btn {
|
||||||
.section .form-group {
|
width: 100%;
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.section .form-group label {
|
.time-row {
|
||||||
display: block;
|
flex-direction: column;
|
||||||
margin-bottom: 8px;
|
gap: 10px;
|
||||||
font-weight: 600;
|
|
||||||
color: #333;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Responsive Design für kleinere Bildschirme */
|
.mode-toggle {
|
||||||
@media (max-width: 768px) {
|
flex-direction: column;
|
||||||
.section select {
|
gap: 0;
|
||||||
font-size: 16px; /* Verhindert Zoom auf iOS */
|
}
|
||||||
padding: 14px 16px;
|
|
||||||
|
.mode-button:first-child {
|
||||||
|
border-right: none;
|
||||||
|
border-bottom: 1px solid #e9ecef;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,6 +66,30 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</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 -->
|
<!-- Basic Settings Section -->
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<h2>🔧 Grundeinstellungen</h2>
|
<h2>🔧 Grundeinstellungen</h2>
|
||||||
@@ -464,6 +488,43 @@
|
|||||||
saveLicence();
|
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
|
// Einstellungen laden
|
||||||
function loadSettings() {
|
function loadSettings() {
|
||||||
fetch("/api/get-settings")
|
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)
|
unsigned long maxTimeDisplay = 20000; // 20 Sekunden Standard (in ms)
|
||||||
bool wifimodeAP = false; // AP-Modus deaktiviert
|
bool wifimodeAP = false; // AP-Modus deaktiviert
|
||||||
String masterlocation;
|
String masterlocation;
|
||||||
|
int operationalMode = 0; // 0=Individual, 1=Wettkampf
|
||||||
|
|
||||||
// Function Declarations
|
// Function Declarations
|
||||||
void OnDataRecv(const uint8_t *mac, const uint8_t *incomingData, int len);
|
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}");
|
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
|
// Statische Dateien
|
||||||
server.serveStatic("/", SPIFFS, "/");
|
server.serveStatic("/", SPIFFS, "/");
|
||||||
server.begin();
|
server.begin();
|
||||||
|
|||||||
Reference in New Issue
Block a user