mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-06 23:57:39 +03:00
## Major Features ### 1. CJK UI Font System - Implemented external font loading system for CJK characters - Added Source Han Sans (思源黑体) as base font for UI rendering - Support for multiple font sizes (20pt, 22pt, 24pt) - Font selection UI for both reader and UI fonts - Automatic fallback to built-in fonts when external fonts unavailable - External UI font now renders ALL characters (including ASCII) for consistent style - Proportional spacing for external fonts (variable width per character) ### 2. Complete I18N Implementation - Added comprehensive internationalization system - Support for English, Chinese Simplified, and Japanese - Translated all UI strings across the entire application - Language selection UI in settings with native language names - English displayed as "English" - Chinese displayed as "简体中文" - Japanese displayed as "日本語" - Dynamic language switching without restart ### 3. Bug Fixes #### Rendering Race Conditions - Fixed race condition where parent and child Activity rendering tasks run simultaneously - Added 500ms delay in child Activity displayTaskLoop() to wait for parent rendering completion - Unified displayTaskLoop() logic: `if (updateRequired && !subActivity)` - Prevents duplicate RED RAM writes and incomplete screen refreshes **Affected Activities:** - CategorySettingsActivity: Unified displayTaskLoop check logic - KOReaderSettingsActivity: Added 500ms delay before first render - CalibreSettingsActivity: Added 500ms delay before first render - FontSelectActivity: Added 500ms delay before first render - ClearCacheActivity: Added 500ms delay and subActivity check - LanguageSelectActivity: Added 500ms delay in displayTaskLoop (not onEnter) #### Button Response Issues - Fixed CrossPointWebServer exit button requiring long press - Added MappedInputManager::update() method - Call update() before wasPressed() in tight HTTP processing loop - Button presses during loop are now properly detected #### ClearCache Crash - Fixed FreeRTOS mutex deadlock when exiting ClearCache activity - Added isExiting flag to prevent operations during exit - Added clearCacheTaskHandle tracking - Wait for clearCache task completion before deleting mutex #### External UI Font Rendering - Fixed ASCII characters not using external UI font (was using built-in EPD font) - Fixed character spacing too wide (now uses proportional spacing via getGlyphMetrics) ## Technical Details **Files Added:** - lib/ExternalFont/: External font loading system - lib/I18n/: Internationalization system - lib/GfxRenderer/cjk_ui_font*.h: Pre-rendered CJK font data - scripts/generate_cjk_ui_font.py: Font generation script - src/activities/settings/FontSelectActivity.*: Font selection UI - src/activities/settings/LanguageSelectActivity.*: Language selection UI - docs/cjk-fonts.md: CJK font documentation - docs/i18n.md: I18N documentation **Files Modified:** - lib/GfxRenderer/: Added CJK font rendering support with proportional spacing - src/activities/: I18N integration across all activities - src/MappedInputManager.*: Added update() method - src/CrossPointSettings.cpp: Added language and font settings **Memory Usage:** - Flash: 94.7% (6204434 bytes / 6553600 bytes) - RAM: 66.4% (217556 bytes / 327680 bytes) ## Testing Notes All rendering race conditions and button response issues have been fixed and tested. ClearCache no longer crashes when exiting. File transfer page now responds to short press on exit button. External UI font now renders all characters with proper proportional spacing. Language selection page displays language names in their native scripts. Co-authored-by: Claude (Anthropic AI Assistant)
469 lines
17 KiB
C++
469 lines
17 KiB
C++
#include "CrossPointWebServerActivity.h"
|
|
|
|
#include <DNSServer.h>
|
|
#include <ESPmDNS.h>
|
|
#include <GfxRenderer.h>
|
|
#include <I18n.h>
|
|
#include <WiFi.h>
|
|
#include <esp_task_wdt.h>
|
|
#include <qrcode.h>
|
|
|
|
#include <cstddef>
|
|
|
|
#include "MappedInputManager.h"
|
|
#include "NetworkModeSelectionActivity.h"
|
|
#include "WifiSelectionActivity.h"
|
|
#include "fontIds.h"
|
|
|
|
namespace {
|
|
// AP Mode configuration
|
|
constexpr const char* AP_SSID = "CrossPoint-Reader";
|
|
constexpr const char* AP_PASSWORD = nullptr; // Open network for ease of use
|
|
constexpr const char* AP_HOSTNAME = "crosspoint";
|
|
constexpr uint8_t AP_CHANNEL = 1;
|
|
constexpr uint8_t AP_MAX_CONNECTIONS = 4;
|
|
|
|
// DNS server for captive portal (redirects all DNS queries to our IP)
|
|
DNSServer* dnsServer = nullptr;
|
|
constexpr uint16_t DNS_PORT = 53;
|
|
} // namespace
|
|
|
|
void CrossPointWebServerActivity::taskTrampoline(void* param) {
|
|
auto* self = static_cast<CrossPointWebServerActivity*>(param);
|
|
self->displayTaskLoop();
|
|
}
|
|
|
|
void CrossPointWebServerActivity::onEnter() {
|
|
ActivityWithSubactivity::onEnter();
|
|
|
|
Serial.printf("[%lu] [WEBACT] [MEM] Free heap at onEnter: %d bytes\n", millis(), ESP.getFreeHeap());
|
|
|
|
renderingMutex = xSemaphoreCreateMutex();
|
|
|
|
// Reset state
|
|
state = WebServerActivityState::MODE_SELECTION;
|
|
networkMode = NetworkMode::JOIN_NETWORK;
|
|
isApMode = false;
|
|
connectedIP.clear();
|
|
connectedSSID.clear();
|
|
lastHandleClientTime = 0;
|
|
updateRequired = true;
|
|
|
|
xTaskCreate(&CrossPointWebServerActivity::taskTrampoline, "WebServerActivityTask",
|
|
2048, // Stack size
|
|
this, // Parameters
|
|
1, // Priority
|
|
&displayTaskHandle // Task handle
|
|
);
|
|
|
|
// Launch network mode selection subactivity
|
|
Serial.printf("[%lu] [WEBACT] Launching NetworkModeSelectionActivity...\n", millis());
|
|
enterNewActivity(new NetworkModeSelectionActivity(
|
|
renderer, mappedInput, [this](const NetworkMode mode) { onNetworkModeSelected(mode); },
|
|
[this]() { onGoBack(); } // Cancel goes back to home
|
|
));
|
|
}
|
|
|
|
void CrossPointWebServerActivity::onExit() {
|
|
ActivityWithSubactivity::onExit();
|
|
|
|
Serial.printf("[%lu] [WEBACT] [MEM] Free heap at onExit start: %d bytes\n", millis(), ESP.getFreeHeap());
|
|
|
|
state = WebServerActivityState::SHUTTING_DOWN;
|
|
|
|
// Stop the web server first (before disconnecting WiFi)
|
|
stopWebServer();
|
|
|
|
// Stop mDNS
|
|
MDNS.end();
|
|
|
|
// Stop DNS server if running (AP mode)
|
|
if (dnsServer) {
|
|
Serial.printf("[%lu] [WEBACT] Stopping DNS server...\n", millis());
|
|
dnsServer->stop();
|
|
delete dnsServer;
|
|
dnsServer = nullptr;
|
|
}
|
|
|
|
// Brief wait for LWIP stack to flush pending packets
|
|
delay(50);
|
|
|
|
// Disconnect WiFi gracefully
|
|
if (isApMode) {
|
|
Serial.printf("[%lu] [WEBACT] Stopping WiFi AP...\n", millis());
|
|
WiFi.softAPdisconnect(true);
|
|
} else {
|
|
Serial.printf("[%lu] [WEBACT] Disconnecting WiFi (graceful)...\n", millis());
|
|
WiFi.disconnect(false); // false = don't erase credentials, send disconnect frame
|
|
}
|
|
delay(30); // Allow disconnect frame to be sent
|
|
|
|
Serial.printf("[%lu] [WEBACT] Setting WiFi mode OFF...\n", millis());
|
|
WiFi.mode(WIFI_OFF);
|
|
delay(30); // Allow WiFi hardware to power down
|
|
|
|
Serial.printf("[%lu] [WEBACT] [MEM] Free heap after WiFi disconnect: %d bytes\n", millis(), ESP.getFreeHeap());
|
|
|
|
// Acquire mutex before deleting task
|
|
Serial.printf("[%lu] [WEBACT] Acquiring rendering mutex before task deletion...\n", millis());
|
|
xSemaphoreTake(renderingMutex, portMAX_DELAY);
|
|
|
|
// Delete the display task
|
|
Serial.printf("[%lu] [WEBACT] Deleting display task...\n", millis());
|
|
if (displayTaskHandle) {
|
|
vTaskDelete(displayTaskHandle);
|
|
displayTaskHandle = nullptr;
|
|
Serial.printf("[%lu] [WEBACT] Display task deleted\n", millis());
|
|
}
|
|
|
|
// Delete the mutex
|
|
Serial.printf("[%lu] [WEBACT] Deleting mutex...\n", millis());
|
|
vSemaphoreDelete(renderingMutex);
|
|
renderingMutex = nullptr;
|
|
Serial.printf("[%lu] [WEBACT] Mutex deleted\n", millis());
|
|
|
|
Serial.printf("[%lu] [WEBACT] [MEM] Free heap at onExit end: %d bytes\n", millis(), ESP.getFreeHeap());
|
|
}
|
|
|
|
void CrossPointWebServerActivity::onNetworkModeSelected(const NetworkMode mode) {
|
|
Serial.printf("[%lu] [WEBACT] Network mode selected: %s\n", millis(),
|
|
mode == NetworkMode::JOIN_NETWORK ? "Join Network" : "Create Hotspot");
|
|
|
|
networkMode = mode;
|
|
isApMode = (mode == NetworkMode::CREATE_HOTSPOT);
|
|
|
|
// Exit mode selection subactivity
|
|
exitActivity();
|
|
|
|
if (mode == NetworkMode::JOIN_NETWORK) {
|
|
// STA mode - launch WiFi selection
|
|
Serial.printf("[%lu] [WEBACT] Turning on WiFi (STA mode)...\n", millis());
|
|
WiFi.mode(WIFI_STA);
|
|
|
|
state = WebServerActivityState::WIFI_SELECTION;
|
|
Serial.printf("[%lu] [WEBACT] Launching WifiSelectionActivity...\n", millis());
|
|
enterNewActivity(new WifiSelectionActivity(renderer, mappedInput,
|
|
[this](const bool connected) { onWifiSelectionComplete(connected); }));
|
|
} else {
|
|
// AP mode - start access point
|
|
state = WebServerActivityState::AP_STARTING;
|
|
updateRequired = true;
|
|
startAccessPoint();
|
|
}
|
|
}
|
|
|
|
void CrossPointWebServerActivity::onWifiSelectionComplete(const bool connected) {
|
|
Serial.printf("[%lu] [WEBACT] WifiSelectionActivity completed, connected=%d\n", millis(), connected);
|
|
|
|
if (connected) {
|
|
// Get connection info before exiting subactivity
|
|
connectedIP = static_cast<WifiSelectionActivity*>(subActivity.get())->getConnectedIP();
|
|
connectedSSID = WiFi.SSID().c_str();
|
|
isApMode = false;
|
|
|
|
exitActivity();
|
|
|
|
// Start mDNS for hostname resolution
|
|
if (MDNS.begin(AP_HOSTNAME)) {
|
|
Serial.printf("[%lu] [WEBACT] mDNS started: http://%s.local/\n", millis(), AP_HOSTNAME);
|
|
}
|
|
|
|
// Start the web server
|
|
startWebServer();
|
|
} else {
|
|
// User cancelled - go back to mode selection
|
|
exitActivity();
|
|
state = WebServerActivityState::MODE_SELECTION;
|
|
enterNewActivity(new NetworkModeSelectionActivity(
|
|
renderer, mappedInput, [this](const NetworkMode mode) { onNetworkModeSelected(mode); },
|
|
[this]() { onGoBack(); }));
|
|
}
|
|
}
|
|
|
|
void CrossPointWebServerActivity::startAccessPoint() {
|
|
Serial.printf("[%lu] [WEBACT] Starting Access Point mode...\n", millis());
|
|
Serial.printf("[%lu] [WEBACT] [MEM] Free heap before AP start: %d bytes\n", millis(), ESP.getFreeHeap());
|
|
|
|
// Configure and start the AP
|
|
WiFi.mode(WIFI_AP);
|
|
delay(100);
|
|
|
|
// Start soft AP
|
|
bool apStarted;
|
|
if (AP_PASSWORD && strlen(AP_PASSWORD) >= 8) {
|
|
apStarted = WiFi.softAP(AP_SSID, AP_PASSWORD, AP_CHANNEL, false, AP_MAX_CONNECTIONS);
|
|
} else {
|
|
// Open network (no password)
|
|
apStarted = WiFi.softAP(AP_SSID, nullptr, AP_CHANNEL, false, AP_MAX_CONNECTIONS);
|
|
}
|
|
|
|
if (!apStarted) {
|
|
Serial.printf("[%lu] [WEBACT] ERROR: Failed to start Access Point!\n", millis());
|
|
onGoBack();
|
|
return;
|
|
}
|
|
|
|
delay(100); // Wait for AP to fully initialize
|
|
|
|
// Get AP IP address
|
|
const IPAddress apIP = WiFi.softAPIP();
|
|
char ipStr[16];
|
|
snprintf(ipStr, sizeof(ipStr), "%d.%d.%d.%d", apIP[0], apIP[1], apIP[2], apIP[3]);
|
|
connectedIP = ipStr;
|
|
connectedSSID = AP_SSID;
|
|
|
|
Serial.printf("[%lu] [WEBACT] Access Point started!\n", millis());
|
|
Serial.printf("[%lu] [WEBACT] SSID: %s\n", millis(), AP_SSID);
|
|
Serial.printf("[%lu] [WEBACT] IP: %s\n", millis(), connectedIP.c_str());
|
|
|
|
// Start mDNS for hostname resolution
|
|
if (MDNS.begin(AP_HOSTNAME)) {
|
|
Serial.printf("[%lu] [WEBACT] mDNS started: http://%s.local/\n", millis(), AP_HOSTNAME);
|
|
} else {
|
|
Serial.printf("[%lu] [WEBACT] WARNING: mDNS failed to start\n", millis());
|
|
}
|
|
|
|
// Start DNS server for captive portal behavior
|
|
// This redirects all DNS queries to our IP, making any domain typed resolve to us
|
|
dnsServer = new DNSServer();
|
|
dnsServer->setErrorReplyCode(DNSReplyCode::NoError);
|
|
dnsServer->start(DNS_PORT, "*", apIP);
|
|
Serial.printf("[%lu] [WEBACT] DNS server started for captive portal\n", millis());
|
|
|
|
Serial.printf("[%lu] [WEBACT] [MEM] Free heap after AP start: %d bytes\n", millis(), ESP.getFreeHeap());
|
|
|
|
// Start the web server
|
|
startWebServer();
|
|
}
|
|
|
|
void CrossPointWebServerActivity::startWebServer() {
|
|
Serial.printf("[%lu] [WEBACT] Starting web server...\n", millis());
|
|
|
|
// Create the web server instance
|
|
webServer.reset(new CrossPointWebServer());
|
|
webServer->begin();
|
|
|
|
if (webServer->isRunning()) {
|
|
state = WebServerActivityState::SERVER_RUNNING;
|
|
Serial.printf("[%lu] [WEBACT] Web server started successfully\n", millis());
|
|
|
|
// Force an immediate render since we're transitioning from a subactivity
|
|
// that had its own rendering task. We need to make sure our display is shown.
|
|
xSemaphoreTake(renderingMutex, portMAX_DELAY);
|
|
render();
|
|
xSemaphoreGive(renderingMutex);
|
|
Serial.printf("[%lu] [WEBACT] Rendered File Transfer screen\n", millis());
|
|
} else {
|
|
Serial.printf("[%lu] [WEBACT] ERROR: Failed to start web server!\n", millis());
|
|
webServer.reset();
|
|
// Go back on error
|
|
onGoBack();
|
|
}
|
|
}
|
|
|
|
void CrossPointWebServerActivity::stopWebServer() {
|
|
if (webServer && webServer->isRunning()) {
|
|
Serial.printf("[%lu] [WEBACT] Stopping web server...\n", millis());
|
|
webServer->stop();
|
|
Serial.printf("[%lu] [WEBACT] Web server stopped\n", millis());
|
|
}
|
|
webServer.reset();
|
|
}
|
|
|
|
void CrossPointWebServerActivity::loop() {
|
|
if (subActivity) {
|
|
// Forward loop to subactivity
|
|
subActivity->loop();
|
|
return;
|
|
}
|
|
|
|
// Handle different states
|
|
if (state == WebServerActivityState::SERVER_RUNNING) {
|
|
// Handle DNS requests for captive portal (AP mode only)
|
|
if (isApMode && dnsServer) {
|
|
dnsServer->processNextRequest();
|
|
}
|
|
|
|
// STA mode: Monitor WiFi connection health
|
|
if (!isApMode && webServer && webServer->isRunning()) {
|
|
static unsigned long lastWifiCheck = 0;
|
|
if (millis() - lastWifiCheck > 2000) { // Check every 2 seconds
|
|
lastWifiCheck = millis();
|
|
const wl_status_t wifiStatus = WiFi.status();
|
|
if (wifiStatus != WL_CONNECTED) {
|
|
Serial.printf("[%lu] [WEBACT] WiFi disconnected! Status: %d\n", millis(), wifiStatus);
|
|
// Show error and exit gracefully
|
|
state = WebServerActivityState::SHUTTING_DOWN;
|
|
updateRequired = true;
|
|
return;
|
|
}
|
|
// Log weak signal warnings
|
|
const int rssi = WiFi.RSSI();
|
|
if (rssi < -75) {
|
|
Serial.printf("[%lu] [WEBACT] Warning: Weak WiFi signal: %d dBm\n", millis(), rssi);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Handle web server requests - maximize throughput with watchdog safety
|
|
if (webServer && webServer->isRunning()) {
|
|
const unsigned long timeSinceLastHandleClient = millis() - lastHandleClientTime;
|
|
|
|
// Log if there's a significant gap between handleClient calls (>100ms)
|
|
if (lastHandleClientTime > 0 && timeSinceLastHandleClient > 100) {
|
|
Serial.printf("[%lu] [WEBACT] WARNING: %lu ms gap since last handleClient\n", millis(),
|
|
timeSinceLastHandleClient);
|
|
}
|
|
|
|
// Reset watchdog BEFORE processing - HTTP header parsing can be slow
|
|
esp_task_wdt_reset();
|
|
|
|
// Process HTTP requests in tight loop for maximum throughput
|
|
// More iterations = more data processed per main loop cycle
|
|
constexpr int MAX_ITERATIONS = 500;
|
|
for (int i = 0; i < MAX_ITERATIONS && webServer->isRunning(); i++) {
|
|
webServer->handleClient();
|
|
// Reset watchdog every 32 iterations
|
|
if ((i & 0x1F) == 0x1F) {
|
|
esp_task_wdt_reset();
|
|
}
|
|
// Yield and check for exit button every 64 iterations
|
|
if ((i & 0x3F) == 0x3F) {
|
|
yield();
|
|
// CRITICAL: Must call update() before wasPressed() to refresh button state
|
|
// Otherwise button presses during the loop will be missed
|
|
mappedInput.update();
|
|
// Check for exit button inside loop for responsiveness
|
|
if (mappedInput.wasPressed(MappedInputManager::Button::Back)) {
|
|
onGoBack();
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
lastHandleClientTime = millis();
|
|
}
|
|
|
|
// Handle exit on Back button (also check outside loop)
|
|
if (mappedInput.wasPressed(MappedInputManager::Button::Back)) {
|
|
onGoBack();
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
void CrossPointWebServerActivity::displayTaskLoop() {
|
|
while (true) {
|
|
if (updateRequired) {
|
|
updateRequired = false;
|
|
xSemaphoreTake(renderingMutex, portMAX_DELAY);
|
|
render();
|
|
xSemaphoreGive(renderingMutex);
|
|
}
|
|
vTaskDelay(10 / portTICK_PERIOD_MS);
|
|
}
|
|
}
|
|
|
|
void CrossPointWebServerActivity::render() const {
|
|
// Only render our own UI when server is running
|
|
// Subactivities handle their own rendering
|
|
if (state == WebServerActivityState::SERVER_RUNNING) {
|
|
renderer.clearScreen();
|
|
renderServerRunning();
|
|
renderer.displayBuffer();
|
|
} else if (state == WebServerActivityState::AP_STARTING) {
|
|
renderer.clearScreen();
|
|
const auto pageHeight = renderer.getScreenHeight();
|
|
renderer.drawCenteredText(UI_12_FONT_ID, pageHeight / 2 - 20, TR(STARTING_HOTSPOT), true, EpdFontFamily::BOLD);
|
|
renderer.displayBuffer();
|
|
}
|
|
}
|
|
|
|
void drawQRCode(const GfxRenderer& renderer, const int x, const int y, const std::string& data) {
|
|
// Implementation of QR code calculation
|
|
// The structure to manage the QR code
|
|
QRCode qrcode;
|
|
uint8_t qrcodeBytes[qrcode_getBufferSize(4)];
|
|
Serial.printf("[%lu] [WEBACT] QR Code (%lu): %s\n", millis(), data.length(), data.c_str());
|
|
|
|
qrcode_initText(&qrcode, qrcodeBytes, 4, ECC_LOW, data.c_str());
|
|
const uint8_t px = 6; // pixels per module
|
|
for (uint8_t cy = 0; cy < qrcode.size; cy++) {
|
|
for (uint8_t cx = 0; cx < qrcode.size; cx++) {
|
|
if (qrcode_getModule(&qrcode, cx, cy)) {
|
|
// Serial.print("**");
|
|
renderer.fillRect(x + px * cx, y + px * cy, px, px, true);
|
|
} else {
|
|
// Serial.print(" ");
|
|
}
|
|
}
|
|
// Serial.print("\n");
|
|
}
|
|
}
|
|
|
|
void CrossPointWebServerActivity::renderServerRunning() const {
|
|
// Use consistent line spacing
|
|
constexpr int LINE_SPACING = 28; // Space between lines
|
|
|
|
renderer.drawCenteredText(UI_12_FONT_ID, 15, TR(FILE_TRANSFER), true, EpdFontFamily::BOLD);
|
|
|
|
if (isApMode) {
|
|
// AP mode display - center the content block
|
|
int startY = 55;
|
|
|
|
renderer.drawCenteredText(UI_10_FONT_ID, startY, TR(HOTSPOT_MODE), true, EpdFontFamily::BOLD);
|
|
|
|
std::string ssidInfo = std::string(TR(NETWORK_PREFIX)) + connectedSSID;
|
|
renderer.drawCenteredText(UI_10_FONT_ID, startY + LINE_SPACING, ssidInfo.c_str());
|
|
|
|
renderer.drawCenteredText(SMALL_FONT_ID, startY + LINE_SPACING * 2, TR(CONNECT_WIFI_HINT));
|
|
|
|
renderer.drawCenteredText(SMALL_FONT_ID, startY + LINE_SPACING * 3, TR(SCAN_QR_WIFI_HINT));
|
|
// Show QR code for URL
|
|
const std::string wifiConfig = std::string("WIFI:S:") + connectedSSID + ";;";
|
|
drawQRCode(renderer, (480 - 6 * 33) / 2, startY + LINE_SPACING * 4, wifiConfig);
|
|
|
|
startY += 6 * 29 + 3 * LINE_SPACING;
|
|
// Show primary URL (hostname)
|
|
std::string hostnameUrl = std::string("http://") + AP_HOSTNAME + ".local/";
|
|
renderer.drawCenteredText(UI_10_FONT_ID, startY + LINE_SPACING * 3, hostnameUrl.c_str(), true, EpdFontFamily::BOLD);
|
|
|
|
// Show IP address as fallback
|
|
std::string ipUrl = std::string(TR(OR_HTTP_PREFIX)) + connectedIP + "/";
|
|
renderer.drawCenteredText(SMALL_FONT_ID, startY + LINE_SPACING * 4, ipUrl.c_str());
|
|
renderer.drawCenteredText(SMALL_FONT_ID, startY + LINE_SPACING * 5, TR(OPEN_URL_HINT));
|
|
|
|
// Show QR code for URL
|
|
renderer.drawCenteredText(SMALL_FONT_ID, startY + LINE_SPACING * 6, TR(SCAN_QR_HINT));
|
|
drawQRCode(renderer, (480 - 6 * 33) / 2, startY + LINE_SPACING * 7, hostnameUrl);
|
|
} else {
|
|
// STA mode display (original behavior)
|
|
const int startY = 65;
|
|
|
|
std::string ssidInfo = std::string(TR(NETWORK_PREFIX)) + connectedSSID;
|
|
if (ssidInfo.length() > 28) {
|
|
ssidInfo.replace(25, ssidInfo.length() - 25, "...");
|
|
}
|
|
renderer.drawCenteredText(UI_10_FONT_ID, startY, ssidInfo.c_str());
|
|
|
|
std::string ipInfo = std::string(TR(IP_ADDRESS_PREFIX)) + connectedIP;
|
|
renderer.drawCenteredText(UI_10_FONT_ID, startY + LINE_SPACING, ipInfo.c_str());
|
|
|
|
// Show web server URL prominently
|
|
std::string webInfo = "http://" + connectedIP + "/";
|
|
renderer.drawCenteredText(UI_10_FONT_ID, startY + LINE_SPACING * 2, webInfo.c_str(), true, EpdFontFamily::BOLD);
|
|
|
|
// Also show hostname URL
|
|
std::string hostnameUrl = std::string(TR(OR_HTTP_PREFIX)) + AP_HOSTNAME + ".local/";
|
|
renderer.drawCenteredText(SMALL_FONT_ID, startY + LINE_SPACING * 3, hostnameUrl.c_str());
|
|
|
|
renderer.drawCenteredText(SMALL_FONT_ID, startY + LINE_SPACING * 4, TR(OPEN_URL_HINT));
|
|
|
|
// Show QR code for URL
|
|
drawQRCode(renderer, (480 - 6 * 33) / 2, startY + LINE_SPACING * 6, webInfo);
|
|
renderer.drawCenteredText(SMALL_FONT_ID, startY + LINE_SPACING * 5, TR(SCAN_QR_HINT));
|
|
}
|
|
|
|
const auto labels = mappedInput.mapLabels(TR(EXIT), "", "", "");
|
|
renderer.drawButtonHints(UI_10_FONT_ID, labels.btn1, labels.btn2, labels.btn3, labels.btn4);
|
|
}
|