add 2.13 part for arduino
This commit is contained in:
parent
2b91f64a19
commit
e25d0bc44a
3 changed files with 47 additions and 22 deletions
|
|
@ -103,10 +103,11 @@ void Epd::SendData(unsigned char data)
|
||||||
*/
|
*/
|
||||||
void Epd::WaitUntilIdle(void)
|
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(100);
|
||||||
}
|
}
|
||||||
DelayMs(200);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Epd::Init(char Mode)
|
int Epd::Init(char Mode)
|
||||||
|
|
@ -276,14 +277,14 @@ void Epd::DisplayPartBaseImage(const unsigned char* frame_buffer)
|
||||||
SendCommand(0x24);
|
SendCommand(0x24);
|
||||||
for (int j = 0; j < h; j++) {
|
for (int j = 0; j < h; j++) {
|
||||||
for (int i = 0; i < w; i++) {
|
for (int i = 0; i < w; i++) {
|
||||||
SendData(frame_buffer[i + j * w]);
|
SendData(pgm_read_byte(&frame_buffer[i + j * w]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SendCommand(0x26);
|
SendCommand(0x26);
|
||||||
for (int j = 0; j < h; j++) {
|
for (int j = 0; j < h; j++) {
|
||||||
for (int i = 0; i < w; i++) {
|
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);
|
SendCommand(0x24);
|
||||||
for (int j = 0; j < h; j++) {
|
for (int j = 0; j < h; j++) {
|
||||||
for (int i = 0; i < w; i++) {
|
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();
|
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
|
* @brief: After this command is transmitted, the chip would enter the
|
||||||
* deep-sleep mode to save power.
|
* deep-sleep mode to save power.
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ public:
|
||||||
void Display(const unsigned char* frame_buffer);
|
void Display(const unsigned char* frame_buffer);
|
||||||
void DisplayPartBaseImage(const unsigned char* frame_buffer);
|
void DisplayPartBaseImage(const unsigned char* frame_buffer);
|
||||||
void DisplayPart(const unsigned char* frame_buffer);
|
void DisplayPart(const unsigned char* frame_buffer);
|
||||||
|
void ClearPart(void);
|
||||||
|
|
||||||
void Sleep(void);
|
void Sleep(void);
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -8,17 +8,22 @@ void setup()
|
||||||
{
|
{
|
||||||
// put your setup code here, to run once:
|
// put your setup code here, to run once:
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
if (epd.Init(FULL) != 0) {
|
Serial.println("epd FULL");
|
||||||
Serial.println("e-Paper init failed");
|
epd.Init(FULL);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Serial.println("e-Paper clear");
|
|
||||||
epd.Clear();
|
|
||||||
|
|
||||||
Serial.println("e-Paper show pic");
|
|
||||||
epd.Display(IMAGE_DATA);
|
epd.Display(IMAGE_DATA);
|
||||||
|
|
||||||
|
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");
|
Serial.println("e-Paper clear and sleep");
|
||||||
epd.Clear();
|
epd.Clear();
|
||||||
epd.Sleep();
|
epd.Sleep();
|
||||||
|
|
@ -29,4 +34,3 @@ void loop()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue