#define LCDWidth 240 //define screen width,height
#define LCDHeight 320
#define _Digole_Serial_I2C_ //To tell compiler compile the special communication only,
//#define TOUCH_SCEEN //if the module equipt with touch screen, use this, otherwise use // to disable it
//#define FLASH_CHIP //if the module equipt with 2MB or 4MB flash chip, use it, otherwise use // to disable it
#define V33 //if the version of firmware on display is V3.3 and newer, use it
//all available are:_Digole_Serial_UART_, _Digole_Serial_I2C_ and _Digole_Serial_SPI_
//end changing
//define 8 bit color, see:https://en.wikipedia.org/wiki/8-bit_color
#define WHITE 0xFF
#define BLACK 0
#define RED 0xE0
#define GREEN 0x1A
#define BLUE 0x03
//define draw window
#define DW_X 5
#define DW_Y 8
#define DW_W (LCDWidth - 10)
#define DW_H (LCDHeight - 15)
#include <DigoleSerial.h>
//--------UART setup
#if defined(_Digole_Serial_UART_)
DigoleSerialDisp mydisp(&Serial, 9600); //UART:Arduino UNO: Pin 1(TX)on arduino to RX on module
#endif
//--------I2C setup
#if defined(_Digole_Serial_I2C_)
#include <Wire.h>
DigoleSerialDisp mydisp(&Wire, '\x27'); //I2C:Arduino UNO: SDA (data line) is on analog input pin 4, and SCL (clock line) is on analog input pin 5 on UNO and Duemilanove
#endif
//--------SPI setup
#if defined(_Digole_Serial_SPI_)
DigoleSerialDisp mydisp(8, 9, 10, 11); //SPI:Pin 8: data, 9:clock, 10: SS, 11:SI. you can assign 255 to SS, and hard ground SS pin on module
#endif
int x,y,r,r1;
void setup() {
mydisp.begin(); //initiate serial port
draw_Filled_Rectangles_Fast();
}
void draw_Filled_Rectangles_Fast(void)
{
mydisp.cleanDrawWindow(); //clear draw window use the new back ground color
mydisp.setRotation(0);
mydisp.drawStr(0, 0, "Draw filled rectangle use draw window");
for (i = 0; i < 20; i++)
{
#ifdef V33
mydisp.setBgColor(random(256));
#else
mydisp.setColor(random(256));
mydisp.setBgColor();
endif
x = random(15, DW_W - 10);//top-left position
y = random(DW_H - 10);
r = random(DW_W - x);//width
r1 = random(DW_H - y);//height
mydisp.setDrawWindow(x, y, r, r1); //draw a filled rectangle:x,y,width,height
mydisp.cleanDrawWindow(); //clear draw window use the new back ground color
}
}