#ifdef ENV_TEST_DISPLAY

#include <Arduino.h>
#include <SPI.h>
#include <LittleFS.h>
#include "config.h"
#include "epd.h"

void setup() {
    Serial.begin(115200);
    Serial.println("display test boot");

    pinMode(PIN_CS,   OUTPUT);
    pinMode(PIN_DC,   OUTPUT);
    pinMode(PIN_RST,  OUTPUT);
    pinMode(PIN_BUSY, INPUT);
    SPI.begin(PIN_SCK, -1, PIN_MOSI, PIN_CS);
    SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0));

    LittleFS.begin(true);

    File f = LittleFS.open("/img.bin", "r");
    if (!f) {
        Serial.println("ERROR: /img.bin not found — did you run uploadfs?");
        return;
    }
    Serial.printf("/img.bin: %u bytes\n", f.size());

    epd_init();
    epd_draw_image_from_file(f);
    f.close();
    epd_sleep();

    Serial.println("done");
}

void loop() {
    delay(60000);
}

#endif
