81 lines
2.2 KiB
C
81 lines
2.2 KiB
C
#pragma once
|
|
#include <Arduino.h>
|
|
#include <ArduinoJson.h>
|
|
#include <ESPAsyncWebServer.h>
|
|
#include <sys/time.h>
|
|
#include <time.h>
|
|
|
|
const char *ssidAP;
|
|
const char *passwordAP = nullptr;
|
|
|
|
char *ssidSTA = nullptr;
|
|
char *passwordSTA = nullptr;
|
|
|
|
// Timer Struktur
|
|
struct TimerData {
|
|
unsigned long startTime1 = 0;
|
|
unsigned long startTime2 = 0;
|
|
unsigned long localStartTime1 = 0;
|
|
unsigned long localStartTime2 = 0;
|
|
unsigned long finishedSince1 = 0;
|
|
unsigned long finishedSince2 = 0;
|
|
unsigned long endTime1 = 0;
|
|
unsigned long endTime2 = 0;
|
|
unsigned long bestTime1 = 0;
|
|
unsigned long bestTime2 = 0;
|
|
bool isRunning1 = false;
|
|
bool isRunning2 = false;
|
|
bool isReady1 = true; // Status für Bahn 1
|
|
bool isReady2 = true; // Status für Bahn 2
|
|
};
|
|
|
|
// 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
|
|
TimerData timerData;
|
|
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)
|
|
bool wifimodeAP = false; // AP-Modus deaktiviert
|
|
String masterlocation;
|
|
|
|
// Function Declarations
|
|
void OnDataRecv(const uint8_t *mac, const uint8_t *incomingData, int len);
|
|
void handleLearningMode(const uint8_t *mac);
|
|
void handleStartLearning();
|
|
void handleStart1(uint64_t timestamp);
|
|
void handleStop1(uint64_t timestamp);
|
|
void handleStart2(uint64_t timestamp);
|
|
void handleStop2(uint64_t timestamp);
|
|
void checkAutoReset();
|
|
void saveButtonConfig();
|
|
void loadButtonConfig();
|
|
void saveBestTimes();
|
|
void loadBestTimes();
|
|
void saveSettings();
|
|
void loadSettings();
|
|
void loadWifiSettings();
|
|
void saveWifiSettings();
|
|
void loadLocationSettings();
|
|
void saveLocationSettings();
|
|
void unlearnButton();
|
|
int checkLicence();
|
|
String getTimerDataJSON(); |