MedieInfo Library U2.5
=======================

Requires:
- ESP32
- ProjectUNION Core 0.3.0
- ProjectUNION MQTT 0.3.0
- PubSubClient
- Adafruit GFX
- Adafruit ST7735 and ST7789 Library
- TJpg_Decoder

Hardware:
- TFT ST7789 240x240
- SPI SCLK GPIO18
- SPI MISO GPIO19
- SPI MOSI GPIO23
- TFT CS GPIO15
- TFT DC GPIO2
- TFT RST GPIO4
- SD CS GPIO5
- Setup button GPIO27

ProjectUNION owns:
- WiFi and setup hotspot
- hostname and mDNS
- language, layout and common pages
- firmware update
- MQTT broker, TLS, reconnect, test and status

MedieInfo owns:
- TFT and SD card
- JPG upload, folders and playlists
- 16 data slides with 4 lines each
- direct MQTT payloads and JSON fields
- mixed image/slide playback
- project-specific MQTT commands and topics

Legacy migration:
- Main configuration is read from namespace: medieinfo
- WiFi fallback is read from namespace: miwifi
- MQTT broker settings are migrated into UnionMqtt
- Media folders, slide definitions and playback files remain on the SD card
- Old Preferences data is not deleted

Recommended test:
1. Upload by USB
2. Verify WiFi and hostname
3. Verify SD and existing media folders
4. Open Media, Slides and Run pages
5. Test an existing JPG
6. Test an existing data slide
7. Verify MQTT broker settings and JSON value updates
8. Test firmware upload


Changes in U2.1
---------------
- Added the missing project_config.h compatibility header.
- Defines APP_VERSION for the original MedieInfo web module.
- Keeps the existing display, SD, slide and playlist logic unchanged.
- Still requires ProjectUNION 0.2.2.


Changes in U2.2
---------------
- Added missing forward declarations required by the large project modules.
- Added shared Preferences instance used by slide storage.
- Fixes missing declarations for:
  - mediaFolderTableHtml()
  - saveMediaFolders()
  - loadDataSlides()
  - loadSlotToCurrentData()
- Project functionality is otherwise unchanged.


Changes in U2.3
---------------
- Added a real global `Preferences prefs;` instance before the project modules are included.
- The previous U2.2 check accidentally detected a local variable with the same name and therefore skipped the global declaration.
- Fixes slide storage compilation in `saveDataSlides()` and `loadDataSlides()`.


Changes in U2.4
---------------
- Restored modal editing for media folders.
- Restored modal editing for slides.
- Added fixed dark modal background, centered dialog and internal scrolling.
- Reduced media thumbnails to a compact gallery size.
- Restored green highlighting for the active playback mode.
- No changes to SD, MQTT, slide or playback functionality.


Changes in U2.5
---------------
- Reduced compiled flash usage to stay below the default OTA partition limit.
- Simplified and minified modal/gallery CSS.
- Shortened a few help texts.
- Modal media editing, modal slide editing and green active playback button remain.
- Project-specific CSS reduced by about 1112 bytes before compilation.


Changes in U2.7 Slim
--------------------
- Removed the unused ArduinoJson include. JSON fields still use the existing
  lightweight built-in extractor.
- Removed only the Weather/Power demo buttons and their demo-data generator.
  Normal slides, MQTT, JSON fields and playlists are unchanged.
- Shortened non-essential help text in all three languages.
- Kept modal media editing, modal slide editing and green active playback button.
- Removed the custom partition experiment; standard OTA partition is used.
- Project web source reduced by about 4040 bytes.


Changes in U2.9 AuditSlim
-------------------------
- Further reduced static web text and modal CSS.
- Replaced the project SVG icon with a smaller equivalent.
- Removed obsolete compatibility wrappers no longer called by the current code.
- Removed source comments/blank lines from the large display module.
- Normal MedieInfo functionality is unchanged.
- Web source reduced by about 417 bytes.
- Display module source reduced by about 2151 bytes.


