Merge pull request #148 from SSYYL/master

Update and fix
This commit is contained in:
SSYYL 2021-03-18 17:59:40 +08:00 committed by GitHub
commit d3f25503ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
73 changed files with 955 additions and 640 deletions

View file

@ -254,7 +254,8 @@ void Epd::SetMemoryPointer(int x, int y) {
*/
void Epd::Sleep() {
SendCommand(DEEP_SLEEP_MODE);
WaitUntilIdle();
SendData(0x01);
// WaitUntilIdle();
}
const unsigned char lut_full_update[] = {

View file

@ -374,7 +374,7 @@ void Epd::SetMemoryPointer(int x, int y) {
void Epd::Sleep() {
SendCommand(0x10);
SendData(0x01);
WaitUntilIdle();
// WaitUntilIdle();
}
/* END OF FILE */

View file

@ -31,57 +31,6 @@
#include <stdlib.h>
#include "epd2in9d.h"
/**
* full screen update LUT
**/
const unsigned char EPD_2IN9D_lut_vcomDC[] = {
0x00, 0x08, 0x00, 0x00, 0x00, 0x02,
0x60, 0x28, 0x28, 0x00, 0x00, 0x01,
0x00, 0x14, 0x00, 0x00, 0x00, 0x01,
0x00, 0x12, 0x12, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00,
};
const unsigned char EPD_2IN9D_lut_ww[] = {
0x40, 0x08, 0x00, 0x00, 0x00, 0x02,
0x90, 0x28, 0x28, 0x00, 0x00, 0x01,
0x40, 0x14, 0x00, 0x00, 0x00, 0x01,
0xA0, 0x12, 0x12, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const unsigned char EPD_2IN9D_lut_bw[] = {
0x40, 0x17, 0x00, 0x00, 0x00, 0x02,
0x90, 0x0F, 0x0F, 0x00, 0x00, 0x03,
0x40, 0x0A, 0x01, 0x00, 0x00, 0x01,
0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const unsigned char EPD_2IN9D_lut_wb[] = {
0x80, 0x08, 0x00, 0x00, 0x00, 0x02,
0x90, 0x28, 0x28, 0x00, 0x00, 0x01,
0x80, 0x14, 0x00, 0x00, 0x00, 0x01,
0x50, 0x12, 0x12, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const unsigned char EPD_2IN9D_lut_bb[] = {
0x80, 0x08, 0x00, 0x00, 0x00, 0x02,
0x90, 0x28, 0x28, 0x00, 0x00, 0x01,
0x80, 0x14, 0x00, 0x00, 0x00, 0x01,
0x50, 0x12, 0x12, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
/**
* partial screen update LUT
**/
@ -175,44 +124,7 @@ void Epd::WaitUntilIdle(void)
busy = DigitalRead(busy_pin);
busy =!(busy & 0x01);
} while(busy);
DelayMs(200);
}
/******************************************************************************
function : LUT download
parameter:
******************************************************************************/
void Epd::SetFullReg(void)
{
SendCommand(0X50); //VCOM AND DATA INTERVAL SETTING
SendData(0xb7); //WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7
unsigned int count;
SendCommand(0x20);
for(count=0; count<44; count++) {
SendData(EPD_2IN9D_lut_vcomDC[count]);
}
SendCommand(0x21);
for(count=0; count<42; count++) {
SendData(EPD_2IN9D_lut_ww[count]);
}
SendCommand(0x22);
for(count=0; count<42; count++) {
SendData(EPD_2IN9D_lut_bw[count]);
}
SendCommand(0x23);
for(count=0; count<42; count++) {
SendData(EPD_2IN9D_lut_wb[count]);
}
SendCommand(0x24);
for(count=0; count<42; count++) {
SendData(EPD_2IN9D_lut_bb[count]);
}
DelayMs(20);
}
/******************************************************************************
@ -221,10 +133,38 @@ parameter:
******************************************************************************/
void Epd::SetPartReg(void)
{
SendCommand(0x82); //vcom_DC setting
SendCommand(0x01); //POWER SETTING
SendData(0x03);
SendData(0x00);
SendData(0x2b);
SendData(0x2b);
SendData(0x03);
SendCommand(0x06); //boost soft start
SendData(0x17); //A
SendData(0x17); //B
SendData(0x17); //C
SendCommand(0x04);
WaitUntilIdle();
SendCommand(0x00); //panel setting
SendData(0xbf); //LUT from OTP128x296
SendCommand(0x30); //PLL setting
SendData(0x3a); // 3a 100HZ 29 150Hz 39 200HZ 31 171HZ
SendCommand(0x61); //resolution setting
SendData(EPD_WIDTH);
SendData((EPD_WIDTH >> 8) & 0xff);
SendData(EPD_HEIGHT & 0xff);
SendCommand(0x82); //vcom_DC setting
SendData(0x12);
SendCommand(0X50);
SendData(0xb7);
SendData(0x97);
unsigned int count;
SendCommand(0x20);
@ -270,35 +210,19 @@ int Epd::Init(void)
Reset();
SendCommand(0x01); //POWER SETTING
SendData(0x03);
SendData(0x00);
SendData(0x2b);
SendData(0x2b);
SendData(0x03);
SendCommand(0x04);
WaitUntilIdle();//waiting for the electronic paper IC to release the idle signal
SendCommand(0x06); //boost soft start
SendData(0x17); //A
SendData(0x17); //B
SendData(0x17); //C
SendCommand(0x00); //panel setting
SendData(0x1f); //LUT from OTPKW-BF KWR-AF BWROTP 0f BWOTP 1f
SendCommand(0x04);
WaitUntilIdle();
SendCommand(0x61); //resolution setting
SendData (0x80);
SendData (0x01);
SendData (0x28);
SendCommand(0x00); //panel setting
SendData(0xbf); //LUT from OTP128x296
SendData(0x0e); //VCOM to 0V fast
SendCommand(0x30); //PLL setting
SendData(0x3a); // 3a 100HZ 29 150Hz 39 200HZ 31 171HZ
SendCommand(0x61); //resolution setting
SendData(EPD_WIDTH);
SendData((EPD_HEIGHT >> 8) & 0xff);
SendData(EPD_HEIGHT & 0xff);
SendCommand(0x82); //vcom_DC setting
SendData(0x28);
SendCommand(0X50); //VCOM AND DATA INTERVAL SETTING
return 0;
}
@ -311,11 +235,19 @@ int Epd::Init(void)
void Epd::Reset(void)
{
DigitalWrite(reset_pin, HIGH);
DelayMs(200);
DelayMs(20);
DigitalWrite(reset_pin, LOW); //module reset
DelayMs(10);
DelayMs(2);
DigitalWrite(reset_pin, HIGH);
DelayMs(200);
DelayMs(20);
DigitalWrite(reset_pin, LOW); //module reset
DelayMs(2);
DigitalWrite(reset_pin, HIGH);
DelayMs(20);
DigitalWrite(reset_pin, LOW); //module reset
DelayMs(2);
DigitalWrite(reset_pin, HIGH);
DelayMs(20);
}
void Epd::Clear(void)
@ -338,7 +270,6 @@ void Epd::Clear(void)
}
}
SetFullReg();
TurnOnDisplay();
}
@ -363,7 +294,6 @@ void Epd::Display(const unsigned char* frame_buffer)
}
// Dev_Delay_ms(10);
SetFullReg();
TurnOnDisplay();
}

View file

