diff options
| author | Your Name <you@example.com> | 2026-05-19 13:44:57 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-19 13:44:57 +0530 |
| commit | cf4ac1bc04a19110bca26f969245dcc9ef265890 (patch) | |
| tree | f448bcc8785c9047049e9cdddbae374ab680cc3d | |
| parent | 2e65cdfdb582cebe6c4fa0f351df88ffe9c4c21c (diff) | |
feat: add WiFi QR code to BOOT and ERROR screens
BOOT screen now shows QR code for AP WiFi + SSID + status text.
ERROR screen reorganized with QR code at top, NO UPSTREAM banner,
setup URL, and 'Scan QR to connect' hint.
| -rw-r--r-- | main/display.c | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/main/display.c b/main/display.c index 53cdd4d..ccd08b7 100644 --- a/main/display.c +++ b/main/display.c | |||
| @@ -184,12 +184,24 @@ static void render_boot_screen(void) { | |||
| 184 | int screen_w = axs15231b_get_width(); | 184 | int screen_w = axs15231b_get_width(); |
| 185 | axs15231b_fill_screen(COLOR_BG); | 185 | axs15231b_fill_screen(COLOR_BG); |
| 186 | 186 | ||
| 187 | char qr_text[320]; | ||
| 188 | build_wifi_qr_string(qr_text, sizeof(qr_text)); | ||
| 189 | render_qr_at(qr_text, 0, 10, screen_w, 220); | ||
| 190 | |||
| 187 | const char *title = "TollGate"; | 191 | const char *title = "TollGate"; |
| 188 | int title_w = strlen(title) * 8 * 2; | 192 | int title_w = strlen(title) * 8 * 2; |
| 189 | display_render_text((screen_w - title_w) / 2, 200, title, COLOR_CYAN, COLOR_BG, 2); | 193 | display_render_text((screen_w - title_w) / 2, 240, title, COLOR_CYAN, COLOR_BG, 2); |
| 190 | 194 | ||
| 191 | int status_w = strlen(s_wifi_status) * 8; | 195 | int status_w = strlen(s_wifi_status) * 8; |
| 192 | display_render_text((screen_w - status_w) / 2, 228, s_wifi_status, COLOR_YELLOW, COLOR_BG, 1); | 196 | display_render_text((screen_w - status_w) / 2, 268, s_wifi_status, COLOR_YELLOW, COLOR_BG, 1); |
| 197 | |||
| 198 | snprintf(qr_text, sizeof(qr_text), "SSID: %s", s_ap_ssid); | ||
| 199 | int ssid_w = strlen(qr_text) * 8; | ||
| 200 | display_render_text((screen_w - ssid_w) / 2, 295, qr_text, COLOR_DIM, COLOR_BG, 1); | ||
| 201 | |||
| 202 | const char *hint = "Scan QR to connect"; | ||
| 203 | int hint_w = strlen(hint) * 8; | ||
| 204 | display_render_text((screen_w - hint_w) / 2, 315, hint, COLOR_DIM, COLOR_BG, 1); | ||
| 193 | 205 | ||
| 194 | axs15231b_flush(); | 206 | axs15231b_flush(); |
| 195 | } | 207 | } |
| @@ -322,30 +334,43 @@ static void render_error_screen(void) { | |||
| 322 | int screen_w = axs15231b_get_width(); | 334 | int screen_w = axs15231b_get_width(); |
| 323 | axs15231b_fill_screen(COLOR_BG); | 335 | axs15231b_fill_screen(COLOR_BG); |
| 324 | 336 | ||
| 325 | axs15231b_fill_rect(0, 190, screen_w, 50, COLOR_RED); | 337 | char qr_text[320]; |
| 338 | build_wifi_qr_string(qr_text, sizeof(qr_text)); | ||
| 339 | render_qr_at(qr_text, 0, 5, screen_w, 150); | ||
| 340 | |||
| 341 | axs15231b_fill_rect(0, 160, screen_w, 36, COLOR_RED); | ||
| 326 | const char *msg = "NO UPSTREAM"; | 342 | const char *msg = "NO UPSTREAM"; |
| 327 | int msg_w = strlen(msg) * 8 * 2; | 343 | int msg_w = strlen(msg) * 8 * 2; |
| 328 | display_render_text((screen_w - msg_w) / 2, 202, msg, COLOR_WHITE, COLOR_RED, 2); | 344 | display_render_text((screen_w - msg_w) / 2, 170, msg, COLOR_WHITE, COLOR_RED, 2); |
| 329 | 345 | ||
| 330 | char line[64]; | 346 | char line[64]; |
| 331 | int lw; | 347 | int lw; |
| 348 | int y = 210; | ||
| 332 | 349 | ||
| 333 | const char *l1 = "Internet unavailable"; | 350 | const char *l1 = "Internet unavailable"; |
| 334 | lw = strlen(l1) * 8; | 351 | lw = strlen(l1) * 8; |
| 335 | display_render_text((screen_w - lw) / 2, 270, l1, COLOR_WHITE, COLOR_BG, 1); | 352 | display_render_text((screen_w - lw) / 2, y, l1, COLOR_WHITE, COLOR_BG, 1); |
| 353 | y += 20; | ||
| 354 | |||
| 355 | const char *l3 = "AP still active"; | ||
| 356 | lw = strlen(l3) * 8; | ||
| 357 | display_render_text((screen_w - lw) / 2, y, l3, COLOR_GREEN, COLOR_BG, 1); | ||
| 358 | y += 20; | ||
| 336 | 359 | ||
| 337 | snprintf(line, sizeof(line), "SSID: %s", s_ap_ssid); | 360 | snprintf(line, sizeof(line), "SSID: %s", s_ap_ssid); |
| 338 | lw = strlen(line) * 8; | 361 | lw = strlen(line) * 8; |
| 339 | display_render_text((screen_w - lw) / 2, 300, line, COLOR_DIM, COLOR_BG, 1); | 362 | display_render_text((screen_w - lw) / 2, y, line, COLOR_DIM, COLOR_BG, 1); |
| 363 | y += 20; | ||
| 340 | 364 | ||
| 341 | const tollgate_config_t *cfg = tollgate_config_get(); | 365 | const tollgate_config_t *cfg = tollgate_config_get(); |
| 342 | snprintf(line, sizeof(line), "Setup: http://%s/setup", cfg->ap_ip_str); | 366 | snprintf(line, sizeof(line), "http://%s/setup", cfg->ap_ip_str); |
| 343 | lw = strlen(line) * 8; | 367 | lw = strlen(line) * 8; |
| 344 | display_render_text((screen_w - lw) / 2, 330, line, COLOR_YELLOW, COLOR_BG, 1); | 368 | display_render_text((screen_w - lw) / 2, y, line, COLOR_YELLOW, COLOR_BG, 1); |
| 369 | y += 16; | ||
| 345 | 370 | ||
| 346 | const char *l3 = "AP still active"; | 371 | const char *hint = "Scan QR to connect"; |
| 347 | lw = strlen(l3) * 8; | 372 | lw = strlen(hint) * 8; |
| 348 | display_render_text((screen_w - lw) / 2, 360, l3, COLOR_GREEN, COLOR_BG, 1); | 373 | display_render_text((screen_w - lw) / 2, y, hint, COLOR_DIM, COLOR_BG, 1); |
| 349 | 374 | ||
| 350 | axs15231b_flush(); | 375 | axs15231b_flush(); |
| 351 | } | 376 | } |