Changes in U2.9 AuditSlim
-------------------------
- Removed the obsolete legacy single-slide MQTT API (/data/#).
- Slides now render directly from the 16-slide arrays.
- Removed duplicate current-slide variables and copy functions.
- Removed unused legacy helper functions and wrappers.
- Normal slide editing, MQTT topics per line, JSON extraction and playlists remain.


Changes in U2.10 DeepSlim
-------------------------
- Removed the obsolete standalone status page; ProjectUNION already provides it.
- Removed unused folder option/table wrappers.
- Removed unused imageExists(), isLang(), yesNo() and playlistStart().
- Removed helpers that became unused after the status-page removal.
- Simplified legacy view synchronization.
- Reused one redirect helper for playback actions.
- No normal media, slide, MQTT, JSON or playlist functionality was removed.


Changes in U2.11 Modular
------------------------
- Updated for the modular ProjectUNION architecture.
- Uses ProjectUNION Core 0.3.0.
- Uses ProjectUNION MQTT 0.3.0.
- Does not include or depend on ProjectUNION DCC.
- No MedieInfo functionality has been changed.


Changes in U2.12 ReleaseSlim
----------------------------
- Removed the one-time migration from the old standalone MedieInfo U1.1.
- Removed reads from the old `medieinfo` and `miwifi` Preferences namespaces.
- Removed legacy WiFi and MQTT transfer code.
- Current ProjectUNION settings and SD-card content are unchanged.
- Normal media, slides, MQTT/JSON, playlists and OTA functionality remain.

Important:
- Use U2.11 once first when upgrading directly from the old pre-UNION version.
- U2.12 is intended for systems already running a ProjectUNION version and
  for new installations.


Changes in U2.13 FinalSlim
--------------------------
- Flags and all three languages are retained.
- Removed old web routes that are no longer linked by the current interface.
- Removed the corresponding unused page handlers.
- Removed legacy MQTT command aliases while retaining the current commands:
  start, stop, next, prev, show N, slide N, folder NAME,
  playlist slides/images/mixed/stop/next/prev and slideshow.
- Normal media, upload, slide editing, MQTT/JSON, playback and OTA remain.


Changes in U2.14 Language
-------------------------
- Translated the remaining Danish text on the Slides page.
- Translated the slide overview, current display and MQTT help table.
- Translated the MedieInfo MQTT connection state on the Status page.
- Danish, English and German are supported.
- No media, slide, MQTT, playback or OTA functionality was changed.


Changes in U2.15 LanguageSlim
-----------------------------
- Keeps Danish, English and German on the Slides page.
- Replaces the long MQTT documentation table with a compact version.
- Shortens several explanatory texts and buttons.
- No media, slide, MQTT, JSON, playback or OTA functionality changed.


Changes in U2.16 LanguageFix
----------------------------
- Fixed compilation error in handleData().
- Restored the local MQTT base-topic variable before the compact MQTT help table.
- No functionality or translations changed.


Changes in U2.17 DropdownLanguage
---------------------------------
- Icon and theme dropdown values now follow Danish, English and German.
- Slide overview uses the same translated icon and theme labels.
- Removed redundant internal IDs in parentheses from dropdowns to save flash.
- No functionality changed.

U2.23 MultiDisplay
------------------
Added selectable TFT support:
- ST7789 240x240 (standard/existing MedieInfo display)
- ST7735 128x150, 0.6-inch (experimental N-scale display)

The display type is selected on the Run/Afvikling page. Saving the display type restarts the ESP32.
The existing ST7789 layout is preserved. The ST7735 option uses a dedicated compact 128x150 data-slide layout.
JPEG images are automatically downscaled by TJpg_Decoder (1/2, 1/4 or 1/8) when needed to fit the small screen.

ST7735 8-pin display signals from Michael's datasheet:
1 LEDA (backlight +)
2 GND
3 RESET
4 RS/DC
5 SDA/MOSI
6 SCL/CLK
7 VDD 3.3V
8 CS

NOTE: This pin order is NOT pin-for-pin identical to the existing MedieInfo D1/D2/D3 connector. Use a correctly wired adapter/cable.
The 128x150 panel is initialized with the standard ST7735 128x160 BLACKTAB sequence and software uses only 150 rows. The physical panel has not yet been tested; a vendor-specific row/column offset may need adjustment after Michael's displays arrive.

U2.23 fix
---------
Fixed display-type saving on the Run/Ablauf page. U2.18 attempted to write the
selection through a Preferences object that was not open at that point. The
selection could therefore be lost when ESP32 restarted, causing ST7789 to be
selected again. U2.23 saves the selection through the ProjectUNION Preferences
instance via saveConfig() before restarting.


U2.23 - shared SPI test fix
---------------------------
- ST7735 SPI clock reduced to 8 MHz (same as successful standalone test).
- SD clock reduced to 4 MHz when ST7735 is selected; ST7789 keeps 10 MHz.
- Explicit TFT-CS HIGH before SD filesystem access.
- Explicit SD-CS HIGH before TFT drawing.
- JPEG callback explicitly releases SD before TFT drawing.
These changes are intended to reproduce the bus discipline proven by Test 2.


U2.23
-----
- ST7735 compact layout moved down by 5 pixels to match the tested panel.
- Added per-slide font size selection: Standard / Large for ST7735 128x150.
- Large font is intended mainly for slides with 1-2 active data lines.
- ST7789 layout remains unchanged.
- Keeps U2.21 JPEG color correction and U2.20 shared-SPI handling.
- SD recommendation: FAT32. Based on practical MedieInfo experience, use a
  normal/full format rather than Windows Quick Format if a card is not detected.
