Add third button: "scan to manage" QR overlay on the current photo
Pressing the manage button (GPIO1) overlays a small QR code -- "SCAN TO MANAGE" -- in the top-right corner of whatever photo is currently on screen, linking to the server's config page, then reverts to the plain photo after 30 seconds. The overlay is spliced into the existing streaming fetch as chunks pass through (frame_client.c's http_read_fn), rather than buffering the full 192,000-byte frame in RAM: only the small overlay rectangle itself (~30KB) is ever held in memory, generated via new stride-parameterized drawing helpers (epd_draw_*_ex in epd_draw.c) that let the existing QR/text drawing code target an arbitrarily-sized buffer instead of a full-frame one. epd7in3e.c is untouched -- it has no idea an overlay exists.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "frame_client.h"
|
||||
#include "reset_button.h"
|
||||
#include "next_button.h"
|
||||
#include "manage_button.h"
|
||||
|
||||
static const char *TAG = "main";
|
||||
|
||||
@@ -30,23 +31,25 @@ void app_main(void)
|
||||
}
|
||||
ESP_ERROR_CHECK(nvs_err);
|
||||
|
||||
/* Arms both buttons as deep-sleep wakeup sources (so holding one wakes
|
||||
* the device promptly, not just during its brief awake windows), then
|
||||
* checks them -- covers both "held while asleep, just woke us up" and
|
||||
* "held while powering on" the same way, since both look identical
|
||||
* from here: the pin is just low right now. */
|
||||
/* Arms all three buttons as deep-sleep wakeup sources (so holding one
|
||||
* wakes the device promptly, not just during its brief awake
|
||||
* windows), then checks them -- covers both "held while asleep, just
|
||||
* woke us up" and "held while powering on" the same way, since both
|
||||
* look identical from here: the pin is just low right now. */
|
||||
reset_button_init();
|
||||
next_button_init();
|
||||
manage_button_init();
|
||||
reset_button_check(); /* clears config + restarts if held the full duration; never returns in that case */
|
||||
|
||||
bool force_advance = next_button_check();
|
||||
bool show_management_qr = manage_button_check();
|
||||
|
||||
frame_config_t cfg;
|
||||
esp_err_t cfg_err = frame_config_load(&cfg);
|
||||
if (cfg_err == ESP_OK) {
|
||||
ESP_LOGI(TAG, "Found stored config for '%s', connecting to home WiFi", cfg.sta_ssid);
|
||||
if (frame_wifi_connect_sta(&cfg) == ESP_OK) {
|
||||
frame_client_run(&cfg, force_advance);
|
||||
frame_client_run(&cfg, force_advance, show_management_qr);
|
||||
return; /* frame_client_run currently never returns */
|
||||
}
|
||||
ESP_LOGW(TAG, "Could not connect to stored WiFi after %d attempts, falling back to provisioning",
|
||||
|
||||
Reference in New Issue
Block a user