/* 
* classGraphics.h
*
* Created: 04/02/2020 21:26:32
* Author: Ledo
*/


#ifndef __CLASSGRAPHICS_H__
#define __CLASSGRAPHICS_H__

#include "fonts.h"
#include "font.h"
#include "classTFT.h"
#include "classW25Qflash.h"
#include "string.h"
#include "tipos.h"
#include <stdio.h>

#define LEFT 0
#define RIGHT 800 //9999
#define CENTER 400 //9998
#define LCD_W 800
#define LCD_H 480

#define PORTRAIT 0
#define LANDSCAPE 1


typedef enum FONTYPE
{
	font8x12,
	font16x16,
	font7seg,
	font48,
	font7_96_144
}FONTYPE;

typedef struct _current_font
{
	uint8_t* font;
	uint16_t x_size;
	uint16_t y_size;
	uint16_t offset;
	uint16_t numchars;
}_current_font;


extern classTFT Display;
extern classW25Qflash W25q;
class classGraphics
{
//variables
public:
    _current_font cfont;
	bool _transparent;
	uint8_t	orient;

protected:
private:

//functions
public:
	classGraphics();
	~classGraphics();
	void drawPoint(uint16_t x,uint16_t y,uint16_t color);
	void drawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
	void drawTriangle(uint16_t x0,uint16_t y0,uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2, uint16_t color);
	void drawFillTriangle(uint16_t x0,uint16_t y0,uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2, uint16_t color);
	void drawRectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
	void drawFillRectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
	void drawCircle(int xc, int yc,uint16_t c,int r, int fill);
	void setFont(FONTYPE fontype);
	void showChar(uint16_t x,uint16_t y,uint16_t fc, uint16_t bc, uint8_t num,uint8_t Size,uint8_t mode);
	void showStr(uint16_t x, uint16_t y, uint16_t fc, uint16_t bc, uint8_t *str,uint8_t Size,uint8_t mode);
	void showString(uint16_t x,uint16_t y,uint8_t Size,uint8_t *p,uint8_t mode);
    void strCenter(uint16_t x, uint16_t y, uint16_t fc, uint16_t bc, uint8_t *str,uint8_t Size,uint8_t mode);
	void showNum(uint16_t x,uint16_t y,uint32_t num,uint8_t len,uint8_t Size);
	void printChar(uint8_t c, int x, int y,uint16_t fc, uint16_t bc);
    void rotateChar(uint8_t c, int x, int y, int pos, int deg, uint16_t fc, uint16_t bc);	
	void print(char *st, int x, int y, int deg, uint16_t fc, uint16_t bc);
	void drawBmp16(uint16_t x,uint16_t y,uint16_t w,uint16_t h,const unsigned char *p);
    void drawBitmap_from_w25q(int x, int y, int sx, int sy,uint32_t p, int scale);
	void drawBitmap(int x, int y, int sx, int sy,uint32_t * p, int scale);
	void printNumI(long num, int x, int y, int length, char filler, uint16_t fc, uint16_t bc);
	void printNumF(double num, uint8_t lenght, uint8_t dec, char filler, int x, int y, uint16_t fc, uint16_t bc);

	void drawTestPage(uint8_t *str);

protected:
private:
	classGraphics( const classGraphics &c );
	classGraphics& operator=( const classGraphics &c );
	uint32_t mypow(uint8_t m,uint8_t n);
	void _fill(uint16_t sx,uint16_t sy,uint16_t ex,uint16_t ey,uint16_t color);
    void _swap(uint16_t *a, uint16_t *b);
	void _draw_circle_8(int xc, int yc, int x, int y, uint16_t c);

}; //classGraphics

#endif //__CLASSGRAPHICS_H__
