/*
  Name:    Display.h
  Author:  Roman Schönfeld & Daniel Hausherr
*/

/***********************************************************************************************
  This work is licensed under a Creative Commons Attribution 4.0 International (CC BY 4.0) License.

  You are free to:

    Share — copy and redistribute the material in any medium or format
    Adapt — remix, transform, and build upon the material
    for any purpose, even commercially.

    The licensor cannot revoke these freedoms as long as you follow the license terms.

  Under the following terms:

    Attribution — You must give appropriate credit, provide a link to the license, and indicate if
    changes were made. You may do so in any reasonable manner, but not in any way that suggests
    the licensor endorses you or your use.

    No additional restrictions — You may not apply legal terms or technological measures that
    legally restrict others from doing anything the license permits.

  Credits:
        Laboratory for Physics and Illumination Technologies,
        University of Applied Sciences Southern Westfalia
        Germany

  Make Light! Support by the BMBF in the development of this device is gratefully acknowledged
***************************************************************************************************/
#ifndef _DISPLAY_h
#define _DISPLAY_h

#if defined(ARDUINO) && ARDUINO >= 100
#include "arduino.h"
#else
#include "WProgram.h"
#endif

#include <TFT.h>

/***************************************************************************************************
**  Define Constants
**
**  Define directives providing meaningful names for constant values.
***************************************************************************************************/
#define _DC           5
#define _CS           3
#define _BL           9
#define _RES          6

#define _TFT_BRIGHTNESS 255
#define _RESET LOW
#define _NRESET HIGH

#define     RGB(r, g, b)                (((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3))

#define     NONE                        RGB(0x00, 0x04, 0x00)
#define     BLACK                       RGB(0x00, 0x00, 0x00)
#define     DKGRAY                      RGB(0x40, 0x40, 0x40)
#define     GRAY                        RGB(0x80, 0x80, 0x80)
#define     LTGRAY                      RGB(0xA0, 0xA0, 0xA0)
#define     WHITE                       RGB(0xFF, 0xFF, 0xFF)
#define     DKRED                       RGB(0x60, 0x00, 0x00)
#define     RED                         RGB(0xFF, 0x00, 0x00)
#define     LTRED                       RGB(0xFF, 0x40, 0x40)
#define     DKGREEN                     RGB(0x00, 0x70, 0x00)
#define     GREEN                       RGB(0x00, 0x8F, 0x00)
#define     LTGREEN                     RGB(0x50, 0xFF, 0x50)
#define     DKBLUE                      RGB(0x00, 0x00, 0x60)
#define     BLUE                        RGB(0x10, 0x10, 0xFF)
#define     LTBLUE                      RGB(0x60, 0x60, 0xFF)
#define     DKYELLOW                    RGB(0x80, 0x80, 0x00)
#define     YELLOW                      RGB(0xFF, 0xFF, 0x00)
#define     LTYELLOW                    RGB(0xFF, 0xFF, 0x80)
#define     DKMAGENTA                   RGB(0x60, 0x00, 0x60)
#define     MAGENTA                     RGB(0xFF, 0x00, 0xFF)
#define     LTMAGENTA                   RGB(0xFF, 0x60, 0xFF)
#define     DKCYAN                      RGB(0x00, 0x60, 0x60)
#define     CYAN                        RGB(0x00, 0xB0, 0xB0)
#define     LTCYAN                      RGB(0x60, 0xFF, 0xFF)
#define     GOLD                        RGB(0x90, 0x90, 0x30)


/***************************************************************************************************
**  init_tft
**
**  Initialisiert das Display
**
**  Input:  None
**  Output: None
***************************************************************************************************/
extern void init_tft();

/***************************************************************************************************
**  set_brightness_tft
**
**  Zum verändern der Helligkeit des Displays
**
**  Input:  pwr Byte Werte zwischen 0 - 255
**  Output: None
***************************************************************************************************/
extern void set_brightness_tft(uint8_t light);

/***************************************************************************************************
**  print_text_tft
**
**  Gibt Text auf dem Display aus
**
**  Input: text, color Farbe der Textzeichen 
**  Output: None
***************************************************************************************************/
extern void print_text_tft(char *text, uint16_t color);

/***************************************************************************************************
**  print_value_tft
**
**  Gibt Werte auf dem Display aus
**
**  Input: value, color Farbe der Zeichen
**  Output: None
***************************************************************************************************/
extern void print_value_tft(uint16_t value, uint16_t color);

/***************************************************************************************************
**  print_value_tft_double
**
**  Gibt Fließkommawerte auf dem Display aus
**
**  Input: value, color Farbe der Zeichen
**  Output: None
***************************************************************************************************/
extern void print_value_tft_double(double value, uint16_t color);

/***************************************************************************************************
**  set_cursor_tft
**
**  Setzt den Kurser auf die Koordinanten x und y
**
**  Input:  x - Achse und y - Achse
**  Output: None
***************************************************************************************************/
extern void set_cursor_tft(uint8_t x, uint8_t y);

/***************************************************************************************************
**  set_text_size_tft
**
**  Bestimmt die Größe der Zeichen
**
**  Input: text_size 
**  Output: None
***************************************************************************************************/
extern void set_text_size_tft(uint8_t text_size);

/***************************************************************************************************
**  clear_area_tft
**
** Bestimmt die Fläche (Rechteck) des Displays, die überzeichnet werden soll
**
**  Input: x,y Koordinate und size_x, size_y Länge, color Farbe des Rechtecks
**  Output: None
***************************************************************************************************/
extern void clear_area_tft(uint8_t x, uint8_t y, uint8_t size_x, uint8_t size_y, uint16_t color);

extern void drawArrowUp(uint8_t x, uint8_t y, char *text, uint16_t color);
extern void drawArrowDown(uint8_t x, uint8_t y, char *text, uint16_t color);
extern void drawArrowRight(uint8_t x, uint8_t y, char *text, uint16_t color);
extern void drawArrowLeft(uint8_t x, uint8_t y, char *text, uint16_t color);
extern void drawMicro(uint8_t x, uint8_t y, uint8_t i, uint16_t color);

#endif