@ -146,9 +146,17 @@ void Epd::WaitUntilIdle(void) {
*/
void Epd::Reset(void) {
DigitalWrite(reset_pin, LOW);
DelayMs(200);
DelayMs(2);
DigitalWrite(reset_pin, HIGH);
DelayMs(200);
DelayMs(20);
DigitalWrite(reset_pin, LOW);
DelayMs(2);
DigitalWrite(reset_pin, HIGH);
DelayMs(20);
DigitalWrite(reset_pin, LOW);
DelayMs(2);
DigitalWrite(reset_pin, HIGH);
DelayMs(20);
}
/**

View file

@ -71,7 +71,7 @@ int Epd::Init(void) {
SendData(0x1D);
SendCommand(0x30);
SendData(0x3C);
SendCommand(0x40);
SendCommand(0x41);
SendData(0x00);
SendCommand(0x50);
SendData(0x37);

View file

@ -58,7 +58,7 @@ int EPD_2in13_V3_test(void)
Paint_NewImage(BlackImage, EPD_2in13_V3_WIDTH, EPD_2in13_V3_HEIGHT, 90, WHITE);
Paint_Clear(WHITE);
#if 0 // show bmp
#if 1 // show bmp
Paint_NewImage(BlackImage, EPD_2in13_V3_WIDTH, EPD_2in13_V3_HEIGHT, 90, WHITE);
printf("show window BMP-----------------\r\n");
Paint_SelectImage(BlackImage);
@ -68,7 +68,7 @@ int EPD_2in13_V3_test(void)
printf("show bmp------------------------\r\n");
Paint_SelectImage(BlackImage);
GUI_ReadBmp("./pic/2in13_2.bmp", 0, 0);
GUI_ReadBmp("./pic/2in13_1.bmp", 0, 0);
EPD_2in13_V3_Display(BlackImage);
DEV_Delay_ms(3000);
#endif

View file

@ -115,7 +115,7 @@ int EPD_2in9d_test(void)
sPaint_time.Hour = 12;
sPaint_time.Min = 34;
sPaint_time.Sec = 56;
UBYTE num = 20;
UBYTE num = 10;
for (;;) {
sPaint_time.Sec = sPaint_time.Sec + 1;
if (sPaint_time.Sec == 60) {
@ -141,17 +141,17 @@ int EPD_2in9d_test(void)
EPD_2IN9D_DisplayPart(BlackImage);
DEV_Delay_ms(500);//Analog clock 1s
}
#endif
printf("Clear...\r\n");
// EPD_2IN9D_Init();
EPD_2IN9D_Clear();
printf("Clear...\r\n");
EPD_2IN9D_Init();
EPD_2IN9D_Clear();
DEV_Delay_ms(2000);//important, at least 2s
printf("Goto Sleep...\r\n");
EPD_2IN9D_Sleep();
free(BlackImage);
BlackImage = NULL;
DEV_Delay_ms(2000);//important, at least 2s
DEV_Delay_ms(3000);//important, at least 2s
// close 5V
printf("close 5V, Module enters 0 power consumption ...\r\n");
DEV_Module_Exit();

View file

@ -0,0 +1,161 @@
/*****************************************************************************
* | File : EPD_4in2_V2_V2_test.c
* | Author : Waveshare team
* | Function : 4.2inch e-paper V2 test demo
* | Info :
*----------------
* | This version: V1.0
* | Date : 2021-02-23
* | Info :
* -----------------------------------------------------------------------------
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documnetation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
******************************************************************************/
#include "EPD_Test.h"
#include "EPD_4in2_V2.h"
#include <string.h>
int EPD_4in2_V2_test(void)
{
printf("EPD_4IN2_V2_test Demo\r\n");
if(DEV_Module_Init()!=0){
return -1;
}
printf("e-Paper Init and Clear...\r\n");
EPD_4IN2_V2_Init();
EPD_4IN2_V2_Clear();
DEV_Delay_ms(500);
//Create a new image cache
UBYTE *BlackImage;
/* you have to edit the startup_stm32fxxx.s file and set a big enough heap size */
UWORD Imagesize = ((EPD_4IN2_V2_WIDTH % 8 == 0)? (EPD_4IN2_V2_WIDTH / 8 ): (EPD_4IN2_V2_WIDTH / 8 + 1)) * EPD_4IN2_V2_HEIGHT;
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
printf("Failed to apply for black memory...\r\n");
return -1;
}
printf("Paint_NewImage\r\n");
Paint_NewImage(BlackImage, EPD_4IN2_V2_WIDTH, EPD_4IN2_V2_HEIGHT, 0, WHITE);
#if 1 // show bmp
printf("show window BMP-----------------\r\n");
Paint_SelectImage(BlackImage);
Paint_Clear(WHITE);
GUI_ReadBmp("./pic/100x100.bmp", 10, 10);
EPD_4IN2_V2_Display(BlackImage);
DEV_Delay_ms(2000);
printf("show bmp------------------------\r\n");
Paint_SelectImage(BlackImage);
GUI_ReadBmp("./pic/4in2.bmp", 0, 0);
EPD_4IN2_V2_Display(BlackImage);
DEV_Delay_ms(2000);
#endif
#if 0 // show image for array
printf("show image for array\r\n");
Paint_SelectImage(BlackImage);
Paint_Clear(WHITE);
Paint_DrawBitMap(gImage_4in2);
EPD_4IN2_V2_Display(BlackImage);
DEV_Delay_ms(2000);
#endif
#if 1 // Drawing on the image
//1.Select Image
printf("SelectImage:BlackImage\r\n");
Paint_SelectImage(BlackImage);
Paint_Clear(WHITE);
// 2.Drawing on the image
printf("Drawing:BlackImage\r\n");
Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
Paint_DrawCircle(45, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
Paint_DrawCircle(105, 95, 20, WHITE, DOT_PIXEL_1X1, DRAW_FILL_FULL);
Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
Paint_DrawString_CN(130, 0, " ÄãºÃabc", &Font12CN, BLACK, WHITE);
Paint_DrawString_CN(130, 20, "΢ѩµç×Ó", &Font24CN, WHITE, BLACK);
printf("EPD_Display\r\n");
// EPD_4IN2_V2_Display(BlackImage);
EPD_4IN2_V2_Display_Base(BlackImage);
DEV_Delay_ms(2000);
#endif
#if 1
printf("Partial refresh\r\n");
Paint_NewImage(BlackImage, 200, 50, 0, WHITE);
PAINT_TIME sPaint_time;
sPaint_time.Hour = 12;
sPaint_time.Min = 34;
sPaint_time.Sec = 56;
UBYTE num = 10;
for (;;) {
sPaint_time.Sec = sPaint_time.Sec + 1;
if (sPaint_time.Sec == 60) {
sPaint_time.Min = sPaint_time.Min + 1;
sPaint_time.Sec = 0;
if (sPaint_time.Min == 60) {
sPaint_time.Hour = sPaint_time.Hour + 1;
sPaint_time.Min = 0;
if (sPaint_time.Hour == 24) {
sPaint_time.Hour = 0;
sPaint_time.Min = 0;
sPaint_time.Sec = 0;
}
}
}
Paint_Clear(WHITE);
Paint_DrawTime(20, 10, &sPaint_time, &Font20, WHITE, BLACK);
EPD_4IN2_V2_PartialDisplay(BlackImage, 80, 200, 200, 50);
DEV_Delay_ms(500);//Analog clock 1s
num = num - 1;
if(num == 0) {
break;
}
}
#endif
EPD_4IN2_V2_Init();
EPD_4IN2_V2_Clear();
printf("Goto Sleep...\r\n");
EPD_4IN2_V2_Sleep();
free(BlackImage);
BlackImage = NULL;
DEV_Delay_ms(2000);//important, at least 2s
// close 5V
printf("close 5V, Module enters 0 power consumption ...\r\n");
DEV_Module_Exit();
return 0;
}

View file

@ -55,7 +55,7 @@ int EPD_4in2_test(void)
Paint_NewImage(BlackImage, EPD_4IN2_WIDTH, EPD_4IN2_HEIGHT, 0, WHITE);
#if 0 // show bmp
#if 1 // show bmp
printf("show window BMP-----------------\r\n");
Paint_SelectImage(BlackImage);
Paint_Clear(WHITE);

View file

@ -72,10 +72,10 @@ int EPD_7in5b_V2_test(void)
#if 1 // show bmp
printf("show window BMP-----------------\r\n");
Paint_SelectImage(BlackImage);
GUI_ReadBmp("./pic/100x100.bmp", 10, 0);
GUI_ReadBmp("./pic/2in9.bmp", 50, 100);
Paint_SelectImage(RYImage);
Paint_Clear(WHITE);
GUI_ReadBmp("./pic/100x100.bmp", 200, 0);
Paint_Clear(WHITE);
GUI_ReadBmp("./pic/2in9.bmp", 350, 100);
EPD_7IN5B_V2_Display(BlackImage, RYImage);
DEV_Delay_ms(2000);

View file

@ -73,6 +73,7 @@ int EPD_3in7_test(void);
int EPD_4in01f_test(void);
int EPD_4in2_test(void);
int EPD_4in2_V2_test(void);
int EPD_4in2bc_test(void);
int EPD_4in2b_V2_test(void);

View file

@ -53,6 +53,7 @@ int main(void)
// EPD_4in01f_test();
// EPD_4in2_test();
// EPD_4in2_V2_test();
// EPD_4in2bc_test();
// EPD_4in2b_V2_test();
@ -81,14 +82,15 @@ int main(void)
// EPD_13in3_test();
/* For Test
if(DEV_Module_Init()!=0){
return -1;
}
while(1) {
DEV_Delay_ms(10000);
}
DEV_Module_Exit();
*/
// For Test
// if(DEV_Module_Init()!=0){
// return -1;
// }
// while(1) {
// EPD_7in5b_V2_test();
// DEV_Delay_ms(10000);
// }
// DEV_Module_Exit();
//
return 0;
}

View file

