#ifndef LOW_LEVEL_DISPLAY_EPAPER_H
#define LOW_LEVEL_DISPLAY_EPAPER_H

#include "low_level_display.h"

// E-paper display configuration structure
struct epaper_config {
    void* spi;           // SPI instance
    int gpio_din;        // MOSI pin
    int gpio_clk;        // Clock pin
    int gpio_cs;         // Chip select pin
    int gpio_dc;         // Data/Command pin
    int gpio_rst;        // Reset pin
    int gpio_busy;       // Busy pin
};

class LowLevelDisplayEPaper : public LowLevelDisplay {
private:
    const epaper_config* config;
    int width;
    int height;
    bool initialized;
    uint8_t* framebuffer;  // E-paper needs a framebuffer
    bool dirty;            // Track if display needs refresh
    
public:
    LowLevelDisplayEPaper(const epaper_config* cfg, int w, int h);
    ~LowLevelDisplayEPaper() override;
    
    // Core display operations - native 1-bit monochrome
    bool init() override;
    void clear(bool white = true) override;
    void draw_pixel(int x, int y, bool white) override;
    void draw_buffer(const uint8_t* bit_buffer) override;
    void refresh() override;  // Actually update the e-paper display
    
    // Display properties
    int get_width() const override { return width; }
    int get_height() const override { return height; }
    DisplayType get_type() const override { return DISPLAY_TYPE_EPAPER; }
    bool is_color() const override { return false; }  // Most e-paper is monochrome
    
    // E-paper specific
    void clear_display();  // Full clear with refresh
    void full_refresh();   // Force full screen refresh (slower but removes ghosting)
    void sleep();          // Put display in low power mode
};

#endif // LOW_LEVEL_DISPLAY_EPAPER_H
