#ifndef __LCD_2INCH_H
#define __LCD_2INCH_H

#include "main.h" 

#define LCD_W   240
#define LCD_H   320 


#define WHITE            0xFFFF
#define BLACK            0x0000
#define BLUE             0x001F
#define BRED             0XF81F
#define GRED             0XFFE0
#define GBLUE            0X07FF
#define RED              0xF800
#define MAGENTA          0xF81F
#define GREEN            0x07E0
#define CYAN             0x7FFF
#define YELLOW           0xFFE0
#define BROWN            0XBC40
#define BRRED            0XFC07
#define GRAY             0X8430

#define ORANGE       0xFBE0
#define PURPLE       0x881F
#define BACKGROUND_COLOR   WHITE

#define LCD_CS_0    HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_RESET)
#define LCD_CS_1    HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_SET)

#define LCD_RST_0   HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_RESET)
#define LCD_RST_1   HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_SET)

#define LCD_DC_0    HAL_GPIO_WritePin(GPIOB, GPIO_PIN_11, GPIO_PIN_RESET)
#define LCD_DC_1    HAL_GPIO_WritePin(GPIOB, GPIO_PIN_11, GPIO_PIN_SET)


typedef struct
{
    uint16_t width;
    uint16_t height;
    uint16_t id;
    uint8_t  dir;
    uint16_t wramcmd;
    uint16_t setxcmd;
    uint16_t setycmd;
} _lcd_dev;

extern _lcd_dev lcddev;


void Lcd_Init(void);
void LCD_Clear(uint16_t color);
void LCD_Set_Cursor(uint16_t x, uint16_t y);
void Draw_Point(uint16_t x, uint16_t y, uint16_t color);
void Spi_write_cmd(uint8_t data);
void Spi_write_data(uint8_t data);
void Spi_write_word(uint16_t data);
void BlackLight_SetValue(uint16_t value);

#endif
