update IP footer
This commit is contained in:
@@ -74,6 +74,7 @@ int g_hourCount = 0;
|
||||
// ── State flags ───────────────────────────────────
|
||||
volatile bool g_dataReady = false;
|
||||
volatile bool g_apMode = false;
|
||||
volatile bool g_fetchNow = false; // flag yêu cầu fetch ngay
|
||||
int g_page = 0;
|
||||
#define TOTAL_PAGES 4
|
||||
|
||||
@@ -207,6 +208,17 @@ void tft_showFetchError() {
|
||||
tftUnlock();
|
||||
}
|
||||
|
||||
// ── Footer hiển thị IP để truy cập trang Config ──
|
||||
void drawFooter() {
|
||||
// Vẽ thanh footer ở 16px dưới cùng
|
||||
tft.drawFastHLine(0, SCREEN_HEIGHT-17, SCREEN_WIDTH, COLOR_HEADER);
|
||||
tft.setTextSize(1); tft.setTextColor(COLOR_CYAN);
|
||||
tft.setCursor(6, SCREEN_HEIGHT-13);
|
||||
tft.print("Config: http://");
|
||||
tft.setTextColor(COLOR_ORANGE);
|
||||
tft.print(WiFi.localIP().toString());
|
||||
}
|
||||
|
||||
// ── Vẽ 4 trang dữ liệu ───────────────────────────
|
||||
void drawPage0() {
|
||||
// Tổng quan
|
||||
@@ -318,6 +330,9 @@ void drawCurrentPage() {
|
||||
case 2: drawPage2(); break;
|
||||
case 3: drawPage3(); break;
|
||||
}
|
||||
if (!g_apMode) {
|
||||
drawFooter();
|
||||
}
|
||||
tftUnlock();
|
||||
}
|
||||
|
||||
@@ -544,7 +559,8 @@ void handleSave() {
|
||||
void handleUpdate() {
|
||||
if (server.hasArg("api")) strncpy(g_api_url, server.arg("api").c_str(), sizeof(g_api_url)-1);
|
||||
savePrefs();
|
||||
server.send(200, "text/plain", "API URL da cap nhat!");
|
||||
g_fetchNow = true; // yêu cầu fetch ngay với API URL mới
|
||||
server.send(200, "text/plain", "API URL da cap nhat! Dang lay du lieu moi...");
|
||||
}
|
||||
|
||||
void handleReset() {
|
||||
@@ -595,7 +611,13 @@ void fetch_task(void* pv) {
|
||||
tft_showFetchError();
|
||||
}
|
||||
}
|
||||
vTaskDelay(60000 / portTICK_PERIOD_MS);
|
||||
// Nếu có yêu cầu fetch ngay (sau khi đổi API URL), không delay 60s
|
||||
if (g_fetchNow) {
|
||||
g_fetchNow = false;
|
||||
vTaskDelay(500 / portTICK_PERIOD_MS); // đợi ngắn rồi fetch tiếp
|
||||
} else {
|
||||
vTaskDelay(60000 / portTICK_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user