@ -30,6 +30,29 @@
#include "EPD_1in54_V2.h"
#include "Debug.h"
const unsigned char WF_PARTIAL_1IN54[159] =
{
0x0,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x80,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x40,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0xF,0x0,0x0,0x0,0x0,0x0,0x1,
0x1,0x1,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,0x0,0x0,0x0,0x0,0x0,0x0,
0x22,0x22,0x22,0x22,0x22,0x22,0x0,0x0,0x0,
0x02,0x17,0x41,0xB0,0x32,0x28,
};
/******************************************************************************
function : Software reset
parameter:
@ -78,7 +101,7 @@ static void EPD_1IN54_V2_ReadBusy(void)
{
Debug("e-Paper busy\r\n");
while(DEV_Digital_Read(EPD_BUSY_PIN) == 1) { //LOW: idle, HIGH: busy
DEV_Delay_ms(100);
DEV_Delay_ms(10);
}
Debug("e-Paper busy release\r\n");
}
@ -91,7 +114,7 @@ static void EPD_1IN54_V2_TurnOnDisplay(void)
{
EPD_1IN54_V2_SendCommand(0x22);
EPD_1IN54_V2_SendData(0xF7);
EPD_1IN54_V2_SendCommand(0x20);
EPD_1IN54_V2_SendCommand(0x20);
EPD_1IN54_V2_ReadBusy();
}
@ -107,6 +130,37 @@ static void EPD_1IN54_V2_TurnOnDisplayPart(void)
EPD_1IN54_V2_ReadBusy();
}
static void EPD_1IN54_V2_SetLut(void)
{
EPD_1IN54_V2_SendCommand(0x32);
for(UBYTE i=0; i<153; i++)
EPD_1IN54_V2_SendData(WF_PARTIAL_1IN54[i]);
EPD_1IN54_V2_ReadBusy();
}
static void EPD_1IN54_V2_SetWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend)
{
EPD_1IN54_V2_SendCommand(0x44); // SET_RAM_X_ADDRESS_START_END_POSITION
EPD_1IN54_V2_SendData((Xstart>>3) & 0xFF);
EPD_1IN54_V2_SendData((Xend>>3) & 0xFF);
EPD_1IN54_V2_SendCommand(0x45); // SET_RAM_Y_ADDRESS_START_END_POSITION
EPD_1IN54_V2_SendData(Ystart & 0xFF);
EPD_1IN54_V2_SendData((Ystart >> 8) & 0xFF);
EPD_1IN54_V2_SendData(Yend & 0xFF);
EPD_1IN54_V2_SendData((Yend >> 8) & 0xFF);
}
static void EPD_1IN54_V2_SetCursor(UWORD Xstart, UWORD Ystart)
{
EPD_1IN54_V2_SendCommand(0x4E); // SET_RAM_X_ADDRESS_COUNTER
EPD_1IN54_V2_SendData(Xstart & 0xFF);
EPD_1IN54_V2_SendCommand(0x4F); // SET_RAM_Y_ADDRESS_COUNTER
EPD_1IN54_V2_SendData(Ystart & 0xFF);
EPD_1IN54_V2_SendData((Ystart >> 8) & 0xFF);
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
@ -127,15 +181,16 @@ void EPD_1IN54_V2_Init(void)
EPD_1IN54_V2_SendCommand(0x11); //data entry mode
EPD_1IN54_V2_SendData(0x01);
EPD_1IN54_V2_SendCommand(0x44); //set Ram-X address start/end position
EPD_1IN54_V2_SendData(0x00);
EPD_1IN54_V2_SendData(0x18); //0x0C-->(18+1)*8=200
// EPD_1IN54_V2_SendCommand(0x44); //set Ram-X address start/end position
// EPD_1IN54_V2_SendData(0x00);
// EPD_1IN54_V2_SendData(0x18); //0x0C-->(18+1)*8=200
EPD_1IN54_V2_SendCommand(0x45); //set Ram-Y address start/end position
EPD_1IN54_V2_SendData(0xC7); //0xC7-->(199+1)=200
EPD_1IN54_V2_SendData(0x00);
EPD_1IN54_V2_SendData(0x00);
EPD_1IN54_V2_SendData(0x00);
// EPD_1IN54_V2_SendCommand(0x45); //set Ram-Y address start/end position
// EPD_1IN54_V2_SendData(0xC7); //0xC7-->(199+1)=200
// EPD_1IN54_V2_SendData(0x00);
// EPD_1IN54_V2_SendData(0x00);
// EPD_1IN54_V2_SendData(0x00);
EPD_1IN54_V2_SetWindows(0, EPD_1IN54_V2_HEIGHT-1, EPD_1IN54_V2_WIDTH-1, 0);
EPD_1IN54_V2_SendCommand(0x3C); //BorderWavefrom
EPD_1IN54_V2_SendData(0x01);
@ -147,12 +202,13 @@ void EPD_1IN54_V2_Init(void)
EPD_1IN54_V2_SendData(0XB1);
EPD_1IN54_V2_SendCommand(0x20);
EPD_1IN54_V2_SendCommand(0x4E); // set RAM x address count to 0;
EPD_1IN54_V2_SendData(0x00);
EPD_1IN54_V2_SendCommand(0x4F); // set RAM y address count to 0X199;
EPD_1IN54_V2_SendData(0xC7);
EPD_1IN54_V2_SendData(0x00);
EPD_1IN54_V2_ReadBusy();
// EPD_1IN54_V2_SendCommand(0x4E); // set RAM x address count to 0;
// EPD_1IN54_V2_SendData(0x00);
// EPD_1IN54_V2_SendCommand(0x4F); // set RAM y address count to 0X199;
// EPD_1IN54_V2_SendData(0xC7);
// EPD_1IN54_V2_SendData(0x00);
EPD_1IN54_V2_SetCursor(0, EPD_1IN54_V2_HEIGHT-1);
EPD_1IN54_V2_ReadBusy();
}
/******************************************************************************
@ -241,9 +297,23 @@ void EPD_1IN54_V2_DisplayPart(UBYTE *Image)
Height = EPD_1IN54_V2_HEIGHT;
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(10);
DEV_Delay_ms(2);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(10);
DEV_Delay_ms(5);
EPD_1IN54_V2_SetLut();
EPD_1IN54_V2_SendCommand(0x37);
EPD_1IN54_V2_SendData(0x00);
EPD_1IN54_V2_SendData(0x00);
EPD_1IN54_V2_SendData(0x00);
EPD_1IN54_V2_SendData(0x00);
EPD_1IN54_V2_SendData(0x00);
EPD_1IN54_V2_SendData(0x40);
EPD_1IN54_V2_SendData(0x00);
EPD_1IN54_V2_SendData(0x00);
EPD_1IN54_V2_SendData(0x00);
EPD_1IN54_V2_SendData(0x00);
EPD_1IN54_V2_SendCommand(0x3C); //BorderWavefrom
EPD_1IN54_V2_SendData(0x80);
@ -257,6 +327,7 @@ void EPD_1IN54_V2_DisplayPart(UBYTE *Image)
}
EPD_1IN54_V2_TurnOnDisplayPart();
}
/******************************************************************************
function : Enter sleep mode
parameter:

View file

@ -82,9 +82,9 @@ void EPD_2in13_V3_ReadBusy(void)
{ //=1 BUSY
if(DEV_Digital_Read(EPD_BUSY_PIN)==0)
break;
DEV_Delay_ms(50);
DEV_Delay_ms(10);
}
DEV_Delay_ms(50);
DEV_Delay_ms(10);
Debug("e-Paper busy release\r\n");
}

View file

@ -112,7 +112,7 @@ void EPD_2IN9_V2_ReadBusy(void)
}
static void EPD_2IN9_V2_LUT(void)
{
{
UBYTE count;
EPD_2IN9_V2_SendCommand(0x32);
for(count=0; count<153; count++)

View file

@ -4,8 +4,8 @@
* | Function : 2.9inch e-paper d
* | Info :
*----------------
* | This version: V2.0
* | Date : 2019-06-12
* | This version: V3.1
* | Date : 2021-03-18
* | Info :
* -----------------------------------------------------------------------------
* V3.0(2019-06-12):
@ -54,57 +54,6 @@
#include "EPD_2in9d.h"
#include "Debug.h"
/**
* full screen update LUT
**/
const unsigned char EPD_2IN9D_lut_vcomDC[] = {
0x00, 0x08, 0x00, 0x00, 0x00, 0x02,
0x60, 0x28, 0x28, 0x00, 0x00, 0x01,
0x00, 0x14, 0x00, 0x00, 0x00, 0x01,
0x00, 0x12, 0x12, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00,
};
const unsigned char EPD_2IN9D_lut_ww[] = {
0x40, 0x08, 0x00, 0x00, 0x00, 0x02,
0x90, 0x28, 0x28, 0x00, 0x00, 0x01,
0x40, 0x14, 0x00, 0x00, 0x00, 0x01,
0xA0, 0x12, 0x12, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const unsigned char EPD_2IN9D_lut_bw[] = {
0x40, 0x17, 0x00, 0x00, 0x00, 0x02,
0x90, 0x0F, 0x0F, 0x00, 0x00, 0x03,
0x40, 0x0A, 0x01, 0x00, 0x00, 0x01,
0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const unsigned char EPD_2IN9D_lut_wb[] = {
0x80, 0x08, 0x00, 0x00, 0x00, 0x02,
0x90, 0x28, 0x28, 0x00, 0x00, 0x01,
0x80, 0x14, 0x00, 0x00, 0x00, 0x01,
0x50, 0x12, 0x12, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const unsigned char EPD_2IN9D_lut_bb[] = {
0x80, 0x08, 0x00, 0x00, 0x00, 0x02,
0x90, 0x28, 0x28, 0x00, 0x00, 0x01,
0x80, 0x14, 0x00, 0x00, 0x00, 0x01,
0x50, 0x12, 0x12, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
/**
* partial screen update LUT
**/
@ -163,11 +112,19 @@ parameter:
static void EPD_2IN9D_Reset(void)
{
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
DEV_Delay_ms(20);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(2);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
DEV_Delay_ms(20);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(2);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(20);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(2);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(20);
}
/******************************************************************************
@ -209,56 +166,48 @@ void EPD_2IN9D_ReadBusy(void)
busy = DEV_Digital_Read(EPD_BUSY_PIN);
busy =!(busy & 0x01);
} while(busy);
DEV_Delay_ms(200);
DEV_Delay_ms(20);
Debug("e-Paper busy release\r\n");
}
/******************************************************************************
function : LUT download
parameter:
******************************************************************************/
static void EPD_SetFullReg(void)
{
EPD_2IN9D_SendCommand(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_2IN9D_SendData(0xb7); //WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7
unsigned int count;
EPD_2IN9D_SendCommand(0x20);
for(count=0; count<44; count++) {
EPD_2IN9D_SendData(EPD_2IN9D_lut_vcomDC[count]);
}
EPD_2IN9D_SendCommand(0x21);
for(count=0; count<42; count++) {
EPD_2IN9D_SendData(EPD_2IN9D_lut_ww[count]);
}
EPD_2IN9D_SendCommand(0x22);
for(count=0; count<42; count++) {
EPD_2IN9D_SendData(EPD_2IN9D_lut_bw[count]);
}
EPD_2IN9D_SendCommand(0x23);
for(count=0; count<42; count++) {
EPD_2IN9D_SendData(EPD_2IN9D_lut_wb[count]);
}
EPD_2IN9D_SendCommand(0x24);
for(count=0; count<42; count++) {
EPD_2IN9D_SendData(EPD_2IN9D_lut_bb[count]);
}
}
/******************************************************************************
function : LUT download
parameter:
******************************************************************************/
static void EPD_2IN9D_SetPartReg(void)
{
EPD_2IN9D_SendCommand(0x82); //vcom_DC setting
EPD_2IN9D_SendCommand(0x01); //POWER SETTING
EPD_2IN9D_SendData(0x03);
EPD_2IN9D_SendData(0x00);
EPD_2IN9D_SendData(0x2b);
EPD_2IN9D_SendData(0x2b);
EPD_2IN9D_SendData(0x03);
EPD_2IN9D_SendCommand(0x06); //boost soft start
EPD_2IN9D_SendData(0x17); //A
EPD_2IN9D_SendData(0x17); //B
EPD_2IN9D_SendData(0x17); //C
EPD_2IN9D_SendCommand(0x04);
EPD_2IN9D_ReadBusy();
EPD_2IN9D_SendCommand(0x00); //panel setting
EPD_2IN9D_SendData(0xbf); //LUT from OTP128x296
EPD_2IN9D_SendCommand(0x30); //PLL setting
EPD_2IN9D_SendData(0x3a); // 3a 100HZ 29 150Hz 39 200HZ 31 171HZ
EPD_2IN9D_SendCommand(0x61); //resolution setting
EPD_2IN9D_SendData(EPD_2IN9D_WIDTH);
EPD_2IN9D_SendData((EPD_2IN9D_HEIGHT >> 8) & 0xff);
EPD_2IN9D_SendData(EPD_2IN9D_HEIGHT & 0xff);
EPD_2IN9D_SendCommand(0x82); //vcom_DC setting
EPD_2IN9D_SendData(0x12);
EPD_2IN9D_SendCommand(0X50);
EPD_2IN9D_SendData(0xb7);
EPD_2IN9D_SendData(0x97);
unsigned int count;
EPD_2IN9D_SendCommand(0x20);
@ -306,36 +255,20 @@ parameter:
void EPD_2IN9D_Init(void)
{
EPD_2IN9D_Reset();
EPD_2IN9D_SendCommand(0x04);
EPD_2IN9D_ReadBusy();//waiting for the electronic paper IC to release the idle signal
EPD_2IN9D_SendCommand(0x01); //POWER SETTING
EPD_2IN9D_SendData(0x03);
EPD_2IN9D_SendData(0x00);
EPD_2IN9D_SendData(0x2b);
EPD_2IN9D_SendData(0x2b);
EPD_2IN9D_SendData(0x03);
EPD_2IN9D_SendCommand(0x00); //panel setting
EPD_2IN9D_SendData(0x1f); //LUT from OTPKW-BF KWR-AF BWROTP 0f BWOTP 1f
EPD_2IN9D_SendCommand(0x06); //boost soft start
EPD_2IN9D_SendData(0x17); //A
EPD_2IN9D_SendData(0x17); //B
EPD_2IN9D_SendData(0x17); //C
EPD_2IN9D_SendCommand(0x61); //resolution setting
EPD_2IN9D_SendData (0x80);
EPD_2IN9D_SendData (0x01);
EPD_2IN9D_SendData (0x28);
EPD_2IN9D_SendCommand(0x04);
EPD_2IN9D_ReadBusy();
EPD_2IN9D_SendCommand(0x00); //panel setting
EPD_2IN9D_SendData(0xbf); //LUT from OTP128x296
EPD_2IN9D_SendData(0x0e); //VCOM to 0V fast
EPD_2IN9D_SendCommand(0x30); //PLL setting
EPD_2IN9D_SendData(0x3a); // 3a 100HZ 29 150Hz 39 200HZ 31 171HZ
EPD_2IN9D_SendCommand(0x61); //resolution setting
EPD_2IN9D_SendData(EPD_2IN9D_WIDTH);
EPD_2IN9D_SendData((EPD_2IN9D_HEIGHT >> 8) & 0xff);
EPD_2IN9D_SendData(EPD_2IN9D_HEIGHT & 0xff);
EPD_2IN9D_SendCommand(0x82); //vcom_DC setting
EPD_2IN9D_SendData(0x28);
EPD_2IN9D_SendCommand(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_2IN9D_SendData(0x97); //WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7
}
/******************************************************************************
@ -361,8 +294,6 @@ void EPD_2IN9D_Clear(void)
EPD_2IN9D_SendData(0xFF);
}
}
EPD_SetFullReg();
EPD_2IN9D_TurnOnDisplay();
}
@ -382,7 +313,6 @@ void EPD_2IN9D_Display(UBYTE *Image)
EPD_2IN9D_SendData(0x00);
}
}
// Dev_Delay_ms(10);
EPD_2IN9D_SendCommand(0x13);
for (UWORD j = 0; j < Height; j++) {
@ -390,9 +320,7 @@ void EPD_2IN9D_Display(UBYTE *Image)
EPD_2IN9D_SendData(Image[i + j * Width]);
}
}
// Dev_Delay_ms(10);
EPD_SetFullReg();
EPD_2IN9D_TurnOnDisplay();
}
@ -430,7 +358,6 @@ void EPD_2IN9D_DisplayPart(UBYTE *Image)
EPD_2IN9D_TurnOnDisplay();
}
/******************************************************************************
function : Enter sleep mode
parameter:

View file

@ -4,8 +4,8 @@
* | Function : 2.9inch e-paper d
* | Info :
*----------------
* | This version: V2.0
* | Date : 2019-06-12
* | This version: V3.1
* | Date : 2021-03-18
* | Info :
* -----------------------------------------------------------------------------
* V3.0(2019-06-12):

View file

@ -267,11 +267,19 @@ parameter:
static void EPD_4IN2_Reset(void)
{
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
DEV_Delay_ms(20);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(2);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
DEV_Delay_ms(20);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(2);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(20);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(2);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(20);
}
/******************************************************************************

View file

@ -0,0 +1,322 @@
/*****************************************************************************
* | File : EPD_4in2_V2_V2.h
* | Author : Waveshare team
* | Function : 4.2inch e-paper V2
* | Info :
*----------------
* | This version: V1.0
* | Date : 2021-02-23
* | Info :
* -----------------------------------------------------------------------------
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documnetation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
******************************************************************************/
#include "EPD_4in2_V2.h"
#include "Debug.h"
UBYTE WF_PARTIAL_4IN2[76] =
{
0X00,0x40,0x00,0x00,0x00,0x00,0x00, // L0 0-6 ABCD
0X80,0x80,0x00,0x00,0x00,0x00,0x00, // L1 0-6 ABCD
0X40,0x40,0x00,0x00,0x00,0x00,0x00, // L2 0-6 ABCD
0X00,0x80,0x00,0x00,0x00,0x00,0x00, // L3 0-6 ABCD
0X00,0x00,0x00,0x00,0x00,0x00,0x00, // VCOM 0-6 ABCD
0x0A,0x00,0x00,0x00,0x02,//0A 0B 0C 0D R
0x01,0x00,0x00,0x00,0x00,//1A 0B 0C 0D R
0x00,0x00,0x00,0x00,0x00,//2A 0B 0C 0D R
0x00,0x00,0x00,0x00,0x00,//3A 0B 0C 0D R
0x00,0x00,0x00,0x00,0x00,//4A 0B 0C 0D R
0x00,0x00,0x00,0x00,0x00,//5A 0B 0C 0D R
0x00,0x00,0x00,0x00,0x00,//6A 0B 0C 0D R
0x17,0x41,0x0, 0x32,0x2C,0x0A
};
/******************************************************************************
function : Software reset
parameter:
******************************************************************************/
static void EPD_4IN2_V2_Reset(void)
{
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(100);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(2);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(100);
}
/******************************************************************************
function : send command
parameter:
Reg : Command register
******************************************************************************/
static void EPD_4IN2_V2_SendCommand(UBYTE Reg)
{
DEV_Digital_Write(EPD_DC_PIN, 0);
DEV_Digital_Write(EPD_CS_PIN, 0);
DEV_SPI_WriteByte(Reg);
DEV_Digital_Write(EPD_CS_PIN, 1);
}
/******************************************************************************
function : send data
parameter:
Data : Write data
******************************************************************************/
static void EPD_4IN2_V2_SendData(UBYTE Data)
{
DEV_Digital_Write(EPD_DC_PIN, 1);
DEV_Digital_Write(EPD_CS_PIN, 0);
DEV_SPI_WriteByte(Data);
DEV_Digital_Write(EPD_CS_PIN, 1);
}
/******************************************************************************
function : Wait until the busy_pin goes LOW
parameter:
******************************************************************************/
void EPD_4IN2_V2_ReadBusy(void)
{
Debug("e-Paper busy\r\n");
while(DEV_Digital_Read(EPD_BUSY_PIN) == 1) { //LOW: idle, HIGH: busy
DEV_Delay_ms(10);
}
Debug("e-Paper busy release\r\n");
}
/******************************************************************************
function : Turn On Display
parameter:
******************************************************************************/
static void EPD_4IN2_V2_TurnOnDisplay(void)
{
EPD_4IN2_V2_SendCommand(0x22);
EPD_4IN2_V2_SendData(0xC7);
EPD_4IN2_V2_SendCommand(0x20);
EPD_4IN2_V2_ReadBusy();
}
static void EPD_4IN2_V2_TurnOnDisplay_Partial(void)
{
EPD_4IN2_V2_SendCommand(0x22);
EPD_4IN2_V2_SendData(0xCF);
EPD_4IN2_V2_SendCommand(0x20);
EPD_4IN2_V2_ReadBusy();
}
/******************************************************************************
function : set the look-up tables
parameter:
******************************************************************************/
static void EPD_4IN2_V2_SetLut(void)
{
UWORD count;
EPD_4IN2_V2_SendCommand(0x32);
for(count=0; count<70; count++) {
EPD_4IN2_V2_SendData(WF_PARTIAL_4IN2[count]);
}
}
/******************************************************************************
function : Setting the display window
parameter:
******************************************************************************/
static void EPD_4IN2_V2_SetWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend)
{
EPD_4IN2_V2_SendCommand(0x44); // SET_RAM_X_ADDRESS_START_END_POSITION
EPD_4IN2_V2_SendData((Xstart>>3) & 0xFF);
EPD_4IN2_V2_SendData((Xend>>3) & 0xFF);
EPD_4IN2_V2_SendCommand(0x45); // SET_RAM_Y_ADDRESS_START_END_POSITION
EPD_4IN2_V2_SendData(Ystart & 0xFF);
EPD_4IN2_V2_SendData((Ystart >> 8) & 0xFF);
EPD_4IN2_V2_SendData(Yend & 0xFF);
EPD_4IN2_V2_SendData((Yend >> 8) & 0xFF);
}
/******************************************************************************
function : Set Cursor
parameter:
******************************************************************************/
static void EPD_4IN2_V2_SetCursor(UWORD Xstart, UWORD Ystart)
{
EPD_4IN2_V2_SendCommand(0x4E); // SET_RAM_X_ADDRESS_COUNTER
EPD_4IN2_V2_SendData(Xstart & 0xFF);
EPD_4IN2_V2_SendCommand(0x4F); // SET_RAM_Y_ADDRESS_COUNTER
EPD_4IN2_V2_SendData(Ystart & 0xFF);
EPD_4IN2_V2_SendData((Ystart >> 8) & 0xFF);
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
void EPD_4IN2_V2_Init(void)
{
EPD_4IN2_V2_Reset();
EPD_4IN2_V2_ReadBusy();
EPD_4IN2_V2_SendCommand(0x12); // soft reset
EPD_4IN2_V2_ReadBusy();
EPD_4IN2_V2_SendCommand(0x74); // IC analog block control
EPD_4IN2_V2_SendData(0x54);
EPD_4IN2_V2_SendCommand(0x7E); // IC digital block control
EPD_4IN2_V2_SendData(0x3B);
EPD_4IN2_V2_SendCommand(0x01); // drive output control
EPD_4IN2_V2_SendData(0x2B); // Y low byte
EPD_4IN2_V2_SendData(0x01); // Y high byte
EPD_4IN2_V2_SendData(0x00);
EPD_4IN2_V2_SendCommand(0x11); // data entry mode
EPD_4IN2_V2_SendData(0x03); // X-mode
EPD_4IN2_V2_SetWindows(0, 0, EPD_4IN2_V2_WIDTH-1, EPD_4IN2_V2_HEIGHT-1);
EPD_4IN2_V2_SendCommand(0x3C); // Border setting
EPD_4IN2_V2_SendData(0x01);
EPD_4IN2_V2_SendCommand(0x18); // use the internal temperature sensor
EPD_4IN2_V2_SendData(0x80);
EPD_4IN2_V2_SendCommand(0x22);
EPD_4IN2_V2_SendData(0xB1);
EPD_4IN2_V2_SendCommand(0x20);
EPD_4IN2_V2_ReadBusy();
EPD_4IN2_V2_SetCursor(0, 0);
EPD_4IN2_V2_ReadBusy();
}
/******************************************************************************
function : Clear screen
parameter:
******************************************************************************/
void EPD_4IN2_V2_Clear(void)
{
UWORD Width, Height;
Width = (EPD_4IN2_V2_WIDTH % 8 == 0)? (EPD_4IN2_V2_WIDTH / 8 ): (EPD_4IN2_V2_WIDTH / 8 + 1);
Height = EPD_4IN2_V2_HEIGHT;
EPD_4IN2_V2_SendCommand(0x24);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_4IN2_V2_SendData(0xFF);
}
}
EPD_4IN2_V2_SendCommand(0x26);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_4IN2_V2_SendData(0x00);
}
}
EPD_4IN2_V2_TurnOnDisplay();
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void EPD_4IN2_V2_Display(UBYTE *Image)
{
UWORD Width, Height;
Width = (EPD_4IN2_V2_WIDTH % 8 == 0)? (EPD_4IN2_V2_WIDTH / 8 ): (EPD_4IN2_V2_WIDTH / 8 + 1);
Height = EPD_4IN2_V2_HEIGHT;
EPD_4IN2_V2_SendCommand(0x24);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_4IN2_V2_SendData(Image[i + j * Width]);
}
}
EPD_4IN2_V2_TurnOnDisplay();
}
// Set Base image for partial refresh
void EPD_4IN2_V2_Display_Base(UBYTE *Image)
{
UWORD Width, Height;
Width = (EPD_4IN2_V2_WIDTH % 8 == 0)? (EPD_4IN2_V2_WIDTH / 8 ): (EPD_4IN2_V2_WIDTH / 8 + 1);
Height = EPD_4IN2_V2_HEIGHT;
EPD_4IN2_V2_SendCommand(0x26);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_4IN2_V2_SendData(Image[i + j * Width]);
}
}
EPD_4IN2_V2_SendCommand(0x24);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_4IN2_V2_SendData(Image[i + j * Width]);
}
}
EPD_4IN2_V2_TurnOnDisplay();
}
// Send partial data for partial refresh
void EPD_4IN2_V2_PartialDisplay(UBYTE *Image, UWORD x, UWORD y, UWORD w, UWORD l)
{
UWORD Width, Height;
Width = (w % 8 == 0)? (w / 8 ): (w / 8 + 1);
Height = l;
EPD_4IN2_V2_ReadBusy();
EPD_4IN2_V2_SetLut();
EPD_4IN2_V2_SendCommand(0x37);
EPD_4IN2_V2_SendData(0x00);
EPD_4IN2_V2_SendData(0x00);
EPD_4IN2_V2_SendData(0x00);
EPD_4IN2_V2_SendData(0x00);
EPD_4IN2_V2_SendData(0x40);
EPD_4IN2_V2_SendData(0x00);
EPD_4IN2_V2_SendData(0x00);
EPD_4IN2_V2_SendCommand(0x3C);
EPD_4IN2_V2_SendData(0x80);
EPD_4IN2_V2_SetWindows(x, y, x+w-1, y+l-1);
EPD_4IN2_V2_SetCursor(x, y);
EPD_4IN2_V2_SendCommand(0x24);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_4IN2_V2_SendData(Image[i + j * Width]);
}
}
EPD_4IN2_V2_TurnOnDisplay_Partial();
}
/******************************************************************************
function : Enter sleep mode
parameter:
******************************************************************************/
void EPD_4IN2_V2_Sleep(void)
{
EPD_4IN2_V2_SendCommand(0x10); // DEEP_SLEEP
EPD_4IN2_V2_SendData(0x01);
DEV_Delay_ms(200);
}

