add 4.01f demo

This commit is contained in:
SSYYL 2021-01-05 15:21:46 +08:00
commit 7b958776c8
52 changed files with 11250 additions and 1902 deletions

View file

@ -0,0 +1,110 @@
/*****************************************************************************
* | File : EPD_4IN01F_test.c
* | Author : Waveshare team
* | Function : 4.01inch F e-paper test demo
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-12-25
* | 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_4IN01F.h"
#include "EPD_Test.h"
int EPD_4in01f_test(void)
{
printf("EPD_4in01f_test Demo\r\n");
if(DEV_Module_Init()!=0){
return -1;
}
printf("e-Paper Init and Clear...\r\n");
EPD_4IN01F_Init();
EPD_4IN01F_Clear(EPD_4IN01F_WHITE);
DEV_Delay_ms(100);
UBYTE *BlackImage;
/* you have to edit the startup_stm32fxxx.s file and set a big enough heap size */
UDOUBLE Imagesize = ((EPD_4IN01F_WIDTH % 2 == 0)? (EPD_4IN01F_WIDTH / 2 ): (EPD_4IN01F_WIDTH / 2 + 1)) * EPD_4IN01F_HEIGHT;
Imagesize = Imagesize/4;
printf("Not enough memory, only part of the window is displayed\r\n");
printf("Imagesize %d\r\n",Imagesize);
if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
printf("Failed to apply for black memory...\r\n");
return -1;
}
Paint_NewImage(BlackImage, EPD_4IN01F_WIDTH/2, EPD_4IN01F_HEIGHT/2, 0, EPD_4IN01F_WHITE);
Paint_SetScale(7);
#if 1
EPD_4IN01F_Display(gImage_4in01);
DEV_Delay_ms(5000);
#endif
#if 1
Paint_Clear(EPD_4IN01F_WHITE);
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(10, 120, "ÄãºÃabc", &Font12CN, EPD_4IN01F_BLACK, WHITE);
Paint_DrawString_CN(10, 140, "ÄãºÃabc", &Font12CN, EPD_4IN01F_GREEN, WHITE);
Paint_DrawString_CN(10, 160, "ÄãºÃabc", &Font12CN, EPD_4IN01F_BLUE, WHITE);
Paint_DrawString_CN(10, 180, "ÄãºÃabc", &Font12CN, EPD_4IN01F_RED, WHITE);
Paint_DrawString_CN(10, 200, "ÄãºÃabc", &Font12CN, EPD_4IN01F_ORANGE, WHITE);
Paint_DrawString_CN(150, 0, "΢ѩµç×Ó", &Font24CN, WHITE, BLACK);
Paint_DrawString_CN(150, 40, "΢ѩµç×Ó", &Font24CN, EPD_4IN01F_GREEN, BLACK);
Paint_DrawString_CN(150, 80, "΢ѩµç×Ó", &Font24CN, EPD_4IN01F_BLUE, BLACK);
Paint_DrawString_CN(150, 120, "΢ѩµç×Ó", &Font24CN, EPD_4IN01F_RED, BLACK);
Paint_DrawString_CN(150, 160, "΢ѩµç×Ó", &Font24CN, EPD_4IN01F_YELLOW, BLACK);
EPD_4IN01F_Display_part(BlackImage, 0, 0, 320, 200);
DEV_Delay_ms(5000);
#endif
printf("e-Paper Clear...\r\n");
EPD_4IN01F_Clear(EPD_4IN01F_WHITE);
DEV_Delay_ms(1000);
EPD_4IN01F_Sleep();
free(BlackImage);
BlackImage = NULL;
// close 5V
printf("close 5V, Module enters 0 power consumption ...\r\n");
DEV_Module_Exit();
return 0;
}

View file

@ -37,10 +37,10 @@ int EPD_5in65f_test(void)
return -1;
}
printf("e-Paper Init and Clear...\r\n");
printf("e-Paper Init and Clear...\r\n");
EPD_5IN65F_Init();
EPD_5IN65F_Clear(EPD_5IN65F_WHITE);
DEV_Delay_ms(100);
DEV_Delay_ms(100);
UBYTE *BlackImage;
/* you have to edit the startup_stm32fxxx.s file and set a big enough heap size */

View file

@ -64,6 +64,8 @@ int EPD_2in66b_test(void);
int EPD_3in7_test(void);
int EPD_4in01f_test(void);
int EPD_4in2_test(void);
int EPD_4in2bc_test(void);
int EPD_4in2b_V2_test(void);

File diff suppressed because it is too large Load diff

View file

@ -64,6 +64,8 @@ extern const unsigned char gImage_2in66br[];
extern const unsigned char gImage_3in7[]; //4 Gray
extern const unsigned char gImage_4in01[];
extern const unsigned char gImage_4in2[];
extern const unsigned char gImage_4in2_4Gray[];
extern const unsigned char gImage_4in2bc_b[];

View file

