#pragma once

#include <stddef.h>
#include <stdint.h>

#include "epd7in3e.h"
#include "fonts.h"

/** Sets one pixel in a malloc'd EPD_FRAME_BYTES buffer (packed 2px/byte, per epd7in3e.h). */
void epd_draw_pixel(uint8_t *frame, int x, int y, epd_color_t color);

/**
 * Draws text (uppercased) in the given sFONT (see components/epaper_fonts)
 * with its top-left corner at (origin_x, origin_y).
 */
void epd_draw_text(uint8_t *frame, const sFONT *font, const char *text, int origin_x, int origin_y);

/** Same as epd_draw_text(), but horizontally centered on center_x. */
void epd_draw_text_centered(uint8_t *frame, const sFONT *font, const char *text, int center_x, int y);

/**
 * Same as epd_draw_pixel()/epd_draw_text()/epd_draw_text_centered(), but
 * against an arbitrarily-sized buffer instead of a full EPD_FRAME_BYTES
 * one -- stride is bytes per row (packed 2px/byte, so width/2), width and
 * height are that buffer's pixel dimensions, used for bounds-checking
 * instead of the panel's fixed EPD_WIDTH/EPD_HEIGHT. The non-_ex
 * functions above are thin wrappers around these, passing
 * EPD_BYTES_PER_ROW/EPD_WIDTH/EPD_HEIGHT -- existing callers are
 * unaffected.
 */
void epd_draw_pixel_ex(uint8_t *buf, int stride, int width, int height, int x, int y, epd_color_t color);
void epd_draw_text_ex(uint8_t *buf, int stride, int width, int height, const sFONT *font, const char *text,
                       int origin_x, int origin_y);
void epd_draw_text_centered_ex(uint8_t *buf, int stride, int width, int height, const sFONT *font, const char *text,
                                int center_x, int y);

/** Draws a line of the given thickness (in pixels) between two points. */
void epd_draw_line(uint8_t *frame, int x0, int y0, int x1, int y1, int thickness);

/** Draws a checkmark (short down-stroke, long up-stroke) inside a size x size box at (x, y). */
void epd_draw_checkmark(uint8_t *frame, int x, int y, int size);
