From fc052be0571ae83a2e41e4efff2bdc0697c7ca65 Mon Sep 17 00:00:00 2001 From: Felix <337477530+du13500@users.noreply.github.com> Date: Mon, 9 Nov 2026 01:08:50 +0100 Subject: [PATCH 01/10] =?UTF-8?q?v0.5.3-dev:=20Men=C3=BC,=20Vorhersage=20a?= =?UTF-8?q?ls=20Ansicht,=20Typenliste,=20Radar-Optionen,=20Sigma-Delta-Tes?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Webinterface: Menü hinter ☰ statt wischbarer Reiterleiste, Auge-Symbol für getippte Passwörter und Keys - 3-Tage-Vorhersage als eigene Ansicht in der Rotation (Migration der alten Einstellung), Rotation in der Reihenfolge der Liste - AircraftLabel.h: eine Tabelle mit 232 Typen im Flash - Radar: Betreiber A/B/C (MilitaryOperator.h), Geschwindigkeit km/h/kt, Steig-/Sinkpfeil, MIL-Markierung, Notfall-Squawk rot im Wechsel - Filter nach Kategorie und Boden; dafür Abfrage aller Flugzeuge im Radius, einzeln eingelesen (RadarScan.h) - Diagnose: erfolgreiche Radarabrufe als eine Zeile, Zusatzabfragen mit "leer"/"übersprungen", aktuelles Flugzeug im Status - Dimmverfahren Sigma-Delta wählbar (Test gegen Aufblitzen) - Workflow-Bausteine auf Node 24, neue Tests Co-Authored-By: Claude Opus 5.5 --- .github/workflows/build.yml | 11 +- src/AircraftLabel.h | 284 ++++++++++++++++++++++++++++++++++-- src/Diagnostics.cpp | 37 ++++- src/Diagnostics.h | 8 +- src/Flight.cpp | 175 +++++++++++++--------- src/Flight.h | 10 +- src/MilitaryOperator.h | 61 ++++++++ src/RadarFilter.h | 37 +++++ src/RadarScan.h | 44 ++++++ src/Version.h | 2 +- src/main.cpp | 197 +++++++++++++++++-------- src/webui_en.h | 2 +- tests/webui.cjs | 14 +- tools/render_screens.py | 5 + tools/test_brightness.py | 13 +- tools/test_diagnostics.py | 12 ++ tools/test_display.py | 70 +++++++-- tools/test_radar.py | 12 +- tools/test_radar_scan.py | 71 +++++++++ tools/webui_en.py | 22 ++- 20 files changed, 899 insertions(+), 188 deletions(-) create mode 100644 src/MilitaryOperator.h create mode 100644 src/RadarFilter.h create mode 100644 src/RadarScan.h create mode 100644 tools/test_radar_scan.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index defcdad..4a40ad7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Repository auschecken - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Firmwareversion ermitteln id: version @@ -37,12 +37,12 @@ jobs: fi - name: Python einrichten - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: '3.12' - name: Node einrichten - uses: actions/setup-node@v4 + uses: actions/setup-node@v5 with: node-version: '22' @@ -76,6 +76,7 @@ jobs: run: | pio pkg install -e smalltv_ultra python3 tools/test_network_json.py + python3 tools/test_radar_scan.py python3 tools/test_airline_cache.py python3 tools/test_vvo_response.py python3 tools/test_geo_buffer.py @@ -103,7 +104,7 @@ jobs: - name: Firmware hochladen if: always() - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: pixelstop-v${{ steps.version.outputs.version }}-firmware path: dist/firmware/ @@ -111,7 +112,7 @@ jobs: - name: Begleitpaket hochladen if: always() - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: pixelstop-v${{ steps.version.outputs.version }}-begleitpaket path: dist/begleitpaket/ diff --git a/src/AircraftLabel.h b/src/AircraftLabel.h index 7a405ff..98fcf02 100644 --- a/src/AircraftLabel.h +++ b/src/AircraftLabel.h @@ -1,20 +1,274 @@ #pragma once +// Display names for ICAO aircraft type designators, at most 18 characters so +// they fit one line in large type. One code = exactly one text; where ICAO +// itself groups variants under one code, the text names what the code covers. +// Unknown codes are shown as the code itself. The table lives in flash. #include +#include +#ifdef ARDUINO +#include +#else +#ifndef PROGMEM +#define PROGMEM +#endif +#ifndef memcpy_P +#define memcpy_P memcpy +#endif +#endif -// Stable display labels for known ICAO types, independent of metadata wording. -static inline const char* aircraftDisplayLabel(const char* code) { - if(!code||!*code)return nullptr; - struct Label {const char* code;const char* text;}; - static const Label labels[]={ - {"E170","Embraer E170"},{"E175","Embraer E175"}, - {"E75L","Embraer E175"},{"E75S","Embraer E175"}, - {"E190","Embraer E190"},{"E195","Embraer E195"}, - {"E290","Embraer E190-E2"},{"E295","Embraer E195-E2"}, - {"A318","Airbus A318"},{"A319","Airbus A319"},{"A320","Airbus A320"}, - {"A321","Airbus A321"},{"A20N","Airbus A320neo"},{"A21N","Airbus A321neo"}, - {"B737","Boeing 737-700"},{"B738","Boeing 737-800"},{"B739","Boeing 737-900"}, - {"B38M","Boeing 737 MAX 8"},{"B39M","Boeing 737 MAX 9"} +struct AircraftTypeName { char code[5]; char name[19]; }; + +// Copies the display name for the code into out; false if the code is unknown. +inline bool aircraftDisplayLabel(const char* code, char* out, size_t cap) { + static const AircraftTypeName table[] PROGMEM = { + // Airbus + {"A318","Airbus A318"}, + {"A319","Airbus A319"}, + {"A19N","Airbus A319neo"}, + {"A320","Airbus A320"}, + {"A20N","Airbus A320neo"}, + {"A321","Airbus A321"}, + {"A21N","Airbus A321neo"}, + {"BCS1","Airbus A220-100"}, + {"BCS3","Airbus A220-300"}, + {"A306","Airbus A300-600"}, + {"A310","Airbus A310"}, + {"A332","Airbus A330-200"}, + {"A333","Airbus A330-300"}, + {"A338","Airbus A330-800"}, + {"A339","Airbus A330-900"}, + {"A342","Airbus A340-200"}, + {"A343","Airbus A340-300"}, + {"A345","Airbus A340-500"}, + {"A346","Airbus A340-600"}, + {"A359","Airbus A350-900"}, + {"A35K","Airbus A350-1000"}, + {"A388","Airbus A380-800"}, + {"A3ST","Airbus Beluga"}, + {"A337","Airbus BelugaXL"}, + // Boeing + {"B712","Boeing 717-200"}, + {"B732","Boeing 737-200"}, + {"B733","Boeing 737-300"}, + {"B734","Boeing 737-400"}, + {"B735","Boeing 737-500"}, + {"B736","Boeing 737-600"}, + {"B737","Boeing 737-700"}, + {"B738","Boeing 737-800"}, + {"B739","Boeing 737-900"}, + {"B37M","Boeing 737 MAX 7"}, + {"B38M","Boeing 737 MAX 8"}, + {"B39M","Boeing 737 MAX 9"}, + {"B3XM","Boeing 737 MAX 10"}, + {"B742","Boeing 747-200"}, + {"B744","Boeing 747-400"}, + {"B748","Boeing 747-8"}, + {"B752","Boeing 757-200"}, + {"B753","Boeing 757-300"}, + {"B762","Boeing 767-200"}, + {"B763","Boeing 767-300"}, + {"B764","Boeing 767-400"}, + {"B772","Boeing 777-200"}, + {"B77L","Boeing 777-200LR/F"}, + {"B773","Boeing 777-300"}, + {"B77W","Boeing 777-300ER"}, + {"B778","Boeing 777-8"}, + {"B779","Boeing 777-9"}, + {"B788","Boeing 787-8"}, + {"B789","Boeing 787-9"}, + {"B78X","Boeing 787-10"}, + // McDonnell Douglas + {"MD11","MD-11"}, + {"DC10","DC-10"}, + {"MD82","MD-82"}, + {"MD83","MD-83"}, + {"MD88","MD-88"}, + {"MD90","MD-90"}, + // Embraer + {"E135","Embraer ERJ-135"}, + {"E145","Embraer ERJ-145"}, + {"E170","Embraer E170"}, + {"E75S","Embraer E175 SW"}, + {"E75L","Embraer E175 LW"}, + {"E190","Embraer E190"}, + {"E195","Embraer E195"}, + {"E290","Embraer E190-E2"}, + {"E295","Embraer E195-E2"}, + {"E120","Embraer EMB-120"}, + // Regional + {"CRJ1","Bombardier CRJ100"}, + {"CRJ2","Bombardier CRJ200"}, + {"CRJ7","Bombardier CRJ700"}, + {"CRJ9","Bombardier CRJ900"}, + {"CRJX","Bombardier CRJ1000"}, + {"DH8A","Dash 8-100"}, + {"DH8B","Dash 8-200"}, + {"DH8C","Dash 8-300"}, + {"DH8D","Dash 8-400"}, + {"AT43","ATR 42-300/320"}, + {"AT45","ATR 42-500"}, + {"AT46","ATR 42-600"}, + {"AT72","ATR 72-200"}, + {"AT75","ATR 72-500"}, + {"AT76","ATR 72-600"}, + {"SF34","Saab 340"}, + {"SB20","Saab 2000"}, + {"F70","Fokker 70"}, + {"F100","Fokker 100"}, + {"RJ85","Avro RJ85"}, + {"RJ1H","Avro RJ100"}, + {"B461","BAe 146-100"}, + {"B462","BAe 146-200"}, + {"B463","BAe 146-300"}, + {"D328","Dornier 328"}, + {"J328","Dornier 328JET"}, + {"D228","Dornier 228"}, + {"DHC6","DHC-6 Twin Otter"}, + {"B190","Beech 1900"}, + {"JS41","Jetstream 41"}, + {"SU95","Sukhoi Superjet"}, + {"C919","COMAC C919"}, + {"AJ27","COMAC ARJ21"}, + // Fracht & Schwer + {"A124","Antonov An-124"}, + {"AN12","Antonov An-12"}, + {"IL76","Ilyushin Il-76"}, + // Russland & GUS + {"T154","Tupolev Tu-154"}, + {"T204","Tupolev Tu-204"}, + {"T214","Tupolev Tu-214"}, + {"IL62","Ilyushin Il-62"}, + {"IL96","Ilyushin Il-96"}, + {"A148","Antonov An-148"}, + {"AN24","Antonov An-24"}, + {"AN26","Antonov An-26"}, + {"AN72","Antonov An-72"}, + {"YK40","Yakovlev Jak-40"}, + {"YK42","Yakovlev Jak-42"}, + {"MI8","Mil Mi-8"}, + // Militär + {"C17","Boeing C-17A"}, + {"A400","Airbus A400M"}, + {"C130","Lockheed C-130"}, + {"C30J","Lockheed C-130J"}, + {"C5M","Lockheed C-5M"}, + {"K35R","Boeing KC-135R"}, + {"E3TF","Boeing E-3 AWACS"}, + {"P8","Boeing P-8A"}, + {"P3","Lockheed P-3 Orion"}, + {"C295","Airbus C295"}, + {"CN35","CASA CN-235"}, + {"C160","Transall C-160"}, + {"EUFI","Eurofighter"}, + {"TOR","Panavia Tornado"}, + {"F35","Lockheed F-35"}, + {"F16","Lockheed F-16"}, + {"B52","Boeing B-52"}, + {"B1","Boeing B-1B"}, + {"B2","Northrop B-2"}, + {"R135","Boeing RC-135"}, + {"E6","Boeing E-6 Mercury"}, + {"C5","Lockheed C-5"}, + {"U2","Lockheed U-2"}, + {"F15","Boeing F-15"}, + {"F18","Boeing F/A-18"}, + {"F22","Lockheed F-22"}, + {"A10","Fairchild A-10"}, + {"E2","Northrop E-2"}, + {"T38","Northrop T-38"}, + {"H64","Boeing AH-64"}, + {"H53","Sikorsky CH-53"}, + {"V22","Bell Boeing V-22"}, + // Business + {"C510","Citation Mustang"}, + {"C525","Citation CJ1"}, + {"C25A","Citation CJ2"}, + {"C25B","Citation CJ3"}, + {"C25C","Citation CJ4"}, + {"C56X","Citation Excel/XLS"}, + {"C68A","Citation Latitude"}, + {"C700","Citation Longitude"}, + {"C750","Citation X"}, + {"E50P","Embraer Phenom 100"}, + {"E55P","Embraer Phenom 300"}, + {"E35L","Legacy 600/650"}, + {"CL30","Challenger 300"}, + {"CL35","Challenger 350"}, + {"CL60","Challenger 6XX"}, + {"GL5T","Global 5000"}, + {"GLEX","Global Express"}, + {"GL7T","Global 7500"}, + {"LJ35","Learjet 35"}, + {"LJ45","Learjet 45"}, + {"LJ60","Learjet 60"}, + {"LJ75","Learjet 75"}, + {"F2TH","Falcon 2000"}, + {"FA50","Falcon 50"}, + {"F900","Falcon 900"}, + {"FA7X","Falcon 7X"}, + {"FA8X","Falcon 8X"}, + {"GLF4","Gulfstream IV/G450"}, + {"GLF5","Gulfstream V/G550"}, + {"GLF6","Gulfstream G650"}, + {"G280","Gulfstream G280"}, + {"GA5C","Gulfstream G500"}, + {"GA6C","Gulfstream G600"}, + {"H25B","Hawker 800/900"}, + {"HDJT","HondaJet"}, + {"PC24","Pilatus PC-24"}, + {"SF50","Cirrus Vision Jet"}, + // Allgemeine Luftfahrt + {"C152","Cessna 152"}, + {"C172","Cessna 172"}, + {"C182","Cessna 182"}, + {"C206","Cessna 206"}, + {"C208","Cessna 208 Caravan"}, + {"P28A","Piper PA-28"}, + {"PA34","Piper PA-34 Seneca"}, + {"SR20","Cirrus SR20"}, + {"SR22","Cirrus SR22"}, + {"DA20","Diamond DA20"}, + {"DA40","Diamond DA40"}, + {"DA42","Diamond DA42"}, + {"DA62","Diamond DA62"}, + {"PC12","Pilatus PC-12"}, + {"PC21","Pilatus PC-21"}, + {"BE9L","King Air 90"}, + {"BE20","King Air 200/250"}, + {"B350","King Air 350"}, + {"TBM7","Daher TBM 700"}, + {"TBM8","Daher TBM 850"}, + {"TBM9","Daher TBM 900-960"}, + {"GLID","Segelflugzeug"}, + {"BALL","Ballon"}, + {"ULAC","Ultraleicht"}, + // Hubschrauber + {"EC20","Airbus H120"}, + {"AS50","Airbus H125/AS350"}, + {"EC30","Airbus H130"}, + {"EC35","Airbus H135"}, + {"EC45","Airbus H145"}, + {"EC55","Airbus H155"}, + {"EC75","Airbus H175"}, + {"BK17","MBB BK 117"}, + {"A109","Leonardo AW109"}, + {"A139","Leonardo AW139"}, + {"A169","Leonardo AW169"}, + {"A189","Leonardo AW189"}, + {"NH90","NH90"}, + {"H60","Sikorsky H-60"}, + {"S92","Sikorsky S-92"}, + {"CH47","Boeing CH-47"}, + {"B06","Bell 206"}, + {"B407","Bell 407"}, + {"B412","Bell 412"}, + {"R22","Robinson R22"}, + {"R44","Robinson R44"}, }; - for(const auto& label:labels)if(!strcmp(code,label.code))return label.text; - return nullptr; + if (!code || !*code || !out || !cap) return false; + for (size_t i = 0; i < sizeof(table) / sizeof(table[0]); i++) { + AircraftTypeName e; memcpy_P(&e, &table[i], sizeof(e)); + if (!strcmp(code, e.code)) { strncpy(out, e.name, cap - 1); out[cap - 1] = 0; return true; } + } + return false; } diff --git a/src/Diagnostics.cpp b/src/Diagnostics.cpp index 83272dc..6ef210c 100644 --- a/src/Diagnostics.cpp +++ b/src/Diagnostics.cpp @@ -11,35 +11,56 @@ static Marker marker={},previous={};static bool previousValid=false; static char resetReason[64]={},resetInfo[192]={}; static uint32_t deferredAt=0,deferredFor=0; static const char ops[][20] PROGMEM={"Start","Radar.Position","Radar.Route","Radar.Metadata","Radar.Airline","Wetter","VVO.Abfahrten","VVO.Suche","Ort.Suche","Ort.Karte","Tracker.Status","Tracker.Position","Tracker.Route","Speichern","Neustart","Countdown","WLAN"}; -static const char stages[][24] PROGMEM={"Start","TLS","HTTP","JSON","OK","Fehler","Heap-knapp","Pause","leer","Antwortformat","JSON:NoMemory","JSON:IncompleteInput","JSON:EmptyInput","JSON:TooDeep","JSON:InvalidInput","Empfang:Fehler","Datei:Fehler","Antwort:ZuGross","Geo:Vorbereitung","Geo:Verbinden","Geo:Empfang","Geo:TLS-frei"}; +static const char stages[][24] PROGMEM={"Start","TLS","HTTP","JSON","OK","Fehler","Heap-knapp","Pause","leer","Antwortformat","JSON:NoMemory","JSON:IncompleteInput","JSON:EmptyInput","JSON:TooDeep","JSON:InvalidInput","Empfang:Fehler","Datei:Fehler","Antwort:ZuGross","Geo:Vorbereitung","Geo:Verbinden","Geo:Empfang","Geo:TLS-frei","übersprungen"}; static uint32_t checksum(const Marker& m){uint32_t h=2166136261UL;const uint8_t* p=(const uint8_t*)&m;for(size_t i=0;i=DS_JSON_MEMORY&&stage<=DS_RESPONSE_LIMIT)){lastError=e;hasLastError=true;strlcpy(lastErrorLookup,lookupContext,sizeof(lastErrorLookup));} marker.at=e.at;marker.heap=e.heap;marker.block=e.block;marker.value=value;marker.code=(uint32_t)(int32_t)code;marker.op=op;marker.stage=stage;writeMarker(); } void deferBackgroundNetwork(uint32_t ms){deferredAt=millis();deferredFor=ms;} bool backgroundNetworkReady(){return (uint32_t)(millis()-deferredAt)>=deferredFor;} -DiagRequest::DiagRequest(DiagOp op):op_(op),started_(millis()){diagEvent(op_,DS_BEGIN);} -DiagRequest::~DiagRequest(){diagEvent(op_,result_,code_,millis()-started_);deferBackgroundNetwork();} -void DiagRequest::stage(DiagStage stage){diagEvent(op_,stage,code_);} -void DiagRequest::http(int code){code_=code;diagEvent(op_,DS_HTTP,code);} +void DiagRequest::note(DiagStage stage,int code){ + if(!compact_){diagEvent(op_,stage,code);return;} + Event e={millis(),ESP.getFreeHeap(),ESP.getMaxFreeBlockSize(),0,(int16_t)code,(uint8_t)op_,(uint8_t)stage}; + if(e.heap enum DiagOp : uint8_t { D_BOOT,D_RADAR,D_RADAR_ROUTE,D_METADATA,D_AIRLINE,D_WEATHER,D_VVO,D_STOP_SEARCH,D_GEO_SEARCH,D_GEO_REVERSE,D_TRACK_STATUS,D_TRACK_LIVE,D_TRACK_ROUTE,D_CONFIG,D_REBOOT,D_COUNTDOWN,D_WIFI,D_COUNT }; -enum DiagStage : uint8_t { DS_BEGIN,DS_TLS,DS_HTTP,DS_JSON,DS_DONE,DS_FAILED,DS_HEAP,DS_WAIT,DS_EMPTY,DS_SCHEMA,DS_JSON_MEMORY,DS_JSON_INCOMPLETE,DS_JSON_EMPTY,DS_JSON_DEPTH,DS_JSON_INVALID,DS_TRANSFER_ERROR,DS_FILE_ERROR,DS_RESPONSE_LIMIT,DS_GEO_PREPARE,DS_GEO_CONNECT,DS_GEO_RECEIVE,DS_GEO_RELEASE }; +enum DiagStage : uint8_t { DS_BEGIN,DS_TLS,DS_HTTP,DS_JSON,DS_DONE,DS_FAILED,DS_HEAP,DS_WAIT,DS_EMPTY,DS_SCHEMA,DS_JSON_MEMORY,DS_JSON_INCOMPLETE,DS_JSON_EMPTY,DS_JSON_DEPTH,DS_JSON_INVALID,DS_TRANSFER_ERROR,DS_FILE_ERROR,DS_RESPONSE_LIMIT,DS_GEO_PREPARE,DS_GEO_CONNECT,DS_GEO_RECEIVE,DS_GEO_RELEASE,DS_SKIPPED }; void diagInit(); void diagEvent(DiagOp op,DiagStage stage,int code=0,uint32_t value=0); void diagLookup(const char* aircraft,const char* callsign); @@ -9,8 +9,14 @@ void diagPrint(Print& out); const char* diagResetReason(); bool backgroundNetworkReady(); void deferBackgroundNetwork(uint32_t ms=750); +// Radar positions run every few seconds: a successful request is logged as a +// single line (with the lowest heap seen during it); the individual steps are +// only written when the request fails. Other requests log every step. class DiagRequest { DiagOp op_; uint32_t started_; int code_=0; DiagStage result_=DS_FAILED; + bool compact_; uint8_t pending_=0; uint32_t minHeap_=0xFFFFFFFFUL,minBlock_=0xFFFFFFFFUL; + struct Step { uint32_t at,heap,block; int16_t code; uint8_t stage; } steps_[6]; + void note(DiagStage stage,int code); public: explicit DiagRequest(DiagOp op); ~DiagRequest(); diff --git a/src/Flight.cpp b/src/Flight.cpp index ea1c809..1968cfe 100644 --- a/src/Flight.cpp +++ b/src/Flight.cpp @@ -1,6 +1,9 @@ #include "Version.h" #include "Flight.h" #include "AircraftPolicy.h" +#include "AircraftLabel.h" +#include "RadarFilter.h" +#include "RadarScan.h" #include "RadarPolicy.h" #include "RequestPolicy.h" #include "RoutePolicy.h" @@ -40,6 +43,7 @@ static uint32_t g_lastEnrichmentMs=0; static const char* g_routeStatus="nicht geprüft"; static const char* g_routeSource="keine"; static int g_routeHttp=0; +static uint16_t g_scanned=0; static float g_homeLat=NAN,g_homeLon=NAN; static uint32_t g_intervalMs=0; @@ -71,7 +75,7 @@ static float distanceKm(float lat1, float lon1, float lat2, float lon2) { return radarFlatDistanceKm(lat1, lon1, lat2, lon2); } -// Fallback names for common airlines and aircraft types. The tables live in +// Fallback names for common airlines (aircraft types: AircraftLabel.h). The tables live in // flash (PROGMEM) and the match is copied into the caller's buffer. struct NameEntry4 { char key[5]; char name[20]; }; static const NameEntry4 AIRLINE_NAMES[] PROGMEM = { @@ -82,17 +86,6 @@ static const NameEntry4 AIRLINE_NAMES[] PROGMEM = { {"BEL","Brussels Airlines"},{"UAE","Emirates"},{"QTR","Qatar Airways"},{"EXS","Jet2"}, {"TUI","TUI"},{"ITY","ITA Airways"},{"IBE","Iberia"},{"VLG","Vueling"} }; -static const NameEntry4 TYPE_NAMES[] PROGMEM = { - {"A20N","Airbus A320neo"},{"A21N","Airbus A321neo"},{"A320","Airbus A320"}, - {"A321","Airbus A321"},{"A319","Airbus A319"},{"A318","Airbus A318"}, - {"A359","Airbus A350-900"},{"A35K","Airbus A350-1000"},{"A333","Airbus A330-300"}, - {"A332","Airbus A330-200"},{"B738","Boeing 737-800"},{"B737","Boeing 737-700"}, - {"B38M","Boeing 737 MAX 8"},{"B39M","Boeing 737 MAX 9"},{"B788","Boeing 787-8"}, - {"B789","Boeing 787-9"},{"B772","Boeing 777-200"},{"B77W","Boeing 777-300ER"}, - {"E190","Embraer E190"},{"E195","Embraer E195"},{"E290","Embraer E190-E2"}, - {"E295","Embraer E195-E2"},{"CRJ9","CRJ900"},{"BCS1","Airbus A220-100"}, - {"BCS3","Airbus A220-300"},{"AT76","ATR 72-600"},{"DH8D","Dash 8 Q400"} -}; // Copies the name for `key` (first `keyLen` chars, 0 = whole key) or `fallback`. static void nameFromTable(const NameEntry4* table, size_t count, const char* key, size_t keyLen, @@ -112,7 +105,9 @@ static RoutePoint jsonPoint(JsonObjectConst o,const char* latKey,const char* lon } static bool lookupRouteAdsbLol(const FlightSnapshot& f,RoutePoint pos,Enrichment& out) { - if(adsbLolBudgetLow()||serviceWaitMs(SERVICE_ADSB_LOL)||serviceMinIntervalMs(SERVICE_ADSB_LOL)||!tlsHeapReady(adsbLolRx()))return false; + // Skipped requests are logged with a reason (value): 1 budget, 2 pause, 3 minimum interval, 4 memory. + uint8_t skip=adsbLolBudgetLow()?1:(serviceWaitMs(SERVICE_ADSB_LOL)?2:(serviceMinIntervalMs(SERVICE_ADSB_LOL)?3:(!tlsHeapReady(adsbLolRx())?4:0))); + if(skip){diagLookup(f.hex,f.callsign);diagEvent(D_RADAR_ROUTE,DS_SKIPPED,0,skip);return false;} DiagRequest trace(D_RADAR_ROUTE);diagLookup(f.hex,f.callsign);trace.stage(DS_TLS); BearSSL::WiFiClientSecure client;makeSecure(client,&g_routeSession,adsbLolRx()); HTTPClient http;http.setTimeout(5000);http.setReuse(false); @@ -126,23 +121,26 @@ static bool lookupRouteAdsbLol(const FlightSnapshot& f,RoutePoint pos,Enrichment int code=http.POST(body);request.clear();body=String();trace.http(code);g_routeHttp=code; serviceResponse(SERVICE_ADSB_LOL,code,http.header("Retry-After").c_str()); if(serviceWaitMs(SERVICE_ADSB_LOL))diagEvent(D_RADAR,DS_WAIT,code,serviceWaitMs(SERVICE_ADSB_LOL)); - if(code!=200){if(code==201)trace.stage(DS_EMPTY);http.end();client.stop();return false;} + if(code!=200){if(code==201)trace.finish(true,DS_EMPTY);http.end();client.stop();return false;} JsonDocument filter(networkJsonAllocator());JsonObject item=filter.to().add(); item["callsign"]=true;item["plausible"]=true;item["_airport_codes_iata"]=true; JsonObject ap=item["_airports"].to().add();ap["lat"]=true;ap["lon"]=true; trace.stage(DS_JSON);JsonDocument doc(networkJsonAllocator());if(!jsonFilterReady(filter,trace)){http.end();client.stop();return false;}AdsbLolBody routeBody(http);auto err=deserializeJson(doc,routeBody,DeserializationOption::Filter(filter));logJsonError(trace,err); filter.clear(); http.end(); client.stop(); - if(err||!doc.is()||!doc.size())return false; + if(err)return false; + // From here the answer was read; "leer" = no usable route for this flight. + if(!doc.is()||!doc.size()){trace.finish(true,DS_EMPTY);return false;} JsonObjectConst r=doc[0]; - if(strcmp(r["callsign"]|"",f.callsign)||!r["plausible"].is()||!r["plausible"].as())return false; - FlightRoute route={};if(!parseFlightRoute(r["_airport_codes_iata"]|"",route)||route.truncated)return false; - JsonArrayConst airports=r["_airports"];if(airports.size()!=route.count)return false; + if(strcmp(r["callsign"]|"",f.callsign)||!r["plausible"].is()||!r["plausible"].as()){trace.finish(true,DS_EMPTY);return false;} + FlightRoute route={};if(!parseFlightRoute(r["_airport_codes_iata"]|"",route)||route.truncated){trace.finish(true,DS_EMPTY);return false;} + JsonArrayConst airports=r["_airports"];if(airports.size()!=route.count){trace.finish(true,DS_EMPTY);return false;} for(uint8_t i=0;i(); @@ -288,6 +287,7 @@ bool flightPollDue(uint16_t pollSec, float visibleShare) { } const FlightSnapshot& flightData() { return g_f; } +uint16_t flightLastScanned() { return g_scanned; } uint32_t flightPollIntervalMs() { return g_intervalMs ? g_intervalMs : RADAR_MOTION_MIN_MS; } float flightLiveDistanceKm(const FlightSnapshot& f) { if(!f.valid||!f.motion.hasMotion||isnan(g_homeLat)||isnan(g_homeLon))return f.distanceKm; @@ -336,7 +336,62 @@ static void flightSuccess(const char* stage = "ok") { g_lastOkMs = millis(); } -bool flightFetch(float homeLat, float homeLon, uint16_t radiusKm) { +// Fields the radar reads per aircraft. +static void addAircraftFields(JsonObject f) { + f["flight"] = true; f["r"] = true; f["t"] = true; f["category"] = true; + f["lat"] = true; f["lon"] = true; f["alt_baro"] = true; f["hex"] = true; + f["gs"] = true; f["track"] = true; f["baro_rate"] = true; f["geom_rate"] = true; f["seen_pos"] = true; + f["squawk"] = true; f["dbFlags"] = true; +} + +// One aircraft object into a snapshot; false without a usable position. +static bool readAircraft(JsonObjectConst a, float homeLat, float homeLon, FlightSnapshot& next) { + strlcpy(next.origin,"N/A",sizeof(next.origin)); + strlcpy(next.destination,"N/A",sizeof(next.destination)); + const char* rawCall = a["flight"] | (a["hex"] | ""); + strlcpy(next.callsign, rawCall, sizeof(next.callsign)); + trimTail(next.callsign); + strlcpy(next.hex, a["hex"] | "", sizeof(next.hex)); + strlcpy(next.registration, a["r"] | "", sizeof(next.registration)); + strlcpy(next.category,a["category"]|"",sizeof(next.category)); + strlcpy(next.typeCode, a["t"] | "", sizeof(next.typeCode)); + strlcpy(next.squawk, a["squawk"] | "", sizeof(next.squawk)); + next.military = ((int)(a["dbFlags"] | 0)) & 1; + next.onGround=a["alt_baro"].is()&&!strcmp(a["alt_baro"].as(),"ground"); + next.altitudeKnown=a["alt_baro"].is(); + next.altitudeFt=next.altitudeKnown?(int32_t)lroundf(a["alt_baro"].as()):0; + float acLat = NAN, acLon = NAN; + if (a["lat"].is()) acLat = a["lat"].as(); + if (a["lon"].is()) acLon = a["lon"].as(); + if(!isfinite(acLat)||!isfinite(acLon)||acLat<-90||acLat>90||acLon<-180||acLon>180)return false; + next.distanceKm = distanceKm(homeLat, homeLon, acLat, acLon); + // Motion for estimates until the next request (not on the ground). + RadarMotion& m = next.motion; + m.lat = acLat; m.lon = acLon; + float seen = a["seen_pos"] | 0.0f; + if (!(seen >= 0.0f) || seen > 60.0f) seen = 0.0f; + m.sampleMs = millis() - (uint32_t)(seen * 1000.0f); + float gs = a["gs"] | -1.0f, track = a["track"] | -1.0f; + next.speedKnown = gs >= 0.0f && gs <= 800.0f; + next.speedKt = next.speedKnown ? gs : 0.0f; + m.hasMotion = !next.onGround && next.speedKnown && track >= 0.0f && track <= 360.0f; + m.speedKt = m.hasMotion ? gs : 0.0f; + m.trackDeg = m.hasMotion ? track : 0.0f; + JsonVariantConst rate = a["baro_rate"].is() ? a["baro_rate"] : a["geom_rate"]; + m.hasRate = !next.onGround && next.altitudeKnown && rate.is() && fabsf(rate.as()) <= 8000.0f; + m.rateFpm = m.hasRate ? rate.as() : 0.0f; + return true; +} + +// Names from the built-in tables, only for the aircraft that is shown. +static void labelAircraft(FlightSnapshot& f) { + if(!aircraftDisplayLabel(f.typeCode, f.typeName, sizeof(f.typeName))) strlcpy(f.typeName, f.typeCode, sizeof(f.typeName)); + nameFromTable(AIRLINE_NAMES, sizeof(AIRLINE_NAMES)/sizeof(AIRLINE_NAMES[0]), f.callsign, 3, "", f.airline, sizeof(f.airline)); +} + +bool flightFetch(float homeLat, float homeLon, uint16_t radiusKm, uint8_t hideMask) { + const bool scan = hideMask != 0; + g_scanned = 0; if(serviceWaitMs(SERVICE_ADSB_LOL))return false; DiagRequest trace(D_RADAR); struct Completion {~Completion(){g_lastPollMs=millis();}} completion; @@ -365,7 +420,7 @@ bool flightFetch(float homeLat, float homeLon, uint16_t radiusKm) { http.setTimeout(5000); http.setReuse(false); - String url = F("https://api.adsb.lol/v2/closest/"); + String url = scan ? F("https://api.adsb.lol/v2/point/") : F("https://api.adsb.lol/v2/closest/"); url += String(homeLat, 4); url += '/'; url += String(homeLon, 4); url += '/'; url += String(radiusNm); @@ -380,57 +435,47 @@ bool flightFetch(float homeLat, float homeLon, uint16_t radiusKm) { if (code != HTTP_CODE_OK) { http.end(); client.stop(); const bool paused=(code==429||code==503)&&serviceWaitMs(SERVICE_ADSB_LOL);return flightFailure(adsbLolAccessDenied(code)?"Zugriff abgelehnt":(paused?"Abrufpause: Anbieter":(code < 0 ? "Verbindung fehlgeschlagen" : "HTTP-Fehler")),paused); } JsonDocument filter(networkJsonAllocator()); - JsonObject f = filter["ac"][0].to(); - f["flight"] = true; f["r"] = true; f["t"] = true; f["category"] = true; - f["lat"] = true; f["lon"] = true; f["alt_baro"] = true; f["hex"] = true; - f["gs"] = true; f["track"] = true; f["baro_rate"] = true; f["geom_rate"] = true; f["seen_pos"] = true; + addAircraftFields(scan ? filter.to() : filter["ac"][0].to()); JsonDocument doc(networkJsonAllocator()); trace.stage(DS_JSON); if(!jsonFilterReady(filter,trace)){http.end();client.stop();return flightFailure("JSON-Speicher knapp");} AdsbLolBody body(http); - auto err = deserializeJson(doc, body, DeserializationOption::Filter(filter)); - logJsonError(trace,err); filter.clear(); http.end(); client.stop(); - if (err) return flightFailure("JSON-Fehler"); - - JsonArrayConst ac = doc["ac"].as(); - if(ac.isNull()){trace.stage(DS_SCHEMA);return flightFailure("Antwortformat-Fehler");} - if (ac.size() == 0) { + bool found = false; + if (!scan) { + auto err = deserializeJson(doc, body, DeserializationOption::Filter(filter)); + logJsonError(trace,err); filter.clear(); http.end(); client.stop(); + if (err) return flightFailure("JSON-Fehler"); + JsonArrayConst ac = doc["ac"].as(); + if(ac.isNull()){trace.stage(DS_SCHEMA);return flightFailure("Antwortformat-Fehler");} + if (ac.size()) { + if(!readAircraft(ac[0].as(),homeLat,homeLon,next)){trace.stage(DS_SCHEMA);return flightFailure("Positionsdaten fehlen");} + found = true; + } + } else { + // All aircraft in the radius, read one at a time (RadarScan.h). + FlightSnapshot cand; + DeserializationError err; + g_scanned = radarScanArray(body, doc, filter, [&](JsonObjectConst a) { + memset(&cand, 0, sizeof(cand)); + if (!readAircraft(a, homeLat, homeLon, cand) || radarHidden(cand.category, cand.onGround, hideMask)) return; + if (!found || cand.distanceKm < next.distanceKm) { next = cand; found = true; } + yield(); + }, err); + if (err) { + logJsonError(trace,err); filter.clear(); http.end(); client.stop(); + if (err == DeserializationError::InvalidInput && !g_scanned) { trace.stage(DS_SCHEMA); return flightFailure("Antwortformat-Fehler"); } + return flightFailure("JSON-Fehler"); + } + filter.clear(); http.end(); client.stop(); + } + if (!found) { memset(&g_f, 0, sizeof(g_f)); g_f.error = false; flightSuccess("keine Flugzeuge");trace.finish(true,DS_EMPTY); return true; } - - JsonObjectConst a = ac[0].as(); - const char* rawCall = a["flight"] | (a["hex"] | ""); - strlcpy(next.callsign, rawCall, sizeof(next.callsign)); - trimTail(next.callsign); - strlcpy(next.hex, a["hex"] | "", sizeof(next.hex)); - strlcpy(next.registration, a["r"] | "", sizeof(next.registration)); - strlcpy(next.category,a["category"]|"",sizeof(next.category)); - strlcpy(next.typeCode, a["t"] | "", sizeof(next.typeCode)); - nameFromTable(TYPE_NAMES, sizeof(TYPE_NAMES)/sizeof(TYPE_NAMES[0]), next.typeCode, 0, next.typeCode, next.typeName, sizeof(next.typeName)); - nameFromTable(AIRLINE_NAMES, sizeof(AIRLINE_NAMES)/sizeof(AIRLINE_NAMES[0]), next.callsign, 3, "", next.airline, sizeof(next.airline)); - next.onGround=a["alt_baro"].is()&&!strcmp(a["alt_baro"].as(),"ground"); - next.altitudeKnown=a["alt_baro"].is(); - next.altitudeFt=next.altitudeKnown?(int32_t)lroundf(a["alt_baro"].as()):0; - if (a["lat"].is() || a["lat"].is()) acLat = a["lat"].as(); - if (a["lon"].is() || a["lon"].is()) acLon = a["lon"].as(); - if(!isfinite(acLat)||!isfinite(acLon)||acLat<-90||acLat>90||acLon<-180||acLon>180){trace.stage(DS_SCHEMA);return flightFailure("Positionsdaten fehlen");} - if (!isnan(acLat) && !isnan(acLon)) next.distanceKm = distanceKm(homeLat, homeLon, acLat, acLon); - // Motion for estimates until the next request (not on the ground). - RadarMotion& m = next.motion; - m.lat = acLat; m.lon = acLon; - float seen = a["seen_pos"] | 0.0f; - if (!(seen >= 0.0f) || seen > 60.0f) seen = 0.0f; - m.sampleMs = millis() - (uint32_t)(seen * 1000.0f); - float gs = a["gs"] | -1.0f, track = a["track"] | -1.0f; - m.hasMotion = !next.onGround && gs >= 0.0f && gs <= 800.0f && track >= 0.0f && track <= 360.0f; - m.speedKt = m.hasMotion ? gs : 0.0f; - m.trackDeg = m.hasMotion ? track : 0.0f; - JsonVariantConst rate = a["baro_rate"].is() ? a["baro_rate"] : a["geom_rate"]; - m.hasRate = !next.onGround && next.altitudeKnown && rate.is() && fabsf(rate.as()) <= 8000.0f; - m.rateFpm = m.hasRate ? rate.as() : 0.0f; + labelAircraft(next); + acLat = next.motion.lat; acLon = next.motion.lon; next.valid = true; next.error = false; } diff --git a/src/Flight.h b/src/Flight.h index 4183825..74c7a6f 100644 --- a/src/Flight.h +++ b/src/Flight.h @@ -21,12 +21,20 @@ struct FlightSnapshot { bool altitudeKnown; bool onGround; RadarMotion motion; // for estimates between requests + char squawk[5]; // transponder code, "7700" etc. + bool military; // adsb.lol database flag + bool speedKnown; + float speedKt; // ground speed }; void flightReset(); // visibleShare: fraction of the time the radar is on screen (for the daily budget). bool flightPollDue(uint16_t pollSec, float visibleShare = 1.0f); -bool flightFetch(float homeLat, float homeLon, uint16_t radiusKm); +// hideMask (RadarFilter.h) > 0 asks for all aircraft in the radius and picks the +// nearest one that is not hidden; 0 asks adsb.lol for the nearest aircraft only. +bool flightFetch(float homeLat, float homeLon, uint16_t radiusKm, uint8_t hideMask = 0); +// Aircraft examined in the last filtered request (0 without filter). +uint16_t flightLastScanned(); const FlightSnapshot& flightData(); // Distance and altitude continued from speed, track and vertical rate. float flightLiveDistanceKm(const FlightSnapshot& f); diff --git a/src/MilitaryOperator.h b/src/MilitaryOperator.h new file mode 100644 index 0000000..681c580 --- /dev/null +++ b/src/MilitaryOperator.h @@ -0,0 +1,61 @@ +#pragma once +// Branch names for well-known military callsign prefixes, for the radar's +// operator display (variant B: branch, variant C: branch / unit). Unknown +// callsigns return false, so the display keeps the name of the callsign (A). +#include +#include +#include + +struct MilitaryOperator { const char* prefix; const char* de; const char* en; const char* unit; }; + +inline const MilitaryOperator* militaryOperatorFor(const char* callsign) { + static const MilitaryOperator table[] = { + {"RCH","US Air Force","US Air Force","AMC"}, // Air Mobility Command ("Reach") + {"SAM","US Air Force","US Air Force","SAM"}, // Special Air Mission + {"CNV","US Navy","US Navy",""}, + {"PAT","US Army","US Army",""}, + {"GAF","Luftwaffe","German Air Force",""}, + {"GAM","Heer","German Army",""}, + {"GNY","Marine","German Navy",""}, + {"RRR","Royal Air Force","Royal Air Force",""}, + {"RFR","Royal Air Force","Royal Air Force",""}, + {"CTM","French Air Force","French Air Force","COTAM"}, + {"FAF","French Air Force","French Air Force",""}, + {"IAM","Italian Air Force","Italian Air Force",""}, + {"AME","Spanish Air Force","Spanish Air Force",""}, + {"BAF","Belgian Air Force","Belgian Air Force",""}, + {"NAF","Royal Neth. AF","Royal Neth. AF",""}, + {"PLF","Polish Air Force","Polish Air Force",""}, + {"CEF","Czech Air Force","Czech Air Force",""}, + {"HAF","Hellenic Air Force","Hellenic Air Force",""}, + {"SUI","Swiss Air Force","Swiss Air Force",""}, + {"CFC","Royal Canadian AF","Royal Canadian AF",""}, + {"ASY","Royal Austr. AF","Royal Austr. AF",""}, + {"NATO","NATO","NATO","AWACS"}, + {"RFF","Russian Air Force","Russian Air Force",""}, + }; + if (!callsign || !*callsign) return nullptr; + for (const auto& m : table) { + size_t n = strlen(m.prefix); + if (!strncmp(callsign, m.prefix, n)) { + // A prefix must be followed by the flight number (digits), not more letters. + char next = callsign[n]; + if (n == 4 || (next >= '0' && next <= '9')) return &m; + } + } + return nullptr; +} + +// variant 1 = branch, 2 = branch / unit (if it fits in `limit` characters). +inline bool militaryOperatorText(const char* callsign, uint8_t variant, bool english, char* out, size_t cap, size_t limit = 18) { + const MilitaryOperator* m = (variant == 1 || variant == 2) ? militaryOperatorFor(callsign) : nullptr; + if (!m || !out || !cap) return false; + const char* branch = english ? m->en : m->de; + out[0] = 0; + if (variant == 2 && m->unit[0] && strlen(branch) + 3 + strlen(m->unit) <= limit && strlen(branch) + 3 + strlen(m->unit) < cap) { + strcpy(out, branch); strcat(out, " / "); strcat(out, m->unit); + } else { + strncpy(out, branch, cap - 1); out[cap - 1] = 0; + } + return true; +} diff --git a/src/RadarFilter.h b/src/RadarFilter.h new file mode 100644 index 0000000..a73d4c8 --- /dev/null +++ b/src/RadarFilter.h @@ -0,0 +1,37 @@ +#pragma once +// Which aircraft the radar may skip, by the ADS-B emitter category the aircraft +// sends itself (A1 light ... A7 rotorcraft, B1 glider, B2 balloon, B4 ultralight, +// B6 drone, C1-C3 surface vehicles/obstacles) and the ground flag. Aircraft +// without a category are never hidden by the category filters. +#include +#include + +enum : uint8_t { + RADAR_HIDE_HELI = 1, // A7 + RADAR_HIDE_LIGHT = 2, // A1 + RADAR_HIDE_SPORT = 4, // B1, B2, B4, B6 + RADAR_HIDE_GROUND = 8, // on the ground and surface vehicles (C*) + RADAR_HIDE_ALL = 15 +}; + +inline bool radarHidden(const char* category, bool onGround, uint8_t mask) { + if (!mask) return false; + const char* c = category ? category : ""; + if ((mask & RADAR_HIDE_GROUND) && (onGround || c[0] == 'C')) return true; + if ((mask & RADAR_HIDE_HELI) && !strcmp(c, "A7")) return true; + if ((mask & RADAR_HIDE_LIGHT) && !strcmp(c, "A1")) return true; + if ((mask & RADAR_HIDE_SPORT) && (!strcmp(c, "B1") || !strcmp(c, "B2") || !strcmp(c, "B4") || !strcmp(c, "B6"))) return true; + return false; +} + +// Emergency squawks: 7500 unlawful interference, 7600 radio failure, 7700 general emergency. +inline bool radarEmergencySquawk(const char* squawk) { + return squawk && (!strcmp(squawk, "7500") || !strcmp(squawk, "7600") || !strcmp(squawk, "7700")); +} + +// Climb/descent indicator: +1 climbing, -1 descending, 0 level or unknown. +static const float RADAR_TREND_FPM = 300.0f; +inline int8_t radarTrend(bool hasRate, float rateFpm) { + if (!hasRate) return 0; + return rateFpm >= RADAR_TREND_FPM ? 1 : (rateFpm <= -RADAR_TREND_FPM ? -1 : 0); +} diff --git a/src/RadarScan.h b/src/RadarScan.h new file mode 100644 index 0000000..ecbde4e --- /dev/null +++ b/src/RadarScan.h @@ -0,0 +1,44 @@ +#pragma once +// Reads the "ac" array of an adsb.lol answer one aircraft at a time, so the +// memory need does not grow with the number of aircraft in the radius. +// Body needs read() and peek() (-1 at the end) and works as an ArduinoJson +// reader; visit(JsonObjectConst) is called for every aircraft object. +#include +#include + +template +inline bool radarScanSkipTo(Body& body, const char* key) { + // Find "key" (with quotes) and the following '['. + size_t matched = 0, len = strlen(key); + for (;;) { + int c = body.read(); + if (c < 0) return false; + if (matched < len) { + matched = (c == key[matched]) ? matched + 1 : (c == key[0] ? 1 : 0); + } else if (c == '[') { + return true; + } else if (c != ':' && c != ' ' && c != '\n' && c != '\r' && c != '\t') { + matched = (c == key[0]) ? 1 : 0; // "ac" was a value or part of another key + } + } +} + +// Returns the number of objects read; err is set on a JSON error. +template +inline uint16_t radarScanArray(Body& body, JsonDocument& doc, const JsonDocument& filter, + Visit visit, DeserializationError& err, uint16_t limit = 800) { + err = DeserializationError::Ok; + if (!radarScanSkipTo(body, "\"ac\"")) { err = DeserializationError::InvalidInput; return 0; } + uint16_t n = 0; + while (n < limit) { + int c = body.peek(); + while (c == ',' || c == ' ' || c == '\n' || c == '\r' || c == '\t') { body.read(); c = body.peek(); } + if (c != '{') break; // ']' or end of data + doc.clear(); + err = deserializeJson(doc, body, DeserializationOption::Filter(filter)); + if (err) return n; + ++n; + visit(doc.as()); + } + return n; +} diff --git a/src/Version.h b/src/Version.h index 8b04ae3..49837a7 100644 --- a/src/Version.h +++ b/src/Version.h @@ -1,6 +1,6 @@ #pragma once // Single place for name and version; every User-Agent is built from it. #define FW_NAME "PixelStop" -#define FW_VERSION "0.5.2-dev" +#define FW_VERSION "0.5.3-dev" #define FW_REPO "github.com/du13500/pixelstop" #define FW_USER_AGENT FW_NAME "/" FW_VERSION " (+https://" FW_REPO ")" diff --git a/src/main.cpp b/src/main.cpp index 77f56fe..eb2a7d7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,6 @@ #include +#include #include #include #include @@ -26,6 +27,8 @@ #include "TimeZones.h" #include "WeatherVisual.h" #include "AircraftLabel.h" +#include "MilitaryOperator.h" +#include "RadarFilter.h" #include "DestinationFormat.h" #include "webui_en.h" @@ -55,6 +58,7 @@ #define C_DGRAY 0x4208 #define C_BLUE 0x041F #define C_CYAN 0x07FF +#define C_KHAKI 0xBDAD enum AppMode : uint8_t { MODE_DEPARTURES = 0, @@ -65,7 +69,14 @@ enum AppMode : uint8_t { MODE_COUNTDOWN1 = 5, MODE_COUNTDOWN2 = 6, MODE_COUNTDOWN3 = 7, - MODE_COUNTDOWN4 = 8 + MODE_COUNTDOWN4 = 8, + MODE_FORECAST = 9 // three-day forecast; appended so stored masks keep their bits +}; +static const uint8_t MODE_COUNT = 10; +// Rotation follows the order of the list in the web interface. +static const uint8_t ROTATION_ORDER[MODE_COUNT] = { + MODE_DEPARTURES, MODE_WEATHER, MODE_FORECAST, MODE_PLANE, MODE_TRACKED_FLIGHT, MODE_CLOCK, + MODE_COUNTDOWN1, MODE_COUNTDOWN2, MODE_COUNTDOWN3, MODE_COUNTDOWN4 }; enum Language : uint8_t { LANG_DE = 0, LANG_EN = 1 }; @@ -96,8 +107,9 @@ struct Settings { uint8_t mode = MODE_DEPARTURES; // current runtime view uint16_t rotationMask = (1U << MODE_DEPARTURES); - uint16_t rotationSec[9] = {30,20,20,15,20,20,20,20,20}; + uint16_t rotationSec[MODE_COUNT] = {30,20,20,15,20,20,20,20,20,15}; uint8_t brightness = 70; + uint8_t backlightMode = 0; // 0 = PWM, 1 = sigma-delta (test against flashes) String timeZone = "Europe/Berlin"; bool nightEnabled = true; @@ -114,7 +126,6 @@ struct Settings { bool departureCompactDestinations = false; bool departureAbbreviate = true; // Hbf, Str., Pl. ... bool departureDropTown = true; // "Dresden Bühlau" -> "Bühlau" - bool weatherForecast = true; // alternate with a three-day forecast page String weatherCity = "Dresden"; // selected real place / fallback title String weatherDisplayName = ""; // optional display-only title @@ -134,6 +145,11 @@ struct Settings { bool planeShowPlace = false; bool planeShowAge = true; uint16_t planePlaceToggleSec = 10; + uint8_t planeOperator = 0; // 0 = name of the callsign, 1 = branch, 2 = both + uint8_t planeSpeed = 0; // 0 = off, 1 = km/h, 2 = knots + bool planeTrend = false; // climb/descent arrow + bool planeMarkMilitary = true; // "MIL" next to the callsign + uint8_t planeHide = 0; // RadarFilter.h bits String trackedFlightNo = ""; String aviationstackKey = ""; @@ -154,7 +170,6 @@ static uint32_t lastModeSwitchMs = 0; static String lastCountdownRendered[4]; static uint8_t departurePage = 0; static uint8_t weatherPage = 0; // 0 = today, 1 = three-day forecast -static uint32_t lastWeatherPageSwitchMs = 0; static bool departurePagingReady = false; static uint32_t lastDeparturePageSwitchMs = 0; static bool planePlacePhase = false; @@ -200,25 +215,25 @@ static const char WEBUI[] PROGMEM = R"HTML(
-

