Added a 2.13V3 Arduino GUI library usage routine

This commit is contained in:
SSYYL 2023-02-16 15:35:08 +08:00
commit cb2805f9b7
8 changed files with 113 additions and 38 deletions

View file

@ -90,6 +90,8 @@ Epd::Epd()
busy_pin = BUSY_PIN;
width = EPD_WIDTH;
height = EPD_HEIGHT;
bufwidth = 128/8; //16
bufheight = 63;
};
/******************************************************************************
@ -281,6 +283,7 @@ void Epd::Reset(void)
DelayMs(2);
DigitalWrite(reset_pin, HIGH);
DelayMs(20);
this->count = 0;
}
/******************************************************************************
@ -332,6 +335,27 @@ void Epd::Display(const unsigned char* frame_buffer)
WaitUntilIdle();
}
void Epd::Display1(const unsigned char* frame_buffer) {
if(this->count == 0){
SendCommand(0x24);
this->count++;
}else if(this->count > 0 && this->count < 4 ){
this->count++;
}
for(int i = 0; i < this->bufwidth * this->bufheight; i++){
SendData(frame_buffer[i]);
}
if(this->count == 4){
SendCommand(0x22);
SendData(0xC7);
SendCommand(0x20);
WaitUntilIdle();
this->count = 0;
}
}
/******************************************************************************
function : Refresh a base image
parameter:

View file

@ -44,6 +44,9 @@ class Epd : EpdIf {
public:
unsigned long width;
unsigned long height;
int bufwidth;
int bufheight;
int count;
Epd();
~Epd();
@ -57,6 +60,7 @@ public:
void Reset(void);
void Clear(void);
void Display(const unsigned char* frame_buffer);
void Display1(const unsigned char* frame_buffer);
void DisplayPartBaseImage(const unsigned char* frame_buffer);
void DisplayPart(const unsigned char* frame_buffer);
void ClearPart(void);

View file

@ -1,7 +1,19 @@
#include <SPI.h>
#include "epd2in13_V3.h"
#include "epdpaint.h"
#include "imagedata.h"
#define COLORED 0
#define UNCOLORED 1
/**
* Due to RAM not enough in Arduino UNO, a frame buffer is not allowed.
* In this case, a smaller image buffer is allocated and you have to
* update a partial display several times.
* 1 byte = 8 pixels, therefore you have to set 8*N pixels at a time.
*/
unsigned char image[1050];
Paint paint(image, 0, 0);
Epd epd;
void setup()
@ -12,17 +24,46 @@ void setup()
epd.Init(FULL);
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.Init(PART);
epd.ClearPart();
}
delay(2000);
Paint paint(image, epd.bufwidth*8, epd.bufheight); //width should be the multiple of 8
paint.Clear(UNCOLORED);
paint.DrawStringAt(8, 2, "e-Paper Demo", &Font12, COLORED);
paint.DrawStringAt(8, 20, "Hello world", &Font12, COLORED);
epd.Display1(image);//1
paint.Clear(UNCOLORED);
paint.DrawRectangle(2,2,50,50,COLORED);
paint.DrawLine(2,2,50,50,COLORED);
paint.DrawLine(2,50,50,2,COLORED);
paint.DrawFilledRectangle(52,2,100,50,COLORED);
paint.DrawLine(52,2,100,50,UNCOLORED);
paint.DrawLine(100,2,52,50,UNCOLORED);
epd.Display1(image);//2
paint.Clear(UNCOLORED);
paint.DrawCircle(25,25,20,COLORED);
paint.DrawFilledCircle(75,25,20,COLORED);
epd.Display1(image);//3
paint.Clear(UNCOLORED);
epd.Display1(image);//4
delay(2000);
// 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.Init(PART);
// epd.ClearPart();
// delay(2000);
// }
epd.Init(FULL);
Serial.println("e-Paper clear and sleep");