$ show aly-fly/EleksTubeHAX
This is a custom firmware project for the EleksTubeHAX family of IPS nixie-tube-style desk clocks. It is an embedded C++ application targeting ESP32 microcontrollers (ESP32, ESP32-S2, S3, C3) using the PlatformIO build system. The firmware provides a full-featured digital clock with customizable clock faces (stored as BMP or CLK images in LittleFS), WiFi connectivity (WPS, static IP), NTP time sync with adaptive polling intervals, battery-backed RTC support (DS1302, DS3231, RX8025T), and RGB backlight control (WS2812 LEDs) with multiple effects (pulse, breath, rainbow). It includes an on-device menu system with button (and gesture sensor) navigation, Home Assistant MQTT auto-discovery for remote control, and IP geolocation for automatic timezone/DST detection. The architecture is a monolith with clear class separation (Backlights, Buttons, Menu, TFTs, Clock, ChipSelect, WiFi_WPS, MQTT_client, IPGeolocation). The code heavily uses conditional compilation (#ifdef HARDWARE_*) to support over a dozen physical clock variants (EleksTube, SI HAI, Xunfeng, IPSTube, MarvelTubes, etc.), which increases complexity but enables a single codebase to target many boards. The project includes forked and modified libraries (TFT_eSPI, NTPClient, RTC_RX8025T, SparkFun APDS9960) integrated into the repo, which may diverge from upstream over time.
The LLM identified 2 files worth highlighting for reuse:
Provides an abstract interface for managing chip select pins across multiple TFT displays, supporting three implementations: shift register (using a 74HC595), I2C GPIO expander (PCA9555), and direct GPIO. The class encapsulates the pin-driving logic so the rest of the firmware can simply call `setDigit(digit)` or `setEnabled(enabled)` without knowing the underlying hardware. This pattern is reusable for any multi-display or multi-SPI-device system where different hardware platforms require different CS wiring. It demonstrates clean hardware abstraction with compile-time polymorphism via macro selection.
A Python script executed at build time that resizes clock face images to fit the smaller 80x160 pixel displays used in the MarvelTubes Mini variant. It reads BMP images from a source directory, scales them to 80x160, and writes the resized copies to a target directory. This script is a reusable pattern for any embedded project that needs to automatically adjust asset sizes for different hardware variants at build time, keeping the source assets at a single resolution. It uses Pillow for image manipulation and could be easily adapted for other image formats or resizing requirements.