/*
 * Copyright (c) 2021 Arm Limited and Contributors. All rights reserved.
 *
 * SPDX-License-Identifier: Apache-2.0
 * 
 * ST7789 TFT LCD Display Driver
 */

#ifndef _PICO_ST7789_H_
#define _PICO_ST7789_H_

#include "hardware/spi.h"

#ifdef __cplusplus
extern "C" {
#endif

struct st7789_config {
    spi_inst_t* spi;
    uint gpio_din;
    uint gpio_clk;
    int gpio_cs;
    uint gpio_dc;
    uint gpio_rst;
    uint gpio_bl;
};

void st7789_init(const struct st7789_config *config, uint16_t width, uint16_t height);
void st7789_fill(uint16_t color);
void st7789_put(uint16_t color);
void st7789_set_cursor(uint16_t x, uint16_t y);
void st7789_write(const uint16_t *data, size_t len);
void st7789_vertical_scroll(uint16_t row);
void st7789_draw_pixel(uint16_t x, uint16_t y, uint16_t color);
void st7789_draw_rect(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color);
void st7789_fill_rect(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color);
void st7789_draw_circle(uint16_t x0, uint16_t y0, uint16_t r, uint16_t color);
void st7789_fill_circle(uint16_t x0, uint16_t y0, uint16_t r, uint16_t color);
void st7789_draw_line(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color);

void st7789_sleep(void);
void st7789_wake(void);
void st7789_set_brightness(uint8_t brightness);
uint8_t st7789_get_brightness(void);

#ifdef __cplusplus
}
#endif

#endif