PixelStop

v)HTML" FW_VERSION R"HTML(
- +

PixelStop

Anzeige
v)HTML" FW_VERSION R"HTML(
+

Anzeigerotation

Programme anhaken und je Ansicht die Anzeigedauer festlegen. Mit nur einem Haken bleibt die Ansicht dauerhaft stehen.

-
+

Sigma-Delta dimmt über einen eigenen Baustein des Chips und wird nicht von WLAN-Aufgaben unterbrochen. Bitte nachts bei geringer Helligkeit vergleichen.

Zeitzone

Gilt für Uhr, Footer, Nachtmodus, Wetter-Zeitangaben und Tages-Countdowns. Sommer- und Winterzeit werden nach den Regeln der ausgewählten Zone umgestellt.

Nachtmodus

Abfahrtsmonitor

Live vom Verkehrsverbund Oberelbe (VVO). Haltestelle suchen, Treffer wählen und Verkehrsmittel auswählen.

Darstellung Fahrziel

Beispiel: „Dresden Bühlau“ wird zu „Bühlau“, wenn die Haltestelle in Dresden liegt.

-

Wetter

Live von Open-Meteo. Ort suchen und den Beobachtungspunkt auf der Karte exakt setzen. Standort gilt nur für dieses Programm.

Ortsnamen
Koordinaten
Farbige Darstellung
+

Wetter

Live von Open-Meteo. Ort suchen und den Beobachtungspunkt auf der Karte exakt setzen. Standort gilt nur für dieses Programm.

Ortsnamen
Koordinaten
Farbige Darstellung

Die 3-Tage-Vorhersage ist eine eigene Ansicht in der Rotation unter „Anzeige“ und nutzt Ort und Einstellungen dieser Seite.

-

Flugradar

Live von adsb.lol. Ort suchen und den Beobachtungspunkt auf der Karte exakt setzen. Standort gilt nur für dieses Programm.

Ortsnamen
Standortname Darstellung
Koordinaten

Zeigt die Sekunden seit dem letzten erfolgreichen Positionsabruf.

Entfernung und Höhe werden zwischen den Abrufen aus Geschwindigkeit, Kurs und Steigrate weitergerechnet. Der Punkt unten links zeigt den Stand: kurz weiß bei neuen Daten, grün im normalen Takt, gelb Abruf überfällig, grau Werte angehalten.

Flugdaten: adsb.lol (ODbL) · Kostenlosen Key holen: anonym, ca. 1 Monat gültig · weitere Wege

ⓘ Mehr dazu

Ohne Schlüssel erlaubt adsb.lol nur eine begrenzte Zahl von Anfragen pro Tag und Internetanschluss; für den Dauerbetrieb ohne Schlüssel 3 min wählen. „-“ eintragen und speichern entfernt einen gespeicherten Schlüssel.

adsb.lol kann Abfragen je nach Serverauslastung vorübergehend begrenzen. Während einer Anbieterpause bleibt das zuletzt empfangene Flugzeug stehen. Nach einer Anbieterbegrenzung verlängert sich das Aktualisierungsintervall automatisch. Nach 10 Minuten ohne erneute Begrenzung gilt wieder das ausgewählte Intervall.

+

Flugradar

Live von adsb.lol. Ort suchen und den Beobachtungspunkt auf der Karte exakt setzen. Standort gilt nur für dieses Programm.

Ortsnamen
Standortname Darstellung
Koordinaten

Zeigt die Sekunden seit dem letzten erfolgreichen Positionsabruf.

Entfernung und Höhe werden zwischen den Abrufen aus Geschwindigkeit, Kurs und Steigrate weitergerechnet. Der Punkt unten links zeigt den Stand: kurz weiß bei neuen Daten, grün im normalen Takt, gelb Abruf überfällig, grau Werte angehalten.

Darstellung

Oberbegriff und „Beides“ gelten für bekannte Militär-Rufzeichen; sonst bleibt der Name zum Rufzeichen.

Im Wechsel mit dem Kennzeichen, alle 3 Sekunden.

Ausblenden

Mit Filter fragt PixelStop alle Flugzeuge im Radius ab und zeigt das nächste passende. Die Antwort ist größer, bei großem Radius dauert der Abruf etwas länger. Flugzeuge ohne Kategorie werden nie ausgeblendet. Notfälle (Squawk 7500/7600/7700) erscheinen immer rot.

Flugdaten: adsb.lol (ODbL) · Kostenlosen Key holen: anonym, ca. 1 Monat gültig · weitere Wege

ⓘ Mehr dazu

Ohne Schlüssel erlaubt adsb.lol nur eine begrenzte Zahl von Anfragen pro Tag und Internetanschluss; für den Dauerbetrieb ohne Schlüssel 3 min wählen. „-“ eintragen und speichern entfernt einen gespeicherten Schlüssel.

adsb.lol kann Abfragen je nach Serverauslastung vorübergehend begrenzen. Während einer Anbieterpause bleibt das zuletzt empfangene Flugzeug stehen. Nach einer Anbieterbegrenzung verlängert sich das Aktualisierungsintervall automatisch. Nach 10 Minuten ohne erneute Begrenzung gilt wieder das ausgewählte Intervall.

Flug-Tracker

Verfolgt genau einen Flug. Plan-/Ist-Zeiten kommen von aviationstack; Höhe und Geschwindigkeit während des Fluges zusätzlich über adsb.lol.

Statusabfragen laufen sparsam und nur, wenn der Tracker tatsächlich angezeigt wird.

@@ -234,8 +249,8 @@ function trNode(n){if(!n)return;if(n.nodeType===3){const v=trText(n.nodeValue);i async function useLang(l){if(l===LANG)return;if(l!=='en'){try{localStorage.setItem('pixelstop.lang','de')}catch(e){}dirty=false;location.reload();return}try{const r=await fetch('/i18n/en.json');if(!r.ok)return;I18N=await r.json();LANG='en';document.documentElement.lang='en';try{localStorage.setItem('pixelstop.lang','en')}catch(e){}trNode(document.body);new MutationObserver(ms=>{for(const m of ms){if(m.type==='childList')m.addedNodes.forEach(trNode);else trNode(m.target)}}).observe(document.body,{subtree:true,childList:true,characterData:true,attributes:true,attributeFilter:['placeholder','title']})}catch(e){}} const $=id=>document.getElementById(id),clamp=(n,a,b)=>Math.max(a,Math.min(b,Number(n)||0)); -const modeNames=['Abfahrten','Wetter','Flugradar','Uhr','Flug-Tracker','Countdown 1','Countdown 2','Countdown 3','Countdown 4']; -const modeDefaults=[30,20,20,15,20,20,20,20,20]; +const modeNames=['Abfahrten','Wetter','Flugradar','Uhr','Flug-Tracker','Countdown 1','Countdown 2','Countdown 3','Countdown 4','3-Tage-Vorhersage']; +const modeDefaults=[30,20,20,15,20,20,20,20,20,15],modeOrder=[0,1,9,2,4,3,5,6,7,8]; function friendly(e){if(e&&e.userMessage)return e.userMessage;if(e instanceof TypeError||String(e).includes('fetch'))return 'Verbindung zum Würfel fehlgeschlagen. Ist der Würfel eingeschaltet und mit dem WLAN verbunden?';return e?.message||'Unbekannter Fehler.'} async function fetchJson(url,opt){let r;const controller=new AbortController(),timer=setTimeout(()=>controller.abort(),25000);try{r=await fetch(url,{...opt,signal:controller.signal})}catch(e){let x=new Error();x.userMessage='Verbindung zum Würfel fehlgeschlagen. Ist der Würfel eingeschaltet und mit dem WLAN verbunden?';throw x}finally{clearTimeout(timer)}let d={};try{d=await r.json()}catch(e){}if(!r.ok||d.ok===false){let x=new Error();x.userMessage=d.error||('Anfrage fehlgeschlagen ('+r.status+').');throw x}return d} function showBox(id,msg,err=false){const span=document.createElement('span');span.className='hint '+(err?'err':'');span.textContent=msg;$(id).replaceChildren(span)} @@ -279,16 +294,20 @@ async function runGeo(){const kind=geoPending.weather?'weather':(geoPending.plan async function ensureMap(kind){await loadLeaflet();let [lat,lon]=coords(kind);if(!Number.isFinite(lat)||!Number.isFinite(lon)){lat=51.0504;lon=13.7373}if(!maps[kind]){const m=L.map(kind+'Map').setView([lat,lon],14);L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png',{maxZoom:19,attribution:'© OpenStreetMap-Mitwirkende'}).addTo(m);const marker=L.marker([lat,lon],{draggable:true}).addTo(m);const picked=p=>{const lon=wrapLongitude(p.lng);setMapPoint(kind,p.lat,lon,false);reversePlace(kind,p.lat,lon)};m.on('click',e=>picked(e.latlng));marker.on('dragend',()=>picked(marker.getLatLng()));maps[kind]=m;markers[kind]=marker}else{maps[kind].setView([lat,lon],maps[kind].getZoom());markers[kind].setLatLng([lat,lon])}setTimeout(()=>maps[kind].invalidateSize(),50)} async function toggleMap(kind){const w=$(kind+'MapWrap'),opening=w.classList.contains('hidden');if(opening&&navigator.onLine===false){showBox(kind+'Results','Internetverbindung erforderlich',true);return}w.classList.toggle('hidden',!opening);if(!opening)return;showBox(kind+'Results','Karte wird geladen…');try{await ensureMap(kind);showBox(kind+'Results','Auf die gewünschte Position in der Karte tippen.')}catch(e){w.classList.add('hidden');showBox(kind+'Results',navigator.onLine===false?'Internetverbindung erforderlich':'Karte konnte nicht geladen werden. Bitte Internetverbindung prüfen oder Koordinaten manuell eingeben.',true)}} function syncMapFromInputs(kind){let [lat,lon]=coords(kind);if(Number.isFinite(lat)&&Number.isFinite(lon)&&maps[kind]){markers[kind].setLatLng([lat,lon]);maps[kind].setView([lat,lon],maps[kind].getZoom())}} -document.querySelectorAll('.tab').forEach(b=>b.addEventListener('click',()=>{document.querySelectorAll('.tab,.page').forEach(x=>x.classList.remove('on'));b.classList.add('on');$(b.dataset.p).classList.add('on')})); +function menu(open){$('mainMenu').classList.toggle('hidden',!open);$('menuBtn').setAttribute('aria-expanded',open?'true':'false')} +$('menuBtn').addEventListener('click',()=>menu($('mainMenu').classList.contains('hidden')));$('mainMenu').addEventListener('click',e=>{if(e.target===$('mainMenu'))menu(false)});document.addEventListener('keydown',e=>{if(e.key==='Escape')menu(false)}); +document.querySelectorAll('.tab').forEach(b=>b.addEventListener('click',()=>{document.querySelectorAll('.tab,.page').forEach(x=>x.classList.remove('on'));b.classList.add('on');$(b.dataset.p).classList.add('on');$('pageName').textContent=b.textContent;menu(false);window.scrollTo(0,0)})); +// Eye button: shows a typed key or password while typing; stored values are never sent back. +document.querySelectorAll('input[type=password]').forEach(inp=>{const w=document.createElement('div');w.className='pw';inp.parentNode.insertBefore(w,inp);w.appendChild(inp);const e=document.createElement('button');e.type='button';e.className='eye';e.classList.add('hidden');e.textContent='👁';e.title='Eingabe anzeigen';e.setAttribute('aria-label','Eingabe anzeigen');w.appendChild(e);const sync=()=>{e.classList.toggle('hidden',!inp.value);if(!inp.value)inp.type='password'};inp.addEventListener('input',sync);e.addEventListener('click',()=>{inp.type=inp.type==='password'?'text':'password'});inp._eyeSync=sync}); function hhmm(m){let h=Math.floor(m/60)%24,mm=m%60;return String(h).padStart(2,'0')+':'+String(mm).padStart(2,'0')}function mins(s){let p=(s||'00:00').split(':');return (+p[0])*60+(+p[1])} -function buildModeRows(){let h='';[0,1,2,4,3,5,6,7,8].forEach(i=>h+=`
`);$('modeRows').innerHTML=h;document.querySelectorAll('.showNow').forEach(b=>b.addEventListener('click',async()=>{try{let r=await fetchJson('/api/show',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({mode:+b.dataset.mode})});toast(r.rotation?'Wird für '+r.sec+' s angezeigt · danach geht die Rotation weiter':'Wird angezeigt · bleibt stehen, bis du wieder speicherst','ok',3200)}catch(e){toast(friendly(e),'err',3500)}}))} +function buildModeRows(){let h='';modeOrder.forEach(i=>h+=`
`);$('modeRows').innerHTML=h;document.querySelectorAll('.showNow').forEach(b=>b.addEventListener('click',async()=>{try{let r=await fetchJson('/api/show',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({mode:+b.dataset.mode})});toast(r.rotation?'Wird für '+r.sec+' s angezeigt · danach geht die Rotation weiter':'Wird angezeigt · bleibt stehen, bis du wieder speicherst','ok',3200)}catch(e){toast(friendly(e),'err',3500)}}))} function buildCountdownCards(){const root=$('countdownSlots');let html='';for(let i=0;i<4;i++)html+=``;root.innerHTML=html;document.querySelectorAll('.cdcard h2.fold').forEach(h=>h.addEventListener('click',()=>h.parentNode.classList.toggle('collapsed')));for(let i=0;i<4;i++){$(`cdType${i}`).addEventListener('change',()=>updateCdFields(i));$(`cdStart${i}`).addEventListener('click',()=>countdownAction(i,'start'));$(`cdStop${i}`).addEventListener('click',()=>countdownAction(i,'stop'))}} function updateCdFields(i){let t=+$(`cdType${i}`).value;$(`cdDays${i}`).classList.toggle('hidden',t!==0);$(`cdHms${i}`).classList.toggle('hidden',t!==1);$(`cdMs${i}`).classList.toggle('hidden',t!==2)} function countdownPayload(i){let t=+$(`cdType${i}`).value,d=0;if(t===1)d=clamp($(`cdH${i}`).value,0,999)*3600+clamp($(`cdM${i}`).value,0,59)*60+clamp($(`cdS${i}`).value,0,59);if(t===2)d=clamp($(`cdOnlyM${i}`).value,0,9999)*60+clamp($(`cdOnlyS${i}`).value,0,59);return{title:$(`cdTitle${i}`).value,titleColor:$(`cdTitleColor${i}`).value,countColor:$(`cdCountColor${i}`).value,type:t,targetDate:$(`cdDate${i}`).value,durationSec:d}} function loadCountdown(i,c){$(`cdTitle${i}`).value=c.title||'';$(`cdTitleColor${i}`).value=c.titleColor||'#ffffff';$(`cdCountColor${i}`).value=c.countColor||'#ff5d56';$(`cdType${i}`).value=c.type??0;$(`cdDate${i}`).value=c.targetDate||'';let d=Number(c.durationSec||0),h=Math.floor(d/3600),m=Math.floor((d%3600)/60),sec=d%60;$(`cdH${i}`).value=h;$(`cdM${i}`).value=m;$(`cdS${i}`).value=sec;$(`cdOnlyM${i}`).value=Math.floor(d/60);$(`cdOnlyS${i}`).value=sec;$(`cdStatus${i}`).textContent=c.active?'aktiv':'inaktiv';$(`cdBadge${i}`).textContent=c.active?'aktiv':(c.title||'');$(`cdCard${i}`).classList.toggle('collapsed',!c.active);updateCdFields(i)} async function countdownAction(i,action){let body=countdownPayload(i);body.slot=i;body.action=action;try{await fetchJson('/api/countdown',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(body)});await load();toast(action==='start'?'Countdown gestartet':'Countdown gestoppt')}catch(e){try{let c=await load();let wanted=action==='start';if(c?.countdowns?.[i]?.active===wanted){toast(action==='start'?'Countdown gestartet':'Countdown gestoppt');return}}catch(_){}toast(friendly(e),'err',4200)}} $('brightness').addEventListener('input',()=> $('brv').textContent=$('brightness').value);$('nightBrightness').addEventListener('input',()=> $('nbv').textContent=$('nightBrightness').value); -async function load(){try{let c=await fetchJson('/api/config');$('lang').value=String(+c.lang===1?1:0);useLang(+c.lang===1?'en':'de');['ssid','hostname','timeZone','stopName','stopPlace','stopId','weatherCity','weatherDisplayName','planePlace','planeDisplayName','trackedFlightNo'].forEach(k=>{if($(k))$(k).value=c[k]??''});['brightness','departureCount','departurePoll','weatherPoll','planeRadiusKm','planePoll','planePlaceToggleSec','trackerStatusPollMin'].forEach(k=>$(k).value=c[k]);['weatherLat','weatherLon','planeLat','planeLon'].forEach(k=>$(k).value=Number(c[k]).toFixed(4));$('weatherSearch').value=c.weatherCity||'';$('planeSearch').value=c.planePlace||'';$('nightEnabled').checked=!!c.nightEnabled;$('nightStart').value=hhmm(c.nightStart);$('nightEnd').value=hhmm(c.nightEnd);$('nightBrightness').value=c.nightBrightness;$('weatherTempColor').checked=!!c.weatherTempColor;$('weatherUnit').value=c.weatherFahrenheit?'F':'C';$('departureCompactDestinations').checked=!!c.departureCompactDestinations;$('departureAbbreviate').checked=c.departureAbbreviate!==false;$('departureDropTown').checked=c.departureDropTown!==false;$('weatherForecast').checked=c.weatherForecast!==false;$('weatherGeoGerman').checked=!!c.geoGermanNames;$('planeGeoGerman').checked=!!c.geoGermanNames;$('planeShowAge').checked=c.planeShowAge!==false;$('planeShowPlace').checked=!!c.planeShowPlace;updatePlanePlaceControls();$('brv').textContent=c.brightness;$('nbv').textContent=c.nightBrightness;let mask=Number(c.rotationMask||0),secs=c.rotationSec||modeDefaults;for(let i=0;i<9;i++){$(`modeOn${i}`).checked=!!(mask&(1<{if(i<4)loadCountdown(i,x)});markDirty(false);statusNow();return c}catch(e){toast(friendly(e),'err',4200);throw e}} +async function load(){try{let c=await fetchJson('/api/config');$('lang').value=String(+c.lang===1?1:0);useLang(+c.lang===1?'en':'de');['ssid','hostname','timeZone','stopName','stopPlace','stopId','weatherCity','weatherDisplayName','planePlace','planeDisplayName','trackedFlightNo'].forEach(k=>{if($(k))$(k).value=c[k]??''});['brightness','departureCount','departurePoll','weatherPoll','planeRadiusKm','planePoll','planePlaceToggleSec','trackerStatusPollMin'].forEach(k=>$(k).value=c[k]);['weatherLat','weatherLon','planeLat','planeLon'].forEach(k=>$(k).value=Number(c[k]).toFixed(4));$('weatherSearch').value=c.weatherCity||'';$('planeSearch').value=c.planePlace||'';$('nightEnabled').checked=!!c.nightEnabled;$('nightStart').value=hhmm(c.nightStart);$('nightEnd').value=hhmm(c.nightEnd);$('nightBrightness').value=c.nightBrightness;$('weatherTempColor').checked=!!c.weatherTempColor;$('weatherUnit').value=c.weatherFahrenheit?'F':'C';$('departureCompactDestinations').checked=!!c.departureCompactDestinations;$('departureAbbreviate').checked=c.departureAbbreviate!==false;$('departureDropTown').checked=c.departureDropTown!==false;$('backlightMode').value=String(+c.backlightMode===1?1:0);$('planeOperator').value=String(c.planeOperator||0);$('planeSpeed').value=String(c.planeSpeed||0);$('planeTrend').checked=!!c.planeTrend;$('planeMarkMilitary').checked=c.planeMarkMilitary!==false;{let hm=Number(c.planeHide||0);$('hideHeli').checked=!!(hm&1);$('hideLight').checked=!!(hm&2);$('hideSport').checked=!!(hm&4);$('hideGround').checked=!!(hm&8)}$('weatherGeoGerman').checked=!!c.geoGermanNames;$('planeGeoGerman').checked=!!c.geoGermanNames;$('planeShowAge').checked=c.planeShowAge!==false;$('planeShowPlace').checked=!!c.planeShowPlace;updatePlanePlaceControls();$('brv').textContent=c.brightness;$('nbv').textContent=c.nightBrightness;let mask=Number(c.rotationMask||0),secs=c.rotationSec||modeDefaults;for(let i=0;i<10;i++){$(`modeOn${i}`).checked=!!(mask&(1<i._eyeSync&&i._eyeSync());$('adsbLolKey').placeholder=c.adsbLolKeySet?'API-Key gespeichert, leer = behalten':'API-Key eintragen';(c.countdowns||[]).forEach((x,i)=>{if(i<4)loadCountdown(i,x)});markDirty(false);statusNow();return c}catch(e){toast(friendly(e),'err',4200);throw e}} async function searchStop(){const box=$('stopResults'),q=$('stopName').value.trim();if(q.length<2){showBox('stopResults','Bitte mindestens zwei Zeichen eingeben.');return}showBox('stopResults','suche beim VVO…');try{const d=await fetchJson('/api/vvo/search?q='+encodeURIComponent(q));if(!d.stops.length){showBox('stopResults','Keine Haltestelle gefunden.');return}box.innerHTML=d.stops.map((x,i)=>``).join('');box.querySelectorAll('button').forEach((b,i)=>b.addEventListener('click',()=>{const x=d.stops[i];$('stopId').value=x.id;$('stopName').value=x.name;$('stopPlace').value=x.place||'';markDirty();showBox('stopResults','Ausgewählt: '+x.label)}))}catch(e){showBox('stopResults',friendly(e),true)}} function searchPlace(kind){if(saving)return;if(navigator.onLine===false){++geoGeneration[kind];geoPending[kind]=null;showBox(kind+'Results','Internetverbindung erforderlich',true);updateSaveGate();return}const q=$(kind+'Search').value.trim();if(q.length<2){showBox(kind+'Results','Bitte mindestens zwei Zeichen eingeben.');return}geoPending[kind]={q,generation:++geoGeneration[kind]};showBox(kind+'Results','suche Ort…');updateSaveGate();scheduleGeo()} function renderPlaceResults(kind,places){const box=$(kind+'Results');if(!places.length){showBox(kind+'Results','Kein Ort gefunden.');return}box.replaceChildren();places.forEach(x=>{const b=document.createElement('button'),s=document.createElement('span');b.type='button';b.className='pickres';b.textContent=x.label;s.className='sig';s.textContent=x.lat.toFixed(4)+', '+x.lon.toFixed(4);b.append(s);b.addEventListener('click',()=>{++geoGeneration[kind];geoPending[kind]=null;$(kind==='weather'?'weatherCity':'planePlace').value=x.name;setMapPoint(kind,x.lat,x.lon,true);markDirty();showBox(kind+'Results','Ausgewählt: '+x.label+(maps[kind]?' · Marker auf Ortsmitte gesetzt':''));updateSaveGate()});box.append(b)});const note=document.createElement('p'),link=document.createElement('a');note.className='mini';note.textContent='Ortsdaten © ';link.href='https://www.openstreetmap.org/copyright';link.target='_blank';link.rel='noopener';link.textContent='OpenStreetMap-Mitwirkende';note.append(link);box.append(note)} @@ -296,8 +315,8 @@ function updatePlanePlaceControls(){const off=!$('planeShowPlace').checked;$('pl function syncGeoLanguage(source){const v=$(source).checked;$('weatherGeoGerman').checked=v;$('planeGeoGerman').checked=v} function signalBars(r){return r>=-50?'▁▂▄▆█':r>=-60?'▁▂▄▆':r>=-70?'▁▂▄':r>=-80?'▁▂':'▁'} async function scanWifi(){showBox('wifiResults','suche WLAN-Netze…');try{let d=await fetchJson('/api/wifi/scan'),best=new Map();(d.networks||[]).forEach(n=>{if(!n.ssid)return;let o=best.get(n.ssid);if(!o||n.rssi>o.rssi)best.set(n.ssid,n)});let a=[...best.values()].sort((x,y)=>y.rssi-x.rssi);if(!a.length){showBox('wifiResults','Keine WLAN-Netze gefunden.');return}$('wifiResults').innerHTML=a.map((n,i)=>``).join('');$('wifiResults').querySelectorAll('button').forEach((b,i)=>b.addEventListener('click',()=>{$('ssid').value=a[i].ssid;showBox('wifiResults','Ausgewählt: '+a[i].ssid)}))}catch(e){showBox('wifiResults',friendly(e),true)}} -async function save(){if(saving||geoBusy||geoPending.weather||geoPending.plane)return;let mask=0,rotationSec=[];for(let i=0;i<9;i++){if($(`modeOn${i}`).checked)mask|=1<90||!Number.isFinite(wlon)||wlon<-180||wlon>180){toast('Bitte gültige Wetter-Koordinaten eingeben.','warn',3500);return}if(!Number.isFinite(plat)||plat<-90||plat>90||!Number.isFinite(plon)||plon<-180||plon>180){toast('Bitte gültige Flugradar-Koordinaten eingeben.','warn',3500);return}let o={lang:+$('lang').value,ssid:$('ssid').value,pass:$('pass').value,hostname:$('hostname').value,rotationMask:mask,rotationSec,brightness:+$('brightness').value,timeZone:$('timeZone').value,nightEnabled:$('nightEnabled').checked,nightStart:mins($('nightStart').value),nightEnd:mins($('nightEnd').value),nightBrightness:+$('nightBrightness').value,stopName:$('stopName').value,stopPlace:$('stopPlace').value,stopId:$('stopId').value,departureCount:+$('departureCount').value,departurePoll:+$('departurePoll').value,vvoMotMask:mot,departureCompactDestinations:$('departureCompactDestinations').checked,departureAbbreviate:$('departureAbbreviate').checked,departureDropTown:$('departureDropTown').checked,weatherForecast:$('weatherForecast').checked,weatherCity:$('weatherCity').value,weatherDisplayName:$('weatherDisplayName').value,weatherLat:wlat,weatherLon:wlon,weatherPoll:+$('weatherPoll').value,weatherTempColor:$('weatherTempColor').checked,weatherFahrenheit:$('weatherUnit').value==='F',geoGermanNames:$('weatherGeoGerman').checked,planePlace:$('planePlace').value,planeDisplayName:$('planeDisplayName').value,planeLat:plat,planeLon:plon,planeRadiusKm:+$('planeRadiusKm').value,planePoll:+$('planePoll').value,planeShowAge:$('planeShowAge').checked,planeShowPlace:$('planeShowPlace').checked,planePlaceToggleSec:+$('planePlaceToggleSec').value,trackedFlightNo:$('trackedFlightNo').value,aviationstackKey:$('aviationstackKey').value,adsbLolKey:$('adsbLolKey').value,trackerStatusPollMin:+$('trackerStatusPollMin').value,countdowns:[0,1,2,3].map(countdownPayload)};saving=true;updateSaveGate();try{let r=await fetchJson('/api/config',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(o)});toast(r.reboot?'Gespeichert · PixelStop startet neu':'✓ Einstellungen gespeichert','ok',r.reboot?5500:2200);if(r.reboot){markDirty(false);setTimeout(()=>location.reload(),7000)}else await load()}catch(e){toast(friendly(e),'err',4200)}finally{saving=false;updateSaveGate()}} -async function statusNow(){try{let s=await fetchJson('/api/status');$('adsbKeyExpired').classList.toggle('hidden',!(s.adsbDenied&&s.adsbKey));$('adsbKeyNeeded').classList.toggle('hidden',!(s.adsbDenied&&!s.adsbKey));$('status').textContent=`Firmware: ${s.fw} ${s.version}\nNetz: ${s.ssid||'-'}\nIP: ${s.ip}\nRSSI: ${s.rssi} dBm\nFreier Heap: ${s.heap} B (${s.maxBlock} B größter Block)\nFlugradar: ${s.flightStage||'-'}${s.flightHttp?` · HTTP ${s.flightHttp}`:''}${s.flightTlsRx?` · TLS RX ${s.flightTlsRx} B`:''}${s.flightTlsMinBlock?` · Blockbedarf ${s.flightTlsMinBlock} B`:''}${s.flightWaitSec?` · Pause ${s.flightWaitSec} s`:''}${s.flightMinIntervalSec?` · Mindestintervall ${s.flightMinIntervalSec} s`:''}\nadsb.lol heute: ${s.adsbToday} Anfragen${s.adsbKey?' · mit Schlüssel':` von 450 · Tagesbudget-Intervall ${s.adsbBudgetSec} s`}\nRadar-Route: ${s.routeStatus||'-'} · ${s.routeSource||'-'}${s.routeHttp?` · HTTP ${s.routeHttp}`:''}\nUptime: ${s.uptime}s\nTracker: ${s.trackerValid?'Daten vorhanden':(s.trackerError?'Fehler':'bereit')}`}catch(e){$('status').textContent='PixelStop derzeit nicht erreichbar.'}} +async function save(){if(saving||geoBusy||geoPending.weather||geoPending.plane)return;let mask=0,rotationSec=[];for(let i=0;i<10;i++){if($(`modeOn${i}`).checked)mask|=1<90||!Number.isFinite(wlon)||wlon<-180||wlon>180){toast('Bitte gültige Wetter-Koordinaten eingeben.','warn',3500);return}if(!Number.isFinite(plat)||plat<-90||plat>90||!Number.isFinite(plon)||plon<-180||plon>180){toast('Bitte gültige Flugradar-Koordinaten eingeben.','warn',3500);return}let o={lang:+$('lang').value,ssid:$('ssid').value,pass:$('pass').value,hostname:$('hostname').value,rotationMask:mask,rotationSec,brightness:+$('brightness').value,timeZone:$('timeZone').value,nightEnabled:$('nightEnabled').checked,nightStart:mins($('nightStart').value),nightEnd:mins($('nightEnd').value),nightBrightness:+$('nightBrightness').value,stopName:$('stopName').value,stopPlace:$('stopPlace').value,stopId:$('stopId').value,departureCount:+$('departureCount').value,departurePoll:+$('departurePoll').value,vvoMotMask:mot,departureCompactDestinations:$('departureCompactDestinations').checked,departureAbbreviate:$('departureAbbreviate').checked,departureDropTown:$('departureDropTown').checked,backlightMode:+$('backlightMode').value,weatherCity:$('weatherCity').value,weatherDisplayName:$('weatherDisplayName').value,weatherLat:wlat,weatherLon:wlon,weatherPoll:+$('weatherPoll').value,weatherTempColor:$('weatherTempColor').checked,weatherFahrenheit:$('weatherUnit').value==='F',geoGermanNames:$('weatherGeoGerman').checked,planePlace:$('planePlace').value,planeDisplayName:$('planeDisplayName').value,planeLat:plat,planeLon:plon,planeRadiusKm:+$('planeRadiusKm').value,planePoll:+$('planePoll').value,planeShowAge:$('planeShowAge').checked,planeShowPlace:$('planeShowPlace').checked,planeOperator:+$('planeOperator').value,planeSpeed:+$('planeSpeed').value,planeTrend:$('planeTrend').checked,planeMarkMilitary:$('planeMarkMilitary').checked,planeHide:($('hideHeli').checked?1:0)|($('hideLight').checked?2:0)|($('hideSport').checked?4:0)|($('hideGround').checked?8:0),planePlaceToggleSec:+$('planePlaceToggleSec').value,trackedFlightNo:$('trackedFlightNo').value,aviationstackKey:$('aviationstackKey').value,adsbLolKey:$('adsbLolKey').value,trackerStatusPollMin:+$('trackerStatusPollMin').value,countdowns:[0,1,2,3].map(countdownPayload)};saving=true;updateSaveGate();try{let r=await fetchJson('/api/config',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(o)});toast(r.reboot?'Gespeichert · PixelStop startet neu':'✓ Einstellungen gespeichert','ok',r.reboot?5500:2200);if(r.reboot){markDirty(false);setTimeout(()=>location.reload(),7000)}else await load()}catch(e){toast(friendly(e),'err',4200)}finally{saving=false;updateSaveGate()}} +async function statusNow(){try{let s=await fetchJson('/api/status');$('adsbKeyExpired').classList.toggle('hidden',!(s.adsbDenied&&s.adsbKey));$('adsbKeyNeeded').classList.toggle('hidden',!(s.adsbDenied&&!s.adsbKey));$('status').textContent=`Firmware: ${s.fw} ${s.version}\nNetz: ${s.ssid||'-'}\nIP: ${s.ip}\nRSSI: ${s.rssi} dBm\nFreier Heap: ${s.heap} B (${s.maxBlock} B größter Block)\nFlugradar: ${s.flightStage||'-'}${s.flightHttp?` · HTTP ${s.flightHttp}`:''}${s.flightTlsRx?` · TLS RX ${s.flightTlsRx} B`:''}${s.flightTlsMinBlock?` · Blockbedarf ${s.flightTlsMinBlock} B`:''}${s.flightWaitSec?` · Pause ${s.flightWaitSec} s`:''}${s.flightMinIntervalSec?` · Mindestintervall ${s.flightMinIntervalSec} s`:''}${s.flightScanned?` · ${s.flightScanned} Flugzeuge geprüft`:''}\nAktuelles Flugzeug: ${s.flightCall||'-'}\nadsb.lol heute: ${s.adsbToday} Anfragen${s.adsbKey?' · mit Schlüssel':` von 450 · Tagesbudget-Intervall ${s.adsbBudgetSec} s`}\nRadar-Route: ${s.routeStatus||'-'} · ${s.routeSource||'-'}${s.routeHttp?` · HTTP ${s.routeHttp}`:''}\nUptime: ${s.uptime}s\nTracker: ${s.trackerValid?'Daten vorhanden':(s.trackerError?'Fehler':'bereit')}`}catch(e){$('status').textContent='PixelStop derzeit nicht erreichbar.'}} async function reboot(){toast('PixelStop startet neu…','ok',5000);try{await fetch('/api/reboot',{method:'POST'})}catch(e){}setTimeout(()=>location.reload(),6000)} async function copyLog(){ try{const r=await fetch('/api/log');if(!r.ok)throw new Error();const text=await r.text();$('diagnosticLog').textContent=text; @@ -412,27 +431,37 @@ static void applyBrightness() { // SmallTV backlight is active-low. int duty = BL_PWM_RANGE - ((int)b * BL_PWM_RANGE / 100); // Reapplying PWM can interrupt very dim backlighting. Update only on change. - static int lastDuty=-1; - if(duty==lastDuty)return; - analogWrite(TFT_BL, duty); - lastDuty=duty; + static int lastDuty=-1,lastMode=-1; + if(duty==lastDuty&&cfg.backlightMode==lastMode)return; + if(cfg.backlightMode==1){ + // Sigma-delta: the chip's own pulse generator, not interrupted by Wi-Fi. + // Active-low: the share of LOW (= light) is b %, at least one step. + uint16_t on=(uint16_t)(((uint32_t)b*256U+99U)/100U);if(on>256)on=256; + if(lastMode!=1){digitalWrite(TFT_BL,HIGH);sigmaDeltaEnable();sigmaDeltaSetPrescaler(255);sigmaDeltaAttachPin(TFT_BL,0);} + sigmaDeltaWrite(0,(uint8_t)(256-on)); + } else { + if(lastMode==1)sigmaDeltaDetachPin(TFT_BL); + analogWrite(TFT_BL, duty); + } + lastDuty=duty;lastMode=cfg.backlightMode; } static bool modeEnabled(uint8_t mode) { - return mode < 9 && (cfg.rotationMask & (1U << mode)); + return mode < MODE_COUNT && (cfg.rotationMask & (1U << mode)); } static uint8_t enabledModeCount() { - uint8_t n=0; for(uint8_t i=0;i<9;i++) if(modeEnabled(i)) n++; return n; + uint8_t n=0; for(uint8_t i=0;i(); for(uint8_t i=0;i<9;i++) rs.add(cfg.rotationSec[i]); + d["mode"] = cfg.mode; d["rotationMask"] = cfg.rotationMask; d["brightness"] = cfg.brightness; d["backlightMode"] = cfg.backlightMode; + JsonArray rs = d["rotationSec"].to(); for(uint8_t i=0;i(); for (uint8_t i=0;i<4;i++) { @@ -503,16 +533,20 @@ static void loadConfig() { JsonDocument d; if (deserializeJson(d, f)) { f.close(); return; } f.close(); cfg.ssid = d["ssid"] | cfg.ssid; cfg.pass = d["pass"] | cfg.pass; cfg.hostname = d["hostname"] | cfg.hostname; if(d["timeZone"].is() && timeZoneIndex(d["timeZone"].as())>=0)cfg.timeZone=d["timeZone"].as(); - cfg.mode = constrain((int)(d["mode"] | cfg.mode), 0, 8); - if(d["rotationMask"].is() || d["rotationMask"].is()) cfg.rotationMask = ((uint16_t)(d["rotationMask"] | cfg.rotationMask)) & 0x01FFU; + cfg.mode = constrain((int)(d["mode"] | cfg.mode), 0, MODE_COUNT-1); + if(d["rotationMask"].is() || d["rotationMask"].is()) cfg.rotationMask = ((uint16_t)(d["rotationMask"] | cfg.rotationMask)) & 0x03FFU; else cfg.rotationMask = (1U << cfg.mode); // migrate v0.4 single-view configuration if(!cfg.rotationMask) cfg.rotationMask = (1U << cfg.mode); - JsonArrayConst rs=d["rotationSec"].as(); if(!rs.isNull()) for(uint8_t i=0;i<9&&i(); if(!rs.isNull()) for(uint8_t i=0;i(); if (!cds.isNull()) for (uint8_t i=0;i<4 && ifillRect(8,35,224,40,C_BLACK); - String cs=f.callsign[0]?String(f.callsign):String("N/A");centerText(cs,42,cs.length()<=6?4:3,C_WHITE); + String cs=f.callsign[0]?String(f.callsign):String("N/A");centerText(cs,42,cs.length()<=6?4:3,emergency?C_RED:C_WHITE); + if(cfg.planeMarkMilitary&&f.military)printDisplayTextAt(214,38,"MIL",1,C_KHAKI); } - if(full||strcmp(f.airline,lastPlaneRendered.airline)){ + lastPlaneCall=callKey; + String op=planeOperatorText(f); + if(full||op!=lastPlaneOperator){ if(!full)gfx->fillRect(8,78,224,20,C_BLACK); - String airline=f.airline[0]?String(f.airline):String("N/A");centerText(crop(airline,36),80,textW(airline,2)<=224?2:1,C_GRAY); + centerText(crop(op,36),80,textW(op,2)<=224?2:1,C_GRAY); } - if(full||strcmp(f.origin,lastPlaneRendered.origin)||strcmp(f.destination,lastPlaneRendered.destination)|| + lastPlaneOperator=op; + const bool routeKnown=f.route.count>0||(f.origin[0]&&strcmp(f.origin,"N/A")); + String routeKey=emergency&&(second||!routeKnown)?String("SQUAWK ")+f.squawk:String(); + if(full||routeKey!=lastPlaneRoute||strcmp(f.origin,lastPlaneRendered.origin)||strcmp(f.destination,lastPlaneRendered.destination)|| f.route.count!=lastPlaneRendered.route.count||f.route.truncated!=lastPlaneRendered.route.truncated|| memcmp(f.route.airports,lastPlaneRendered.route.airports,sizeof(f.route.airports))){ if(!full)gfx->fillRect(8,102,224,29,C_BLACK); - drawFlightRoute(f.route,f.origin,f.destination,105); + if(routeKey.length())centerText(routeKey,105,3,C_RED); + else drawFlightRoute(f.route,f.origin,f.destination,105); } + lastPlaneRoute=routeKey; if(full||strcmp(f.typeName,lastPlaneRendered.typeName)||strcmp(f.typeCode,lastPlaneRendered.typeCode)){ if(!full)gfx->fillRect(8,136,224,23,C_BLACK); centerText(compactType(f),139,2,C_WHITE); } - if(full||strcmp(f.registration,lastPlaneRendered.registration)){ + String reg=f.registration[0]?String(f.registration):String("N/A"); + if(cfg.planeSpeed&&f.speedKnown&&(second||!f.registration[0]))reg=planeSpeedText(f); + if(full||reg!=lastPlaneReg){ if(!full)gfx->fillRect(8,161,224,24,C_BLACK); - centerText(f.registration[0]?String(f.registration):String("N/A"),164,2,C_GRAY); + centerText(reg,164,2,C_GRAY); } + lastPlaneReg=reg; String dist=planeDistance(f),alt=planeAltitude(f); if(full||dist!=lastPlaneDist){ - if(!full)gfx->fillRect(8,190,112,24,C_BLACK); + if(!full)gfx->fillRect(8,190,104,24,C_BLACK); gfx->setTextSize(2);gfx->setTextColor(C_CYAN);gfx->setCursor(10,194);gfx->print(dist); } if(full||alt!=lastPlaneAlt){ - if(!full)gfx->fillRect(120,190,112,24,C_BLACK); + if(!full)gfx->fillRect(128,190,104,24,C_BLACK); gfx->setTextSize(2);gfx->setTextColor(C_CYAN);gfx->setCursor(230-textW(alt,2),194);gfx->print(alt); } + // Climb/descent arrow between distance and altitude (optional). + int8_t trend=cfg.planeTrend&&!f.onGround?radarTrend(f.motion.hasRate,f.motion.rateFpm):0; + if(full||trend!=lastPlaneTrend){ + if(!full)gfx->fillRect(112,190,16,24,C_BLACK); + if(trend>0)gfx->fillTriangle(120,195,114,206,126,206,C_CYAN); + else if(trend<0)gfx->fillTriangle(114,196,126,196,120,207,C_CYAN); + } + lastPlaneTrend=trend; lastPlaneDist=dist;lastPlaneAlt=alt; if(full||f.error!=lastPlaneRendered.error||paused!=lastPlanePauseRendered||cfg.planeShowAge!=lastPlaneAgeRendered){ if(!full)gfx->fillRect(8,223,186,14,C_BLACK); @@ -1179,7 +1249,8 @@ static void drawActive() { int8_t slot=countdownSlotFromMode(cfg.mode); if(slot>=0){drawCountdown((uint8_t)slot);return;} switch (cfg.mode) { - case MODE_WEATHER: weatherPage=0; lastWeatherPageSwitchMs=millis(); drawWeather(); break; + case MODE_WEATHER: weatherPage=0; drawWeather(); break; + case MODE_FORECAST: weatherPage=1; drawWeather(); break; case MODE_PLANE: planePlacePhase=false; lastPlanePlaceSwitchMs=millis(); drawPlane(); break; case MODE_CLOCK: drawClock(); break; case MODE_TRACKED_FLIGHT: drawTrackedFlight(); break; @@ -1247,12 +1318,13 @@ static void updateCountdownSettings(JsonObjectConst in,CountdownSlot& c) { static void apiGetConfig() { JsonDocument d; - d["ssid"]=cfg.ssid;d["hostname"]=cfg.hostname;d["mode"]=cfg.mode;d["rotationMask"]=cfg.rotationMask;d["brightness"]=cfg.brightness;d["timeZone"]=cfg.timeZone; - JsonArray rs=d["rotationSec"].to();for(uint8_t i=0;i<9;i++)rs.add(cfg.rotationSec[i]); + d["ssid"]=cfg.ssid;d["hostname"]=cfg.hostname;d["mode"]=cfg.mode;d["rotationMask"]=cfg.rotationMask;d["brightness"]=cfg.brightness;d["backlightMode"]=cfg.backlightMode;d["timeZone"]=cfg.timeZone; + JsonArray rs=d["rotationSec"].to();for(uint8_t i=0;i0;d["adsbLolKeySet"]=cfg.adsbLolKey.length()>0; JsonArray a=d["countdowns"].to();for(uint8_t i=0;i<4;i++)countdownToJson(a.add(),cfg.countdown[i]); sendJson(d); @@ -1266,10 +1338,11 @@ static void apiPostConfig() { if(d["ssid"].is())cfg.ssid=d["ssid"].as(); if(d["pass"].is()){String x=d["pass"].as();if(x.length())cfg.pass=x;} if(d["hostname"].is())cfg.hostname=d["hostname"].as(); - uint16_t mask=((uint16_t)(d["rotationMask"]|cfg.rotationMask))&0x01FFU;if(mask)cfg.rotationMask=mask; - JsonArrayConst rs=d["rotationSec"].as();if(!rs.isNull())for(uint8_t i=0;i<9&&i();if(!rs.isNull())for(uint8_t i=0;i())cfg.timeZone=d["timeZone"].as(); cfg.nightEnabled=d["nightEnabled"]|cfg.nightEnabled;cfg.nightStart=constrain((int)(d["nightStart"]|cfg.nightStart),0,1439);cfg.nightEnd=constrain((int)(d["nightEnd"]|cfg.nightEnd),0,1439);cfg.nightBrightness=constrain((int)(d["nightBrightness"]|cfg.nightBrightness),1,100); if(d["stopName"].is()) cfg.stopName=d["stopName"].as(); @@ -1283,7 +1356,6 @@ static void apiPostConfig() { cfg.departureCompactDestinations=d["departureCompactDestinations"]|cfg.departureCompactDestinations; cfg.departureAbbreviate=d["departureAbbreviate"]|cfg.departureAbbreviate; cfg.departureDropTown=d["departureDropTown"]|cfg.departureDropTown; - cfg.weatherForecast=d["weatherForecast"]|cfg.weatherForecast; if(d["weatherCity"].is()) cfg.weatherCity=d["weatherCity"].as(); if(d["weatherDisplayName"].is()) cfg.weatherDisplayName=d["weatherDisplayName"].as(); cfg.weatherLat=d["weatherLat"]|cfg.weatherLat; cfg.weatherLon=d["weatherLon"]|cfg.weatherLon; @@ -1298,6 +1370,8 @@ static void apiPostConfig() { cfg.planePoll=constrain((int)(d["planePoll"]|cfg.planePoll),3,300); cfg.planeShowAge=d["planeShowAge"]|cfg.planeShowAge;cfg.planeShowPlace=d["planeShowPlace"]|cfg.planeShowPlace; cfg.planePlaceToggleSec=(d["planePlaceToggleSec"]|cfg.planePlaceToggleSec)==0?0:constrain((int)(d["planePlaceToggleSec"]|cfg.planePlaceToggleSec),5,30); + cfg.planeOperator=constrain((int)(d["planeOperator"]|cfg.planeOperator),0,2);cfg.planeSpeed=constrain((int)(d["planeSpeed"]|cfg.planeSpeed),0,2); + cfg.planeTrend=d["planeTrend"]|cfg.planeTrend;cfg.planeMarkMilitary=d["planeMarkMilitary"]|cfg.planeMarkMilitary;cfg.planeHide=((uint8_t)(d["planeHide"]|cfg.planeHide))&RADAR_HIDE_ALL; if(d["trackedFlightNo"].is()){cfg.trackedFlightNo=d["trackedFlightNo"].as();cfg.trackedFlightNo.trim();cfg.trackedFlightNo.toUpperCase();} if(d["aviationstackKey"].is()){String x=d["aviationstackKey"].as();x.trim();if(x.length())cfg.aviationstackKey=x;} // adsb.lol key: empty keeps the stored key, "-" removes it. @@ -1309,8 +1383,8 @@ static void apiPostConfig() { if(!saveConfig()){diagEvent(D_CONFIG,DS_FAILED);cfg=previous;server.send_P(500,"application/json",PSTR("{\"ok\":false,\"error\":\"Einstellungen konnten nicht gespeichert werden.\"}"));return;}diagEvent(D_CONFIG,DS_DONE);applyTimeZone();applyBrightness();if(oldAdsbKey!=cfg.adsbLolKey){adsbLolSetKey(cfg.adsbLolKey);serviceClear(SERVICE_ADSB_LOL);flightReset();} uint16_t activated=cfg.rotationMask & ~previous.rotationMask; if(previous.stopId!=cfg.stopId||previous.departureCount!=cfg.departureCount||previous.vvoMotMask!=cfg.vvoMotMask||(activated&(1U<MODE_COUNTDOWN4){server.send_P(400,"application/json",PSTR("{\"ok\":false,\"error\":\"Unbekanntes Programm.\"}"));return;} + if(mode<0||mode>=MODE_COUNT){server.send_P(400,"application/json",PSTR("{\"ok\":false,\"error\":\"Unbekanntes Programm.\"}"));return;} // Tell the web interface how long the view stays before the rotation continues. const bool rotating=enabledModeCount()>1; char reply[56];snprintf_P(reply,sizeof(reply),PSTR("{\"ok\":true,\"sec\":%u,\"rotation\":%s}"), @@ -1350,7 +1424,7 @@ static void apiCountdown() { static void apiStatus() { JsonDocument d;d["fw"]=FW_NAME;d["version"]=FW_VERSION;d["ssid"]=apMode?"PixelStop-Setup":WiFi.SSID();d["ip"]=apMode?WiFi.softAPIP().toString():WiFi.localIP().toString();d["rssi"]=apMode?0:WiFi.RSSI();d["heap"]=ESP.getFreeHeap();d["uptime"]=millis()/1000; - d["maxBlock"]=ESP.getMaxFreeBlockSize();d["vvoCount"]=vvoCount();d["vvoError"]=vvoError();d["weatherValid"]=weatherData().valid;d["weatherError"]=weatherData().error;d["flightValid"]=flightData().valid;d["flightError"]=flightData().error;d["flightStage"]=flightStageName();d["flightHttp"]=flightLastHttp();d["flightTlsRx"]=flightTlsRx();d["flightTlsMinBlock"]=flightTlsMinBlock();d["flightWaitSec"]=flightWaitSec();d["flightMinIntervalSec"]=serviceMinIntervalMs(SERVICE_ADSB_LOL)/1000;d["adsbToday"]=adsbLolRequestsToday();d["adsbDenied"]=adsbLolAccessDenied(flightLastHttp());d["adsbKey"]=adsbLolHasKey();d["adsbBudgetSec"]=adsbLolBudgetIntervalMs(radarVisibleShare())/1000;d["routeStatus"]=flightRouteStatus();d["routeSource"]=flightRouteSource();d["routeHttp"]=flightRouteHttp();d["flightAgeSec"]=flightLastOkMs()?(millis()-flightLastOkMs())/1000:0;d["trackerValid"]=trackedFlightData().valid;d["trackerError"]=trackedFlightData().error;sendJson(d); + d["maxBlock"]=ESP.getMaxFreeBlockSize();d["vvoCount"]=vvoCount();d["vvoError"]=vvoError();d["weatherValid"]=weatherData().valid;d["weatherError"]=weatherData().error;d["flightValid"]=flightData().valid;d["flightError"]=flightData().error;d["flightStage"]=flightStageName();d["flightHttp"]=flightLastHttp();d["flightTlsRx"]=flightTlsRx();d["flightTlsMinBlock"]=flightTlsMinBlock();d["flightWaitSec"]=flightWaitSec();d["flightMinIntervalSec"]=serviceMinIntervalMs(SERVICE_ADSB_LOL)/1000;d["adsbToday"]=adsbLolRequestsToday();d["adsbDenied"]=adsbLolAccessDenied(flightLastHttp());d["flightScanned"]=flightLastScanned();d["flightCall"]=flightData().valid?flightData().callsign:"";d["adsbKey"]=adsbLolHasKey();d["adsbBudgetSec"]=adsbLolBudgetIntervalMs(radarVisibleShare())/1000;d["routeStatus"]=flightRouteStatus();d["routeSource"]=flightRouteSource();d["routeHttp"]=flightRouteHttp();d["flightAgeSec"]=flightLastOkMs()?(millis()-flightLastOkMs())/1000:0;d["trackerValid"]=trackedFlightData().valid;d["trackerError"]=trackedFlightData().error;sendJson(d); } static void apiVvoSearch() { @@ -1465,7 +1539,7 @@ void loop() { if(t.tm_min!=lastMinute){ lastMinute=t.tm_min; if(cfg.mode==MODE_CLOCK) drawClock(false); - else if(cfg.mode==MODE_DEPARTURES||cfg.mode==MODE_WEATHER||cfg.mode==MODE_PLANE||cfg.mode==MODE_TRACKED_FLIGHT) drawFooterClockOnly(); + else if(cfg.mode==MODE_DEPARTURES||cfg.mode==MODE_WEATHER||cfg.mode==MODE_FORECAST||cfg.mode==MODE_PLANE||cfg.mode==MODE_TRACKED_FLIGHT) drawFooterClockOnly(); } } int8_t slot=countdownSlotFromMode(cfg.mode); @@ -1483,9 +1557,6 @@ void loop() { } } - if(cfg.mode==MODE_WEATHER&&cfg.weatherForecast&&weatherData().valid&&weatherData().days){ - if((uint32_t)(nowMs-lastWeatherPageSwitchMs)>=8000UL){weatherPage^=1;lastWeatherPageSwitchMs=nowMs;drawWeather(false);} - }else if(weatherPage){weatherPage=0;lastWeatherPageSwitchMs=nowMs;if(cfg.mode==MODE_WEATHER)drawWeather(true);} if(cfg.departureCount==10&&vvoCount()>5){ if(!departurePagingReady){departurePagingReady=true;departurePage=0;lastDeparturePageSwitchMs=nowMs;} @@ -1502,10 +1573,10 @@ void loop() { uint8_t task=cursor;cursor=(cursor+1)%6;bool ran=false; if(task==0&&modeEnabled(MODE_DEPARTURES)&&cfg.stopId.length()&&vvoPollDue(cfg.departurePoll)){ vvoFetchDepartures(cfg.stopId,cfg.departureCount,cfg.vvoMotMask);if(cfg.mode==MODE_DEPARTURES)drawDepartures(false);ran=true; - }else if(task==1&&modeEnabled(MODE_WEATHER)&&weatherPollDue(cfg.weatherPoll)){ - weatherFetch(cfg.weatherLat,cfg.weatherLon,cfg.timeZone.c_str());if(cfg.mode==MODE_WEATHER)drawWeather(false);ran=true; + }else if(task==1&&(modeEnabled(MODE_WEATHER)||modeEnabled(MODE_FORECAST))&&weatherPollDue(cfg.weatherPoll)){ + weatherFetch(cfg.weatherLat,cfg.weatherLon,cfg.timeZone.c_str());if(cfg.mode==MODE_WEATHER||cfg.mode==MODE_FORECAST)drawWeather(false);ran=true; }else if(task==2&&radarActive()&&flightPollDue(cfg.planePoll,radarVisibleShare())){ - flightFetch(cfg.planeLat,cfg.planeLon,cfg.planeRadiusKm);if(cfg.mode==MODE_PLANE)drawPlane(false);ran=true; + flightFetch(cfg.planeLat,cfg.planeLon,cfg.planeRadiusKm,cfg.planeHide);if(cfg.mode==MODE_PLANE)drawPlane(false);ran=true; }else if(task==3&&radarActive()&&flightEnrichmentDue()){ flightEnrich();if(cfg.mode==MODE_PLANE)drawPlane(false);ran=true; }else if(cfg.mode==MODE_TRACKED_FLIGHT&&cfg.trackedFlightNo.length()&&cfg.aviationstackKey.length()){ diff --git a/src/webui_en.h b/src/webui_en.h index 9b85ab0..cc8dfe7 100644 --- a/src/webui_en.h +++ b/src/webui_en.h @@ -1,3 +1,3 @@ // Generated by tools/webui_en.py. English texts for the web interface. #pragma once -static const char WEBUI_EN[] PROGMEM = R"EN({"exact":{"Abfahrten":"Departures","Wetter":"Weather","Flugradar":"Flight radar","Uhr":"Clock","Flug-Tracker":"Flight tracker","Countdown":"Countdown","Anzeige":"Display","System":"System","Abfahrtsmonitor":"Departure board","Anzeigerotation":"Display rotation","Diagnose":"Diagnostics","Wartung":"Maintenance","Status":"Status","WLAN":"Wi-Fi","Dienste und Datenquellen":"Services and data sources","Erweiterte Einstellungen":"Advanced settings","Ortsdienst":"Place search service","Einstellungen speichern":"Save settings","Sprache / Language":"Sprache / Language","Programme anhaken und je Ansicht die Anzeigedauer festlegen. Mit nur einem Haken bleibt die Ansicht dauerhaft stehen.":"Tick the views to show and set how long each one stays. With only one ticked, that view stays permanently.","Helligkeit:":"Brightness:","Nacht-Helligkeit:":"Night brightness:","Nachtmodus":"Night mode","nachts dimmen":"dim at night","Beginn":"Start","Ende":"End","Zeitzone":"Time zone","Lokale Zeit":"Local time","Uhrzeit":"Time","Gilt für Uhr, Footer, Nachtmodus, Wetter-Zeitangaben und Tages-Countdowns. Sommer- und Winterzeit werden nach den Regeln der ausgewählten Zone umgestellt.":"Used for the clock, footer, night mode, weather times and day countdowns. Daylight saving time follows the rules of the selected zone.","Live vom Verkehrsverbund Oberelbe (VVO). Haltestelle suchen, Treffer wählen und Verkehrsmittel auswählen.":"Live from Verkehrsverbund Oberelbe (VVO). Search for a stop, pick a result and choose the modes of transport.","Haltestelle suchen":"Search stop","Haltestelle":"Stop","VVO-Haltestellen-ID":"VVO stop ID","Anzahl Abfahrten":"Number of departures","Aktualisierung":"Refresh","Verkehrsmittel":"Modes of transport","Zug":"Train","S-Bahn":"S-Bahn","Straßenbahn":"Tram","Bus":"Bus","Seil-/Schwebebahn":"Cable car / suspension railway","Fähre":"Ferry","AST / Rufbus":"On-demand bus","Darstellung Fahrziel":"Destination display","Lange Ziele kompakt darstellen":"Show long destinations in small type","Ziele abkürzen (Hbf, Bf, Str., Pl., St.)":"Abbreviate destinations (Hbf, Bf, Str., Pl., St.)","Ortsnamen der Haltestelle weglassen":"Omit the town name of the stop","Beispiel: „Dresden Bühlau“ wird zu „Bühlau“, wenn die Haltestelle in Dresden liegt.":"Example: “Dresden Bühlau” becomes “Bühlau” when the stop itself is in Dresden.","Suchen":"Search","noch keine Haltestelle gewählt":"no stop selected yet","z. B. Pohlandplatz":"e.g. Pohlandplatz","Keine Haltestelle gefunden.":"No stop found.","suche beim VVO…":"searching VVO…","Live von Open-Meteo. Ort suchen und den Beobachtungspunkt auf der Karte exakt setzen. Standort gilt nur für dieses Programm.":"Live from Open-Meteo. Search for a place and set the exact point on the map. The location applies to this view only.","Ort suchen":"Search place","Auf Karte auswählen":"Pick on map","Ausgewählter Standort":"Selected location","Anzeigename":"Display name","optional, leer = gefundener Ortsname":"optional, empty = found place name","Ortsnamen":"Place names","Auf Deutsch anzeigen, wenn verfügbar":"Show in German if available","Breitengrad":"Latitude","Längengrad":"Longitude","Temperatureinheit":"Temperature unit","Celsius (°C)":"Celsius (°C)","Fahrenheit (°F)":"Fahrenheit (°F)","Farbige Darstellung":"Colours","Aktuelle Temperatur farbig darstellen":"Colour the current temperature","3-Tage-Vorhersage im Wechsel anzeigen":"Alternate with a 3-day forecast","z. B. Dresden oder 01237":"e.g. Dresden or 01237","z. B. ZUHAUSE":"e.g. HOME","z. B. Schönefeld":"e.g. Schönefeld","Kartenmaterial © OpenStreetMap-Mitwirkende. Auf die gewünschte Position tippen, um den Standort exakt zu setzen.":"Map data © OpenStreetMap contributors. Tap the desired position to set the exact location.","Live von adsb.lol. Ort suchen und den Beobachtungspunkt auf der Karte exakt setzen. Standort gilt nur für dieses Programm.":"Live from adsb.lol. Search for a place and set the exact point on the map. The location applies to this view only.","Standortname Darstellung":"Location name","Auf dem Display anzeigen":"Show on the display","Standortname Wechselintervall":"Location name interval","Kein Wechsel":"No switching","Radius":"Radius","Zeit seit letztem Abruf anzeigen":"Show time since last update","Zeigt die Sekunden seit dem letzten erfolgreichen Positionsabruf.":"Shows the seconds since the last successful position update.","Entfernung und Höhe werden zwischen den Abrufen aus Geschwindigkeit, Kurs und Steigrate weitergerechnet. Der Punkt unten links zeigt den Stand: kurz weiß bei neuen Daten, grün im normalen Takt, gelb Abruf überfällig, grau Werte angehalten.":"Between updates, distance and altitude are continued from speed, track and vertical rate. The dot at the bottom left shows the state: briefly white on new data, green on schedule, yellow update overdue, grey values frozen.","Flugdaten:":"Flight data:","adsb.lol":"adsb.lol","(ODbL) · Kostenlosen Key holen:":"(ODbL) · Get a free key:","anonym, ca. 1 Monat gültig":"anonymous, valid for about a month","weitere Wege":"other ways","adsb.lol lehnt den Key ab – vermutlich ist er abgelaufen. Neuen Key holen und hier eintragen.":"adsb.lol rejects the key – it has probably expired. Get a new key and enter it here.","adsb.lol lehnt Anfragen ohne Key ab. Mit einem kostenlosen Key geht es weiter.":"adsb.lol rejects requests without a key. A free key gets it working again.","adsb.lol API-Key":"adsb.lol API key","optional":"optional","Ohne Schlüssel erlaubt adsb.lol nur eine begrenzte Zahl von Anfragen pro Tag und Internetanschluss; für den Dauerbetrieb ohne Schlüssel 3 min wählen. „-“ eintragen und speichern entfernt einen gespeicherten Schlüssel.":"Without a key adsb.lol only allows a limited number of requests per day and internet connection; for continuous use without a key choose 3 min. Enter “-” and save to remove a stored key.","adsb.lol kann Abfragen je nach Serverauslastung vorübergehend begrenzen. Während einer Anbieterpause bleibt das zuletzt empfangene Flugzeug stehen. Nach einer Anbieterbegrenzung verlängert sich das Aktualisierungsintervall automatisch. Nach 10 Minuten ohne erneute Begrenzung gilt wieder das ausgewählte Intervall.":"adsb.lol may temporarily limit requests depending on server load. During a provider pause the last received aircraft stays on screen. After a limit the refresh interval is extended automatically; after 10 minutes without another limit the selected interval applies again.","Verfolgt genau einen Flug. Plan-/Ist-Zeiten kommen von aviationstack; Höhe und Geschwindigkeit während des Fluges zusätzlich über adsb.lol.":"Follows exactly one flight. Scheduled and actual times come from aviationstack; altitude and speed in flight additionally from adsb.lol.","Flugnummer":"Flight number","aviationstack API-Key":"aviationstack API key","Status-Aktualisierung":"Status refresh","Statusabfragen laufen sparsam und nur, wenn der Tracker tatsächlich angezeigt wird.":"Status requests are sparing and only run while the tracker is actually shown.","z. B. AF1234":"e.g. AF1234","API-Key eintragen":"Enter API key","API-Key gespeichert, leer = behalten":"API key stored, empty = keep","Vier dauerhaft gespeicherte Slots. Tages-Countdowns sind reine Kalendertage; Zeit-Countdowns laufen nach Null automatisch mit Plus weiter.":"Four permanently stored slots. Day countdowns count calendar days; time countdowns continue with a plus sign after zero.","Optionaler Titel":"Optional title","Titelfarbe":"Title colour","Timer-Art":"Timer type","Tage":"Days","Stunden : Minuten : Sekunden":"Hours : Minutes : Seconds","Minuten : Sekunden":"Minutes : Seconds","Zieltag":"Target date","Stunden":"Hours","Minuten":"Minutes","Sekunden":"Seconds","Countdown-Farbe":"Countdown colour","Farbe":"Colour","inaktiv":"inactive","aktiv":"active","Start / aktivieren":"Start / activate","Stoppen":"Stop","z. B. URLAUB":"e.g. VACATION","Countdown gestartet":"Countdown started","Jetzt anzeigen":"Show now","Wird angezeigt · bleibt stehen, bis du wieder speicherst":"Showing · stays until you save again","Koordinaten":"Coordinates","ⓘ Mehr dazu":"ⓘ More info","Countdown gestoppt":"Countdown stopped","Netzwerke suchen":"Scan networks","SSID":"SSID","Passwort":"Password","Hostname":"Hostname","leer = gespeichertes Passwort behalten":"empty = keep stored password","Log laden":"Load log","Log kopieren":"Copy log","Noch nicht geladen.":"Not loaded yet.","lade…":"loading…","Firmware-Update":"Firmware update","Neustart":"Restart","Ortsauswahl über die Internetverbindung dieses Browsers. ©":"Place search via this browser's internet connection. ©","OpenStreetMap-Mitwirkende":"OpenStreetMap contributors","Nutzungsregeln":"Usage policy",": nur manuelle Auswahl, höchstens eine Anfrage pro Sekunde für die Anwendung.":": manual selection only, at most one request per second for the application.","Adresse des Ortsdienstes":"Place search service URL","Nominatim-kompatibler Dienst. Gilt für diesen Browser.":"Nominatim-compatible service. Applies to this browser.","Ortsdienst übernehmen":"Use this service","Für die verwendeten Dienste gelten die Bedingungen der jeweiligen Anbieter. Daten und Verfügbarkeit können eingeschränkt sein.":"The terms of each provider apply to the services used. Data and availability may be limited.","Verkehrsverbund Oberelbe (VVO) ·":"Verkehrsverbund Oberelbe (VVO) ·","Anbieterinformationen":"Provider information","Nutzungsbedingungen":"Terms of use","Radarpositionen und Routen":"Radar positions and routes","API und Datenlizenz":"API and data licence","Zusatzdaten und Routen":"Additional data and routes","Dokumentation und Datenbedingungen":"Documentation and data terms","Karten":"Maps","Copyright und Datenlizenz":"Copyright and data licence","Kartenkacheln":"Map tiles","OpenStreetMap-Kachelserver ·":"OpenStreetMap tile servers ·","Kartenbibliothek":"Map library","Projektinformationen":"Project information","Nutzungshinweise":"Usage notes","Nominatim: nur manuelle Ortssuche, höchstens eine Anfrage pro Sekunde für die Anwendung; Suchergebnisse werden zwischengespeichert. Open-Meteo: die kostenlose API ist für nichtkommerzielle Nutzung vorgesehen. aviationstack benötigt einen eigenen API-Schlüssel und unterliegt dessen Tarifgrenzen.":"Nominatim: manual place search only, at most one request per second for the application; results are cached. Open-Meteo: the free API is intended for non-commercial use. aviationstack requires your own API key and is subject to its plan limits.","adsbdb nennt gesonderte Weiterverwendungsbedingungen für Routendaten. Links und Bedingungen zuletzt geprüft am 11.10.2026.":"adsbdb states separate reuse terms for route data. Links and terms last checked on 11 Oct 2026.","PixelStop · entwickelt von du13500 ·":"PixelStop · developed by du13500 ·","Auf die gewünschte Position in der Karte tippen.":"Tap the desired position on the map.","Bitte die laufende Ortsauswahl abwarten.":"Please wait for the current place lookup.","Bitte eine gültige HTTPS-Adresse eingeben.":"Please enter a valid HTTPS address.","Bitte gültige Flugradar-Koordinaten eingeben.":"Please enter valid radar coordinates.","Bitte gültige Wetter-Koordinaten eingeben.":"Please enter valid weather coordinates.","Bitte mindestens ein Programm für die Anzeige auswählen.":"Please select at least one view.","Bitte mindestens ein Verkehrsmittel auswählen.":"Please select at least one mode of transport.","Bitte mindestens zwei Zeichen eingeben.":"Please enter at least two characters.","Daten vorhanden":"data available","Fehler":"error","bereit":"ready","Der Ortsdienst bittet um eine Pause. Bitte später erneut versuchen.":"The place service asks for a pause. Please try again later.","Gespeichert · PixelStop startet neu":"Saved · PixelStop restarts","Internetverbindung erforderlich":"Internet connection required","Karte konnte nicht geladen werden. Bitte Internetverbindung prüfen oder Koordinaten manuell eingeben.":"The map could not be loaded. Check the internet connection or enter coordinates manually.","Karte wird geladen…":"Loading map…","Kein Ort gefunden.":"No place found.","Keine WLAN-Netze gefunden.":"No Wi-Fi networks found.","Leaflet konnte nicht geladen werden":"Leaflet could not be loaded","Log derzeit nicht erreichbar.":"Log currently unavailable.","Log kopiert":"Log copied","Log markiert · bitte Kopieren wählen":"Log selected · please choose Copy","Ortsdienst für diesen Browser gespeichert":"Place service saved for this browser","Ortsdienst nicht erreichbar. Internetverbindung des Browsers prüfen.":"Place service unreachable. Check the browser's internet connection.","Ortsname wird ermittelt…":"Looking up place name…","PixelStop startet neu…":"PixelStop restarts…","Position ausgewählt · kein Ortsname verfügbar. Optional einen Anzeigenamen eingeben.":"Position selected · no place name available. Optionally enter a display name.","PixelStop derzeit nicht erreichbar.":"PixelStop currently unreachable.","Unbekannter Fehler.":"Unknown error.","Verbindung zum Würfel fehlgeschlagen. Ist der Würfel eingeschaltet und mit dem WLAN verbunden?":"Connection to the cube failed. Is it switched on and connected to Wi-Fi?","Wird gespeichert…":"Saving…","suche Ort…":"searching place…","suche WLAN-Netze…":"scanning Wi-Fi…","✓ Einstellungen gespeichert":"✓ Settings saved","Countdown 1":"Countdown 1","Countdown 2":"Countdown 2","Countdown 3":"Countdown 3","Countdown 4":"Countdown 4"},"prefix":{"Anfrage fehlgeschlagen (":"Request failed (","Wird für ":"Showing for ","Ausgewählt: ":"Selected: ","Kartenposition übernommen: ":"Map position applied: ","Ortsdaten © ":"Place data © ","Ortsdienst antwortet mit HTTP ":"Place service answered HTTP ","Position ausgewählt · ":"Position selected · "},"frag":{" · Marker auf Ortsmitte gesetzt":" · marker set to place centre"," · Ortsname wird ermittelt…":" · looking up place name…"," Optional einen Anzeigenamen eingeben.":" Optionally enter a display name."," s angezeigt · danach geht die Rotation weiter":" s · then the rotation continues"},"lines":{"Netz: ":"Network: ","Freier Heap: ":"Free heap: "," B größter Block)":" B largest block)","Flugradar: ":"Radar: ","Mindestintervall":"minimum interval","Radar-Route: ":"Radar route: ","adsb.lol heute: ":"adsb.lol today: "," Anfragen":" requests"," · mit Schlüssel":" · with key"," von 450 · Tagesbudget-Intervall ":" of 450 · daily budget interval ","Tracker: ":"Tracker: "}})EN"; +static const char WEBUI_EN[] PROGMEM = R"EN({"exact":{"Abfahrten":"Departures","Wetter":"Weather","Flugradar":"Flight radar","Uhr":"Clock","Flug-Tracker":"Flight tracker","Countdown":"Countdown","Anzeige":"Display","System":"System","Abfahrtsmonitor":"Departure board","Anzeigerotation":"Display rotation","Diagnose":"Diagnostics","Wartung":"Maintenance","Status":"Status","WLAN":"Wi-Fi","Dienste und Datenquellen":"Services and data sources","Erweiterte Einstellungen":"Advanced settings","Ortsdienst":"Place search service","Einstellungen speichern":"Save settings","Sprache / Language":"Sprache / Language","Programme anhaken und je Ansicht die Anzeigedauer festlegen. Mit nur einem Haken bleibt die Ansicht dauerhaft stehen.":"Tick the views to show and set how long each one stays. With only one ticked, that view stays permanently.","Helligkeit:":"Brightness:","Nacht-Helligkeit:":"Night brightness:","Nachtmodus":"Night mode","nachts dimmen":"dim at night","Beginn":"Start","Ende":"End","Zeitzone":"Time zone","Lokale Zeit":"Local time","Uhrzeit":"Time","Gilt für Uhr, Footer, Nachtmodus, Wetter-Zeitangaben und Tages-Countdowns. Sommer- und Winterzeit werden nach den Regeln der ausgewählten Zone umgestellt.":"Used for the clock, footer, night mode, weather times and day countdowns. Daylight saving time follows the rules of the selected zone.","Live vom Verkehrsverbund Oberelbe (VVO). Haltestelle suchen, Treffer wählen und Verkehrsmittel auswählen.":"Live from Verkehrsverbund Oberelbe (VVO). Search for a stop, pick a result and choose the modes of transport.","Haltestelle suchen":"Search stop","Haltestelle":"Stop","VVO-Haltestellen-ID":"VVO stop ID","Anzahl Abfahrten":"Number of departures","Aktualisierung":"Refresh","Verkehrsmittel":"Modes of transport","Zug":"Train","S-Bahn":"S-Bahn","Straßenbahn":"Tram","Bus":"Bus","Seil-/Schwebebahn":"Cable car / suspension railway","Fähre":"Ferry","AST / Rufbus":"On-demand bus","Darstellung Fahrziel":"Destination display","Lange Ziele kompakt darstellen":"Show long destinations in small type","Ziele abkürzen (Hbf, Bf, Str., Pl., St.)":"Abbreviate destinations (Hbf, Bf, Str., Pl., St.)","Ortsnamen der Haltestelle weglassen":"Omit the town name of the stop","Beispiel: „Dresden Bühlau“ wird zu „Bühlau“, wenn die Haltestelle in Dresden liegt.":"Example: “Dresden Bühlau” becomes “Bühlau” when the stop itself is in Dresden.","Suchen":"Search","noch keine Haltestelle gewählt":"no stop selected yet","z. B. Pohlandplatz":"e.g. Pohlandplatz","Keine Haltestelle gefunden.":"No stop found.","suche beim VVO…":"searching VVO…","Live von Open-Meteo. Ort suchen und den Beobachtungspunkt auf der Karte exakt setzen. Standort gilt nur für dieses Programm.":"Live from Open-Meteo. Search for a place and set the exact point on the map. The location applies to this view only.","Ort suchen":"Search place","Auf Karte auswählen":"Pick on map","Ausgewählter Standort":"Selected location","Anzeigename":"Display name","optional, leer = gefundener Ortsname":"optional, empty = found place name","Ortsnamen":"Place names","Auf Deutsch anzeigen, wenn verfügbar":"Show in German if available","Breitengrad":"Latitude","Längengrad":"Longitude","Temperatureinheit":"Temperature unit","Celsius (°C)":"Celsius (°C)","Fahrenheit (°F)":"Fahrenheit (°F)","Farbige Darstellung":"Colours","Aktuelle Temperatur farbig darstellen":"Colour the current temperature","3-Tage-Vorhersage im Wechsel anzeigen":"Alternate with a 3-day forecast","z. B. Dresden oder 01237":"e.g. Dresden or 01237","z. B. ZUHAUSE":"e.g. HOME","z. B. Schönefeld":"e.g. Schönefeld","Kartenmaterial © OpenStreetMap-Mitwirkende. Auf die gewünschte Position tippen, um den Standort exakt zu setzen.":"Map data © OpenStreetMap contributors. Tap the desired position to set the exact location.","Live von adsb.lol. Ort suchen und den Beobachtungspunkt auf der Karte exakt setzen. Standort gilt nur für dieses Programm.":"Live from adsb.lol. Search for a place and set the exact point on the map. The location applies to this view only.","Standortname Darstellung":"Location name","Auf dem Display anzeigen":"Show on the display","Standortname Wechselintervall":"Location name interval","Kein Wechsel":"No switching","Radius":"Radius","Zeit seit letztem Abruf anzeigen":"Show time since last update","Zeigt die Sekunden seit dem letzten erfolgreichen Positionsabruf.":"Shows the seconds since the last successful position update.","Entfernung und Höhe werden zwischen den Abrufen aus Geschwindigkeit, Kurs und Steigrate weitergerechnet. Der Punkt unten links zeigt den Stand: kurz weiß bei neuen Daten, grün im normalen Takt, gelb Abruf überfällig, grau Werte angehalten.":"Between updates, distance and altitude are continued from speed, track and vertical rate. The dot at the bottom left shows the state: briefly white on new data, green on schedule, yellow update overdue, grey values frozen.","Flugdaten:":"Flight data:","Ausblenden":"Hide","Beides (z. B. US Air Force / AMC)":"Both (e.g. US Air Force / AMC)","Betreiber":"Operator","Darstellung":"Display","Dimmverfahren":"Dimming method","Eingabe anzeigen":"Show input","Geschwindigkeit":"Speed","Hauptnavigation":"Main navigation","Hubschrauber":"Helicopters","Kleinflugzeuge":"Light aircraft","Knoten (kt)":"Knots (kt)","Menü öffnen":"Open menu","Militär mit „MIL“ markieren":"Mark military with “MIL”","km/h":"km/h","nicht anzeigen":"do not show","Im Wechsel mit dem Kennzeichen, alle 3 Sekunden.":"Alternating with the registration, every 3 seconds.","Name zum Rufzeichen (z. B. Air Mobility Command)":"Name of the callsign (e.g. Air Mobility Command)","Oberbegriff (z. B. US Air Force)":"Branch (e.g. US Air Force)","Oberbegriff und „Beides“ gelten für bekannte Militär-Rufzeichen; sonst bleibt der Name zum Rufzeichen.":"Branch and “Both” apply to known military callsigns; otherwise the name of the callsign stays.","Segler, Ballone, Ultraleicht, Drohnen":"Gliders, balloons, ultralights, drones","am Boden":"on the ground","Mit Filter fragt PixelStop alle Flugzeuge im Radius ab und zeigt das nächste passende. Die Antwort ist größer, bei großem Radius dauert der Abruf etwas länger. Flugzeuge ohne Kategorie werden nie ausgeblendet. Notfälle (Squawk 7500/7600/7700) erscheinen immer rot.":"With a filter, PixelStop requests all aircraft in the radius and shows the nearest matching one. The answer is larger; with a large radius the request takes a little longer. Aircraft without a category are never hidden. Emergencies (squawk 7500/7600/7700) always appear in red.","Standard (PWM)":"Standard (PWM)","Sigma-Delta (Test gegen Aufblitzen)":"Sigma-delta (test against flashes)","Sigma-Delta dimmt über einen eigenen Baustein des Chips und wird nicht von WLAN-Aufgaben unterbrochen. Bitte nachts bei geringer Helligkeit vergleichen.":"Sigma-delta dims with a dedicated block of the chip and is not interrupted by Wi-Fi tasks. Please compare at night at low brightness.","Steig- und Sinkflug als ▲▼ anzeigen":"Show climb and descent as ▲▼","Die 3-Tage-Vorhersage ist eine eigene Ansicht in der Rotation unter „Anzeige“ und nutzt Ort und Einstellungen dieser Seite.":"The 3-day forecast is a view of its own in the rotation under “Display” and uses the location and settings of this page.","3-Tage-Vorhersage":"3-day forecast","adsb.lol":"adsb.lol","(ODbL) · Kostenlosen Key holen:":"(ODbL) · Get a free key:","anonym, ca. 1 Monat gültig":"anonymous, valid for about a month","weitere Wege":"other ways","adsb.lol lehnt den Key ab – vermutlich ist er abgelaufen. Neuen Key holen und hier eintragen.":"adsb.lol rejects the key – it has probably expired. Get a new key and enter it here.","adsb.lol lehnt Anfragen ohne Key ab. Mit einem kostenlosen Key geht es weiter.":"adsb.lol rejects requests without a key. A free key gets it working again.","adsb.lol API-Key":"adsb.lol API key","optional":"optional","Ohne Schlüssel erlaubt adsb.lol nur eine begrenzte Zahl von Anfragen pro Tag und Internetanschluss; für den Dauerbetrieb ohne Schlüssel 3 min wählen. „-“ eintragen und speichern entfernt einen gespeicherten Schlüssel.":"Without a key adsb.lol only allows a limited number of requests per day and internet connection; for continuous use without a key choose 3 min. Enter “-” and save to remove a stored key.","adsb.lol kann Abfragen je nach Serverauslastung vorübergehend begrenzen. Während einer Anbieterpause bleibt das zuletzt empfangene Flugzeug stehen. Nach einer Anbieterbegrenzung verlängert sich das Aktualisierungsintervall automatisch. Nach 10 Minuten ohne erneute Begrenzung gilt wieder das ausgewählte Intervall.":"adsb.lol may temporarily limit requests depending on server load. During a provider pause the last received aircraft stays on screen. After a limit the refresh interval is extended automatically; after 10 minutes without another limit the selected interval applies again.","Verfolgt genau einen Flug. Plan-/Ist-Zeiten kommen von aviationstack; Höhe und Geschwindigkeit während des Fluges zusätzlich über adsb.lol.":"Follows exactly one flight. Scheduled and actual times come from aviationstack; altitude and speed in flight additionally from adsb.lol.","Flugnummer":"Flight number","aviationstack API-Key":"aviationstack API key","Status-Aktualisierung":"Status refresh","Statusabfragen laufen sparsam und nur, wenn der Tracker tatsächlich angezeigt wird.":"Status requests are sparing and only run while the tracker is actually shown.","z. B. AF1234":"e.g. AF1234","API-Key eintragen":"Enter API key","API-Key gespeichert, leer = behalten":"API key stored, empty = keep","Vier dauerhaft gespeicherte Slots. Tages-Countdowns sind reine Kalendertage; Zeit-Countdowns laufen nach Null automatisch mit Plus weiter.":"Four permanently stored slots. Day countdowns count calendar days; time countdowns continue with a plus sign after zero.","Optionaler Titel":"Optional title","Titelfarbe":"Title colour","Timer-Art":"Timer type","Tage":"Days","Stunden : Minuten : Sekunden":"Hours : Minutes : Seconds","Minuten : Sekunden":"Minutes : Seconds","Zieltag":"Target date","Stunden":"Hours","Minuten":"Minutes","Sekunden":"Seconds","Countdown-Farbe":"Countdown colour","Farbe":"Colour","inaktiv":"inactive","aktiv":"active","Start / aktivieren":"Start / activate","Stoppen":"Stop","z. B. URLAUB":"e.g. VACATION","Countdown gestartet":"Countdown started","Jetzt anzeigen":"Show now","Wird angezeigt · bleibt stehen, bis du wieder speicherst":"Showing · stays until you save again","Koordinaten":"Coordinates","ⓘ Mehr dazu":"ⓘ More info","Countdown gestoppt":"Countdown stopped","Netzwerke suchen":"Scan networks","SSID":"SSID","Passwort":"Password","Hostname":"Hostname","leer = gespeichertes Passwort behalten":"empty = keep stored password","Log laden":"Load log","Log kopieren":"Copy log","Noch nicht geladen.":"Not loaded yet.","lade…":"loading…","Firmware-Update":"Firmware update","Neustart":"Restart","Ortsauswahl über die Internetverbindung dieses Browsers. ©":"Place search via this browser's internet connection. ©","OpenStreetMap-Mitwirkende":"OpenStreetMap contributors","Nutzungsregeln":"Usage policy",": nur manuelle Auswahl, höchstens eine Anfrage pro Sekunde für die Anwendung.":": manual selection only, at most one request per second for the application.","Adresse des Ortsdienstes":"Place search service URL","Nominatim-kompatibler Dienst. Gilt für diesen Browser.":"Nominatim-compatible service. Applies to this browser.","Ortsdienst übernehmen":"Use this service","Für die verwendeten Dienste gelten die Bedingungen der jeweiligen Anbieter. Daten und Verfügbarkeit können eingeschränkt sein.":"The terms of each provider apply to the services used. Data and availability may be limited.","Verkehrsverbund Oberelbe (VVO) ·":"Verkehrsverbund Oberelbe (VVO) ·","Anbieterinformationen":"Provider information","Nutzungsbedingungen":"Terms of use","Radarpositionen und Routen":"Radar positions and routes","API und Datenlizenz":"API and data licence","Zusatzdaten und Routen":"Additional data and routes","Dokumentation und Datenbedingungen":"Documentation and data terms","Karten":"Maps","Copyright und Datenlizenz":"Copyright and data licence","Kartenkacheln":"Map tiles","OpenStreetMap-Kachelserver ·":"OpenStreetMap tile servers ·","Kartenbibliothek":"Map library","Projektinformationen":"Project information","Nutzungshinweise":"Usage notes","Nominatim: nur manuelle Ortssuche, höchstens eine Anfrage pro Sekunde für die Anwendung; Suchergebnisse werden zwischengespeichert. Open-Meteo: die kostenlose API ist für nichtkommerzielle Nutzung vorgesehen. aviationstack benötigt einen eigenen API-Schlüssel und unterliegt dessen Tarifgrenzen.":"Nominatim: manual place search only, at most one request per second for the application; results are cached. Open-Meteo: the free API is intended for non-commercial use. aviationstack requires your own API key and is subject to its plan limits.","adsbdb nennt gesonderte Weiterverwendungsbedingungen für Routendaten. Links und Bedingungen zuletzt geprüft am 11.10.2026.":"adsbdb states separate reuse terms for route data. Links and terms last checked on 11 Oct 2026.","PixelStop · entwickelt von du13500 ·":"PixelStop · developed by du13500 ·","Auf die gewünschte Position in der Karte tippen.":"Tap the desired position on the map.","Bitte die laufende Ortsauswahl abwarten.":"Please wait for the current place lookup.","Bitte eine gültige HTTPS-Adresse eingeben.":"Please enter a valid HTTPS address.","Bitte gültige Flugradar-Koordinaten eingeben.":"Please enter valid radar coordinates.","Bitte gültige Wetter-Koordinaten eingeben.":"Please enter valid weather coordinates.","Bitte mindestens ein Programm für die Anzeige auswählen.":"Please select at least one view.","Bitte mindestens ein Verkehrsmittel auswählen.":"Please select at least one mode of transport.","Bitte mindestens zwei Zeichen eingeben.":"Please enter at least two characters.","Daten vorhanden":"data available","Fehler":"error","bereit":"ready","Der Ortsdienst bittet um eine Pause. Bitte später erneut versuchen.":"The place service asks for a pause. Please try again later.","Gespeichert · PixelStop startet neu":"Saved · PixelStop restarts","Internetverbindung erforderlich":"Internet connection required","Karte konnte nicht geladen werden. Bitte Internetverbindung prüfen oder Koordinaten manuell eingeben.":"The map could not be loaded. Check the internet connection or enter coordinates manually.","Karte wird geladen…":"Loading map…","Kein Ort gefunden.":"No place found.","Keine WLAN-Netze gefunden.":"No Wi-Fi networks found.","Leaflet konnte nicht geladen werden":"Leaflet could not be loaded","Log derzeit nicht erreichbar.":"Log currently unavailable.","Log kopiert":"Log copied","Log markiert · bitte Kopieren wählen":"Log selected · please choose Copy","Ortsdienst für diesen Browser gespeichert":"Place service saved for this browser","Ortsdienst nicht erreichbar. Internetverbindung des Browsers prüfen.":"Place service unreachable. Check the browser's internet connection.","Ortsname wird ermittelt…":"Looking up place name…","PixelStop startet neu…":"PixelStop restarts…","Position ausgewählt · kein Ortsname verfügbar. Optional einen Anzeigenamen eingeben.":"Position selected · no place name available. Optionally enter a display name.","PixelStop derzeit nicht erreichbar.":"PixelStop currently unreachable.","Unbekannter Fehler.":"Unknown error.","Verbindung zum Würfel fehlgeschlagen. Ist der Würfel eingeschaltet und mit dem WLAN verbunden?":"Connection to the cube failed. Is it switched on and connected to Wi-Fi?","Wird gespeichert…":"Saving…","suche Ort…":"searching place…","suche WLAN-Netze…":"scanning Wi-Fi…","✓ Einstellungen gespeichert":"✓ Settings saved","Countdown 1":"Countdown 1","Countdown 2":"Countdown 2","Countdown 3":"Countdown 3","Countdown 4":"Countdown 4"},"prefix":{"Anfrage fehlgeschlagen (":"Request failed (","Wird für ":"Showing for ","Ausgewählt: ":"Selected: ","Kartenposition übernommen: ":"Map position applied: ","Ortsdaten © ":"Place data © ","Ortsdienst antwortet mit HTTP ":"Place service answered HTTP ","Position ausgewählt · ":"Position selected · "},"frag":{" · Marker auf Ortsmitte gesetzt":" · marker set to place centre"," · Ortsname wird ermittelt…":" · looking up place name…"," Optional einen Anzeigenamen eingeben.":" Optionally enter a display name."," s angezeigt · danach geht die Rotation weiter":" s · then the rotation continues"},"lines":{"Netz: ":"Network: ","Freier Heap: ":"Free heap: "," B größter Block)":" B largest block)","Flugradar: ":"Radar: ","Mindestintervall":"minimum interval","Radar-Route: ":"Radar route: ","adsb.lol heute: ":"adsb.lol today: "," Anfragen":" requests"," · mit Schlüssel":" · with key"," von 450 · Tagesbudget-Intervall ":" of 450 · daily budget interval ","Tracker: ":"Tracker: ","Aktuelles Flugzeug: ":"Current aircraft: "," Flugzeuge geprüft":" aircraft checked"}})EN"; diff --git a/tests/webui.cjs b/tests/webui.cjs index b5bec7d..e339cd5 100644 --- a/tests/webui.cjs +++ b/tests/webui.cjs @@ -4,6 +4,8 @@ const source=fs.readFileSync(path.join(__dirname,'../src/main.cpp'),'utf8'); const version=(fs.readFileSync(path.join(__dirname,'../src/Version.h'),'utf8').match(/FW_VERSION "([^"]+)"/)||[])[1]; const html=[...source.matchAll(/R"HTML\(([\s\S]*?)\)HTML"/g)].map(m=>m[1]).join('').replace(/(v)(<\/span>)/,`$1${version}$2`); const fixture={ssid:'Testnetz',hostname:'pixelstop',timeZone:'Europe/Berlin',stopName:'Pohlandplatz',stopId:'fixture',weatherCity:'Dresden',weatherLat:51,weatherLon:13,planePlace:'Dresden',planeLat:51,planeLon:13,nightStart:1320,nightEnd:420,nightEnabled:true,brightness:70,nightBrightness:12,rotationMask:1,rotationSec:[30,20,20,15,20,20,20,20,20],departureCount:4,departurePoll:30,weatherPoll:600,planeRadiusKm:25,planePoll:10,planePlaceToggleSec:10,trackerStatusPollMin:15,vvoMotMask:127,countdowns:[]}; +// Pages are reached through the menu button (drawer), like a user would. +async function go(page,id){await page.locator('#menuBtn').click();await page.locator(`[data-p="${id}"]`).click();assert(await page.locator('#mainMenu').evaluate(e=>e.classList.contains('hidden')),'Menu closes after choosing a page');} (async()=>{ const engine=process.env.SMALLTV_BROWSER==='chromium'?chromium:webkit; const browser=await engine.launch({headless:true,...(process.env.SMALLTV_WEBKIT_EXECUTABLE?{executablePath:process.env.SMALLTV_WEBKIT_EXECUTABLE}:{})}); @@ -24,7 +26,7 @@ const fixture={ssid:'Testnetz',hostname:'pixelstop',timeZone:'Europe/Berlin',sto assert(!(await page.locator('#wetter').textContent()).includes('Ortsauswahl über diesen Browser')); assert(!(await page.locator('#flugradar').textContent()).includes('Ortsauswahl über diesen Browser')); - assert.deepStrictEqual(await page.locator('#modeRows .modeLeft span').allTextContents(),['Abfahrten','Wetter','Flugradar','Flug-Tracker','Uhr','Countdown 1','Countdown 2','Countdown 3','Countdown 4']); + assert.deepStrictEqual(await page.locator('#modeRows .modeLeft span').allTextContents(),['Abfahrten','Wetter','3-Tage-Vorhersage','Flugradar','Flug-Tracker','Uhr','Countdown 1','Countdown 2','Countdown 3','Countdown 4']); assert.strictEqual(await page.locator('#brightness').getAttribute('min'),'1'); assert.strictEqual(await page.locator('#nightBrightness').getAttribute('min'),'1'); assert.strictEqual(await page.locator('#timeZone option').count(),50); @@ -42,7 +44,7 @@ const fixture={ssid:'Testnetz',hostname:'pixelstop',timeZone:'Europe/Berlin',sto if(width<=560)assert(layout.b.top>=layout.a.bottom+5); else {assert(layout.b.left-layout.a.right>=9);assert(Math.abs(layout.a.width-layout.b.width)<1);} assert(!layout.overflow,`Page overflow at ${width}`); - await page.locator('[data-p="flugradar"]').click(); + await go(page,'flugradar'); assert(await page.locator('#planePlaceToggleSec').isDisabled()); await page.locator('#planeShowPlace').check();assert(await page.locator('#planePlaceToggleSec').isEnabled()); await page.locator('#planePlaceToggleSec').selectOption('0'); @@ -55,11 +57,11 @@ const fixture={ssid:'Testnetz',hostname:'pixelstop',timeZone:'Europe/Berlin',sto }); assert.deepStrictEqual(style.head,style.label); if(process.env.SMALLTV_SCREENSHOTS&&[390,820].includes(width)){ - await page.locator('[data-p="anzeige"]').click(); + await go(page,'anzeige'); await page.locator('#nightStart').scrollIntoViewIfNeeded(); await page.screenshot({path:path.join(process.env.SMALLTV_SCREENSHOTS,`night-${width}.png`)}); } - await page.locator('[data-p="anzeige"]').click(); + await go(page,'anzeige'); await page.locator('#timeZone').selectOption('Asia/Tokyo'); await page.getByRole('button',{name:'Einstellungen speichern',exact:true}).click(); await page.waitForFunction(()=>document.querySelector('.toast')?.textContent.includes('gespeichert')); @@ -69,7 +71,7 @@ const fixture={ssid:'Testnetz',hostname:'pixelstop',timeZone:'Europe/Berlin',sto await page.waitForFunction(()=>document.getElementById('timeZone').value==='Asia/Tokyo'); assert(!(await page.locator('#planeShowAge').isChecked()),'Disabled age restored incorrectly'); if(width===390){ - await page.locator('[data-p="wetter"]').click(); + await go(page,'wetter'); const requests=[];let releaseFirst; await page.route('http://smalltv.test/api/geo/**',()=>{throw new Error('Geo must not use the ESP8266 HTTP endpoints')}); await page.route('https://nominatim.openstreetmap.org/reverse**',async r=>{ @@ -152,7 +154,7 @@ const fixture={ssid:'Testnetz',hostname:'pixelstop',timeZone:'Europe/Berlin',sto await page.evaluate(()=>reversePlace('weather',13,23));await page.waitForFunction(()=>!geoBusy&&!geoPending.weather); assert.strictEqual(limited,1,'Provider pause must apply to both search/map programs'); assert(await page.locator('#saveBtn').isEnabled(),'Provider pause must release save'); - await page.locator('[data-p="system"]').click(); + await go(page,'system'); assert(!(await page.locator('#geoAdvanced').evaluate(e=>e.open)),'Advanced settings must start closed'); await page.locator('#geoAdvanced summary').click(); await page.locator('#geoProviderUrl').fill('https://geo.example.test/nominatim/');await page.locator('#geoProviderBtn').click(); diff --git a/tools/render_screens.py b/tools/render_screens.py index 04674ff..e1a2b64 100644 --- a/tools/render_screens.py +++ b/tools/render_screens.py @@ -90,6 +90,9 @@ def top_level_items(code): template T constrain(T x,A a,B b){return x<(T)a?(T)a:(x>(T)b?(T)b:x);} uint32_t millis(); inline void analogWrite(int,int){} +#define HIGH 1 +inline void digitalWrite(int,int){} +inline void sigmaDeltaEnable(){} inline void sigmaDeltaSetPrescaler(uint8_t){} inline void sigmaDeltaAttachPin(int,int){} inline void sigmaDeltaDetachPin(int){} inline void sigmaDeltaWrite(int,uint8_t){} inline long lround_(double v){return lround(v);} inline size_t strlcpy(char*d,const char*s,size_t n){size_t l=strlen(s);if(n){size_t c=l #define TFT_BL 5 #define BL_PWM_RANGE 1023 -struct {uint8_t brightness=1,nightBrightness=1;bool nightEnabled=false;uint16_t nightStart=1320,nightEnd=420;}cfg; +struct {uint8_t brightness=1,nightBrightness=1,backlightMode=0;bool nightEnabled=false;uint16_t nightStart=1320,nightEnd=420;}cfg; static time_t fakeNow=0;static int writes=0,last=-1; void analogWrite(int pin,int duty){assert(pin==5);writes++;last=duty;} +#define HIGH 1 +static int sdWrites=0,sdLast=-1,attached=0,detached=0,prescaler=-1; +void digitalWrite(int pin,int v){assert(pin==5&&v==HIGH);} +void sigmaDeltaEnable(){} void sigmaDeltaSetPrescaler(uint8_t p){prescaler=p;} +void sigmaDeltaAttachPin(int pin,int ch){assert(pin==5&&ch==0);attached++;} void sigmaDeltaDetachPin(int pin){assert(pin==5);detached++;} +void sigmaDeltaWrite(int ch,uint8_t v){assert(ch==0);sdWrites++;sdLast=v;} '''+code+r''' int main(){ applyBrightness();assert(writes==1&&last==1013); @@ -29,6 +35,11 @@ fakeNow+=8*3600;applyBrightness();assert(writes==4&&last==819); cfg.brightness=100;applyBrightness();assert(writes==5&&last==0); cfg.brightness=120;applyBrightness();assert(writes==5); + // Sigma-delta: active-low pulse density, attach once, back to PWM detaches. + cfg.nightEnabled=false;cfg.brightness=1;cfg.backlightMode=1;applyBrightness();assert(attached==1&&prescaler==255&&sdLast==253&&writes==5); + applyBrightness();assert(sdWrites==1);cfg.brightness=50;applyBrightness();assert(sdLast==128&&attached==1); + cfg.brightness=100;applyBrightness();assert(sdLast==0); + cfg.backlightMode=0;applyBrightness();assert(detached==1&&writes==6&&last==0); } ''') subprocess.run(['g++','-std=c++11',str(f),'-o',str(p/'test')],check=True) diff --git a/tools/test_diagnostics.py b/tools/test_diagnostics.py index 3698dd6..e0cbf12 100644 --- a/tools/test_diagnostics.py +++ b/tools/test_diagnostics.py @@ -47,6 +47,18 @@ ESP.rtc[128+8]^=1;diagInit();assert(!previousValid); // checksum detects corrupted RTC clockMs=0xfffffff0;deferBackgroundNetwork(750);clockMs=733;assert(!backgroundNetworkReady());clockMs=734;assert(backgroundNetworkReady()); clockMs=1000;{DiagRequest request(D_WEATHER);clockMs=1200;request.http(200);request.finish(true);}assert(marker.op==D_WEATHER&&marker.stage==DS_DONE&&marker.value==200); + // Radar positions: one line on success (lowest heap of the request), all steps on failure. + diagInit();uint8_t before=next;auto added=[&](){return (uint8_t)((next+24-before)%24);};ESP.heap=25000;ESP.block=12000; + clockMs=2000;{DiagRequest r(D_RADAR);r.stage(DS_TLS);ESP.heap=5100;ESP.block=3700;r.http(200);r.stage(DS_JSON);ESP.heap=21000;ESP.block=15000;clockMs=2300;r.finish(true);} + assert(added()==1);{const Event& e=events[(next+23)%24];assert(e.op==D_RADAR&&e.stage==DS_DONE&&e.heap==5100&&e.block==3700&&e.value==300&&e.code==200);} + assert(marker.op==D_RADAR&&marker.stage==DS_DONE); + before=next;{DiagRequest r(D_RADAR);r.stage(DS_TLS);r.http(429);} + assert(added()==4);assert(events[(next+23)%24].stage==DS_FAILED&&events[(next+22)%24].stage==DS_HTTP&&events[(next+21)%24].stage==DS_TLS&&events[(next+20)%24].stage==DS_BEGIN); + assert(hasLastError&&lastError.op==D_RADAR&&lastError.code==429); + before=next;{DiagRequest r(D_RADAR);r.http(200);r.finish(true,DS_EMPTY);}assert(added()==1&&events[(next+23)%24].stage==DS_EMPTY); + before=next;{DiagRequest r(D_RADAR_ROUTE);r.http(200);r.finish(true);}assert(added()==3); // other requests keep every step + diagEvent(D_RADAR_ROUTE,DS_SKIPPED,0,2);{Print o;diagPrint(o);assert(o.text.find("übersprungen")!=std::string::npos);} + diagInit();assert(previousValid&&previous.stage==DS_SKIPPED); } ''' with tempfile.TemporaryDirectory() as tmp: diff --git a/tools/test_display.py b/tools/test_display.py index ebac8fa..13e1231 100644 --- a/tools/test_display.py +++ b/tools/test_display.py @@ -29,6 +29,8 @@ def struct(name,file): #include "WeatherVisual.h" #include "DestinationFormat.h" #include "RadarMotion.h" +#include "RadarFilter.h" +#include "MilitaryOperator.h" #define PSTR(x) (x) #define FPSTR(x) (x) #define PGM_P const char* @@ -45,7 +47,8 @@ def struct(name,file): struct Rect {int x,y,w,h,color;}; struct Circle {int x,y,r,color;}; struct Line {int x,y,x2,y2,color;}; -std::vector draws;std::vector rects;std::vector circles;std::vector lines; +struct Tri {int x0,y0,x1,y1,x2,y2,color;}; +std::vector draws;std::vector rects;std::vector circles;std::vector lines;std::vector tris; String footer;int fullScreens=0; struct Gfx { int x=0,y=0,size=1; @@ -54,13 +57,14 @@ def struct(name,file): void write(uint8_t){x+=6*size;} void fillRect(int x,int y,int w,int h,int c){rects.push_back({x,y,w,h,c});} void fillCircle(int x,int y,int r,int c){circles.push_back({x,y,r,c});} void drawLine(int x,int y,int x2,int y2,int c){lines.push_back({x,y,x2,y2,c});} + void fillTriangle(int a,int b,int c,int d,int e,int f,int col){tris.push_back({a,b,c,d,e,f,col});} void drawPixel(int x,int y,int c){fillRect(x,y,1,1,c);} void drawFastHLine(int x,int y,int w,int c){drawLine(x,y,x+w-1,y,c);} void drawFastVLine(int x,int y,int h,int c){drawLine(x,y,x,y+h-1,c);} } display; Gfx* gfx=&display; const double PI=3.14159265358979323846; -const int C_BLACK=0,C_WHITE=1,C_YELLOW=2,C_GRAY=3,C_RED=4,C_GREEN=5,C_CYAN=6,C_DGRAY=7,TFT_W=240; +const int C_BLACK=0,C_WHITE=1,C_YELLOW=2,C_GRAY=3,C_RED=4,C_GREEN=5,C_CYAN=6,C_DGRAY=7,C_KHAKI=8,TFT_W=240; void centerText(const String& s,int y,int size,int color){draws.push_back({s,y,size,-1,color});} void drawFooter(const String& s,bool=true,int=8){footer=s;} void printDisplayTextAt(int,int,const String& s,uint8_t size,uint16_t); @@ -71,7 +75,7 @@ def struct(name,file): const int COUNTDOWN_DAYS=0; struct CountdownSlot{String title,titleColor="#ffffff",countColor="#ffffff";uint8_t type=1;}; enum Language:uint8_t{LANG_DE=0,LANG_EN=1}; -struct Settings{uint8_t lang=LANG_DE;String stopPlace;String trackedFlightNo,aviationstackKey,planePlace,planeDisplayName,stopName,stopId,weatherDisplayName,weatherCity,timeZone;bool planeShowPlace=false,planeShowAge=true,departureCompactDestinations=false,departureAbbreviate=true,departureDropTown=true,weatherForecast=true,weatherFahrenheit=false,weatherTempColor=false;uint16_t planePlaceToggleSec=10;uint8_t departureCount=5;CountdownSlot countdown[4];} cfg; +struct Settings{uint8_t lang=LANG_DE;String stopPlace;String trackedFlightNo,aviationstackKey,planePlace,planeDisplayName,stopName,stopId,weatherDisplayName,weatherCity,timeZone;bool planeShowPlace=false,planeShowAge=true,departureCompactDestinations=false,departureAbbreviate=true,departureDropTown=true,weatherForecast=true,weatherFahrenheit=false,weatherTempColor=false;uint16_t planePlaceToggleSec=10;uint8_t planeOperator=0,planeSpeed=0;bool planeTrend=false,planeMarkMilitary=true;uint8_t departureCount=5;CountdownSlot countdown[4];} cfg; static String tr(PGM_P de,PGM_P en){return String(cfg.lang==LANG_EN?en:de);} #define TR(de,en) tr(PSTR(de),PSTR(en)) String lastCountdownRendered[4];uint8_t departurePage=0;uint8_t weatherPage=0; @@ -103,16 +107,18 @@ def struct(name,file): uint32_t clockMs=100000,lastOkMs=65000;bool providerPaused=false; uint32_t millis(){return clockMs;}float flightLiveDistanceKm(const FlightSnapshot& f){return f.distanceKm;}int32_t flightLiveAltitudeFt(const FlightSnapshot& f){return f.altitudeFt;}uint32_t flightPollIntervalMs(){return 30000;}uint32_t flightLastOkMs(){return lastOkMs;}bool flightProviderPaused(){return providerPaused;}static int lastHttp=0;int flightLastHttp(){return lastHttp;}static bool adsbLolAccessDenied(int c){return c==401||c==403||c==426;} String trackedFlightDuration(const TrackedFlightSnapshot&){return "01:30";} -void clearDraws(){draws.clear();rects.clear();circles.clear();lines.clear();fullScreens=0;footer="not drawn";} +void clearDraws(){draws.clear();rects.clear();circles.clear();lines.clear();tris.clear();fullScreens=0;footer="not drawn";} ''' post=r''' int main(){ - for(const char* code:{"E170","E175","E75L","E75S","E190","E195","E290","E295","B38M","B39M","A21N"}){ - FlightSnapshot sample={};strcpy(sample.typeCode,code); - String first=compactType(sample);assert(first==aircraftDisplayLabel(code)); + for(const char* code:{"E170","E75L","E75S","E190","E195","E290","E295","B38M","B39M","A21N","C17","B77L","CL60","A35K","B3XM","T154"}){ + FlightSnapshot sample={};strcpy(sample.typeCode,code);char label[19];assert(aircraftDisplayLabel(code,label,sizeof label)); + String first=compactType(sample);assert(first==label); strcpy(sample.typeName,"A long metadata description with additional variant information"); assert(compactType(sample)==first);assert(textW(first,2)<=224); } + {FlightSnapshot sample={};strcpy(sample.typeCode,"ZZZZ");assert(compactType(sample)=="ZZZZ");char label[19];assert(!aircraftDisplayLabel("ZZZZ",label,sizeof label)); + aircraftDisplayLabel("C17",label,sizeof label);assert(String(label)=="Boeing C-17A");aircraftDisplayLabel("CL60",label,sizeof label);assert(String(label)=="Challenger 6XX");} cfg.planeShowPlace=true;cfg.planeDisplayName="WUNSCHTEXT";cfg.planePlaceToggleSec=0;planePlacePhase=false;clearDraws();drawPlaneHeader();assert(draws.back().text=="WUNSCHTEXT"); cfg={}; FlightRoute route={}; @@ -147,8 +153,8 @@ def struct(name,file): clockMs=lastOkMs+2000;clearDraws();drawPlane(false);assert(circles.size()==1&&circles[0].color==C_GREEN); clockMs=100000;clearDraws();drawPlane(false);assert(circles.empty()&&fullScreens==0); plane.distanceKm=9.7f;clearDraws();drawPlane(false);assert(fullScreens==0&&rects.size()==1&&draws.size()==1); - assert(rects[0].x==8&&rects[0].y==190&&rects[0].w==112&&rects[0].h==24);assert(draws[0].text=="9.7 km"); - plane.altitudeFt=30000;clearDraws();drawPlane(false);assert(fullScreens==0&&rects.size()==1&&rects[0].x==120); + assert(rects[0].x==8&&rects[0].y==190&&rects[0].w==104&&rects[0].h==24);assert(draws[0].text=="9.7 km"); + plane.altitudeFt=30000;clearDraws();drawPlane(false);assert(fullScreens==0&&rects.size()==1&&rects[0].x==128); strcpy(plane.airline,"Turkish Airlines");clearDraws();drawPlane(false);assert(fullScreens==0&&rects.size()==1&&rects[0].y==78); parseFlightRoute("OSL-LEJ-IST",plane.route);clearDraws();drawPlane(false);assert(fullScreens==0&&rects.size()==1&&rects[0].y==102); plane.error=true;clearDraws();drawPlane(false);assert(fullScreens==0&&footer=="LETZTER STAND"); @@ -175,6 +181,39 @@ def struct(name,file): cfg.planeShowAge=true;clearDraws();drawPlane(false);assert(draws.back().text=="17s"&&draws.back().x==84); plane.valid=false;clearDraws();drawPlaneAge();assert(draws.empty()&&rects.empty()); providerPaused=false;plane.valid=true;plane.error=false; + // Emergency: red callsign, "SQUAWK 7700" alternates with the route every 3 s; permanent without route. + cfg.planeShowAge=false;clockMs=300000;strcpy(plane.squawk,"7700");clearDraws();drawPlane(); + {bool red=false,sq=false;for(auto d:draws){if(d.text==plane.callsign&&d.color==C_RED)red=true;if(d.text=="SQUAWK 7700")sq=true;}assert(red&&!sq);} + clockMs=303000;clearDraws();drawPlane(false);assert(fullScreens==0&&draws.size()==1&&draws[0].text=="SQUAWK 7700"&&draws[0].color==C_RED&&rects.size()==1&&rects[0].y==102); + clockMs=306000;clearDraws();drawPlane(false);assert(draws.size()==1&&draws[0].text!="SQUAWK 7700"); + FlightRoute keepRoute=plane.route;char keepO[4],keepD[4];strcpy(keepO,plane.origin);strcpy(keepD,plane.destination); + plane.route={};strcpy(plane.origin,"N/A");strcpy(plane.destination,"N/A");clearDraws();drawPlane(false);assert(draws.size()==1&&draws[0].text=="SQUAWK 7700"); + clockMs=309000;clearDraws();drawPlane(false);assert(draws.empty()); + plane.route=keepRoute;strcpy(plane.origin,keepO);strcpy(plane.destination,keepD);plane.squawk[0]=0;clearDraws();drawPlane(false); + {bool white=false;for(auto d:draws)if(d.text==plane.callsign&&d.color==C_WHITE)white=true;assert(white);} + // Military: MIL badge; operator variants A/B/C. + strcpy(plane.callsign,"RCH5060");strcpy(plane.airline,"Air Mobility Command");plane.military=true;clearDraws();drawPlane(false); + {bool mil=false;for(auto d:draws)if(d.text=="MIL"&&d.x==214)mil=true;assert(mil);} + assert(planeOperatorText(plane)=="Air Mobility Command");cfg.planeOperator=1;assert(planeOperatorText(plane)=="US Air Force"); + cfg.planeOperator=2;assert(planeOperatorText(plane)=="US Air Force / AMC");strcpy(plane.callsign,"EZY2064");assert(planeOperatorText(plane)=="Air Mobility Command"); + strcpy(plane.callsign,"GAF681");assert(planeOperatorText(plane)=="Luftwaffe");cfg.lang=LANG_EN;assert(planeOperatorText(plane)=="German Air Force");cfg.lang=LANG_DE; + strcpy(plane.callsign,"RCHX12");assert(planeOperatorText(plane)=="Air Mobility Command"); + cfg.planeMarkMilitary=false;strcpy(plane.callsign,"RCH5060");clearDraws();drawPlane(false);for(auto d:draws)assert(d.text!="MIL"); + cfg.planeOperator=0;plane.military=false;cfg.planeMarkMilitary=true; + // Speed alternates with the registration; without registration it stays. + plane.speedKnown=true;plane.speedKt=467;cfg.planeSpeed=1;clockMs=300000;clearDraws();drawPlane(); + clockMs=303000;clearDraws();drawPlane(false);assert(draws.size()==1&&draws[0].text=="865 km/h"&&rects[0].y==161); + cfg.planeSpeed=2;clockMs=309000;clearDraws();drawPlane(false);assert(draws.size()==1&&draws[0].text=="467 kt"); + clockMs=312000;clearDraws();drawPlane(false);assert(draws.size()==1&&draws[0].text==plane.registration); + plane.registration[0]=0;clearDraws();drawPlane(false);assert(draws.size()==1&&draws[0].text=="467 kt"); + cfg.planeSpeed=0;strcpy(plane.registration,"TC-JRS"); + // Trend arrow: only with the option and from 300 ft/min; level flight leaves the gap empty. + plane.motion.hasRate=true;plane.motion.rateFpm=1200;clearDraws();drawPlane(false);assert(tris.empty()); + cfg.planeTrend=true;clearDraws();drawPlane(false);assert(tris.size()==1&&tris[0].y0tris[0].y0); + plane.motion.rateFpm=150;clearDraws();drawPlane(false);assert(tris.empty()&&rects.size()==1&&rects[0].x==112); + clearDraws();drawPlane(false);assert(tris.empty()&&rects.empty()); + cfg.planeTrend=false;plane.motion.hasRate=false;cfg.planeShowAge=true; // Weather motifs: night partly clouded must have a moon; fog has no cloud. clearDraws();drawWeatherIcon(2,false);assert(circles.size()==5&&circles[0].color==C_WHITE&&circles[1].color==C_BLACK); clearDraws();drawWeatherIcon(45,true);assert(circles.empty()&&rects.size()==4&&lines.empty()); @@ -195,8 +234,9 @@ def struct(name,file): assert(crop("Москва",4)=="Мос.");clearDraws();drawSpecialGlyph(0,0,2,specialGlyph(0x416),C_WHITE);assert(!rects.empty()); for(auto q:rects)assert(q.x+q.w<=10&&q.y+q.h<=14); plane.onGround=true;assert(planeAltitude(plane)=="GND");plane.onGround=false;plane.altitudeKnown=false;assert(planeAltitude(plane)=="N/A");plane.altitudeKnown=true;plane.altitudeFt=0;assert(planeAltitude(plane)=="0 m"); - strcpy(plane.typeName,"Reims-Cessna F172N Skyhawk");strcpy(plane.typeCode,"C172");assert(compactType(plane)=="Cessna F172N"); - strcpy(plane.typeName,"A very long unrecognized manufacturer and model");assert(compactType(plane)=="C172"); + strcpy(plane.typeName,"Reims-Cessna F172N Skyhawk");strcpy(plane.typeCode,"C172");assert(compactType(plane)=="Cessna 172"); + strcpy(plane.typeCode,"ZZ72");assert(compactType(plane)=="Cessna F172N"); + strcpy(plane.typeName,"A very long unrecognized manufacturer and model");assert(compactType(plane)=="ZZ72"); // Weather: an identical refresh draws nothing; changed temperature restores its unit. cfg.weatherCity="Dresden";weather.valid=true;weather.code=2;weather.isDay=false;weather.currentC=15;weather.highC=20;weather.lowC=8;weather.rainPct=10; clearDraws();drawWeather();assert(fullScreens==1);clearDraws();drawWeather(false);assert(fullScreens==0&&rects.empty()&&draws.empty()&&circles.empty()); @@ -233,8 +273,12 @@ def struct(name,file): puts("Real display: selective radar/new aircraft, stale states, tracker footer, weather motifs and Unicode bounds OK"); } ''' -pre+='\nstatic bool lastPlanePauseRendered=false,lastPlaneAgeRendered=true;\nstatic String lastPlaneDist,lastPlaneAlt;static int32_t lastPlaneDot=-1;static const int PLANE_FOOTER_X=18;\n' -names=['nextCodepoint','glyphCount','drawSpecialGlyph','textW','crop','stopTown','departureText','beginView','visibleText','visibleCenter','planePlaceTitle','drawPlaneHeader','routePart','drawFlightRoute','samePlane','planeDistance','planeAltitude','compactType','planeFooterLabel','drawPlaneAge','drawPlaneDot','drawPlaneFooter','drawPlane','drawTrackedFlight','wxLen','drawCloud','drawSun','drawMoon','drawSnowflake','drawWeatherIconAt','drawWeatherIcon','drawSunEventIcon','centerTextIn','drawForecast','drawWeather','drawDepartures','segMask','drawSevenDigit','sevenUnit','sevenCharWidth','drawSevenString','drawCountdown','drawClock'] +pre+='\nstatic bool lastPlanePauseRendered=false,lastPlaneAgeRendered=true;\nstatic String lastPlaneDist,lastPlaneAlt;static int32_t lastPlaneDot=-1;static const int PLANE_FOOTER_X=18;\nstatic String lastPlaneCall,lastPlaneOperator,lastPlaneRoute,lastPlaneReg;static int8_t lastPlaneTrend=0;\n' +names=['nextCodepoint','glyphCount','drawSpecialGlyph','textW','crop','stopTown','departureText','beginView','visibleText','visibleCenter','planePlaceTitle','drawPlaneHeader','routePart','drawFlightRoute','samePlane','planeDistance','planeAltitude','compactType','planeFooterLabel','drawPlaneAge','drawPlaneDot','drawPlaneFooter','planeSecondPhase','planeOperatorText','planeSpeedText','drawPlane','drawTrackedFlight','wxLen','drawCloud','drawSun','drawMoon','drawSnowflake','drawWeatherIconAt','drawWeatherIcon','drawSunEventIcon','centerTextIn','drawForecast','drawWeather','drawDepartures','segMask','drawSevenDigit','sevenUnit','sevenCharWidth','drawSevenString','drawCountdown','drawClock'] +import collections +_types=re.findall(r'\{"([A-Z0-9]{2,4})","([^"]*)"\}',(root/'src/AircraftLabel.h').read_text()) +assert len(_types)>=200 and all(len(n)<=18 and n.isascii() for _,n in _types),'aircraft names must be ASCII and at most 18 characters' +assert not [c for c,k in collections.Counter(c for c,_ in _types).items() if k>1],'duplicate aircraft codes' with tempfile.TemporaryDirectory() as t: p=Path(t);(p/'test.cpp').write_text(pre+'\n'+'\n'.join(fn(name) for name in names)+'\n'+post) subprocess.run(['g++','-std=c++11','-Wall','-Wextra','-Werror','-I'+str(root/'src'),str(p/'test.cpp'),'-o',str(p/'test')],check=True) diff --git a/tools/test_radar.py b/tools/test_radar.py index 542aba4..1b317f2 100644 --- a/tools/test_radar.py +++ b/tools/test_radar.py @@ -39,27 +39,27 @@ def function(name): static uint8_t g_consecutiveFailures=0; static int g_lastHttp=0; static const char* g_stage="bereit"; -static uint16_t g_adsbLolRx=512; +static uint16_t g_adsbLolRx=512,g_scanned=0; static int probes=0,requests=0; static uint16_t adsbLolRx(){++probes;return g_adsbLolRx;} ''' funcs='\n'.join(function(n) for n in ['tlsHeapReady','flightPollDue','flightExpire','flightFailure','flightSuccess']) # Run the original pre-request section verbatim; replace only the network body. fetch=function('flightFetch').split(' uint16_t radiusNm',1)[0] -fetch+=' (void)homeLat;(void)homeLon;(void)radiusKm;requests++;return true;\n}\n' +fetch+=' (void)homeLat;(void)homeLon;(void)radiusKm;(void)scan;requests++;return true;\n}\n' tests='''int main(){ - for(auto rx:{512,1024,4096}){g_adsbLolRx=rx;ESP.heap=25248;ESP.block=11368;assert(flightFetch(51,13,25));} + for(auto rx:{512,1024,4096}){g_adsbLolRx=rx;ESP.heap=25248;ESP.block=11368;assert(flightFetch(51,13,25,0));} assert(requests==3&&probes==3); g_f.valid=true;g_f.error=false;g_lastOkMs=10000;clockMs=15000; - ESP.block=6000;assert(!flightFetch(51,13,25));assert(requests==3&&probes==3); + ESP.block=6000;assert(!flightFetch(51,13,25,0));assert(requests==3&&probes==3); assert(g_f.valid&&g_f.error);assert(!strcmp(g_stage,"übersprungen: Heap")); assert(!flightPollDue(5,1.0f));clockMs=20001;assert(flightPollDue(5,1.0f)); minimumInterval=15000;clockMs=29999;assert(!flightPollDue(5,1.0f));clockMs=30000;assert(flightPollDue(5,1.0f));minimumInterval=0; budgetInterval=12000;clockMs=26999;assert(!flightPollDue(5,0.25f)&&lastShare==0.25f);clockMs=27000;assert(flightPollDue(5,0.25f)&&g_intervalMs==12000);budgetInterval=0; clockMs=39999;assert(!flightExpire());clockMs=40000;assert(flightExpire());assert(!g_f.valid&&g_f.error);assert(!flightExpire()); - ESP.heap=25768;ESP.block=13192;g_adsbLolRx=512;assert(flightFetch(51,13,25)); + ESP.heap=25768;ESP.block=13192;g_adsbLolRx=512;assert(flightFetch(51,13,25,0)); g_f={true,false};flightSuccess();assert(!g_consecutiveFailures&&g_lastOkMs==40000); - WiFi.state=0;clockMs=45000;assert(!flightFetch(51,13,25));assert(g_f.valid&&g_f.error);assert(!strcmp(g_stage,"kein WLAN")); + WiFi.state=0;clockMs=45000;assert(!flightFetch(51,13,25,0));assert(g_f.valid&&g_f.error);assert(!strcmp(g_stage,"kein WLAN")); clockMs=70000;assert(!flightFailure("HTTP-Fehler"));assert(!g_f.valid); // Confirmed provider pauses preserve data beyond normal expiry, even after // the cooldown timer ends, until the next actual result. Real errors expire. diff --git a/tools/test_radar_scan.py b/tools/test_radar_scan.py new file mode 100644 index 0000000..d805ab1 --- /dev/null +++ b/tools/test_radar_scan.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python3 +"""Radar filter: all aircraft read one by one, hidden categories skipped, nearest kept.""" +from pathlib import Path +import subprocess,tempfile +root=Path(__file__).resolve().parents[1] +lib=root/'.pio/libdeps/smalltv_ultra/ArduinoJson/src' +if not lib.is_dir():raise SystemExit('Install pinned ArduinoJson with pio pkg install before this test') +test=r''' +#include +#include "RadarScan.h" +#include "RadarFilter.h" +#include +#include +#include +#include +// Minimal stream: read/peek for the scanner, readBytes for ArduinoJson. +struct Body { + std::string s; size_t i=0; + explicit Body(const char* t):s(t){} + int read(){return i();f["hex"]=true;f["category"]=true;f["alt_baro"]=true;f["d"]=true; + Pick p; + uint16_t n=radarScanArray(b,doc,filter,[&](JsonObjectConst a){ + p.seen++;bool ground=a["alt_baro"].is()&&!strcmp(a["alt_baro"],"ground"); + if(radarHidden(a["category"]|"",ground,mask))return; + float d=a["d"]|1e9f;if(d