View file

@ -0,0 +1,47 @@
/*****************************************************************************
* | File : EPD_4in2_V2_V2_V2.h
* | Author : Waveshare team
* | Function : 4.2inch e-paper V2
* | Info :
*----------------
* | This version: V1.0
* | Date : 2021-02-23
* | Info :
* -----------------------------------------------------------------------------
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documnetation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
******************************************************************************/
#ifndef _EPD_4IN2_V2_H_
#define _EPD_4IN2_V2_H_
#include "DEV_Config.h"
// Display resolution
#define EPD_4IN2_V2_WIDTH 400
#define EPD_4IN2_V2_HEIGHT 300
void EPD_4IN2_V2_Init(void);
void EPD_4IN2_V2_Clear(void);
void EPD_4IN2_V2_Display(UBYTE *Image);
void EPD_4IN2_V2_Display_Base(UBYTE *Image);
void EPD_4IN2_V2_PartialDisplay(UBYTE *Image, UWORD x, UWORD y, UWORD w, UWORD l);
void EPD_4IN2_V2_Sleep(void);
#endif

View file

@ -29,7 +29,7 @@
#
******************************************************************************/
#include "EPD_5in65f.h"
#include "stdlib.h"
/******************************************************************************
function:
@ -103,10 +103,6 @@ void EPD_5IN65F_Init(void)
EPD_5IN65F_SendData(0x00);
EPD_5IN65F_SendData(0x23);
EPD_5IN65F_SendData(0x23);
EPD_5IN65F_SendCommand(0x82);
EPD_5IN65F_SendData(0x1d);
EPD_5IN65F_SendCommand(0x03);
EPD_5IN65F_SendData(0x00);
EPD_5IN65F_SendCommand(0x06);
@ -114,8 +110,8 @@ void EPD_5IN65F_Init(void)
EPD_5IN65F_SendData(0xC7);
EPD_5IN65F_SendData(0x1D);
EPD_5IN65F_SendCommand(0x30);
EPD_5IN65F_SendData(0x3C);
EPD_5IN65F_SendCommand(0x40);
EPD_5IN65F_SendData(0x39);
EPD_5IN65F_SendCommand(0x41);
EPD_5IN65F_SendData(0x00);
EPD_5IN65F_SendCommand(0x50);
EPD_5IN65F_SendData(0x37);
@ -175,12 +171,14 @@ void EPD_5IN65F_Display(const UBYTE *image)
for(i=0; i<EPD_5IN65F_HEIGHT; i++) {
for(j=0; j<EPD_5IN65F_WIDTH/2; j++) {
EPD_5IN65F_SendData(image[j+((EPD_5IN65F_WIDTH/2)*i)]);
// printf("0x%x, ", image[j+((EPD_5IN65F_WIDTH/2)*i)]);
// k++;
// if(k == 16) {
// printf("\n");
// k = 0;
// }
/* print image to array
printf("0x%x, ", image[j+((EPD_5IN65F_WIDTH/2)*i)]);
k++;
if(k == 16) {
printf("\n");
k = 0;
}
*/
}
}
EPD_5IN65F_SendCommand(0x04);//0x04

