Update UI icons & show more wifi status via LED

This commit is contained in:
Matt
2025-12-14 18:47:03 +00:00
parent 9b534de1ec
commit bc97c96f2a
4 changed files with 40 additions and 35 deletions

View File

@@ -288,9 +288,9 @@
</div> </div>
<div class="btn-group"> <div class="btn-group">
<button id="resetBtn" class="secondary">Rst</button> <button title="Reset to default rate, attenuation & test settings" id="resetBtn" class="secondary">&olarr;</button>
<button id="wifiBtn" class="secondary">Wifi</button> <button title="Change wifi access point" id="wifiBtn" class="secondary">&#128732;</button>
<button id="powerOff" class="secondary">Off</button> <button title="Power off the esp-scope" id="powerOff" class="secondary">&#9889;</button>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -24,11 +24,6 @@
// Tag for logging // Tag for logging
static const char* TAG = "ESP-SCOPE"; static const char* TAG = "ESP-SCOPE";
#define ESP_MAXIMUM_RETRY 5
/* FreeRTOS event group to signal when we are connected*/
// Embedded index.html // Embedded index.html
extern const uint8_t index_html_start[] asm("_binary_index_html_start"); extern const uint8_t index_html_start[] asm("_binary_index_html_start");
extern const uint8_t index_html_end[] asm("_binary_index_html_end"); extern const uint8_t index_html_end[] asm("_binary_index_html_end");
@@ -285,9 +280,17 @@ static void show_status_led() {
while (true) { while (true) {
int64_t now = esp_timer_get_time() / 1000; int64_t now = esp_timer_get_time() / 1000;
#ifdef CONFIG_LED_BUILTIN #ifdef CONFIG_LED_BUILTIN
vTaskDelay(pdMS_TO_TICKS(is_ap ? 500 : 100)); if (is_ap) {
vTaskDelay(pdMS_TO_TICKS(500));
gpio_set_level(CONFIG_LED_BUILTIN, 1); gpio_set_level(CONFIG_LED_BUILTIN, 1);
vTaskDelay(pdMS_TO_TICKS(500));
} else {
if (is_connected()) {
vTaskDelay(pdMS_TO_TICKS(100));
gpio_set_level(CONFIG_LED_BUILTIN, 1);
}
vTaskDelay(pdMS_TO_TICKS(s_ws_client_fd == -1 ? 900 : 200)); vTaskDelay(pdMS_TO_TICKS(s_ws_client_fd == -1 ? 900 : 200));
}
gpio_set_level(CONFIG_LED_BUILTIN, 0); gpio_set_level(CONFIG_LED_BUILTIN, 0);
#else #else
vTaskDelay(pdMS_TO_TICKS(1000)); vTaskDelay(pdMS_TO_TICKS(1000));
@@ -483,14 +486,12 @@ static esp_err_t index_js_handler(httpd_req_t* req) {
static const httpd_uri_t uri_index_js = { static const httpd_uri_t uri_index_js = {
.uri = "/index.js", .method = HTTP_GET, .handler = index_js_handler, .user_ctx = NULL}; .uri = "/index.js", .method = HTTP_GET, .handler = index_js_handler, .user_ctx = NULL};
static esp_err_t power_handler(httpd_req_t* req) { static const char *bye = "<head></head><body style='font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Helvetica, Arial, sans-serif;\n background: #1a1a1a;\n color: #e0e0e0;'><h1>Bye!</h1>Press \"reset\" on your esp-scope to start it up again</body>";
#ifdef CONFIG_LED_BUILTIN
gpio_set_level(CONFIG_LED_BUILTIN, 0);
#endif
static esp_err_t power_handler(httpd_req_t* req) {
httpd_resp_set_type(req, "text/html"); httpd_resp_set_type(req, "text/html");
httpd_resp_set_hdr(req, "Content-Type", "text/html; charset=utf-8"); httpd_resp_set_hdr(req, "Content-Type", "text/html; charset=utf-8");
httpd_resp_send(req, "<html><body><h1>Bye!</h1></body></html>", HTTPD_RESP_USE_STRLEN); httpd_resp_send(req, bye, HTTPD_RESP_USE_STRLEN);
// delay to ensure network is flushed // delay to ensure network is flushed
vTaskDelay(pdMS_TO_TICKS(200)); vTaskDelay(pdMS_TO_TICKS(200));

View File

@@ -22,7 +22,6 @@ static const char *TAG = "WIFI_MGR";
// Event Group // Event Group
static EventGroupHandle_t s_wifi_event_group; static EventGroupHandle_t s_wifi_event_group;
#define WIFI_CONNECTED_BIT BIT0 #define WIFI_CONNECTED_BIT BIT0
#define WIFI_FAIL_BIT BIT1
// Server Handle for registering handlers // Server Handle for registering handlers
static httpd_handle_t s_server_handle = NULL; static httpd_handle_t s_server_handle = NULL;
@@ -44,6 +43,10 @@ static void wifi_init_station(const char* ssid, const char* pass);
#define NVS_KEY_SSID "ssid" #define NVS_KEY_SSID "ssid"
#define NVS_KEY_PASS "pass" #define NVS_KEY_PASS "pass"
bool is_connected(void) {
return xEventGroupWaitBits(s_wifi_event_group, WIFI_CONNECTED_BIT, pdFALSE, pdFALSE, 1) & WIFI_CONNECTED_BIT;
}
// WiFi Event Handler // WiFi Event Handler
static void event_handler(void *arg, esp_event_base_t event_base, static void event_handler(void *arg, esp_event_base_t event_base,
int32_t event_id, void *event_data) { int32_t event_id, void *event_data) {

View File

@@ -13,4 +13,5 @@ void wifi_manager_register_uri(httpd_handle_t server);
// Helper to erase NVS credentials (can be called by button handler) // Helper to erase NVS credentials (can be called by button handler)
void wifi_manager_erase_config(void); void wifi_manager_erase_config(void);
bool is_connected(void);
#endif // WIFI_MANAGER_H #endif // WIFI_MANAGER_H