Updates STM32 and Arduino refresh rates (1.54v2, 2.9v2, 7.5)

This commit is contained in:
SSYYL 2021-07-19 15:03:19 +08:00
commit 588163b176
22 changed files with 1634 additions and 7190 deletions

View file

@ -30,6 +30,79 @@
#include <stdlib.h>
#include "epd1in54_V2.h"
// waveform full refresh
unsigned char WF_Full_1IN54[159] =
{
0x80, 0x48, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x40, 0x48, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x80, 0x48, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x40, 0x48, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0xA, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x8, 0x1, 0x0, 0x8, 0x1, 0x0, 0x2,
0xA, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x0, 0x0, 0x0,
0x22, 0x17, 0x41, 0x0, 0x32, 0x20
};
// waveform partial refresh(fast)
unsigned char WF_PARTIAL_1IN54_0[159] =
{
0x0,0x40,0x0,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,0x0,0x0,0x0,
// 0x0,0x0,0x0,0x0,0x0,0x0,0x0,
// 0x0,0x0,0x0,0x0,0x0,0x0,0x0,
// 0x0,0x0,0x0,0x0,0x0,0x0,0x0,
// 0x0,0x0,0x0,0x0,0x0,0x0,0x0,
// 0x0,0x0,0x0,0x0,0x0,0x0,0x0,
// 0x0,0x0,0x0,0x0,0x0,0x0,0x0,
// 0x0,0x0,0x0,0x0,0x0,0x0,0x0,
// 0x0,0x0,0x0,0x0,0x0,0x0,0x0,
// 0x0,0x0,0x0,0x0,0x0,0x0,0x0,
// 0x22,0x22,0x22,0x22,0x22,0x22,0x0,0x0,0x0,
// 0x22,0x17,0x41,0x0,0x32,0x20,
// };
Epd::~Epd()
{
};
@ -73,6 +146,33 @@ void Epd::WaitUntilIdle(void)
DelayMs(200);
}
void Epd::Lut(unsigned char* lut)
{
SendCommand(0x32);
for(unsigned char i=0; i<153; i++)
SendData(lut[i]);
WaitUntilIdle();
}
void Epd::SetLut(unsigned char* lut)
{
Lut(lut);
SendCommand(0x3f);
SendData(lut[153]);
SendCommand(0x03);
SendData(lut[154]);
SendCommand(0x04);
SendData(lut[155]);
SendData(lut[156]);
SendData(lut[157]);
SendCommand(0x2c);
SendData(lut[158]);
}
// High Direction
int Epd::HDirInit(void)
{
@ -121,6 +221,8 @@ int Epd::HDirInit(void)
SendData(0xC7);
SendData(0x00);
WaitUntilIdle();
SetLut(WF_Full_1IN54);
/* EPD hardware init end */
return 0;
@ -151,12 +253,12 @@ int Epd::LDirInit(void)
SendCommand(0x44);
/* x point must be the multiple of 8 or the last 3 bits will be ignored */
SendData((0 >> 3) & 0xFF);
SendData((200 >> 3) & 0xFF);
SendData((199 >> 3) & 0xFF);
SendCommand(0x45);
SendData(0 & 0xFF);
SendData((0 >> 8) & 0xFF);
SendData(200 & 0xFF);
SendData((200 >> 8) & 0xFF);
SendData(199 & 0xFF);
SendData((199 >> 8) & 0xFF);
SendCommand(0x3C); //BorderWavefrom
SendData(0x01);
@ -174,6 +276,8 @@ int Epd::LDirInit(void)
SendData(0xC7);
SendData(0x00);
WaitUntilIdle();
SetLut(WF_Full_1IN54);
/* EPD hardware init end */
return 0;
@ -188,11 +292,11 @@ int Epd::LDirInit(void)
void Epd::Reset(void)
{
DigitalWrite(reset_pin, HIGH);
DelayMs(200);
DelayMs(20);
DigitalWrite(reset_pin, LOW); //module reset
DelayMs(10);
DelayMs(5);
DigitalWrite(reset_pin, HIGH);
DelayMs(200);
DelayMs(20);
}
void Epd::Clear(void)
@ -207,6 +311,12 @@ void Epd::Clear(void)
SendData(0xff);
}
}
SendCommand(0x26);
for (int j = 0; j < h; j++) {
for (int i = 0; i < w; i++) {
SendData(0xff);
}
}
//DISPLAY REFRESH
DisplayFrame();
}
@ -339,7 +449,7 @@ void Epd::DisplayFrame(void)
{
//DISPLAY REFRESH
SendCommand(0x22);
SendData(0xF7);
SendData(0xc7);
SendCommand(0x20);
WaitUntilIdle();
}
@ -347,7 +457,7 @@ void Epd::DisplayFrame(void)
void Epd::DisplayPartFrame(void)
{
SendCommand(0x22);
SendData(0xFF);
SendData(0xcF);
SendCommand(0x20);
WaitUntilIdle();
}
@ -365,9 +475,9 @@ void Epd::SetFrameMemory(
int y_end;
DigitalWrite(reset_pin, LOW); //module reset
DelayMs(10);
DelayMs(2);
DigitalWrite(reset_pin, HIGH);
DelayMs(10);
DelayMs(2);
SendCommand(0x3c);
SendData(0x80);
@ -402,6 +512,74 @@ void Epd::SetFrameMemory(
}
}
void Epd::SetFrameMemoryPartial(
const unsigned char* image_buffer,
int x,
int y,
int image_width,
int image_height
)
{
int x_end;
int y_end;
DigitalWrite(reset_pin, LOW); //module reset
DelayMs(2);
DigitalWrite(reset_pin, HIGH);
DelayMs(2);
SetLut(WF_PARTIAL_1IN54_0);
SendCommand(0x37);
SendData(0x00);
SendData(0x00);
SendData(0x00);
SendData(0x00);
SendData(0x00);
SendData(0x40);
SendData(0x00);
SendData(0x00);
SendData(0x00);
SendData(0x00);
SendCommand(0x3c);
SendData(0x80);
SendCommand(0x22);
SendData(0xc0);
SendCommand(0x20);
WaitUntilIdle();
if (
image_buffer == NULL ||
x < 0 || image_width < 0 ||
y < 0 || image_height < 0
) {
return;
}
/* x point must be the multiple of 8 or the last 3 bits will be ignored */
x &= 0xF8;
image_width &= 0xF8;
if (x + image_width >= this->width) {
x_end = this->width - 1;
} else {
x_end = x + image_width - 1;
}
if (y + image_height >= this->height) {
y_end = this->height - 1;
} else {
y_end = y + image_height - 1;
}
SetMemoryArea(x, y, x_end, y_end);
SetMemoryPointer(x, y);
SendCommand(0x24);
/* send the image data */
for (int j = 0; j < y_end - y + 1; j++) {
for (int i = 0; i < (x_end - x + 1) / 8; i++) {
SendData(image_buffer[i + j * (image_width / 8)]);
}
}
}
/**
* @brief: After this command is transmitted, the chip would enter the
* deep-sleep mode to save power.