@ -0,0 +1,216 @@
/*****************************************************************************
* | File : EPD_4IN01F.c
* | Author : Waveshare team
* | Function : 4.01inch e-paper
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-12-25
* | 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_4in01f.h"
/******************************************************************************
function : Software reset
parameter:
******************************************************************************/
static void EPD_4IN01F_Reset(void)
{
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(1);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
}
/******************************************************************************
function : send command
parameter:
Reg : Command register
******************************************************************************/
static void EPD_4IN01F_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_4IN01F_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);
}
static void EPD_4IN01F_BusyHigh(void)// If BUSYN=0 then waiting
{
while(!(DEV_Digital_Read(EPD_BUSY_PIN)));
}
static void EPD_4IN01F_BusyLow(void)// If BUSYN=1 then waiting
{
while(DEV_Digital_Read(EPD_BUSY_PIN));
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
void EPD_4IN01F_Init(void)
{
EPD_4IN01F_Reset();
EPD_4IN01F_BusyHigh();
EPD_4IN01F_SendCommand(0x00);
EPD_4IN01F_SendData(0x2f);
EPD_4IN01F_SendData(0x00);
EPD_4IN01F_SendCommand(0x01);
EPD_4IN01F_SendData(0x37);
EPD_4IN01F_SendData(0x00);
EPD_4IN01F_SendData(0x05);
EPD_4IN01F_SendData(0x05);
EPD_4IN01F_SendCommand(0x03);
EPD_4IN01F_SendData(0x00);
EPD_4IN01F_SendCommand(0x06);
EPD_4IN01F_SendData(0xC7);
EPD_4IN01F_SendData(0xC7);
EPD_4IN01F_SendData(0x1D);
EPD_4IN01F_SendCommand(0x41);
EPD_4IN01F_SendData(0x00);
EPD_4IN01F_SendCommand(0x50);
EPD_4IN01F_SendData(0x37);
EPD_4IN01F_SendCommand(0x60);
EPD_4IN01F_SendData(0x22);
EPD_4IN01F_SendCommand(0x61);
EPD_4IN01F_SendData(0x02);
EPD_4IN01F_SendData(0x80);
EPD_4IN01F_SendData(0x01);
EPD_4IN01F_SendData(0x90);
EPD_4IN01F_SendCommand(0xE3);
EPD_4IN01F_SendData(0xAA);
}
/******************************************************************************
function : Clear screen
parameter:
******************************************************************************/
void EPD_4IN01F_Clear(UBYTE color)
{
EPD_4IN01F_SendCommand(0x61);//Set Resolution setting
EPD_4IN01F_SendData(0x02);
EPD_4IN01F_SendData(0x80);
EPD_4IN01F_SendData(0x01);
EPD_4IN01F_SendData(0x90);
EPD_4IN01F_SendCommand(0x10);
for(int i=0; i<EPD_4IN01F_WIDTH/2; i++) {
for(int j=0; j<EPD_4IN01F_HEIGHT; j++)
EPD_4IN01F_SendData((color<<4)|color);
}
EPD_4IN01F_SendCommand(0x04);//0x04
EPD_4IN01F_BusyHigh();
EPD_4IN01F_SendCommand(0x12);//0x12
EPD_4IN01F_BusyHigh();
EPD_4IN01F_SendCommand(0x02); //0x02
EPD_4IN01F_BusyLow();
DEV_Delay_ms(500);
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void EPD_4IN01F_Display(const UBYTE *image)
{
unsigned long i,j;
EPD_4IN01F_SendCommand(0x61);//Set Resolution setting
EPD_4IN01F_SendData(0x02);
EPD_4IN01F_SendData(0x80);
EPD_4IN01F_SendData(0x01);
EPD_4IN01F_SendData(0x90);
EPD_4IN01F_SendCommand(0x10);
for(i=0; i<EPD_4IN01F_HEIGHT; i++) {
for(j=0; j<EPD_4IN01F_WIDTH/2; j++)
EPD_4IN01F_SendData(image[j+((EPD_4IN01F_WIDTH/2)*i)]);
}
EPD_4IN01F_SendCommand(0x04);//0x04
EPD_4IN01F_BusyHigh();
EPD_4IN01F_SendCommand(0x12);//0x12
EPD_4IN01F_BusyHigh();
EPD_4IN01F_SendCommand(0x02); //0x02
EPD_4IN01F_BusyLow();
DEV_Delay_ms(200);
}
/******************************************************************************
function : Sends the part image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void EPD_4IN01F_Display_part(const UBYTE *image, UWORD xstart, UWORD ystart,
UWORD image_width, UWORD image_heigh)
{
unsigned long i,j;
EPD_4IN01F_SendCommand(0x61);//Set Resolution setting
EPD_4IN01F_SendData(0x02);
EPD_4IN01F_SendData(0x80);
EPD_4IN01F_SendData(0x01);
EPD_4IN01F_SendData(0x90);
EPD_4IN01F_SendCommand(0x10);
for(i=0; i<EPD_4IN01F_HEIGHT; i++) {
for(j=0; j< EPD_4IN01F_WIDTH/2; j++) {
if(i<image_heigh+ystart && i>=ystart && j<(image_width+xstart)/2 && j>=xstart/2) {
EPD_4IN01F_SendData(image[(j-xstart/2) + (image_width/2*(i-ystart))]);
}
else {
EPD_4IN01F_SendData(0x11);
}
}
}
EPD_4IN01F_SendCommand(0x04);//0x04
EPD_4IN01F_BusyHigh();
EPD_4IN01F_SendCommand(0x12);//0x12
EPD_4IN01F_BusyHigh();
EPD_4IN01F_SendCommand(0x02); //0x02
EPD_4IN01F_BusyLow();
DEV_Delay_ms(200);
}
/******************************************************************************
function : Enter sleep mode
parameter:
******************************************************************************/
void EPD_4IN01F_Sleep(void)
{
DEV_Delay_ms(100);
EPD_4IN01F_SendCommand(0x07);
EPD_4IN01F_SendData(0xA5);
}

View file

@ -0,0 +1,60 @@
/*****************************************************************************
* | File : EPD_4IN01F.h
* | Author : Waveshare team
* | Function : 4.01inch e-paper
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-12-25
* | 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_4IN01F_H__
#define __EPD_4IN01F_H__
#include "DEV_Config.h"
/**********************************
Color Index
**********************************/
#define EPD_4IN01F_BLACK 0x0 /// 000
#define EPD_4IN01F_WHITE 0x1 /// 001
#define EPD_4IN01F_GREEN 0x2 /// 010
#define EPD_4IN01F_BLUE 0x3 /// 011
#define EPD_4IN01F_RED 0x4 /// 100
#define EPD_4IN01F_YELLOW 0x5 /// 101
#define EPD_4IN01F_ORANGE 0x6 /// 110
#define EPD_4IN01F_CLEAN 0x7 /// 111 unavailable Afterimage
#define EPD_4IN01F_WIDTH 640
#define EPD_4IN01F_HEIGHT 400
void EPD_4IN01F_Clear(UBYTE color);
void EPD_4IN01F_Sleep(void);
void EPD_4IN01F_Display(const UBYTE *image);
void EPD_4IN01F_Init(void);
void EPD_4IN01F_Display_part(const UBYTE *image, UWORD xstart, UWORD ystart, UWORD image_width, UWORD image_heigh);
#endif

View file

@ -40,7 +40,7 @@ static void EPD_4IN2B_V2_Reset(void)
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(5);
DEV_Delay_ms(2);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
}

View file

@ -149,46 +149,6 @@ void EPD_5IN65F_Clear(UBYTE color)
DEV_Delay_ms(500);
}
/******************************************************************************
function : show 7 kind of color block
parameter:
******************************************************************************/
void EPD_5IN65F_Show7Block(void)
{
unsigned long i,j,k;
unsigned char const Color_seven[8] =
{EPD_5IN65F_BLACK,EPD_5IN65F_BLUE,EPD_5IN65F_GREEN,EPD_5IN65F_ORANGE,
EPD_5IN65F_RED,EPD_5IN65F_YELLOW,EPD_5IN65F_WHITE,EPD_5IN65F_WHITE};
EPD_5IN65F_SendCommand(0x61);//Set Resolution setting
EPD_5IN65F_SendData(0x02);
EPD_5IN65F_SendData(0x58);
EPD_5IN65F_SendData(0x01);
EPD_5IN65F_SendData(0xC0);
EPD_5IN65F_SendCommand(0x10);
for(i=0; i<224; i++) {
for(k = 0 ; k < 4; k ++) {
for(j = 0 ; j < 75; j ++) {
EPD_5IN65F_SendData((Color_seven[k]<<4) |Color_seven[k]);
}
}
}
for(i=0; i<224; i++) {
for(k = 4 ; k < 8; k ++) {
for(j = 0 ; j < 75; j ++) {
EPD_5IN65F_SendData((Color_seven[k]<<4) |Color_seven[k]);
}
}
}
EPD_5IN65F_SendCommand(0x04);//0x04
EPD_5IN65F_BusyHigh();
EPD_5IN65F_SendCommand(0x12);//0x12
EPD_5IN65F_BusyHigh();
EPD_5IN65F_SendCommand(0x02); //0x02
EPD_5IN65F_BusyLow();
DEV_Delay_ms(200);
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:

View file

@ -49,7 +49,6 @@ Color Index
#define EPD_5IN65F_HEIGHT 448
void EPD_5IN65F_Clear(UBYTE color);
void EPD_5IN65F_Show7Block(void);
void EPD_5IN65F_Sleep(void);
void EPD_5IN65F_Display(const UBYTE *image);
void EPD_5IN65F_Init(void);