Binary file not shown.

After

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

View file

@ -76,5 +76,5 @@ except IOError as e:
except KeyboardInterrupt:
logging.info("ctrl + c:")
epd1in54b.epdconfig.module_exit()
epd1in54b_V2.epdconfig.module_exit()
exit()

View file

@ -28,8 +28,8 @@ try:
# Drawing on the Horizontal image
logging.info("1.Drawing on the Horizontal image...")
HBlackimage = Image.new('1', (epd.height, epd.width), 255) # 298*126
HRYimage = Image.new('1', (epd.height, epd.width), 255) # 298*126 ryimage: red or yellow image
HBlackimage = Image.new('1', (epd.height, epd.width), 255) # 296*152
HRYimage = Image.new('1', (epd.height, epd.width), 255) # 296*152 ryimage: red or yellow image
drawblack = ImageDraw.Draw(HBlackimage)
drawry = ImageDraw.Draw(HRYimage)
drawblack.text((10, 0), 'hello world', font = font24, fill = 0)
@ -62,8 +62,8 @@ try:
# Drawing on the Vertical image
logging.info("4.Drawing on the Vertical image...")
LBlackimage = Image.new('1', (epd.width, epd.height), 255) # 126*298
LRYimage = Image.new('1', (epd.width, epd.height), 255) # 126*298
LBlackimage = Image.new('1', (epd.width, epd.height), 255) # 152*296
LRYimage = Image.new('1', (epd.width, epd.height), 255) # 152*296
drawblack = ImageDraw.Draw(LBlackimage)
drawry = ImageDraw.Draw(LRYimage)
time.sleep(3)

