Merge pull request #221 from SSYYL/master
3.7inch arduino example added a partial refresh example
This commit is contained in:
commit
c7d03f0ad3
5 changed files with 26 additions and 12 deletions
|
|
@ -286,7 +286,7 @@ void Epd::TurnOnDisplay(void)
|
||||||
function : Initialize the e-Paper register
|
function : Initialize the e-Paper register
|
||||||
parameter:
|
parameter:
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
void Epd::Init()
|
int Epd::Init()
|
||||||
{
|
{
|
||||||
/* this calls the peripheral hardware interface, see epdif */
|
/* this calls the peripheral hardware interface, see epdif */
|
||||||
if (IfInit() != 0) {
|
if (IfInit() != 0) {
|
||||||
|
|
@ -323,6 +323,8 @@ void Epd::Init()
|
||||||
|
|
||||||
SendCommand(0x82); //vcom_DC setting
|
SendCommand(0x82); //vcom_DC setting
|
||||||
SendData(0x28);
|
SendData(0x28);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Epd::Clear(void)
|
void Epd::Clear(void)
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ public:
|
||||||
|
|
||||||
Epd();
|
Epd();
|
||||||
~Epd();
|
~Epd();
|
||||||
void Init(void);
|
int Init(void);
|
||||||
void SendCommand(unsigned char command);
|
void SendCommand(unsigned char command);
|
||||||
void SendData(unsigned char data);
|
void SendData(unsigned char data);
|
||||||
void ReadBusy(void);
|
void ReadBusy(void);
|
||||||
|
|
|
||||||
|
|
@ -223,7 +223,7 @@ void Epd::Reset(void) {
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
function : Display
|
function : Display
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
void Epd::DisplayFrame(const UBYTE *Image) {
|
void Epd::DisplayFrame(const UBYTE *Image, bool isBase) {
|
||||||
UWORD i;
|
UWORD i;
|
||||||
UWORD IMAGE_COUNTER = width * height / 8;
|
UWORD IMAGE_COUNTER = width * height / 8;
|
||||||
|
|
||||||
|
|
@ -238,9 +238,11 @@ void Epd::DisplayFrame(const UBYTE *Image) {
|
||||||
for (i = 0; i < IMAGE_COUNTER; i++) {
|
for (i = 0; i < IMAGE_COUNTER; i++) {
|
||||||
SendData(pgm_read_byte(&Image[i]));
|
SendData(pgm_read_byte(&Image[i]));
|
||||||
}
|
}
|
||||||
SendCommand(0x26);
|
if(isBase) {
|
||||||
for (i = 0; i < IMAGE_COUNTER; i++) {
|
SendCommand(0x26);
|
||||||
SendData(pgm_read_byte(&Image[i]));
|
for (i = 0; i < IMAGE_COUNTER; i++) {
|
||||||
|
SendData(pgm_read_byte(&Image[i]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Load_LUT(1);
|
Load_LUT(1);
|
||||||
|
|
@ -320,7 +322,10 @@ void Epd::DisplayFrame_Part(const UBYTE *Image, UWORD Xstart, UWORD Ystart, UWOR
|
||||||
Load_LUT(1);
|
Load_LUT(1);
|
||||||
else
|
else
|
||||||
Load_LUT(0);
|
Load_LUT(0);
|
||||||
SendCommand(0x20);
|
}
|
||||||
|
|
||||||
|
void Epd::TurnOnDisplay(void) {
|
||||||
|
SendCommand(0x20);
|
||||||
WaitUntilIdle();
|
WaitUntilIdle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,10 +44,11 @@ public:
|
||||||
int Init(void);
|
int Init(void);
|
||||||
void WaitUntilIdle(void);
|
void WaitUntilIdle(void);
|
||||||
void Reset(void);
|
void Reset(void);
|
||||||
void DisplayFrame(const UBYTE *Image);
|
void DisplayFrame(const UBYTE *Image, bool isBase);
|
||||||
void SendCommand(unsigned char command);
|
void SendCommand(unsigned char command);
|
||||||
void DisplayFrame_Partial(const UBYTE *Image, UWORD Xstart, UWORD Ystart, UWORD iwidth, UWORD iheight);
|
void DisplayFrame_Partial(const UBYTE *Image, UWORD Xstart, UWORD Ystart, UWORD iwidth, UWORD iheight);
|
||||||
void DisplayFrame_Part(const UBYTE *Image, UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, bool isGC);
|
void DisplayFrame_Part(const UBYTE *Image, UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, bool isGC);
|
||||||
|
void TurnOnDisplay(void);
|
||||||
void SendData(unsigned char data);
|
void SendData(unsigned char data);
|
||||||
void Sleep(void);
|
void Sleep(void);
|
||||||
void Clear(UBYTE mode);
|
void Clear(UBYTE mode);
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ void setup() {
|
||||||
Serial.print("e-Paper Clear\r\n ");
|
Serial.print("e-Paper Clear\r\n ");
|
||||||
epd.Clear(1);
|
epd.Clear(1);
|
||||||
Serial.print("draw image\r\n ");
|
Serial.print("draw image\r\n ");
|
||||||
epd.DisplayFrame(IMAGE_DATA); // Set base image
|
epd.DisplayFrame(IMAGE_DATA, true); // Set base image
|
||||||
delay(3000);
|
delay(3000);
|
||||||
|
|
||||||
paint.SetWidth(40);
|
paint.SetWidth(40);
|
||||||
|
|
@ -59,7 +59,7 @@ void setup() {
|
||||||
|
|
||||||
UBYTE i;
|
UBYTE i;
|
||||||
time_start_ms = millis();
|
time_start_ms = millis();
|
||||||
for(i=0; i<10; i++) {
|
for(i=0; i<5; i++) {
|
||||||
time_now_s = (millis() - time_start_ms) / 1000;
|
time_now_s = (millis() - time_start_ms) / 1000;
|
||||||
char time_string[] = {'0', '0', ':', '0', '0', '\0'};
|
char time_string[] = {'0', '0', ':', '0', '0', '\0'};
|
||||||
time_string[0] = time_now_s / 60 / 10 + '0';
|
time_string[0] = time_now_s / 60 / 10 + '0';
|
||||||
|
|
@ -71,7 +71,13 @@ void setup() {
|
||||||
paint.DrawStringAt(20, 10, time_string, &Font16, COLORED);
|
paint.DrawStringAt(20, 10, time_string, &Font16, COLORED);
|
||||||
Serial.print("refresh------\r\n ");
|
Serial.print("refresh------\r\n ");
|
||||||
// epd.DisplayFrame_Partial(paint.GetImage(), 20, 100, 40, 120); // Width must be a multiple of 8
|
// epd.DisplayFrame_Partial(paint.GetImage(), 20, 100, 40, 120); // Width must be a multiple of 8
|
||||||
epd.DisplayFrame_Part(paint.GetImage(), 40, 30, 80, 140, false); // Xstart must be a multiple of 8
|
/* Writes new data to RAM */
|
||||||
|
epd.DisplayFrame_Part(paint.GetImage(), 40+i*40, 30, 80+i*40, 140, false); // Xstart must be a multiple of 8
|
||||||
|
/* Displays and toggles the RAM currently in use */
|
||||||
|
epd.TurnOnDisplay();
|
||||||
|
/* Writes the last data to another RAM */
|
||||||
|
epd.DisplayFrame_Part(paint.GetImage(), 40+i*40, 30, 80+i*40, 140, false); // Xstart must be a multiple of 8
|
||||||
|
delay(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.print("clear and sleep......\r\n ");
|
Serial.print("clear and sleep......\r\n ");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue