Add 4.37inch e-Paper (G) Arduino Program and some fix.
This commit is contained in:
parent
7431785a9c
commit
31c2e4176e
18 changed files with 1518 additions and 534 deletions
|
|
@ -64,13 +64,11 @@ int Epd::Init() {
|
|||
SendData(0x4F);
|
||||
SendData(0x6B);
|
||||
|
||||
|
||||
SendCommand(0x06);
|
||||
SendData(0xD7);
|
||||
SendData(0xDE);
|
||||
SendData(0x12);
|
||||
|
||||
|
||||
SendCommand(0x61);
|
||||
SendData(0x00);
|
||||
SendData(0xA8);
|
||||
|
|
@ -165,9 +163,6 @@ void Epd::Clear(UBYTE color)
|
|||
UWORD Width, Height;
|
||||
Width = (WIDTH % 4 == 0)? (WIDTH / 4 ): (WIDTH / 4 + 1);
|
||||
Height = HEIGHT;
|
||||
|
||||
SendCommand(0x68);
|
||||
SendData(0x01);
|
||||
|
||||
SendCommand(0x04);
|
||||
ReadBusyH();
|
||||
|
|
@ -175,15 +170,10 @@ void Epd::Clear(UBYTE color)
|
|||
SendCommand(0x10);
|
||||
for (UWORD j = 0; j < Height; j++) {
|
||||
for (UWORD i = 0; i < Width; i++) {
|
||||
for(UBYTE k = 0; k < 4; k++) {
|
||||
SendData(color);
|
||||
}
|
||||
SendData((color<<6) | (color<<4) | (color<<2) | color);
|
||||
}
|
||||
}
|
||||
|
||||
SendCommand(0x68);
|
||||
SendData(0x00);
|
||||
|
||||
TurnOnDisplay();
|
||||
}
|
||||
|
||||
|
|
@ -196,9 +186,6 @@ void Epd::Display(UBYTE *Image)
|
|||
UWORD Width, Height;
|
||||
Width = (WIDTH % 4 == 0)? (WIDTH / 4 ): (WIDTH / 4 + 1);
|
||||
Height = HEIGHT;
|
||||
|
||||
SendCommand(0x68);
|
||||
SendData(0x01);
|
||||
|
||||
SendCommand(0x04);
|
||||
ReadBusyH();
|
||||
|
|
@ -212,33 +199,27 @@ void Epd::Display(UBYTE *Image)
|
|||
TurnOnDisplay();
|
||||
}
|
||||
|
||||
void Epd::Display_part(UBYTE *Image, UWORD xstart, UWORD ystart, UWORD image_width, UWORD image_heigh)
|
||||
void Epd::Display_part(UBYTE *Image, UWORD xstart, UWORD ystart, UWORD image_width, UWORD image_height)
|
||||
{
|
||||
UWORD Width, Height;
|
||||
UWORD Width, Height, i, j;
|
||||
Width = (WIDTH % 4 == 0)? (WIDTH / 4 ): (WIDTH / 4 + 1);
|
||||
Height = HEIGHT;
|
||||
|
||||
SendCommand(0x68);
|
||||
SendData(0x01);
|
||||
|
||||
SendCommand(0x04);
|
||||
ReadBusyH();
|
||||
|
||||
SendCommand(0x10);
|
||||
for (UWORD j = 0; j < Height; j++) {
|
||||
for (UWORD i = 0; i < Width; i++) {
|
||||
if((j >= xstart/4) && (j < (image_width + xstart)/4) && (i >= ystart) && (i <= (ystart + image_heigh)) )
|
||||
{
|
||||
SendData(pgm_read_byte(&Image[(i-ystart) * image_width/4 + j - xstart/4]));
|
||||
// Serial.print(Image[(i-ystart) * image_width/8 + j - xstart], HEX);
|
||||
// Serial.print(" ");
|
||||
for(i=0; i<Height; i++) {
|
||||
for(j=0; j< Width; j++) {
|
||||
if(i<image_height+ystart && i>=ystart && j<(image_width+xstart)/4 && j>=xstart/4) {
|
||||
SendData(pgm_read_byte(&Image[(j-xstart/4) + (image_width/4*(i-ystart))]));
|
||||
}
|
||||
else
|
||||
{
|
||||
SendData(0x55);
|
||||
}
|
||||
}
|
||||
else {
|
||||
SendData(0x55);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TurnOnDisplay();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,11 +33,11 @@
|
|||
#define EPD_WIDTH 168
|
||||
#define EPD_HEIGHT 400
|
||||
|
||||
//colour
|
||||
#define black 0x00
|
||||
#define white 0x55
|
||||
#define yellow 0xAA
|
||||
#define red 0xFF
|
||||
// Color
|
||||
#define black 0x0
|
||||
#define white 0x1
|
||||
#define yellow 0x2
|
||||
#define red 0x3
|
||||
|
||||
#define UWORD unsigned int
|
||||
#define UBYTE unsigned char
|
||||
|
|
@ -59,9 +59,9 @@ public:
|
|||
void TurnOnDisplay(void);
|
||||
void Clear(UBYTE color);
|
||||
void Display(UBYTE *Image);
|
||||
void Display_part(UBYTE *Image, UWORD xstart, UWORD ystart, UWORD image_width, UWORD image_height);
|
||||
void Sleep(void);
|
||||
|
||||
|
||||
private:
|
||||
unsigned int reset_pin;
|
||||
unsigned int dc_pin;
|
||||
|
|
|
|||
|
|
@ -39,14 +39,20 @@ void setup() {
|
|||
return;
|
||||
}
|
||||
|
||||
Serial.print("While \r\n");
|
||||
epd.Clear(white); // While
|
||||
Serial.print("White \r\n");
|
||||
epd.Clear(white);
|
||||
delay(2000);
|
||||
|
||||
epd.Init();
|
||||
Serial.print("Image \r\n");
|
||||
epd.Display(IMAGE_DATA);
|
||||
delay(2000);
|
||||
|
||||
epd.Init();
|
||||
Serial.print("Small Image \r\n");
|
||||
epd.Display_part(IMAGE_DATA, 0 ,0, 168, 400);
|
||||
delay(2000);
|
||||
|
||||
epd.Init();
|
||||
Serial.print("Clear...\r\n");
|
||||
epd.Clear(white);
|
||||
|
|
@ -54,7 +60,6 @@ void setup() {
|
|||
|
||||
Serial.print("Goto Sleep...\r\n");
|
||||
epd.Sleep();
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue