diff --git a/data/about.html b/data/about.html deleted file mode 100644 index 7b49b14..0000000 --- a/data/about.html +++ /dev/null @@ -1,480 +0,0 @@ - - - - - - Über NinjaCross Timer - - - - - - ← Zurück zum Timer - - -
-

🏊‍♀️ Über NinjaCross Timer

-

Der professionelle Zeitmesser für Ninjacross Wettkämpfe

-
- -
-
-

🎯 Was ist NinjaCross?

-

- NinjaCross ist ein aufregender Wassersport, der Geschwindigkeit, Technik und Athletik kombiniert. - Teilnehmer durchqueren Schwimmbahnen mit verschiedenen Hindernissen und Herausforderungen, - wobei Zeit und Präzision entscheidend sind. -

-

- Unser Timer-System wurde speziell entwickelt, um professionelle Wettkämpfe zu unterstützen - und präzise Zeitmessungen für bis zu zwei Bahnen gleichzeitig zu ermöglichen. -

-
- -
-

⚡ Funktionen

-
-
-

🎲 Dual-Timer

-

Gleichzeitige Zeitmessung für zwei Bahnen mit präziser Synchronisation

-
-
-

📱 Responsive Design

-

Optimiert für alle Geräte - Desktop, Tablet und Smartphone

-
-
-

🏆 Bestzeiten

-

Automatische Verfolgung und Anzeige der besten Tageszeiten

-
-
-

📚 Lernmodus

-

Interaktiver Modus für Training und Schulungszwecke

-
-
-

⚙️ Einfache Bedienung

-

Intuitive Benutzeroberfläche für schnelle und fehlerfreie Bedienung

-
-
-

🔄 Live-Sync

-

Echtzeitaktualisierung aller Timer-Daten über Backend-Integration

-
-
-
- -
-

📊 Technische Spezifikationen

-
-
- 0.01s - Präzision -
-
- 2 - Bahnen -
-
- 50ms - Update-Rate -
-
- 100% - Responsive -
-
- -

🔧 Technologie-Stack

- -
- -
-

👥 Entwicklung

-
-

🚀 Entwickelt mit ❤️ von Carsten Graf

-

- Dieses Projekt wurde mit Leidenschaft für den NinjaCross-Sport entwickelt, - um Wettkämpfe professioneller und spannender zu gestalten. -

-
-
- -
-

🎮 Bedienung

-

Grundfunktionen

- - -

Status-Anzeigen

- -
- -
-
-

🏁 Bereit für den Wettkampf?

-

- Starten Sie jetzt mit dem professionellen NinjaCross Timer - und erleben Sie präzise Zeitmessung auf höchstem Niveau! -

