diff --git a/ESP32_AP-Flasher/data/tagtypes/00.json b/ESP32_AP-Flasher/data/tagtypes/00.json index af150aac..f6e0f49c 100644 --- a/ESP32_AP-Flasher/data/tagtypes/00.json +++ b/ESP32_AP-Flasher/data/tagtypes/00.json @@ -13,7 +13,7 @@ }, "shortlut": 2, "options": ["button", "customlut"], - "contentids": [ 0, 1, 2, 3, 4, 5, 7, 10, 14, 15, 17, 18, 19, 20, 21], + "contentids": [ 22, 23, 1, 2, 3, 4, 5, 7, 10, 14, 15, 17, 18, 19, 20, 21], "template": { "1": { "weekday": [ 76, 9, "fonts/calibrib30" ], diff --git a/ESP32_AP-Flasher/data/tagtypes/01.json b/ESP32_AP-Flasher/data/tagtypes/01.json index 9773536d..31aec876 100644 --- a/ESP32_AP-Flasher/data/tagtypes/01.json +++ b/ESP32_AP-Flasher/data/tagtypes/01.json @@ -13,7 +13,7 @@ }, "shortlut": 2, "options": ["button", "customlut"], - "contentids": [ 0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 15, 16, 17, 18, 19, 20, 21 ], + "contentids": [ 22, 23, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 15, 16, 17, 18, 19, 20, 21 ], "template": { "1": { "weekday": [ 148, -3, "Signika-SB.ttf", 60 ], diff --git a/ESP32_AP-Flasher/data/tagtypes/02.json b/ESP32_AP-Flasher/data/tagtypes/02.json index 361416eb..90eeda1c 100644 --- a/ESP32_AP-Flasher/data/tagtypes/02.json +++ b/ESP32_AP-Flasher/data/tagtypes/02.json @@ -13,7 +13,7 @@ }, "shortlut": 1, "options": ["button"], - "contentids": [ 0, 1, 4, 5, 7, 8, 9, 10, 11, 17, 18, 19, 20], + "contentids": [ 22, 23, 1, 4, 5, 7, 8, 9, 10, 11, 17, 18, 19, 20], "template": { "1": { "weekday": [ 200, 0, "Signika-SB.ttf", 70 ], diff --git a/ESP32_AP-Flasher/data/tagtypes/05.json b/ESP32_AP-Flasher/data/tagtypes/05.json index c86bfca5..45681a9a 100644 --- a/ESP32_AP-Flasher/data/tagtypes/05.json +++ b/ESP32_AP-Flasher/data/tagtypes/05.json @@ -13,7 +13,7 @@ }, "shortlut": 1, "options": [], - "contentids": [ 0, 1, 4, 5, 7, 8, 9, 10, 11, 17, 18, 19, 20], + "contentids": [ 22, 23, 1, 4, 5, 7, 8, 9, 10, 11, 17, 18, 19, 20], "template": { "1": { "weekday": [ 320, -5, "Signika-SB.ttf", 100 ], diff --git a/ESP32_AP-Flasher/data/tagtypes/11.json b/ESP32_AP-Flasher/data/tagtypes/11.json index f0a88ef2..1266a8f4 100644 --- a/ESP32_AP-Flasher/data/tagtypes/11.json +++ b/ESP32_AP-Flasher/data/tagtypes/11.json @@ -13,6 +13,6 @@ }, "shortlut": 0, "options": ["button"], - "contentids": [ 0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 14, 15, 16, 17, 18, 19, 20, 21], + "contentids": [ 22, 23, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 14, 15, 16, 17, 18, 19, 20, 21], "usetemplate": 1 } diff --git a/ESP32_AP-Flasher/data/tagtypes/21.json b/ESP32_AP-Flasher/data/tagtypes/21.json index 95202a64..f181d0cd 100644 --- a/ESP32_AP-Flasher/data/tagtypes/21.json +++ b/ESP32_AP-Flasher/data/tagtypes/21.json @@ -11,6 +11,6 @@ }, "shortlut": 0, "options": ["button", "customlut"], - "contentids": [ 0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 15, 16, 17, 18, 19, 20, 21 ], + "contentids": [ 22, 23, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 15, 16, 17, 18, 19, 20, 21 ], "usetemplate": 1 } diff --git a/ESP32_AP-Flasher/data/tagtypes/2E.json b/ESP32_AP-Flasher/data/tagtypes/2E.json index dea87c20..39466d08 100644 --- a/ESP32_AP-Flasher/data/tagtypes/2E.json +++ b/ESP32_AP-Flasher/data/tagtypes/2E.json @@ -13,7 +13,7 @@ }, "shortlut": 0, "options": ["button"], - "contentids": [ 0, 1, 5, 8, 9, 7, 19, 10, 11 ], + "contentids": [ 22, 23, 1, 5, 8, 9, 7, 19, 10, 11 ], "usetemplate": 1, "template": { "1": { diff --git a/ESP32_AP-Flasher/data/tagtypes/2F.json b/ESP32_AP-Flasher/data/tagtypes/2F.json index 52e72bdb..4db62b9a 100644 --- a/ESP32_AP-Flasher/data/tagtypes/2F.json +++ b/ESP32_AP-Flasher/data/tagtypes/2F.json @@ -13,7 +13,7 @@ }, "shortlut": 0, "options": ["button"], - "contentids": [ 0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 17, 18, 19, 20], + "contentids": [ 22, 23, 1, 2, 3, 4, 5, 7, 8, 9, 11, 17, 18, 19, 20], "usetemplate": 1, "template": { "1": { diff --git a/ESP32_AP-Flasher/data/tagtypes/30.json b/ESP32_AP-Flasher/data/tagtypes/30.json index 97bf153e..24117480 100644 --- a/ESP32_AP-Flasher/data/tagtypes/30.json +++ b/ESP32_AP-Flasher/data/tagtypes/30.json @@ -13,6 +13,6 @@ }, "shortlut": 0, "options": ["button"], - "contentids": [ 0, 1, 2, 3, 4, 8, 7, 19, 10, 21 ], + "contentids": [ 22, 23, 1, 2, 3, 4, 8, 7, 19, 10, 21 ], "usetemplate": 0 } \ No newline at end of file diff --git a/ESP32_AP-Flasher/data/tagtypes/31.json b/ESP32_AP-Flasher/data/tagtypes/31.json index 0ce9c617..cfa83aaa 100644 --- a/ESP32_AP-Flasher/data/tagtypes/31.json +++ b/ESP32_AP-Flasher/data/tagtypes/31.json @@ -13,7 +13,7 @@ }, "shortlut": 0, "options": ["button", "led"], - "contentids": [ 0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 16, 17, 18, 19, 20], + "contentids": [ 22, 23, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 16, 17, 18, 19, 20], "template": { "1": { "weekday": [148, 5, "Signika-SB.ttf", 60], diff --git a/ESP32_AP-Flasher/data/tagtypes/33.json b/ESP32_AP-Flasher/data/tagtypes/33.json index c897e1f9..2d9289c9 100644 --- a/ESP32_AP-Flasher/data/tagtypes/33.json +++ b/ESP32_AP-Flasher/data/tagtypes/33.json @@ -13,7 +13,7 @@ }, "shortlut": 0, "options": ["button", "led"], - "contentids": [ 0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 16, 17, 18, 19, 20], + "contentids": [ 22, 23, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 16, 17, 18, 19, 20], "usetemplate": 1, "template": { "1": { diff --git a/ESP32_AP-Flasher/data/tagtypes/34.json b/ESP32_AP-Flasher/data/tagtypes/34.json index e9d570bd..62a5b72f 100644 --- a/ESP32_AP-Flasher/data/tagtypes/34.json +++ b/ESP32_AP-Flasher/data/tagtypes/34.json @@ -13,6 +13,6 @@ }, "shortlut": 1, "options": ["led"], - "contentids": [ 0, 1, 4, 5, 7, 8, 9, 10, 11, 17, 18, 19, 20 ], + "contentids": [ 22, 23, 1, 4, 5, 7, 8, 9, 10, 11, 17, 18, 19, 20 ], "usetemplate": 2 } \ No newline at end of file diff --git a/ESP32_AP-Flasher/data/tagtypes/35.json b/ESP32_AP-Flasher/data/tagtypes/35.json index a7135c6a..a1dafd5a 100644 --- a/ESP32_AP-Flasher/data/tagtypes/35.json +++ b/ESP32_AP-Flasher/data/tagtypes/35.json @@ -11,7 +11,7 @@ "red": [ 255, 0, 0 ], "gray": [ 150, 150, 150 ] }, - "contentids": [ 0, 1, 4, 5, 8, 9, 7, 19, 10, 11 ], + "contentids": [ 22, 23, 1, 4, 5, 8, 9, 7, 19, 10, 11 ], "usetemplate": 1, "template": { "1": { diff --git a/ESP32_AP-Flasher/data/tagtypes/36.json b/ESP32_AP-Flasher/data/tagtypes/36.json index 64b9d3c0..33c98b3b 100644 --- a/ESP32_AP-Flasher/data/tagtypes/36.json +++ b/ESP32_AP-Flasher/data/tagtypes/36.json @@ -13,6 +13,6 @@ }, "shortlut": 0, "options": ["button", "led"], - "contentids": [ 0, 1, 4, 5, 7, 8, 9, 10, 11, 17, 18, 19, 20], + "contentids": [ 22, 23, 1, 4, 5, 7, 8, 9, 10, 11, 17, 18, 19, 20], "usetemplate": 1 } diff --git a/ESP32_AP-Flasher/data/tagtypes/60.json b/ESP32_AP-Flasher/data/tagtypes/60.json index be478c7f..4c9a732d 100644 --- a/ESP32_AP-Flasher/data/tagtypes/60.json +++ b/ESP32_AP-Flasher/data/tagtypes/60.json @@ -13,6 +13,6 @@ }, "shortlut": 0, "options": ["led"], - "contentids": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 17, 18, 19, 20 ], + "contentids": [ 22, 23, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 17, 18, 19, 20 ], "usetemplate": 1 } diff --git a/ESP32_AP-Flasher/data/tagtypes/61.json b/ESP32_AP-Flasher/data/tagtypes/61.json index 892bebe8..61a47369 100644 --- a/ESP32_AP-Flasher/data/tagtypes/61.json +++ b/ESP32_AP-Flasher/data/tagtypes/61.json @@ -13,6 +13,6 @@ }, "shortlut": 0, "options": ["led"], - "contentids": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 17, 18, 19, 20 ], + "contentids": [ 22, 23, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 17, 18, 19, 20 ], "usetemplate": 1 } diff --git a/ESP32_AP-Flasher/data/tagtypes/62.json b/ESP32_AP-Flasher/data/tagtypes/62.json index 7ef160d7..a966c0a1 100644 --- a/ESP32_AP-Flasher/data/tagtypes/62.json +++ b/ESP32_AP-Flasher/data/tagtypes/62.json @@ -13,6 +13,6 @@ }, "shortlut": 0, "options": ["led"], - "contentids": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 17, 18, 19, 20 ], + "contentids": [ 22, 23, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 17, 18, 19, 20 ], "usetemplate": 1 } diff --git a/ESP32_AP-Flasher/data/tagtypes/E0.json b/ESP32_AP-Flasher/data/tagtypes/E0.json index 9f1a3f37..dc6f8d24 100644 --- a/ESP32_AP-Flasher/data/tagtypes/E0.json +++ b/ESP32_AP-Flasher/data/tagtypes/E0.json @@ -13,7 +13,7 @@ }, "shortlut": 0, "options": [], - "contentids": [ 0, 1, 2, 3, 4, 8, 7, 19, 10, 11, 21 ], + "contentids": [ 22, 1, 2, 3, 4, 8, 7, 19, 10, 11, 21 ], "usetemplate": 1, "template": { "21": [ diff --git a/ESP32_AP-Flasher/data/www/content_cards.json.gz b/ESP32_AP-Flasher/data/www/content_cards.json.gz index e9760ed8..41cbe7c3 100644 Binary files a/ESP32_AP-Flasher/data/www/content_cards.json.gz and b/ESP32_AP-Flasher/data/www/content_cards.json.gz differ diff --git a/ESP32_AP-Flasher/data/www/index.html.gz b/ESP32_AP-Flasher/data/www/index.html.gz index 0cc6ebe5..099d1245 100644 Binary files a/ESP32_AP-Flasher/data/www/index.html.gz and b/ESP32_AP-Flasher/data/www/index.html.gz differ diff --git a/ESP32_AP-Flasher/data/www/main.css.gz b/ESP32_AP-Flasher/data/www/main.css.gz index 7f23b3d0..ccb13a2b 100644 Binary files a/ESP32_AP-Flasher/data/www/main.css.gz and b/ESP32_AP-Flasher/data/www/main.css.gz differ diff --git a/ESP32_AP-Flasher/data/www/main.js.gz b/ESP32_AP-Flasher/data/www/main.js.gz index a492598e..93c2b1a2 100644 Binary files a/ESP32_AP-Flasher/data/www/main.js.gz and b/ESP32_AP-Flasher/data/www/main.js.gz differ diff --git a/ESP32_AP-Flasher/data/www/painter.js.gz b/ESP32_AP-Flasher/data/www/painter.js.gz index fa1a72c2..c7ba5c3c 100644 Binary files a/ESP32_AP-Flasher/data/www/painter.js.gz and b/ESP32_AP-Flasher/data/www/painter.js.gz differ diff --git a/ESP32_AP-Flasher/include/system.h b/ESP32_AP-Flasher/include/system.h index 37838077..b5862413 100644 --- a/ESP32_AP-Flasher/include/system.h +++ b/ESP32_AP-Flasher/include/system.h @@ -6,6 +6,7 @@ #define WAKEUP_REASON_NFC 3 #define WAKEUP_REASON_BUTTON1 4 #define WAKEUP_REASON_BUTTON2 5 +#define WAKEUP_REASON_FAILED_OTA_FW 0xE0 #define WAKEUP_REASON_FIRSTBOOT 0xFC #define WAKEUP_REASON_NETWORK_SCAN 0xFD #define WAKEUP_REASON_WDT_RESET 0xFE diff --git a/ESP32_AP-Flasher/src/contentmanager.cpp b/ESP32_AP-Flasher/src/contentmanager.cpp index 5cb86762..b7962fe5 100644 --- a/ESP32_AP-Flasher/src/contentmanager.cpp +++ b/ESP32_AP-Flasher/src/contentmanager.cpp @@ -216,7 +216,11 @@ void drawNew(const uint8_t mac[8], const bool buttonPressed, tagRecord *&taginfo } switch (taginfo->contentMode) { - case 0: // Image + case 0: // Not configured + case 22: // Static image + case 23: // Static image (advanced) + case 24: // External image + case 25: // Home Assistant { String configFilename = cfgobj["filename"].as(); if (!util::isEmptyOrNull(configFilename)) { diff --git a/ESP32_AP-Flasher/src/ips_display.cpp b/ESP32_AP-Flasher/src/ips_display.cpp index 39cd14df..92fb1f6f 100644 --- a/ESP32_AP-Flasher/src/ips_display.cpp +++ b/ESP32_AP-Flasher/src/ips_display.cpp @@ -63,7 +63,7 @@ void sendAvail(uint8_t wakeupReason) { WiFi.macAddress(mac); memcpy(&eadr.src, mac, 6); eadr.adr.lastPacketRSSI = WiFi.RSSI(); - eadr.adr.currentChannel = WiFi.channel(); + eadr.adr.currentChannel = config.channel; eadr.adr.hwType = 0xE0; eadr.adr.wakeupReason = wakeupReason; eadr.adr.capabilities = 0; diff --git a/ESP32_AP-Flasher/src/newproto.cpp b/ESP32_AP-Flasher/src/newproto.cpp index 178e0c04..c8c76f04 100644 --- a/ESP32_AP-Flasher/src/newproto.cpp +++ b/ESP32_AP-Flasher/src/newproto.cpp @@ -513,6 +513,8 @@ void processDataReq(struct espAvailDataReq* eadr, bool local, IPAddress remoteIP reason = "Network scan"; else if (eadr->adr.wakeupReason == WAKEUP_REASON_WDT_RESET) reason = "Watchdog reset"; + else if (eadr->adr.wakeupReason == WAKEUP_REASON_FAILED_OTA_FW) + reason = "Firmware update rejected"; sprintf(buffer, "%02X%02X%02X%02X%02X%02X%02X%02X %s", eadr->src[7], eadr->src[6], eadr->src[5], eadr->src[4], eadr->src[3], eadr->src[2], eadr->src[1], eadr->src[0], reason); logLine(buffer); } diff --git a/ESP32_AP-Flasher/src/web.cpp b/ESP32_AP-Flasher/src/web.cpp index 66f8b801..66672aa9 100644 --- a/ESP32_AP-Flasher/src/web.cpp +++ b/ESP32_AP-Flasher/src/web.cpp @@ -734,7 +734,11 @@ void doImageUpload(AsyncWebServerRequest *request, String filename, size_t index } } taginfo->modeConfigJson = "{\"filename\":\"" + dst + ".jpg\",\"timetolive\":\"" + String(ttl) + "\",\"dither\":\"" + String(dither) + "\",\"delete\":\"1\", \"preload\":\"" + String(preload) + "\", \"preload_lut\":\"" + String(preloadlut) + "\", \"preload_type\":\"" + String(preloadtype) + "\"}"; - taginfo->contentMode = 0; + if (request->hasParam("contentmode", true)) { + taginfo->contentMode = request->getParam("contentmode", true)->value().toInt(); + } else { + taginfo->contentMode = 24; + } taginfo->nextupdate = 0; wsSendTaginfo(mac, SYNC_USERCFG); request->send(200, "text/plain", "Ok, saved"); diff --git a/ESP32_AP-Flasher/wwwroot/content_cards.json b/ESP32_AP-Flasher/wwwroot/content_cards.json index b0aaed83..e9c7e184 100644 --- a/ESP32_AP-Flasher/wwwroot/content_cards.json +++ b/ESP32_AP-Flasher/wwwroot/content_cards.json @@ -1,8 +1,14 @@ [ { "id": 0, + "name": "", + "desc": "Not configured", + "param": [] + }, + { + "id": 22, "name": "Static image", - "desc": "Shows a static image, from file system, painter or external source. Make sure to resize the image to the correct resolution.", + "desc": "Shows a static image, from file system or painter. Make sure to resize the image to the correct resolution.", "param": [ { "key": "filename", @@ -10,12 +16,6 @@ "desc": "Local filename on the littlefs drive", "type": "jpgfile" }, - { - "key": "timetolive", - "name": "TimeToLive", - "desc": "Amount (minutes) that this image will stay valid. The tag might not respond meanwhile", - "type": "int" - }, { "key": "dither", "name": "Dithering", @@ -25,50 +25,21 @@ "0": "off", "1": "on" } - }, - { - "key": "preload", - "name": "Display or Preload", - "desc": "Display now or preload for later use", - "type": "select", - "options": { - "0": "Display", - "1": "Preload" - } - }, - { - "key": "preload_lut", - "name": "Preload LUT", - "desc": "Triggered preload images will display with this LUT", - "type": "select", - "options": { - "0": "Default", - "1": "No Repeats", - "2": "Fast No Reds", - "3": "Fast" - } - }, - { - "key": "preload_type", - "name": "Preload Image type", - "desc": "Preload type to send to tag, for later recall, or special use", - "type": "select", - "options": { - "0": "Normal", - "1": "UI: Splash Screen", - "2": "UI: Lost connection", - "3": "UI: AP Found", - "4": "UI: No AP Found", - "5": "UI: Long Term Sleep", - "15": "Slideshow image", - "16": "Wake: Button 1", - "17": "Wake: Button 2", - "29": "Wake: GPIO", - "30": "Wake: NFC" - } } ] }, + { + "id": 24, + "name": "External image", + "desc": "Image from external source", + "param": [ ] + }, + { + "id": 25, + "name": "Home Assistant", + "desc": "Image from Home Assistant", + "param": [ ] + }, { "id": 1, "name": "Current date", @@ -116,13 +87,13 @@ { "id": 4, "name": "Current weather", - "desc": "Current weather. Weather data by Open-Meteo.com. Parameters Lat, Lon and Time Zone are filled automatically from the entered location. In case of an ambiguous location, you can alter those manually.", + "desc": "Current weather. Weather data by Open-Meteo.com. Parameters Lat, Lon and Time Zone are filled automatically from the entered location. In case of an ambiguous location, choose from the drop down list.", "param": [ { "key": "location", "name": "Location", "desc": "Name of the city. This is used to lookup the lat/long data, and to display as the title", - "type": "text" + "type": "geoselect" }, { "key": "units", @@ -163,7 +134,7 @@ "key": "location", "name": "Location", "desc": "Name of the city. This is used to lookup the lat/long data, and to display as the title", - "type": "text" + "type": "geoselect" }, { "key": "units", @@ -204,7 +175,7 @@ "key": "location", "name": "Location", "desc": "Name of the city. This is used to lookup the lat/long data, and to display as the title", - "type": "text" + "type": "geoselect" }, { "key": "#lat", @@ -525,6 +496,76 @@ } ] }, + { + "id": 23, + "name": "Image preload", + "desc": "Preloads an image to be shown at different situations. Make sure to resize the image to the correct resolution.", + "param": [ + { + "key": "filename", + "name": "Filename", + "desc": "Local filename on the littlefs drive", + "type": "jpgfile" + }, + { + "key": "timetolive", + "name": "TimeToLive", + "desc": "Amount (minutes) that this image will stay valid. The tag might not respond meanwhile", + "type": "int" + }, + { + "key": "dither", + "name": "Dithering", + "desc": "Turn halftone dithering on or off. Turn it on when displaying photos. For texts, you better leave if off", + "type": "select", + "options": { + "0": "off", + "1": "on" + } + }, + { + "key": "preload", + "name": "Display or Preload", + "desc": "Display now or preload for later use", + "type": "select", + "options": { + "0": "Display", + "1": "Preload" + } + }, + { + "key": "preload_lut", + "name": "Preload LUT", + "desc": "Triggered preload images will display with this LUT", + "type": "select", + "options": { + "0": "Default", + "1": "No Repeats", + "2": "Fast No Reds", + "3": "Fast" + } + }, + { + "key": "preload_type", + "name": "Preload Image type", + "desc": "Preload type to send to tag, for later recall, or special use", + "type": "select", + "options": { + "0": "Normal", + "1": "UI: Splash Screen", + "2": "UI: Lost connection", + "3": "UI: AP Found", + "4": "UI: No AP Found", + "5": "UI: Long Term Sleep", + "15": "Slideshow image", + "16": "Wake: Button 1", + "17": "Wake: Button 2", + "29": "Wake: GPIO", + "30": "Wake: NFC" + } + } + ] + }, { "id": 21, "name": "Access point info", diff --git a/ESP32_AP-Flasher/wwwroot/main.css b/ESP32_AP-Flasher/wwwroot/main.css index fc3bd1d5..a9a12dd4 100644 --- a/ESP32_AP-Flasher/wwwroot/main.css +++ b/ESP32_AP-Flasher/wwwroot/main.css @@ -675,6 +675,22 @@ ul.messages li.new { color: white; } +#georesults { + position: absolute; + background: white; + cursor: pointer; + width: 240px; + max-height: 115px; + overflow-y: scroll; + padding: 0px 2px 0px 2px; + & div { + display:flex; + } + & div:hover { + background-color: #e0e0e0; + } +} + #paintbutton { padding: 1px 3px; border: 1px solid black; diff --git a/ESP32_AP-Flasher/wwwroot/main.js b/ESP32_AP-Flasher/wwwroot/main.js index d221946b..04d61148 100644 --- a/ESP32_AP-Flasher/wwwroot/main.js +++ b/ESP32_AP-Flasher/wwwroot/main.js @@ -6,6 +6,7 @@ const WAKEUP_REASON_GPIO = 2; const WAKEUP_REASON_NFC = 3; const WAKEUP_REASON_BUTTON1 = 4; const WAKEUP_REASON_BUTTON2 = 5; +const WAKEUP_REASON_FAILED_OTA_FW = 0xE0; const WAKEUP_REASON_FIRSTBOOT = 0xFC; const WAKEUP_REASON_NETWORK_SCAN = 0xFD; const WAKEUP_REASON_WDT_RESET = 0xFE; @@ -326,6 +327,10 @@ function processTags(tagArray) { $('#tag' + tagmac + ' .nextcheckin').innerHTML = "Watchdog reset!" $('#tag' + tagmac).style.background = "#d0a0a0"; break; + case WAKEUP_REASON_FAILED_OTA_FW: + $('#tag' + tagmac + ' .nextcheckin').innerHTML = "Firmware update rejected!" + $('#tag' + tagmac).style.background = "#f0a0a0"; + break; } $('#tag' + tagmac + ' .pendingicon').style.display = (element.pending ? 'inline-block' : 'none'); div.classList.add("tagflash"); @@ -482,8 +487,8 @@ $('#cfgsave').onclick = function() { if (contentMode) { extraoptions?.forEach(element => { - if ($('#opt' + element.key)) { - obj[element.key] = $('#opt' + element.key).value; + if (document.getElementById('opt' + element.key)) { + obj[element.key] = document.getElementById('opt' + element.key).value; } }); formData.append("contentmode", contentMode); @@ -614,9 +619,6 @@ $('#cfgautoupdate').onclick = async function() { else showMessage('Error: auto update failed'); formData.append("contentmode", 5); formData.append("modecfgjson", JSON.stringify(obj)); - formData.append("rotate", $('#cfgrotate').value); - formData.append("lut", $('#cfglut').value); - formData.append("invert", $('#cfginvert').value); fetch("/save_cfg", { method: "POST", body: formData @@ -786,7 +788,7 @@ function contentselected() { if (contentDef) { $('#customoptions').innerHTML = "

" + contentDef?.desc + "

" } - $('#paintbutton').style.display = (contentMode == 0 ? 'inline-block' : 'none'); + $('#paintbutton').style.display = (contentMode == 22 || contentMode == 23 ? 'inline-block' : 'none'); let extraoptions = contentDef?.param ?? null; extraoptions?.forEach(element => { let label = document.createElement("label"); @@ -849,6 +851,11 @@ function contentselected() { input.appendChild(optionElement); } break; + case 'geoselect': + input.type = "text"; + input.classList.add("geoselect"); + input.setAttribute("autocomplete", "off"); + break; } input.id = 'opt' + element.key; input.title = element.desc; @@ -856,6 +863,12 @@ function contentselected() { let p = document.createElement("p"); p.appendChild(label); p.appendChild(input); + if (element.type == 'geoselect') { + input.addEventListener('input', debounce(searchLocations, 300)); + const resultsContainer = document.createElement('div'); + resultsContainer.id = 'georesults'; + p.appendChild(resultsContainer); + } $('#customoptions').appendChild(p); }); } @@ -1469,3 +1482,62 @@ function setFilterAndShow(filter) { GroupSortFilter(); $(`[data-target='tagtab']`).click(); } + +// geocoding typeahead + +async function searchLocations() { + const query = $(".geoselect").value.trim(); + document.getElementById('opt#lat').value = ''; + document.getElementById('opt#lon').value = ''; + if (document.getElementById('opt#tz')) document.getElementById('opt#tz').value = ''; + + if (query.length === 0) { + $('#georesults').innerHTML = ''; + return; + } + + try { + const response = await fetch(`https://geocoding-api.open-meteo.com/v1/search?name=${query}&count=10&language=en&format=json`); + const data = await response.json(); + displayResults(data.results); + } catch (error) { + console.error('Error fetching data:', error); + } +} + +function displayResults(results) { + $('#georesults').innerHTML = ''; + $('#georesults').style.top = $(".geoselect").offsetTop + $(".geoselect").offsetHeight + "px"; + $('#georesults').style.left = $(".geoselect").offsetLeft + 'px'; + // $('#georesults').style.width = $(".geoselect").offsetWidth + 'px'; + if (results) { + results.forEach(result => { + const option = document.createElement('div'); + option.textContent = result.name + ', ' + result.admin1 + ', ' + result.country ; + option.addEventListener('click', () => selectLocation(result)); + $('#georesults').appendChild(option); + }); + } +} + +function selectLocation(location) { + $(".geoselect").value = location.name; + document.getElementById('opt#lat').value = location.latitude; + document.getElementById('opt#lon').value = location.longitude; + if (document.getElementById('opt#tz')) document.getElementById('opt#tz').value = location.timezone; + $('#georesults').innerHTML = ''; + console.log('Selected location:', location); +} + +function debounce(func, delay) { + let timeoutId; + return function () { + const context = this; + const args = arguments; + + clearTimeout(timeoutId); + timeoutId = setTimeout(() => { + func.apply(context, args); + }, delay); + }; +} \ No newline at end of file diff --git a/ESP32_AP-Flasher/wwwroot/painter.js b/ESP32_AP-Flasher/wwwroot/painter.js index 7cf83afd..aa904c85 100644 --- a/ESP32_AP-Flasher/wwwroot/painter.js +++ b/ESP32_AP-Flasher/wwwroot/painter.js @@ -100,6 +100,7 @@ function startPainter(mac, width, height) { const formData = new FormData(); formData.append('mac', mac); formData.append('dither', '0'); + formData.append('contentmode', '22'); formData.append('file', binaryImage, 'image.jpg'); const xhr = new XMLHttpRequest(); xhr.open('POST', '/imgupload');