108 lines
2.9 KiB
C++
108 lines
2.9 KiB
C++
#pragma once
|
|
#include <Arduino.h>
|
|
#include <ArduinoJson.h>
|
|
#include <ESPAsyncWebServer.h>
|
|
#include <sys/time.h>
|
|
#include <time.h>
|
|
#include <vector>
|
|
|
|
const char *ssidAP;
|
|
const char *passwordAP = nullptr;
|
|
|
|
char *ssidSTA = nullptr;
|
|
char *passwordSTA = nullptr;
|
|
|
|
// Timer Struktur für Bahn 1
|
|
struct TimerData1 {
|
|
unsigned long startTime = 0;
|
|
unsigned long localStartTime = 0;
|
|
unsigned long finishedSince = 0;
|
|
unsigned long endTime = 0;
|
|
unsigned long bestTime = 0;
|
|
bool isRunning = false;
|
|
bool isReady = true; // Status für Bahn 1
|
|
bool isArmed = false; // Status für Bahn 1 (armiert/nicht armiert)
|
|
char RFIDUID[32] = "";
|
|
};
|
|
|
|
// Struktur für lokale Zeiten (Leaderboard)
|
|
struct LocalTime {
|
|
String uid;
|
|
String name;
|
|
unsigned long timeMs;
|
|
unsigned long timestamp;
|
|
};
|
|
|
|
// Timer Struktur für Bahn 2
|
|
struct TimerData2 {
|
|
unsigned long startTime = 0;
|
|
unsigned long localStartTime = 0;
|
|
unsigned long finishedSince = 0;
|
|
unsigned long endTime = 0;
|
|
unsigned long bestTime = 0;
|
|
bool isRunning = false;
|
|
bool isReady = true; // Status für Bahn 2
|
|
bool isArmed = false; // Status für Bahn 2 (armiert/nicht armiert)
|
|
char RFIDUID[32] = "";
|
|
};
|
|
|
|
// Button Konfiguration
|
|
struct ButtonConfig {
|
|
uint8_t mac[6];
|
|
bool isAssigned = false;
|
|
float voltage = 0.0;
|
|
unsigned long lastHeartbeat = 0; // Zeit des letzten Heartbeats (millis)
|
|
bool heartbeatActive = false; // Status: aktiv/inaktiv
|
|
};
|
|
|
|
struct ButtonConfigs {
|
|
ButtonConfig start1;
|
|
ButtonConfig stop1;
|
|
ButtonConfig start2;
|
|
ButtonConfig stop2;
|
|
};
|
|
|
|
extern const char *firmwareversion;
|
|
|
|
// Globale Variablen
|
|
TimerData1 timerData1;
|
|
TimerData2 timerData2;
|
|
ButtonConfigs buttonConfigs;
|
|
bool learningMode = false;
|
|
int learningStep = 0; // 0=Start1, 1=Stop1, 2=Start2, 3=Stop2
|
|
unsigned long maxTimeBeforeReset = 300000; // 5 Minuten default
|
|
unsigned long maxTimeDisplay = 20000; // 20 Sekunden Standard (in ms)
|
|
unsigned long minTimeForLeaderboard =
|
|
5000; // 5 Sekunden minimum für Leaderboard (in ms)
|
|
bool wifimodeAP = false; // AP-Modus deaktiviert
|
|
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)
|
|
|
|
// Lokales Leaderboard
|
|
std::vector<LocalTime> localTimes;
|
|
|
|
// Function Declarations
|
|
void OnDataRecv(const uint8_t *mac, const uint8_t *incomingData, int len);
|
|
void handleLearningMode(const uint8_t *mac);
|
|
void handleStartLearning();
|
|
void checkAutoReset();
|
|
void saveButtonConfig();
|
|
void loadButtonConfig();
|
|
void saveBestTimes();
|
|
void loadBestTimes();
|
|
void saveSettings();
|
|
void loadSettings();
|
|
void loadWifiSettings();
|
|
void clearLocalLeaderboard();
|
|
void saveWifiSettings();
|
|
void loadLocationSettings();
|
|
void saveLocationSettings();
|
|
void unlearnButton();
|
|
int checkLicence();
|
|
String getTimerDataJSON(); |