- Timer starten 🚀 -
-
-
- - - - \ No newline at end of file diff --git a/data/index.css b/data/index.css index 21ab08e..a998911 100644 --- a/data/index.css +++ b/data/index.css @@ -29,8 +29,8 @@ html { position: fixed; top: 20px; left: 20px; - width: 200px; - height: 60px; + width: auto; + height: auto; z-index: 1000; border-radius: 10px; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2); diff --git a/data/index.html b/data/index.html index a925045..e604a6c 100644 --- a/data/index.html +++ b/data/index.html @@ -9,8 +9,7 @@ - ⚙️ @@ -201,8 +200,9 @@ ws.onmessage = (event) => { setInterval(syncFromBackend, 1000); // Smooth update every 50ms - setInterval(updateDisplay, 50); - + setInterval(updateDisplay, 50); + + // Initial load syncFromBackend(); diff --git a/data/ota/firmware.bin b/data/ota/firmware.bin new file mode 100644 index 0000000..ab53524 Binary files /dev/null and b/data/ota/firmware.bin differ diff --git a/platformio.ini b/platformio.ini index f52a88d..514cdc5 100644 --- a/platformio.ini +++ b/platformio.ini @@ -31,6 +31,7 @@ lib_deps = esp32async/AsyncTCP@^3.4.2 mlesniew/PicoMQTT@^1.3.0 miguelbalboa/MFRC522@^1.4.12 + adafruit/RTClib@^2.1.4 [env:wemos_d1_mini32_OTA] board = wemos_d1_mini32 @@ -42,6 +43,7 @@ lib_deps = esp32async/AsyncTCP@^3.4.2 mlesniew/PicoMQTT@^1.3.0 miguelbalboa/MFRC522@^1.4.12 + adafruit/RTClib@^2.1.4 upload_protocol = espota upload_port = 192.168.1.94 @@ -60,6 +62,7 @@ lib_deps = esp32async/AsyncTCP@^3.4.2 mlesniew/PicoMQTT@^1.3.0 miguelbalboa/MFRC522@^1.4.12 + adafruit/RTClib@^2.1.4 [env:esp32thing] board = esp32thing @@ -67,6 +70,8 @@ monitor_speed = 115200 build_flags = -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue +board_upload.flash_size = 16MB +board_build.partitions = default_16MB.csv targets = uploadfs board_build.psram = disabled lib_deps = @@ -76,6 +81,4 @@ lib_deps = esp32async/AsyncTCP@^3.4.2 mlesniew/PicoMQTT@^1.3.0 miguelbalboa/MFRC522@^1.4.12 - - - + adafruit/RTClib@^2.1.4 diff --git a/src/communication.h b/src/communication.h index 76058b0..5b477e4 100644 --- a/src/communication.h +++ b/src/communication.h @@ -54,14 +54,12 @@ void readButtonJSON(const char * topic, const char * payload) { // Extract values from JSON int pressType = doc["type"] | 0; const char* buttonId = doc["buttonmac"] | "unknown"; - const char* messageId = doc["messageId"] | "unknown"; uint64_t timestamp = doc["timestamp"] | 0; // Print received data Serial.printf("Button Press Received:\n"); Serial.printf(" Type: %d\n", pressType); Serial.printf(" Button MAC: %s\n", buttonId); - Serial.printf(" Message ID: %s\n", messageId); Serial.printf(" Timestamp: %llu\n", timestamp); diff --git a/src/statusled.h b/src/statusled.h index 226fb17..0fdb224 100644 --- a/src/statusled.h +++ b/src/statusled.h @@ -3,7 +3,6 @@ #define LED_PIN 13 - // Status LED unsigned long lastLedBlink = 0; bool ledState = false; diff --git a/src/timesync.h b/src/timesync.h index 0e6ab2e..81414fc 100644 --- a/src/timesync.h +++ b/src/timesync.h @@ -5,6 +5,10 @@ #include #include #include +#include +#include "RTClib.h" + +RTC_PCF8523 rtc; // Globale Zeitvariablen struct timeval tv; @@ -12,6 +16,9 @@ struct timezone tz; time_t now; struct tm timeinfo; +//Prototypen für Zeit-Management-Funktionen +void setupRTC(); +void setRTC(DateTime dt); void setupTimeAPI(AsyncWebServer& server); String getCurrentTimeJSON(); bool setSystemTime(long timestamp); @@ -49,6 +56,7 @@ bool setSystemTime(long timestamp) { if (settimeofday(&tv, NULL) == 0) { Serial.println("Zeit erfolgreich gesetzt: " + String(timestamp)); + setRTC(DateTime(timestamp)); return true; } else { Serial.println("Fehler beim Setzen der Zeit"); @@ -58,6 +66,8 @@ bool setSystemTime(long timestamp) { void setupTimeAPI(AsyncWebServer& server) { + setupRTC(); + // API-Endpunkt: Aktuelle Zeit abrufen server.on("/api/time", HTTP_GET, [](AsyncWebServerRequest *request){ String response = getCurrentTimeJSON(); @@ -202,3 +212,37 @@ uint64_t getCurrentTimestampMs() { gettimeofday(&tv, NULL); return (uint64_t)tv.tv_sec * 1000LL + (uint64_t)tv.tv_usec / 1000LL; } + +void setupRTC() { + + Wire.begin(); + + Serial.println("Initialisiere RTC..."); + // Versuche RTC mit Wire zu initialisieren + if (!rtc.begin()) { // Versuche RTC zu initialisieren, Timeout nach 10 Sekunden + Serial.println("RTC nicht gefunden! Versuche erneut..."); + } + + if (!rtc.initialized()) { + Serial.println("RTC nicht initialisiert, versuche Initialisierung..."); + rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); + } else { + Serial.println("RTC bereits initialisiert."); + } + + rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // Setze die RTC auf die Kompilierungszeit + Serial.println("RTC initialisiert."); + // Aktuelle Zeit vom RTC abrufen + DateTime now = rtc.now(); + Serial.printf("Aktuelle RTC-Zeit: %04d-%02d-%02d %02d:%02d:%02d\n", + now.year(), now.month(), now.day(), now.hour(), now.minute(), now.second()); + rtc.start(); // RTC starten, falls gestoppt +} + +// Funktion zum Setzen der RTC-Zeit +void setRTC(DateTime dt) { + rtc.adjust(dt); + DateTime newtime = rtc.now(); + Serial.printf("RTC-Zeit gesetzt: %04d-%02d-%02d %02d:%02d:%02d\n", + newtime.year(), newtime.month(), newtime.day(), newtime.hour(), newtime.minute(), newtime.second()); +} \ No newline at end of file diff --git a/src/wificlass.h b/src/wificlass.h index 9a37a67..6b36082 100644 --- a/src/wificlass.h +++ b/src/wificlass.h @@ -19,11 +19,7 @@ void setupWifi() { uniqueSSID = getUniqueSSID(); ssidAP = uniqueSSID.c_str(); - //print station SSID - Serial.println("Access Point SSID: " + String(ssidSTA)); - Serial.println("Access Point PW: " + String(passwordSTA)); - -if (ssidSTA == nullptr || passwordSTA == nullptr || String(ssidSTA).isEmpty() || String(passwordSTA).isEmpty() ) { + if (ssidSTA == nullptr || passwordSTA == nullptr || String(ssidSTA).isEmpty() || String(passwordSTA).isEmpty() ) { Serial.println("Fehler: ssidSTA oder passwordSTA ist null!"); WiFi.mode(WIFI_MODE_AP); WiFi.softAP(ssidAP, passwordAP);