diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4a40ad7..f56491e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -85,6 +85,7 @@ jobs: run: | set -o pipefail pio run -e smalltv_ultra 2>&1 | tee build.log + python3 tools/check_ram.py build.log - name: Ergebnis vorbereiten if: always() diff --git a/CHANGELOG.md b/CHANGELOG.md index e0bf80f..4a25e4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Änderungen +## v0.5.3.1-dev + +- **Radar: Speicher zurückgeholt.** v0.5.3 belegte 748 Byte mehr festen Arbeitsspeicher als v0.5.2; während einer TLS-Abfrage blieben dadurch zeitweise nur ~4,3 KB frei, und die Antwort ließ sich nicht mehr einlesen („JSON:NoMemory“, Radar ohne Daten). Die Militär-Tabelle liegt jetzt im Flash, ebenso einige kurze Anzeigetexte. +- **Build-Prüfung:** `tools/check_ram.py` lässt den Build scheitern, wenn der feste RAM-Verbrauch über 51.600 Byte steigt. + ## v0.5.3-dev - **Webinterface-Menü:** Die wischbare Reiterleiste ist ersetzt durch ein Menü hinter der Taste ☰ (ausklappend wie beim RavestickBoard). Unter dem Titel steht die aktuelle Seite. diff --git a/README.en.md b/README.en.md index 90f7fc7..3f6a134 100644 --- a/README.en.md +++ b/README.en.md @@ -6,7 +6,7 @@ Bought as a small Wi-Fi cube with a rather modest stock firmware – and from day one with the plan to turn it into something of my own. [![Build](https://github.com/du13500/pixelstop/actions/workflows/build.yml/badge.svg)](https://github.com/du13500/pixelstop/actions/workflows/build.yml) -![Version](https://img.shields.io/badge/version-v0.5.3--dev-orange) +![Version](https://img.shields.io/badge/version-v0.5.3.1--dev-orange) ![Hardware](https://img.shields.io/badge/hardware-ESP8266%20%C2%B7%20SmallTV--Ultra-blue) ![Hardware test](https://img.shields.io/badge/hardware%20test-v0.5.3%20pending-yellow) ![Hobby project](https://img.shields.io/badge/hobby%20project-non--commercial-lightgrey) @@ -59,7 +59,7 @@ Plus night mode, brightness down to 1 %, place search with a map, Greek and Cyri -## Status: v0.5.3-dev +## Status: v0.5.3.1-dev | Area | Status | | --- | --- | diff --git a/README.md b/README.md index 0eb44de..4751653 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Gekauft als kleiner WLAN-Würfel mit eher bescheidener Werksfirmware – und von Anfang an mit dem Plan, etwas Eigenes daraus zu machen. [![Build](https://github.com/du13500/pixelstop/actions/workflows/build.yml/badge.svg)](https://github.com/du13500/pixelstop/actions/workflows/build.yml) -![Version](https://img.shields.io/badge/version-v0.5.3--dev-orange) +![Version](https://img.shields.io/badge/version-v0.5.3.1--dev-orange) ![Hardware](https://img.shields.io/badge/hardware-ESP8266%20%C2%B7%20SmallTV--Ultra-blue) ![Hardwaretest](https://img.shields.io/badge/hardwaretest-v0.5.3%20offen-yellow) ![Hobbyprojekt](https://img.shields.io/badge/hobbyprojekt-nicht%20kommerziell-lightgrey) @@ -59,7 +59,7 @@ Dazu kommen Nachtmodus, Helligkeit ab 1 %, Ortssuche mit Karte, griechische und -## Entwicklungsstand: v0.5.3-dev +## Entwicklungsstand: v0.5.3.1-dev | Bereich | Stand | | --- | --- | diff --git a/TESTPLAN.md b/TESTPLAN.md index 1a65b6a..40530a9 100644 --- a/TESTPLAN.md +++ b/TESTPLAN.md @@ -1,9 +1,11 @@ # Testplan -Stand: v0.5.3-dev (09.11.2026). Dieser Plan wird mit jeder Version aktualisiert; frühere Pläne stehen in der Git-Historie, Änderungen in [`CHANGELOG.md`](CHANGELOG.md). +Stand: v0.5.3.1-dev (10.11.2026). Dieser Plan wird mit jeder Version aktualisiert; frühere Pläne stehen in der Git-Historie, Änderungen in [`CHANGELOG.md`](CHANGELOG.md). ## Hardwaretest v0.5.3-dev +0. **v0.5.3.1:** Radar über mehrere Stunden ohne „JSON:NoMemory“ im Log; kleinster freier Speicher der Radar-Zeilen wieder um 5 KB. + 1. **Dimmverfahren:** Nachts bei 1–10 % unter *Anzeige → Dimmverfahren* zwischen Standard (PWM) und Sigma-Delta wechseln. Aufblitzen, Fiepen und saubere Helligkeitsstufen vergleichen; dabei auch Radar mit Abrufen und offenes Webinterface laufen lassen. 2. **Webinterface:** Menü hinter ☰ öffnen und schließen (Tippen daneben, Escape), Seitenname unter dem Titel; Auge-Symbol nur beim Tippen, nach dem Speichern wieder verdeckt und leer. 3. **3-Tage-Vorhersage:** nach dem Update als eigene Zeile unter „Wetter“ angehakt (wenn sie vorher aktiv war); eigene Dauer, ▶ Jetzt anzeigen; Wetter-Reiter ohne die alte Checkbox. Rotation in der Reihenfolge der Liste. diff --git a/src/MilitaryOperator.h b/src/MilitaryOperator.h index 681c580..b51a0cf 100644 --- a/src/MilitaryOperator.h +++ b/src/MilitaryOperator.h @@ -2,14 +2,26 @@ // 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). +// The table lives in flash; entries are copied out one at a time. #include #include #include +#ifdef ARDUINO +#include +#else +#ifndef PROGMEM +#define PROGMEM +#endif +#ifndef memcpy_P +#define memcpy_P memcpy +#endif +#endif -struct MilitaryOperator { const char* prefix; const char* de; const char* en; const char* unit; }; +struct MilitaryOperator { char prefix[5]; char de[19]; char en[19]; char unit[6]; }; -inline const MilitaryOperator* militaryOperatorFor(const char* callsign) { - static const MilitaryOperator table[] = { +// Copies the entry for the callsign into out; false if none matches. +inline bool militaryOperatorFor(const char* callsign, MilitaryOperator& out) { + static const MilitaryOperator table[] PROGMEM = { {"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",""}, @@ -34,26 +46,28 @@ inline const MilitaryOperator* militaryOperatorFor(const char* callsign) { {"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)) { + if (!callsign || !*callsign) return false; + for (size_t i = 0; i < sizeof(table) / sizeof(table[0]); i++) { + memcpy_P(&out, &table[i], sizeof(out)); + size_t n = strlen(out.prefix); + if (!strncmp(callsign, out.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; + if (n == 4 || (next >= '0' && next <= '9')) return true; } } - return nullptr; + return false; } // 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; + MilitaryOperator m; + if ((variant != 1 && variant != 2) || !out || !cap || !militaryOperatorFor(callsign, m)) return false; + const char* branch = english ? m.en : m.de; + size_t combined = strlen(branch) + 3 + strlen(m.unit); 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); + if (variant == 2 && m.unit[0] && combined <= limit && combined < cap) { + strcpy(out, branch); strcat(out, " / "); strcat(out, m.unit); } else { strncpy(out, branch, cap - 1); out[cap - 1] = 0; } diff --git a/src/Version.h b/src/Version.h index 49837a7..6004d89 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.3-dev" +#define FW_VERSION "0.5.3.1-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 3d356bb..71596ea 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1061,7 +1061,7 @@ static const int PLANE_FOOTER_X=18; // Name of the position source in the footer (prepared for further sources). static const char* planeSourceLabel="ADSB.LOL"; static String planeFooterLabel() { - return flightProviderPaused()?String(TR("ABRUFPAUSE","PAUSED")):(flightData().error?String(TR("LETZTER STAND","LAST DATA")):String(planeSourceLabel)+" LIVE"); + return flightProviderPaused()?String(TR("ABRUFPAUSE","PAUSED")):(flightData().error?String(TR("LETZTER STAND","LAST DATA")):String(planeSourceLabel)+F(" LIVE")); } static void drawPlaneAge() { if(!cfg.planeShowAge||!flightData().valid)return; @@ -1097,7 +1097,7 @@ static String planeOperatorText(const FlightSnapshot& f) { return f.airline[0]?String(f.airline):String("N/A"); } static String planeSpeedText(const FlightSnapshot& f) { - return cfg.planeSpeed==2?String((int)lroundf(f.speedKt))+" kt":String((int)lroundf(f.speedKt*1.852f))+" km/h"; + return cfg.planeSpeed==2?String((int)lroundf(f.speedKt))+F(" kt"):String((int)lroundf(f.speedKt*1.852f))+F(" km/h"); } static void drawPlane(bool force=true) { const FlightSnapshot& f=flightData(); @@ -1122,7 +1122,7 @@ static void drawPlane(bool force=true) { if(full||callKey!=lastPlaneCall){ if(!full)gfx->fillRect(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,emergency?C_RED:C_WHITE); - if(cfg.planeMarkMilitary&&f.military)printDisplayTextAt(214,38,"MIL",1,C_KHAKI); + if(cfg.planeMarkMilitary&&f.military)printDisplayTextAt(214,38,String(F("MIL")),1,C_KHAKI); } lastPlaneCall=callKey; String op=planeOperatorText(f); @@ -1133,7 +1133,7 @@ static void drawPlane(bool force=true) { lastPlaneOperator=op; const bool routeKnown=f.route.count>0||(f.origin[0]&&strcmp(f.origin,"N/A")); // In an emergency the whole route line is red: route and squawk alternate. - String routeKey=emergency?((second||!routeKnown)?String("SQUAWK ")+f.squawk:String("!")):String(); + String routeKey=emergency?((second||!routeKnown)?String(F("SQUAWK "))+f.squawk:String(F("!"))):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))){ diff --git a/tools/check_ram.py b/tools/check_ram.py new file mode 100644 index 0000000..77e23f5 --- /dev/null +++ b/tools/check_ram.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 +"""Fails the build when the static RAM use grows past the limit. + +The ESP8266 has ~80 KB RAM; every byte of static data is missing from the heap +during TLS requests, where only a few KB are left. v0.5.3 lost ~750 bytes this +way and radar answers no longer fit. Raise the limit only on purpose. +""" +import re, sys +LIMIT = 51600 # bytes; v0.5.2 used 51396 +log = open(sys.argv[1] if len(sys.argv) > 1 else 'build.log', encoding='utf-8', errors='replace').read() +m = re.search(r'RAM:.*?used (\d+) bytes from (\d+) bytes', log) +if not m: + sys.exit('RAM line not found in build log') +used = int(m.group(1)) +print(f'Static RAM: {used} bytes (limit {LIMIT}, {LIMIT - used:+d} bytes headroom)') +if used > LIMIT: + sys.exit(f'Static RAM {used} bytes exceeds the limit of {LIMIT} bytes – move constant data to flash (PROGMEM/F()).') diff --git a/tools/test_display.py b/tools/test_display.py index a8ade43..fce92ad 100644 --- a/tools/test_display.py +++ b/tools/test_display.py @@ -32,6 +32,7 @@ def struct(name,file): #include "RadarFilter.h" #include "MilitaryOperator.h" #define PSTR(x) (x) +#define F(x) (x) #define FPSTR(x) (x) #define PGM_P const char* struct String:std::string {