View file

@ -91,10 +91,11 @@ try:
num = num + 1
if(num == 10):
break
epd.init()
logging.info("Clear...")
epd.Clear(0xFF)
time.sleep(2)
logging.info("Goto Sleep...")
epd.sleep()

View file

@ -74,7 +74,7 @@ try:
epd.Clear()
logging.info("3.read bmp file")
Himage = Image.open(os.path.join(picdir, '4.01inch-e-Paper.bmp'))
Himage = Image.open(os.path.join(picdir, '4in01-1.bmp'))
epd.display(epd.getbuffer(Himage))
time.sleep(3)

View file

@ -49,7 +49,7 @@ try:
epd.display(epd.getbuffer(Himage))
time.sleep(3)
logging.info("2.Drawing on the Vertical image...")
# logging.info("2.Drawing on the Vertical image...")
Himage = Image.new('RGB', (epd.height, epd.width), 0xffffff) # 255: clear the frame
draw = ImageDraw.Draw(Himage)
draw.text((10, 0), 'hello world', font = font24, fill = 0)
@ -72,24 +72,14 @@ try:
time.sleep(3)
logging.info("3.read bmp file")
Himage = Image.open(os.path.join(picdir, '5in65f0.bmp'))
epd.display(epd.getbuffer(Himage))
time.sleep(3)
Himage = Image.open(os.path.join(picdir, '5in65f.bmp'))
epd.display(epd.getbuffer(Himage))
time.sleep(3)
Himage = Image.open(os.path.join(picdir, '5in65f2.bmp'))
epd.display(epd.getbuffer(Himage))
time.sleep(3)
Himage = Image.open(os.path.join(picdir, '5in65f3.bmp'))
epd.display(epd.getbuffer(Himage))
time.sleep(3)
Himage = Image.open(os.path.join(picdir, '5in65f4.bmp'))
epd.display(epd.getbuffer(Himage))
time.sleep(3)
epd.Clear()
logging.info("Goto Sleep...")
epd.sleep()

View file

@ -75,7 +75,7 @@ try:
logging.info("4.read bmp file on window")
Himage2 = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame
Himage2_Other = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame
bmp = Image.open(os.path.join(picdir, '100x100.bmp'))
bmp = Image.open(os.path.join(picdir, '2in9.bmp'))
Himage2.paste(bmp, (50,10))
Himage2_Other.paste(bmp, (50,300))
epd.display(epd.getbuffer(Himage2), epd.getbuffer(Himage2_Other))

View file

@ -99,23 +99,23 @@ class EPD:
return 0
def setWindows(self, Xstart, Ystart, Xend, Yend):
self.send_command(0x44); # SET_RAM_X_ADDRESS_START_END_POSITION
self.send_data((Xstart>>3) & 0x1F);
self.send_data((Xend>>3) & 0x1F);
self.send_command(0x44) # SET_RAM_X_ADDRESS_START_END_POSITION
self.send_data((Xstart>>3) & 0x1F)
self.send_data((Xend>>3) & 0x1F)
self.send_command(0x45); # SET_RAM_Y_ADDRESS_START_END_POSITION
self.send_data(Ystart & 0xFF);
self.send_data((Ystart >> 8) & 0x01);
self.send_data(Yend & 0xFF);
self.send_data((Yend >> 8) & 0x01);
self.send_command(0x45) # SET_RAM_Y_ADDRESS_START_END_POSITION
self.send_data(Ystart & 0xFF)
self.send_data((Ystart >> 8) & 0x01)
self.send_data(Yend & 0xFF)
self.send_data((Yend >> 8) & 0x01)
def setCursor(self, Xstart, Ystart):
self.send_command(0x4E); # SET_RAM_X_ADDRESS_COUNTER
self.send_data(Xstart & 0x1F);
self.send_command(0x4E) # SET_RAM_X_ADDRESS_COUNTER
self.send_data(Xstart & 0x1F)
self.send_command(0x4F); # SET_RAM_Y_ADDRESS_COUNTER
self.send_data(Ystart & 0xFF);
self.send_data((Ystart >> 8) & 0x01);
self.send_command(0x4F) # SET_RAM_Y_ADDRESS_COUNTER
self.send_data(Ystart & 0xFF)
self.send_data((Ystart >> 8) & 0x01)
def turnon_display(self):
self.send_command(0x20)
@ -148,13 +148,6 @@ class EPD:
def display(self, Blackimage, Redimage):
if (Blackimage == None or Redimage == None):
return
self.send_command(0x4E)
self.send_data(0x01)
self.send_command(0x4F)
self.send_data(0x27)
self.send_data(0x01)
self.send_command(0x24)
for j in range(0, self.height):
for i in range(0, int(self.width / 8)):
@ -169,7 +162,6 @@ class EPD:
def Clear(self):
self.send_command(0x24)
for j in range(0, self.height):
for i in range(0, int(self.width / 8)):

View file

@ -236,7 +236,7 @@ class EPD:
self.send_command(0x22);
self.send_data(0xC0);
self.send_command(0x20);
self.send_command(0x20);
self.ReadBusy();
self.SetWindow(0, 0, self.width - 1, self.height - 1)

View file

