#pragma once
#include <Arduino.h>
#include <SPI.h>
#include <FS.h>

// One-shot panel hardware init — pinModes for the panel's GPIO contract and
// SPI.begin() with the right bus/CS layout. Each panel driver implements
// this for its own pinout: single-CS for the 7.3", dual-CS + power-enable
// for the 13.3". Callers hit this once at boot, then use epd_init() per
// redraw cycle.
void epd_setup_pins();

void epd_init();
void epd_sleep();
void epd_fill(uint8_t color);
void epd_draw_image_from_file(fs::File& f);

// Draw the image streamed from `f` with a `thickness`-pixel border of `color`
// overlaid. If `f` is not a full-frame .bin (size mismatch), falls back to
// epd_fill(color) so callers don't have to pre-validate.
void epd_draw_image_with_border(fs::File& f, uint8_t color, int thickness);

// Draw a QR code centred on the display.
// bg/fg are EPD color nibbles (COLOR_WHITE / COLOR_BLACK).
struct QRCode;
void epd_draw_qr(QRCode* qr, uint8_t cellPx, uint8_t bg, uint8_t fg);

// Draw the setup screen: pre-rendered background from LittleFS with QR overlaid.
void epd_draw_ap_screen(QRCode* qr);
// Same layout as ap_screen but with red accents and a "Connection Failed —
// try again" label, served after a failed WiFi join attempt.
void epd_draw_ap_screen_retry(QRCode* qr);
void epd_draw_setup_screen(QRCode* qr);
