/*******************************************************************
 File: display.h
 Date: 30-September-2020
 Author: Peter Spindler
********************************************************************/
 
#ifndef _DISPLAY_H_
#define _DISPLAY_H_

#include "fonts.h"

typedef struct {
	int16_t x;
	int16_t y;
} DISPLAY_POINT_TypeDef;

typedef enum {
	ALIGN_LEFT,
	ALIGN_CENTER,
	ALIGN_RIGHT
} DISPLAY_ALIGN_TypeDef;

#define LCD_ORIENTATION_PORTRAIT         ((uint8_t)0x00)
#define LCD_ORIENTATION_LANDSCAPE        ((uint8_t)0x01)
#define LCD_ORIENTATION_LANDSCAPE_ROT180 ((uint32_t)0x02)

#define LCD_COLOR_BLUE          ((uint16_t)0x001F)
#define LCD_COLOR_GREEN         ((uint16_t)0x07E0)
#define LCD_COLOR_RED           ((uint16_t)0xF800)
#define LCD_COLOR_CYAN          ((uint16_t)0x07FF)
#define LCD_COLOR_MAGENTA       ((uint16_t)0xF81F)
#define LCD_COLOR_YELLOW        ((uint16_t)0xFFE0)
#define LCD_COLOR_LIGHTBLUE     ((uint16_t)0x841F)
#define LCD_COLOR_LIGHTGREEN    ((uint16_t)0x87F0)
#define LCD_COLOR_LIGHTRED      ((uint16_t)0xFC10)
#define LCD_COLOR_LIGHTMAGENTA  ((uint16_t)0xFC1F)
#define LCD_COLOR_LIGHTYELLOW   ((uint16_t)0xFFF0)
#define LCD_COLOR_DARKBLUE      ((uint16_t)0x0010)
#define LCD_COLOR_DARKGREEN     ((uint16_t)0x0400)
#define LCD_COLOR_DARKRED       ((uint16_t)0x8000)
#define LCD_COLOR_DARKCYAN      ((uint16_t)0x0410)
#define LCD_COLOR_DARKMAGENTA   ((uint16_t)0x8010)
#define LCD_COLOR_DARKYELLOW    ((uint16_t)0x8400)
#define LCD_COLOR_WHITE         ((uint16_t)0xFFFF)
#define LCD_COLOR_LIGHTGRAY     ((uint16_t)0xD69A)
#define LCD_COLOR_GRAY          ((uint16_t)0x8410)
#define LCD_COLOR_DARKGRAY      ((uint16_t)0x4208)
#define LCD_COLOR_BLACK         ((uint16_t)0x0000)
#define LCD_COLOR_BROWN         ((uint16_t)0xA145)
#define LCD_COLOR_ORANGE        ((uint16_t)0xFD20)

void Display_WriteCommand( uint8_t Reg );
void Display_WriteData( uint16_t Value );

void Display_Init( void );
void Display_On( void );
void Display_Off( void );

uint16_t Display_GetHeight( void );
uint16_t Display_GetWidth( void );
void Display_Clear( uint16_t Color );
void Display_PrintString( uint16_t x, uint16_t y, uint16_t ColorFront, uint16_t ColorBack, FONT_TypeDef *Font, char *String );
void Display_Printf( uint16_t x, uint16_t y, uint16_t ColorFront, uint16_t ColorBack, FONT_TypeDef *Font, char *Format, ... );
uint16_t Display_GetStringWidth( FONT_TypeDef *Font, char *String );
uint16_t Display_GetFontCharHeight( FONT_TypeDef *Font );

void Display_DrawPixel( uint16_t x, uint16_t y, uint16_t Color );
void Display_DrawLine( uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t Color );
void Display_DrawRect( uint16_t x, uint16_t y, uint16_t Width, uint16_t Height, uint16_t Color );
void Display_FillRect( uint16_t x, uint16_t y, uint16_t Width, uint16_t Height, uint16_t Color );
void Display_DrawCircle( uint16_t x, uint16_t y, uint16_t Radius, uint16_t Color );
void Display_FillCircle( uint16_t x, uint16_t Ypos, uint16_t Radius, uint16_t Color );

void Display_DrawEllipse( uint16_t x, uint16_t y, uint16_t xRadius, uint16_t yRadius, uint16_t Color );
void Display_FillEllipse( uint16_t x, uint16_t y, uint16_t xRadius, uint16_t yRadius, uint16_t Color );

void Display_DrawPolygon( DISPLAY_POINT_TypeDef *Points, uint16_t PointCount, uint16_t Color );
void Display_FillTriangle( uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3, uint16_t Color );
void Display_FillPolygon( DISPLAY_POINT_TypeDef *Points, uint16_t PointCount, uint16_t Color );

void Display_Test( void );

#endif
