add 2.13 part for arduino

This commit is contained in:
hnwangkg-ezio 2019-12-27 17:32:28 +08:00
commit e25d0bc44a
3 changed files with 47 additions and 22 deletions

View file

@ -103,10 +103,11 @@ void Epd::SendData(unsigned char data)
*/
void Epd::WaitUntilIdle(void)
{
while(DigitalRead(busy_pin) == 1) { //LOW: idle, HIGH: busy
while(1) { //LOW: idle, HIGH: busy
if(DigitalRead(busy_pin) == 0)
break;
DelayMs(100);
}
DelayMs(200);
}
int Epd::Init(char Mode)
@ -276,14 +277,14 @@ void Epd::DisplayPartBaseImage(const unsigned char* frame_buffer)
SendCommand(0x24);
for (int j = 0; j < h; j++) {
for (int i = 0; i < w; i++) {
SendData(frame_buffer[i + j * w]);
SendData(pgm_read_byte(&frame_buffer[i + j * w]));
}
}
SendCommand(0x26);
for (int j = 0; j < h; j++) {
for (int i = 0; i < w; i++) {
SendData(frame_buffer[i + j * w]);
SendData(pgm_read_byte(&frame_buffer[i + j * w]));
}
}
}
@ -304,7 +305,7 @@ void Epd::DisplayPart(const unsigned char* frame_buffer)
SendCommand(0x24);
for (int j = 0; j < h; j++) {
for (int i = 0; i < w; i++) {
SendData(frame_buffer[i + j * w]);
SendData(pgm_read_byte(&frame_buffer[i + j * w]));
}
}
}
@ -316,6 +317,25 @@ void Epd::DisplayPart(const unsigned char* frame_buffer)
WaitUntilIdle();
}
void Epd::ClearPart(void)
{
int w, h;
w = (EPD_WIDTH % 8 == 0)? (EPD_WIDTH / 8 ): (EPD_WIDTH / 8 + 1);
h = EPD_HEIGHT;
SendCommand(0x24);
for (int j = 0; j < h; j++) {
for (int i = 0; i < w; i++) {
SendData(0xff);
}
}
//DISPLAY REFRESH
SendCommand(0x22);
SendData(0x0C);
SendCommand(0x20);
WaitUntilIdle();
}
/**
* @brief: After this command is transmitted, the chip would enter the
* deep-sleep mode to save power.

View file

@ -56,6 +56,7 @@ public:
void Display(const unsigned char* frame_buffer);
void DisplayPartBaseImage(const unsigned char* frame_buffer);
void DisplayPart(const unsigned char* frame_buffer);
void ClearPart(void);
void Sleep(void);
private:

View file

@ -6,22 +6,27 @@ Epd epd;
void setup()
{
// put your setup code here, to run once:
Serial.begin(9600);
if (epd.Init(FULL) != 0) {
Serial.println("e-Paper init failed");
return;
}
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println("epd FULL");
epd.Init(FULL);
epd.Display(IMAGE_DATA);
Serial.println("e-Paper clear");
epd.Clear();
Serial.println("e-Paper show pic");
epd.Display(IMAGE_DATA);
Serial.println("e-Paper clear and sleep");
epd.Clear();
epd.Sleep();
Serial.println("epd PART");
epd.DisplayPartBaseImage(IMAGE_DATA);
char i = 0;
for (i = 0; i < 10; i++) {
Serial.println("e-Paper PART IMAGE_DATA");
epd.Init(PART);
epd.DisplayPart(IMAGE_DATA);
Serial.println("e-Paper PART Clear");
epd.ClearPart();
}
epd.Init(FULL);
Serial.println("e-Paper clear and sleep");
epd.Clear();
epd.Sleep();
}
@ -29,4 +34,3 @@ void loop()
{
}