#ifndef _2INCH9_EPD_H_
#define _2INCH9_EPD_H_

#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "Arduino.h"



 /* Pin wiring definion
 *      3.3V --> VCC  
 *      GND  --> GND
 *      IO27 --> CS
 *      IO18 --> CLK
 *      IO23 --> MOSI
 *      IO14  --> DC
 *      IO33  --> RST
 *      IO13  --> BUSY
 * */
//IO settings
#define TEST_Pin  7 
#define BUSY_Pin  13 
#define RES_Pin   33 
#define DC_Pin    14 

#define CS_Pin    27 
#define SCK_Pin   18 
#define SDI_Pin   23

#define black   0x00  /// 00
#define white   0x01  /// 01
#define yellow  0x02  /// 10
#define red     0x03  /// 11

#define EPD_WIDTH   128
#define EPD_HEIGHT  296
#define EPD_ARRAY  EPD_WIDTH*EPD_HEIGHT/4


#define Source_BITS     128
#define Gate_BITS   296
#define ALLSCREEN_BYTES  9472 

// Color
#define  EPD_2IN9G_BLACK   0x0
#define  EPD_2IN9G_WHITE   0x1
#define  EPD_2IN9G_YELLOW  0x2
#define  EPD_2IN9G_RED     0x3

#define TEST_0  digitalWrite(TEST_Pin,LOW)
#define TEST_1  digitalWrite(TEST_Pin,HIGH) 

#define EPD_W21_MOSI_0  digitalWrite(SDI_Pin,LOW)
#define EPD_W21_MOSI_1  digitalWrite(SDI_Pin,HIGH) 

#define EPD_W21_CLK_0  digitalWrite(SCK_Pin,LOW)
#define EPD_W21_CLK_1  digitalWrite(SCK_Pin,HIGH)


#define EPD_W21_CS_0   digitalWrite(CS_Pin,LOW)
#define EPD_W21_CS_1   digitalWrite(CS_Pin,HIGH)

#define EPD_W21_DC_0   digitalWrite(DC_Pin,LOW)
#define EPD_W21_DC_1   digitalWrite(DC_Pin,HIGH)
#define EPD_W21_RST_0  digitalWrite(RES_Pin,LOW)
#define EPD_W21_RST_1  digitalWrite(RES_Pin,HIGH)
#define isEPD_W21_BUSY digitalRead(BUSY_Pin)

//Full screen refresh display
void EPD_HW_Init(void); 
void EPD_WhiteScreen_White(void);
void EPD_WhiteScreen_Black(void);
void EPD_DeepSleep(void);
void EPD_WhiteScreen_Red(void);
void EPD_WhiteScreen_Yellow(void);
void PIC_display(const unsigned char* picData);   
void GUI_display(const unsigned char* picData);

                         
#endif