@ -1,5 +1,8 @@
#!/usr/bin/python
# -*- coding:utf-8 -*-
# *****************************************************************************
# * | File : epd2in9d.py
# * | File : epd2in9d.py
# * | Author : Waveshare team
# * | Function : Electronic paper driver
# * | Info :
@ -27,7 +30,6 @@
# THE SOFTWARE.
#
import logging
from . import epdconfig
from PIL import Image
@ -45,57 +47,6 @@ class EPD:
self.cs_pin = epdconfig.CS_PIN
self.width = EPD_WIDTH
self.height = EPD_HEIGHT
lut_vcomDC = [
0x00, 0x08, 0x00, 0x00, 0x00, 0x02,
0x60, 0x28, 0x28, 0x00, 0x00, 0x01,
0x00, 0x14, 0x00, 0x00, 0x00, 0x01,
0x00, 0x12, 0x12, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00,
]
lut_ww = [
0x40, 0x08, 0x00, 0x00, 0x00, 0x02,
0x90, 0x28, 0x28, 0x00, 0x00, 0x01,
0x40, 0x14, 0x00, 0x00, 0x00, 0x01,
0xA0, 0x12, 0x12, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
]
lut_bw = [
0x40, 0x17, 0x00, 0x00, 0x00, 0x02,
0x90, 0x0F, 0x0F, 0x00, 0x00, 0x03,
0x40, 0x0A, 0x01, 0x00, 0x00, 0x01,
0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
]
lut_wb = [
0x80, 0x08, 0x00, 0x00, 0x00, 0x02,
0x90, 0x28, 0x28, 0x00, 0x00, 0x01,
0x80, 0x14, 0x00, 0x00, 0x00, 0x01,
0x50, 0x12, 0x12, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
]
lut_bb = [
0x80, 0x08, 0x00, 0x00, 0x00, 0x02,
0x90, 0x28, 0x28, 0x00, 0x00, 0x01,
0x80, 0x14, 0x00, 0x00, 0x00, 0x01,
0x50, 0x12, 0x12, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
]
lut_vcom1 = [
0x00, 0x19, 0x01, 0x00, 0x00, 0x01,
@ -151,11 +102,19 @@ class EPD:
# Hardware reset
def reset(self):
epdconfig.digital_write(self.reset_pin, 1)
epdconfig.delay_ms(200)
epdconfig.delay_ms(20)
epdconfig.digital_write(self.reset_pin, 0)
epdconfig.delay_ms(5)
epdconfig.digital_write(self.reset_pin, 1)
epdconfig.delay_ms(200)
epdconfig.delay_ms(20)
epdconfig.digital_write(self.reset_pin, 0)
epdconfig.delay_ms(5)
epdconfig.digital_write(self.reset_pin, 1)
epdconfig.delay_ms(20)
epdconfig.digital_write(self.reset_pin, 0)
epdconfig.delay_ms(5)
epdconfig.digital_write(self.reset_pin, 1)
epdconfig.delay_ms(20)
def send_command(self, command):
epdconfig.digital_write(self.dc_pin, 0)
@ -173,8 +132,9 @@ class EPD:
logging.debug("e-Paper busy")
while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy
self.send_command(0x71)
epdconfig.delay_ms(100)
epdconfig.delay_ms(10)
logging.debug("e-Paper busy release")
def TurnOnDisplay(self):
self.send_command(0x12)
epdconfig.delay_ms(10)
@ -186,65 +146,56 @@ class EPD:
# EPD hardware init start
self.reset()
self.send_command(0x01) # POWER SETTING
self.send_command(0x04)
self.ReadBusy() #waiting for the electronic paper IC to release the idle signal
self.send_command(0x00) #panel setting
self.send_data(0x1f) # LUT from OTPKW-BF KWR-AF BWROTP 0f BWOTP 1f
self.send_command(0x61) #resolution setting
self.send_data (0x80)
self.send_data (0x01)
self.send_data (0x28)
self.send_command(0X50) #VCOM AND DATA INTERVAL SETTING
self.send_data(0x97) #WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7
return 0
def SetPartReg(self):
self.send_command(0x01) #POWER SETTING
self.send_data(0x03)
self.send_data(0x00)
self.send_data(0x2b)
self.send_data(0x2b)
self.send_data(0x03)
self.send_command(0x06) # boost soft start
self.send_data(0x17) # A
self.send_data(0x17) # B
self.send_data(0x17) # C
self.send_command(0x06) #boost soft start
self.send_data(0x17) #A
self.send_data(0x17) #B
self.send_data(0x17) #C
self.send_command(0x04)
self.ReadBusy()
self.send_command(0x00) # panel setting
self.send_data(0xbf) # LUT from OTP,128x296
self.send_data(0x0d) # VCOM to 0V fast
self.send_command(0x00) #panel setting
self.send_data(0xbf) #LUT from OTP128x296
self.send_command(0x30) #PLL setting
self.send_data(0x3a) # 3a 100HZ 29 150Hz 39 200HZ 31 171HZ
self.send_command(0x30) #PLL setting
self.send_data(0x3a) # 3a 100HZ 29 150Hz 39 200HZ 31 171HZ
self.send_command(0x61) # resolution setting
self.send_command(0x61) #resolution setting
self.send_data(self.width)
self.send_data((self.height >> 8) & 0xff)
self.send_data(self.height& 0xff)
self.send_data(self.height & 0xff)
self.send_command(0x82) #vcom_DC setting
self.send_data(0x12)
self.send_command(0x82) # vcom_DC setting
self.send_data(0x28)
return 0
def SetFullReg(self):
self.send_command(0x82)
self.send_data(0x00)
self.send_command(0X50)
self.send_data(0x97)
self.send_command(0x20) # vcom
for count in range(0, 44):
self.send_data(self.lut_vcomDC[count])
self.send_command(0x21) # ww --
for count in range(0, 42):
self.send_data(self.lut_ww[count])
self.send_command(0x22) # bw r
for count in range(0, 42):
self.send_data(self.lut_bw[count])
self.send_command(0x23) # wb w
for count in range(0, 42):
self.send_data(self.lut_wb[count])
self.send_command(0x24) # bb b
for count in range(0, 42):
self.send_data(self.lut_bb[count])
def SetPartReg(self):
self.send_command(0x82)
self.send_data(0x03)
self.send_command(0X50)
self.send_data(0x47)
self.send_command(0x20) # vcom
for count in range(0, 44):
self.send_data(self.lut_vcom1[count])
@ -296,7 +247,6 @@ class EPD:
self.send_data(image[i])
epdconfig.delay_ms(10)
self.SetFullReg()
self.TurnOnDisplay()
def DisplayPartial(self, image):
@ -335,7 +285,6 @@ class EPD:
self.send_data(0xFF)
epdconfig.delay_ms(10)
self.SetFullReg()
self.TurnOnDisplay()
def sleep(self):

View file

@ -202,11 +202,19 @@ class EPD:
# Hardware reset
def reset(self):
epdconfig.digital_write(self.reset_pin, 1)
epdconfig.delay_ms(200)
epdconfig.delay_ms(20)
epdconfig.digital_write(self.reset_pin, 0)
epdconfig.delay_ms(5)
epdconfig.digital_write(self.reset_pin, 1)
epdconfig.delay_ms(200)
epdconfig.delay_ms(20)
epdconfig.digital_write(self.reset_pin, 0)
epdconfig.delay_ms(5)
epdconfig.digital_write(self.reset_pin, 1)
epdconfig.delay_ms(20)
epdconfig.digital_write(self.reset_pin, 0)
epdconfig.delay_ms(5)
epdconfig.digital_write(self.reset_pin, 1)
epdconfig.delay_ms(20)
def send_command(self, command):
epdconfig.digital_write(self.dc_pin, 0)

View file

@ -109,7 +109,7 @@ class EPD:
self.send_data(0x1D)
self.send_command(0x30)
self.send_data(0x3c)
self.send_command(0x40)
self.send_command(0x41)
self.send_data(0x00)
self.send_command(0x50)
self.send_data(0x37)

Binary file not shown.

After

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 750 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 750 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 59 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 788 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 788 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 788 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 788 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 788 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 788 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 788 KiB

After

Width:  |  Height:  |  Size: 788 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 788 KiB

File diff suppressed because one or more lines are too long

View file

@ -244,7 +244,7 @@
<Group>
<GroupName>Application/MDK-ARM</GroupName>
<tvExp>1</tvExp>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>

View file

@ -3,7 +3,7 @@
<title>Static Call Graph - [epd-demo\epd-demo.axf]</title></head>
<body><HR>
<H1>Static Call Graph for image epd-demo\epd-demo.axf</H1><HR>
<BR><P>#&#060CALLGRAPH&#062# ARM Linker, 5060750: Last Updated: Mon Feb 22 15:54:10 2021
<BR><P>#&#060CALLGRAPH&#062# ARM Linker, 5060750: Last Updated: Thu Mar 18 17:52:13 2021
<BR><P>
<H3>Maximum Stack Usage = 136 bytes + Unknown(Cycles, Untraceable Function Pointers)</H3><H3>
Call chain for Maximum Stack Depth:</H3>

View file

@ -1159,7 +1159,7 @@ Removing Unused input sections from the image.
Removing epd_2in9d_test.o(.rev16_text), (4 bytes).
Removing epd_2in9d_test.o(.revsh_text), (4 bytes).
Removing epd_2in9d_test.o(.rrx_text), (6 bytes).
Removing epd_2in9d_test.o(.text), (1048 bytes).
Removing epd_2in9d_test.o(.text), (1068 bytes).
Removing epd_2in13_test.o(.rev16_text), (4 bytes).
Removing epd_2in13_test.o(.revsh_text), (4 bytes).
Removing epd_2in13_test.o(.rrx_text), (6 bytes).
@ -1319,8 +1319,8 @@ Removing Unused input sections from the image.
Removing epd_2in9d.o(.rev16_text), (4 bytes).
Removing epd_2in9d.o(.revsh_text), (4 bytes).
Removing epd_2in9d.o(.rrx_text), (6 bytes).
Removing epd_2in9d.o(.text), (1044 bytes).
Removing epd_2in9d.o(.constdata), (424 bytes).
Removing epd_2in9d.o(.text), (1012 bytes).
Removing epd_2in9d.o(.constdata), (212 bytes).
Removing epd_2in13.o(.rev16_text), (4 bytes).
Removing epd_2in13.o(.revsh_text), (4 bytes).
Removing epd_2in13.o(.rrx_text), (6 bytes).
@ -1365,7 +1365,7 @@ Removing Unused input sections from the image.
Removing epd_4in2.o(.rev16_text), (4 bytes).
Removing epd_4in2.o(.revsh_text), (4 bytes).
Removing epd_4in2.o(.rrx_text), (6 bytes).
Removing epd_4in2.o(.text), (1732 bytes).
Removing epd_4in2.o(.text), (1796 bytes).
Removing epd_4in2.o(.constdata), (634 bytes).
Removing epd_4in2bc.o(.rev16_text), (4 bytes).
Removing epd_4in2bc.o(.revsh_text), (4 bytes).
@ -1450,7 +1450,7 @@ Removing Unused input sections from the image.
Removing cdrcmple.o(.text), (48 bytes).
Removing depilogue.o(.text), (186 bytes).
458 unused section(s) (total 964795 bytes) removed from the image.
458 unused section(s) (total 964635 bytes) removed from the image.
==============================================================================

View file

@ -127,14 +127,14 @@ int EPD_2in9d_test(void)
#endif
printf("Clear...\r\n");
// EPD_2IN9D_Init();
EPD_2IN9D_Init();
EPD_2IN9D_Clear();
DEV_Delay_ms(2000);//important, at least 2s
printf("Goto Sleep...\r\n");
EPD_2IN9D_Sleep();
free(BlackImage);
BlackImage = NULL;
DEV_Delay_ms(2000);//important, at least 2s
// close 5V
printf("close 5V, Module enters 0 power consumption ...\r\n");
DEV_Module_Exit();

View file

@ -4,8 +4,8 @@
* | Function : 2.9inch e-paper d
* | Info :
*----------------
* | This version: V2.0
* | Date : 2019-06-12
* | This version: V3.1
* | Date : 2021-03-18
* | Info :
* -----------------------------------------------------------------------------
* V3.0(2019-06-12):
@ -54,57 +54,6 @@
#include "EPD_2in9d.h"
#include "Debug.h"
/**
* full screen update LUT
**/
const unsigned char EPD_2IN9D_lut_vcomDC[] = {
0x00, 0x08, 0x00, 0x00, 0x00, 0x02,
0x60, 0x28, 0x28, 0x00, 0x00, 0x01,
0x00, 0x14, 0x00, 0x00, 0x00, 0x01,
0x00, 0x12, 0x12, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00,
};
const unsigned char EPD_2IN9D_lut_ww[] = {
0x40, 0x08, 0x00, 0x00, 0x00, 0x02,
0x90, 0x28, 0x28, 0x00, 0x00, 0x01,
0x40, 0x14, 0x00, 0x00, 0x00, 0x01,
0xA0, 0x12, 0x12, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const unsigned char EPD_2IN9D_lut_bw[] = {
0x40, 0x17, 0x00, 0x00, 0x00, 0x02,
0x90, 0x0F, 0x0F, 0x00, 0x00, 0x03,
0x40, 0x0A, 0x01, 0x00, 0x00, 0x01,
0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const unsigned char EPD_2IN9D_lut_wb[] = {
0x80, 0x08, 0x00, 0x00, 0x00, 0x02,
0x90, 0x28, 0x28, 0x00, 0x00, 0x01,
0x80, 0x14, 0x00, 0x00, 0x00, 0x01,
0x50, 0x12, 0x12, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const unsigned char EPD_2IN9D_lut_bb[] = {
0x80, 0x08, 0x00, 0x00, 0x00, 0x02,
0x90, 0x28, 0x28, 0x00, 0x00, 0x01,
0x80, 0x14, 0x00, 0x00, 0x00, 0x01,
0x50, 0x12, 0x12, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
/**
* partial screen update LUT
**/
@ -163,11 +112,19 @@ parameter:
static void EPD_2IN9D_Reset(void)
{
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
DEV_Delay_ms(20);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(2);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
DEV_Delay_ms(20);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(2);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(20);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(2);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(20);
}
/******************************************************************************
@ -209,56 +166,48 @@ void EPD_2IN9D_ReadBusy(void)
busy = DEV_Digital_Read(EPD_BUSY_PIN);
busy =!(busy & 0x01);
} while(busy);
DEV_Delay_ms(200);
DEV_Delay_ms(20);
Debug("e-Paper busy release\r\n");
}
/******************************************************************************
function : LUT download
parameter:
******************************************************************************/
static void EPD_SetFullReg(void)
{
EPD_2IN9D_SendCommand(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_2IN9D_SendData(0xb7); //WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7
unsigned int count;
EPD_2IN9D_SendCommand(0x20);
for(count=0; count<44; count++) {
EPD_2IN9D_SendData(EPD_2IN9D_lut_vcomDC[count]);
}
EPD_2IN9D_SendCommand(0x21);
for(count=0; count<42; count++) {
EPD_2IN9D_SendData(EPD_2IN9D_lut_ww[count]);
}
EPD_2IN9D_SendCommand(0x22);
for(count=0; count<42; count++) {
EPD_2IN9D_SendData(EPD_2IN9D_lut_bw[count]);
}
EPD_2IN9D_SendCommand(0x23);
for(count=0; count<42; count++) {
EPD_2IN9D_SendData(EPD_2IN9D_lut_wb[count]);
}
EPD_2IN9D_SendCommand(0x24);
for(count=0; count<42; count++) {
EPD_2IN9D_SendData(EPD_2IN9D_lut_bb[count]);
}
}
/******************************************************************************
function : LUT download
parameter:
******************************************************************************/
static void EPD_2IN9D_SetPartReg(void)
{
EPD_2IN9D_SendCommand(0x82); //vcom_DC setting
EPD_2IN9D_SendCommand(0x01); //POWER SETTING
EPD_2IN9D_SendData(0x03);
EPD_2IN9D_SendData(0x00);
EPD_2IN9D_SendData(0x2b);
EPD_2IN9D_SendData(0x2b);
EPD_2IN9D_SendData(0x03);
EPD_2IN9D_SendCommand(0x06); //boost soft start
EPD_2IN9D_SendData(0x17); //A
EPD_2IN9D_SendData(0x17); //B
EPD_2IN9D_SendData(0x17); //C
EPD_2IN9D_SendCommand(0x04);
EPD_2IN9D_ReadBusy();
EPD_2IN9D_SendCommand(0x00); //panel setting
EPD_2IN9D_SendData(0xbf); //LUT from OTP128x296
EPD_2IN9D_SendCommand(0x30); //PLL setting
EPD_2IN9D_SendData(0x3a); // 3a 100HZ 29 150Hz 39 200HZ 31 171HZ
EPD_2IN9D_SendCommand(0x61); //resolution setting
EPD_2IN9D_SendData(EPD_2IN9D_WIDTH);
EPD_2IN9D_SendData((EPD_2IN9D_HEIGHT >> 8) & 0xff);
EPD_2IN9D_SendData(EPD_2IN9D_HEIGHT & 0xff);
EPD_2IN9D_SendCommand(0x82); //vcom_DC setting
EPD_2IN9D_SendData(0x12);
EPD_2IN9D_SendCommand(0X50);
EPD_2IN9D_SendData(0xb7);
EPD_2IN9D_SendData(0x97);
unsigned int count;
EPD_2IN9D_SendCommand(0x20);
@ -306,36 +255,20 @@ parameter:
void EPD_2IN9D_Init(void)
{
EPD_2IN9D_Reset();
EPD_2IN9D_SendCommand(0x04);
EPD_2IN9D_ReadBusy();//waiting for the electronic paper IC to release the idle signal
EPD_2IN9D_SendCommand(0x01); //POWER SETTING
EPD_2IN9D_SendData(0x03);
EPD_2IN9D_SendData(0x00);
EPD_2IN9D_SendData(0x2b);
EPD_2IN9D_SendData(0x2b);
EPD_2IN9D_SendData(0x03);
EPD_2IN9D_SendCommand(0x00); //panel setting
EPD_2IN9D_SendData(0x1f); //LUT from OTPKW-BF KWR-AF BWROTP 0f BWOTP 1f
EPD_2IN9D_SendCommand(0x06); //boost soft start
EPD_2IN9D_SendData(0x17); //A
EPD_2IN9D_SendData(0x17); //B
EPD_2IN9D_SendData(0x17); //C
EPD_2IN9D_SendCommand(0x61); //resolution setting
EPD_2IN9D_SendData (0x80);
EPD_2IN9D_SendData (0x01);
EPD_2IN9D_SendData (0x28);
EPD_2IN9D_SendCommand(0x04);
EPD_2IN9D_ReadBusy();
EPD_2IN9D_SendCommand(0x00); //panel setting
EPD_2IN9D_SendData(0xbf); //LUT from OTP128x296
EPD_2IN9D_SendData(0x0e); //VCOM to 0V fast
EPD_2IN9D_SendCommand(0x30); //PLL setting
EPD_2IN9D_SendData(0x3a); // 3a 100HZ 29 150Hz 39 200HZ 31 171HZ
EPD_2IN9D_SendCommand(0x61); //resolution setting
EPD_2IN9D_SendData(EPD_2IN9D_WIDTH);
EPD_2IN9D_SendData((EPD_2IN9D_HEIGHT >> 8) & 0xff);
EPD_2IN9D_SendData(EPD_2IN9D_HEIGHT & 0xff);
EPD_2IN9D_SendCommand(0x82); //vcom_DC setting
EPD_2IN9D_SendData(0x28);
EPD_2IN9D_SendCommand(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_2IN9D_SendData(0x97); //WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7
}
/******************************************************************************
@ -361,8 +294,6 @@ void EPD_2IN9D_Clear(void)
EPD_2IN9D_SendData(0xFF);
}
}
EPD_SetFullReg();
EPD_2IN9D_TurnOnDisplay();
}
@ -382,7 +313,6 @@ void EPD_2IN9D_Display(UBYTE *Image)
EPD_2IN9D_SendData(0x00);
}
}
// Dev_Delay_ms(10);
EPD_2IN9D_SendCommand(0x13);
for (UWORD j = 0; j < Height; j++) {
@ -390,9 +320,7 @@ void EPD_2IN9D_Display(UBYTE *Image)
EPD_2IN9D_SendData(Image[i + j * Width]);
}
}
// Dev_Delay_ms(10);
EPD_SetFullReg();
EPD_2IN9D_TurnOnDisplay();
}
@ -430,7 +358,6 @@ void EPD_2IN9D_DisplayPart(UBYTE *Image)
EPD_2IN9D_TurnOnDisplay();
}
/******************************************************************************
function : Enter sleep mode
parameter:

View file

@ -271,11 +271,19 @@ parameter:
static void EPD_4IN2_Reset(void)
{
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
DEV_Delay_ms(20);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(2);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
DEV_Delay_ms(20);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(2);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(20);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(2);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(20);
}
/******************************************************************************

View file

@ -105,7 +105,7 @@ void EPD_5IN65F_Init(void)
EPD_5IN65F_SendData(0x1D);
EPD_5IN65F_SendCommand(0x30);
EPD_5IN65F_SendData(0x3C);
EPD_5IN65F_SendCommand(0x40);
EPD_5IN65F_SendCommand(0x41);
EPD_5IN65F_SendData(0x00);
EPD_5IN65F_SendCommand(0x50);
EPD_5IN65F_SendData(0x37);