Added a function that can refresh only part of the screen area.
This commit is contained in:
parent
fb3ce18166
commit
ce29fad2c3
4 changed files with 357 additions and 297 deletions
|
@ -30,49 +30,63 @@
|
|||
|
||||
static const UBYTE lut_4Gray_GC[] =
|
||||
{
|
||||
0x2A,0x06,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//1
|
||||
0x28,0x06,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//2
|
||||
0x20,0x06,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//3
|
||||
0x14,0x06,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//4
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//5
|
||||
0x00,0x02,0x02,0x0A,0x00,0x00,0x00,0x08,0x08,0x02,//6
|
||||
0x00,0x02,0x02,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,//7
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//8
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//9
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//10
|
||||
0x22,0x22,0x22,0x22,0x22
|
||||
0x2A,0x06,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//1
|
||||
0x28,0x06,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//2
|
||||
0x20,0x06,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//3
|
||||
0x14,0x06,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//4
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//5
|
||||
0x00,0x02,0x02,0x0A,0x00,0x00,0x00,0x08,0x08,0x02,//6
|
||||
0x00,0x02,0x02,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,//7
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//8
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//9
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//10
|
||||
0x22,0x22,0x22,0x22,0x22
|
||||
};
|
||||
|
||||
static const UBYTE lut_1Gray_GC[] =
|
||||
{
|
||||
0x2A,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//1
|
||||
0x05,0x2A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//2
|
||||
0x2A,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//3
|
||||
0x05,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//4
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//5
|
||||
0x00,0x02,0x03,0x0A,0x00,0x02,0x06,0x0A,0x05,0x00,//6
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//7
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//8
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//9
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//10
|
||||
0x22,0x22,0x22,0x22,0x22
|
||||
0x2A,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//1
|
||||
0x05,0x2A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//2
|
||||
0x2A,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//3
|
||||
0x05,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//4
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//5
|
||||
0x00,0x02,0x03,0x0A,0x00,0x02,0x06,0x0A,0x05,0x00,//6
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//7
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//8
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//9
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//10
|
||||
0x22,0x22,0x22,0x22,0x22
|
||||
};
|
||||
|
||||
static const UBYTE lut_1Gray_DU[] =
|
||||
{
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//1
|
||||
0x01,0x2A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x0A,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//3
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//5
|
||||
0x00,0x00,0x05,0x05,0x00,0x05,0x03,0x05,0x05,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//7
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//9
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x22,0x22,0x22,0x22,0x22
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//1
|
||||
0x01,0x2A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x0A,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//3
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//5
|
||||
0x00,0x00,0x05,0x05,0x00,0x05,0x03,0x05,0x05,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//7
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//9
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x22,0x22,0x22,0x22,0x22
|
||||
};
|
||||
|
||||
static const UBYTE lut_1Gray_A2[] =
|
||||
{
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //1
|
||||
0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //2
|
||||
0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //3
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //4
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //5
|
||||
0x00,0x00,0x03,0x05,0x00,0x00,0x00,0x00,0x00,0x00, //6
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //7
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //8
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //9
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //10
|
||||
0x22,0x22,0x22,0x22,0x22
|
||||
};
|
||||
|
||||
Epd::~Epd() {
|
||||
};
|
||||
|
@ -87,80 +101,80 @@ Epd::Epd() {
|
|||
};
|
||||
|
||||
int Epd::Init(void) {
|
||||
if (IfInit() != 0) {
|
||||
return -1;
|
||||
}
|
||||
Reset();
|
||||
if (IfInit() != 0) {
|
||||
return -1;
|
||||
}
|
||||
Reset();
|
||||
|
||||
SendCommand(0x12);
|
||||
DelayMs(300);
|
||||
|
||||
SendCommand(0x46);
|
||||
SendData(0xF7);
|
||||
WaitUntilIdle();
|
||||
SendCommand(0x47);
|
||||
SendData(0xF7);
|
||||
WaitUntilIdle();
|
||||
|
||||
SendCommand(0x01); // setting gaet number
|
||||
SendData(0xDF);
|
||||
SendData(0x01);
|
||||
SendData(0x00);
|
||||
SendCommand(0x12);
|
||||
DelayMs(300);
|
||||
|
||||
SendCommand(0x03); // set gate voltage
|
||||
SendData(0x00);
|
||||
SendCommand(0x46);
|
||||
SendData(0xF7);
|
||||
WaitUntilIdle();
|
||||
SendCommand(0x47);
|
||||
SendData(0xF7);
|
||||
WaitUntilIdle();
|
||||
|
||||
SendCommand(0x04); // set source voltage
|
||||
SendData(0x41);
|
||||
SendData(0xA8);
|
||||
SendData(0x32);
|
||||
SendCommand(0x01); // setting gaet number
|
||||
SendData(0xDF);
|
||||
SendData(0x01);
|
||||
SendData(0x00);
|
||||
|
||||
SendCommand(0x11); // set data entry sequence
|
||||
SendData(0x03);
|
||||
SendCommand(0x03); // set gate voltage
|
||||
SendData(0x00);
|
||||
|
||||
SendCommand(0x3C); // set border
|
||||
SendData(0x00);
|
||||
SendCommand(0x04); // set source voltage
|
||||
SendData(0x41);
|
||||
SendData(0xA8);
|
||||
SendData(0x32);
|
||||
|
||||
SendCommand(0x0C); // set booster strength
|
||||
SendData(0xAE);
|
||||
SendData(0xC7);
|
||||
SendData(0xC3);
|
||||
SendData(0xC0);
|
||||
SendData(0xC0);
|
||||
SendCommand(0x11); // set data entry sequence
|
||||
SendData(0x03);
|
||||
|
||||
SendCommand(0x18); // set internal sensor on
|
||||
SendData(0x80);
|
||||
|
||||
SendCommand(0x2C); // set vcom value
|
||||
SendData(0x44);
|
||||
|
||||
SendCommand(0x37); // set display option, these setting turn on previous function
|
||||
SendData(0x00);
|
||||
SendData(0xff);
|
||||
SendData(0xff);
|
||||
SendData(0xff);
|
||||
SendData(0xff);
|
||||
SendData(0x4f);
|
||||
SendData(0xff);
|
||||
SendData(0xff);
|
||||
SendData(0xff);
|
||||
SendData(0xff);
|
||||
SendCommand(0x3C); // set border
|
||||
SendData(0x00);
|
||||
|
||||
SendCommand(0x44); // setting X direction start/end position of RAM
|
||||
SendData(0x00);
|
||||
SendData(0x00);
|
||||
SendData(0x17);
|
||||
SendData(0x01);
|
||||
SendCommand(0x0C); // set booster strength
|
||||
SendData(0xAE);
|
||||
SendData(0xC7);
|
||||
SendData(0xC3);
|
||||
SendData(0xC0);
|
||||
SendData(0xC0);
|
||||
|
||||
SendCommand(0x45); // setting Y direction start/end position of RAM
|
||||
SendData(0x00);
|
||||
SendData(0x00);
|
||||
SendData(0xDF);
|
||||
SendData(0x01);
|
||||
SendCommand(0x18); // set internal sensor on
|
||||
SendData(0x80);
|
||||
|
||||
SendCommand(0x22); // Display Update Control 2
|
||||
SendData(0xCF);
|
||||
return 0;
|
||||
SendCommand(0x2C); // set vcom value
|
||||
SendData(0x44);
|
||||
|
||||
SendCommand(0x37); // set display option, these setting turn on previous function
|
||||
SendData(0x00);
|
||||
SendData(0xff);
|
||||
SendData(0xff);
|
||||
SendData(0xff);
|
||||
SendData(0xff);
|
||||
SendData(0x4f);
|
||||
SendData(0xff);
|
||||
SendData(0xff);
|
||||
SendData(0xff);
|
||||
SendData(0xff);
|
||||
|
||||
SendCommand(0x44); // setting X direction start/end position of RAM
|
||||
SendData(0x00);
|
||||
SendData(0x00);
|
||||
SendData(0x17);
|
||||
SendData(0x01);
|
||||
|
||||
SendCommand(0x45); // setting Y direction start/end position of RAM
|
||||
SendData(0x00);
|
||||
SendData(0x00);
|
||||
SendData(0xDF);
|
||||
SendData(0x01);
|
||||
|
||||
SendCommand(0x22); // Display Update Control 2
|
||||
SendData(0xCF);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -183,15 +197,13 @@ void Epd::SendData(unsigned char data) {
|
|||
* @brief: Wait until the busy_pin goes HIGH
|
||||
*/
|
||||
void Epd::WaitUntilIdle(void) {
|
||||
Serial.print("e-Paper busy \r\n ");
|
||||
UBYTE busy;
|
||||
do
|
||||
{
|
||||
busy = DigitalRead(busy_pin);
|
||||
}
|
||||
while(busy);
|
||||
DelayMs(200);
|
||||
Serial.print("e-Paper busy release \r\n ");
|
||||
Serial.print("e-Paper busy \r\n ");
|
||||
UBYTE busy;
|
||||
do {
|
||||
busy = DigitalRead(busy_pin);
|
||||
} while(busy);
|
||||
DelayMs(200);
|
||||
Serial.print("e-Paper busy release \r\n ");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -200,78 +212,131 @@ void Epd::WaitUntilIdle(void) {
|
|||
* see Epd::Sleep();
|
||||
*/
|
||||
void Epd::Reset(void) {
|
||||
DigitalWrite(reset_pin, LOW); //module reset
|
||||
DelayMs(1);
|
||||
DigitalWrite(reset_pin, HIGH);
|
||||
DelayMs(200);
|
||||
DelayMs(20);
|
||||
DigitalWrite(reset_pin, LOW); //module reset
|
||||
DelayMs(2);
|
||||
DigitalWrite(reset_pin, HIGH);
|
||||
DelayMs(20);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
function : Display
|
||||
******************************************************************************/
|
||||
void Epd::DisplayFrame(const UBYTE *Image) {
|
||||
UWORD i;
|
||||
UWORD IMAGE_COUNTER = width * height / 8;
|
||||
UWORD i;
|
||||
UWORD IMAGE_COUNTER = width * height / 8;
|
||||
|
||||
SendCommand(0x4E);
|
||||
SendData(0x00);
|
||||
SendData(0x00);
|
||||
SendCommand(0x4F);
|
||||
SendData(0x00);
|
||||
SendData(0x00);
|
||||
SendCommand(0x4E);
|
||||
SendData(0x00);
|
||||
SendData(0x00);
|
||||
SendCommand(0x4F);
|
||||
SendData(0x00);
|
||||
SendData(0x00);
|
||||
|
||||
SendCommand(0x24);
|
||||
for (i = 0; i < IMAGE_COUNTER; i++)
|
||||
{
|
||||
SendData(pgm_read_byte(&Image[i]));
|
||||
}
|
||||
SendCommand(0x24);
|
||||
for (i = 0; i < IMAGE_COUNTER; i++) {
|
||||
SendData(pgm_read_byte(&Image[i]));
|
||||
}
|
||||
SendCommand(0x26);
|
||||
for (i = 0; i < IMAGE_COUNTER; i++) {
|
||||
SendData(pgm_read_byte(&Image[i]));
|
||||
}
|
||||
|
||||
Load_LUT(1);
|
||||
SendCommand(0x20);
|
||||
WaitUntilIdle();
|
||||
Load_LUT(1);
|
||||
SendCommand(0x20);
|
||||
WaitUntilIdle();
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
function : Partial Display
|
||||
note:
|
||||
1. iwidth must be a multiple of 8
|
||||
2. The update will clear other parts of the image data
|
||||
******************************************************************************/
|
||||
void Epd::DisplayFrame_Partial(const UBYTE *Image, UWORD Xstart, UWORD Ystart, UWORD iwidth, UWORD iheight) {
|
||||
UWORD i, j;
|
||||
SendCommand(0x4E);
|
||||
SendData(0x00);
|
||||
SendData(0x00);
|
||||
SendCommand(0x4F);
|
||||
SendData(0x00);
|
||||
SendData(0x00);
|
||||
UWORD i, j;
|
||||
SendCommand(0x4E);
|
||||
SendData(0x00);
|
||||
SendData(0x00);
|
||||
SendCommand(0x4F);
|
||||
SendData(0x00);
|
||||
SendData(0x00);
|
||||
|
||||
SendCommand(0x24);
|
||||
for(i=0; i<EPD_WIDTH; i++) {
|
||||
for(j=0; j<EPD_HEIGHT/8; j++) {
|
||||
if(i>=Ystart && i<Ystart+iheight && j>=Xstart/8 && j<(Xstart+iwidth)/8)
|
||||
SendData(Image[(j-Xstart/8) + (i-Ystart)*iwidth/8]);
|
||||
else
|
||||
SendData(0xff);
|
||||
SendCommand(0x24);
|
||||
for(i=0; i<EPD_WIDTH; i++) {
|
||||
for(j=0; j<EPD_HEIGHT/8; j++) {
|
||||
if(i>=Ystart && i<Ystart+iheight && j>=Xstart/8 && j<(Xstart+iwidth)/8)
|
||||
SendData(Image[(j-Xstart/8) + (i-Ystart)*iwidth/8]);
|
||||
else
|
||||
SendData(0xff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Load_LUT(0);
|
||||
SendCommand(0x20);
|
||||
WaitUntilIdle();
|
||||
|
||||
Load_LUT(0);
|
||||
SendCommand(0x20);
|
||||
WaitUntilIdle();
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
function : Sends part the image buffer in RAM to e-Paper and displays
|
||||
notes:
|
||||
1. Xstart must be a multiple of 8
|
||||
1. isGC: use GC mode to clear base-image
|
||||
******************************************************************************/
|
||||
void Epd::DisplayFrame_Part(const UBYTE *Image, UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, bool isGC)
|
||||
{
|
||||
UWORD i, Width;
|
||||
Width = (Xend-Xstart)%8 == 0 ? (Xend-Xstart)/8 : (Xend-Xstart)/8+1;
|
||||
UWORD IMAGE_COUNTER = Width * (Yend-Ystart);
|
||||
|
||||
Xend -= 1;
|
||||
Yend -= 1;
|
||||
|
||||
SendCommand(0x44);
|
||||
SendData(Xstart & 0xff);
|
||||
SendData((Xstart>>8) & 0x03);
|
||||
SendData(Xend & 0xff);
|
||||
SendData((Xend>>8) & 0x03);
|
||||
SendCommand(0x45);
|
||||
SendData(Ystart & 0xff);
|
||||
SendData((Ystart>>8) & 0x03);
|
||||
SendData(Yend & 0xff);
|
||||
SendData((Yend>>8) & 0x03);
|
||||
|
||||
SendCommand(0x4E); // SET_RAM_X_ADDRESS_COUNTER
|
||||
SendData(Xstart & 0xFF);
|
||||
|
||||
SendCommand(0x4F); // SET_RAM_Y_ADDRESS_COUNTER
|
||||
SendData(Ystart & 0xFF);
|
||||
SendData((Ystart >> 8) & 0xFF);
|
||||
|
||||
SendCommand(0x24);
|
||||
for (i = 0; i < IMAGE_COUNTER; i++)
|
||||
{
|
||||
SendData(Image[i]);
|
||||
}
|
||||
if(isGC)
|
||||
Load_LUT(1);
|
||||
else
|
||||
Load_LUT(0);
|
||||
SendCommand(0x20);
|
||||
WaitUntilIdle();
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
function : set the look-up tables
|
||||
parameter:
|
||||
******************************************************************************/
|
||||
void Epd::Load_LUT(UBYTE mode) {
|
||||
UWORD i;
|
||||
SendCommand(0x32);
|
||||
for (i = 0; i < 105; i++) {
|
||||
if(mode == 1)
|
||||
SendData(lut_1Gray_GC[i]);
|
||||
else if(mode == 0)
|
||||
SendData(lut_1Gray_DU[i]);
|
||||
}
|
||||
UWORD i;
|
||||
SendCommand(0x32);
|
||||
for (i = 0; i < 105; i++) {
|
||||
if(mode == 1)
|
||||
SendData(lut_1Gray_GC[i]);
|
||||
else if(mode == 0)
|
||||
SendData(lut_1Gray_A2[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
@ -281,28 +346,27 @@ parameter:
|
|||
1:clear all
|
||||
******************************************************************************/
|
||||
void Epd::Clear(UBYTE mode) {
|
||||
UWORD i;
|
||||
UWORD IMAGE_COUNTER = width * height / 8;
|
||||
UWORD i;
|
||||
UWORD IMAGE_COUNTER = width * height / 8;
|
||||
|
||||
SendCommand(0x4E);
|
||||
SendData(0x00);
|
||||
SendData(0x00);
|
||||
SendCommand(0x4F);
|
||||
SendData(0x00);
|
||||
SendData(0x00);
|
||||
|
||||
SendCommand(0x24);
|
||||
for (i = 0; i < IMAGE_COUNTER; i++)
|
||||
{
|
||||
SendData(0xff);
|
||||
}
|
||||
if(mode)
|
||||
Load_LUT(1);
|
||||
else
|
||||
Load_LUT(0);
|
||||
SendCommand(0x20);
|
||||
WaitUntilIdle();
|
||||
SendCommand(0x4E);
|
||||
SendData(0x00);
|
||||
SendData(0x00);
|
||||
SendCommand(0x4F);
|
||||
SendData(0x00);
|
||||
SendData(0x00);
|
||||
|
||||
SendCommand(0x24);
|
||||
for (i = 0; i < IMAGE_COUNTER; i++)
|
||||
{
|
||||
SendData(0xff);
|
||||
}
|
||||
if(mode)
|
||||
Load_LUT(1);
|
||||
else
|
||||
Load_LUT(0);
|
||||
SendCommand(0x20);
|
||||
WaitUntilIdle();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -319,7 +383,4 @@ void Epd::Sleep(void) {
|
|||
SendCommand(0X07); //deep sleep
|
||||
SendData(0xA5);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* END OF FILE */
|
||||
|
|
|
@ -47,6 +47,7 @@ public:
|
|||
void DisplayFrame(const UBYTE *Image);
|
||||
void SendCommand(unsigned char command);
|
||||
void DisplayFrame_Partial(const UBYTE *Image, UWORD Xstart, UWORD Ystart, UWORD iwidth, UWORD iheight);
|
||||
void DisplayFrame_Part(const UBYTE *Image, UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, bool isGC);
|
||||
void SendData(unsigned char data);
|
||||
void Sleep(void);
|
||||
void Clear(UBYTE mode);
|
||||
|
|
|
@ -32,51 +32,55 @@
|
|||
#define COLORED 0
|
||||
#define UNCOLORED 1
|
||||
|
||||
UBYTE image[800];
|
||||
UBYTE image[700];
|
||||
Paint paint(image, 0, 0); // width should be the multiple of 8
|
||||
UDOUBLE time_start_ms;
|
||||
UDOUBLE time_now_s;
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(115200);
|
||||
Epd epd;
|
||||
if (epd.Init() != 0) {
|
||||
Serial.print("e-Paper init failed");
|
||||
return;
|
||||
}
|
||||
Serial.print("3.7inch e-paper demo\r\n ");
|
||||
Serial.print("e-Paper Clear\r\n ");
|
||||
epd.Clear(1);
|
||||
Serial.print("draw image\r\n ");
|
||||
epd.DisplayFrame(IMAGE_DATA);
|
||||
delay(4000);
|
||||
epd.Clear(0);
|
||||
|
||||
UBYTE i;
|
||||
time_start_ms = millis();
|
||||
for(i=0; i<10; i++) {
|
||||
time_now_s = (millis() - time_start_ms) / 1000;
|
||||
char time_string[] = {'0', '0', ':', '0', '0', '\0'};
|
||||
time_string[0] = time_now_s / 60 / 10 + '0';
|
||||
time_string[1] = time_now_s / 60 % 10 + '0';
|
||||
time_string[3] = time_now_s % 60 / 10 + '0';
|
||||
time_string[4] = time_now_s % 60 % 10 + '0';
|
||||
paint.SetWidth(48);
|
||||
paint.SetHeight(100);
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(115200);
|
||||
Epd epd;
|
||||
if (epd.Init() != 0) {
|
||||
Serial.print("e-Paper init failed");
|
||||
return;
|
||||
}
|
||||
Serial.print("3.7inch e-paper demo\r\n ");
|
||||
Serial.print("e-Paper Clear\r\n ");
|
||||
epd.Clear(1);
|
||||
Serial.print("draw image\r\n ");
|
||||
epd.DisplayFrame(IMAGE_DATA); // Set base image
|
||||
delay(3000);
|
||||
|
||||
paint.SetWidth(40);
|
||||
paint.SetHeight(120);
|
||||
paint.SetRotate(ROTATE_270);
|
||||
paint.Clear(UNCOLORED);
|
||||
paint.DrawStringAt(20, 10, time_string, &Font16, COLORED);
|
||||
Serial.print("refresh------\r\n ");
|
||||
epd.DisplayFrame_Partial(paint.GetImage(), 20, 100, 48, 100);
|
||||
}
|
||||
|
||||
Serial.print("clear and sleep......\r\n ");
|
||||
epd.Clear(1);
|
||||
epd.Sleep();
|
||||
|
||||
UBYTE i;
|
||||
time_start_ms = millis();
|
||||
for(i=0; i<10; i++) {
|
||||
time_now_s = (millis() - time_start_ms) / 1000;
|
||||
char time_string[] = {'0', '0', ':', '0', '0', '\0'};
|
||||
time_string[0] = time_now_s / 60 / 10 + '0';
|
||||
time_string[1] = time_now_s / 60 % 10 + '0';
|
||||
time_string[3] = time_now_s % 60 / 10 + '0';
|
||||
time_string[4] = time_now_s % 60 % 10 + '0';
|
||||
|
||||
paint.Clear(UNCOLORED);
|
||||
paint.DrawStringAt(20, 10, time_string, &Font16, COLORED);
|
||||
Serial.print("refresh------\r\n ");
|
||||
// epd.DisplayFrame_Partial(paint.GetImage(), 20, 100, 40, 120); // Width must be a multiple of 8
|
||||
epd.DisplayFrame_Part(paint.GetImage(), 40, 30, 80, 140, false); // Xstart must be a multiple of 8
|
||||
}
|
||||
|
||||
Serial.print("clear and sleep......\r\n ");
|
||||
epd.Init();
|
||||
epd.Clear(1);
|
||||
epd.Sleep();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
// put your main code here, to run repeatedly:
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue