fix 2.9_V2 & 4.01f

This commit is contained in:
SSYYL 2021-01-26 14:35:45 +08:00
commit 7c368a22af
65 changed files with 4803 additions and 335 deletions

View file

@ -0,0 +1,241 @@
/*****************************************************************************
* | File : EPD_10in2b.c
* | Author : Waveshare team
* | Function : 10.2inch b e-paper test demo
* | Info :
*----------------
* | This version: V1.0
* | Date : 2021-01-20
* | 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_10in2b.h"
#include "Debug.h"
/******************************************************************************
function : Software reset
parameter:
******************************************************************************/
static void EPD_10IN2b_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_10IN2b_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_10IN2b_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_10IN2b_ReadBusy(void)
{
Debug("e-Paper busy\r\n");
while(1)
{ //=1 BUSY
if(DEV_Digital_Read(EPD_BUSY_PIN)==0)
break;
DEV_Delay_ms(20);
}
DEV_Delay_ms(20);
Debug("e-Paper busy release\r\n");
}
/******************************************************************************
function : Turn On Display
parameter:
******************************************************************************/
static void EPD_10IN2b_TurnOnDisplay(void)
{
EPD_10IN2b_SendCommand(0x22); //Display Update Control
EPD_10IN2b_SendData(0xC7);
EPD_10IN2b_SendCommand(0x20); //Activate Display Update Sequence
EPD_10IN2b_ReadBusy();
}
/******************************************************************************
function : Setting the display window
parameter:
******************************************************************************/
static void EPD_10IN2b_SetWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend)
{
EPD_10IN2b_SendCommand(0x44); // SET_RAM_X_ADDRESS_START_END_POSITION
EPD_10IN2b_SendData(Xstart & 0xFF);
EPD_10IN2b_SendData((Xstart>>8) & 0x03);
EPD_10IN2b_SendData(Xend & 0xFF);
EPD_10IN2b_SendData((Xend>>8) & 0x03);
EPD_10IN2b_SendCommand(0x45); // SET_RAM_Y_ADDRESS_START_END_POSITION
EPD_10IN2b_SendData(Ystart & 0xFF);
EPD_10IN2b_SendData((Ystart>>8) & 0x03);
EPD_10IN2b_SendData(Yend & 0xFF);
EPD_10IN2b_SendData((Yend>>8) & 0x03);
}
/******************************************************************************
function : Set Cursor
parameter:
******************************************************************************/
static void EPD_10IN2b_SetCursor(UWORD Xstart, UWORD Ystart)
{
EPD_10IN2b_SendCommand(0x4E); // SET_RAM_X_ADDRESS_COUNTER
EPD_10IN2b_SendData(Xstart & 0xFF);
EPD_10IN2b_SendData((Xstart>>8) & 0x03);
EPD_10IN2b_SendCommand(0x4F); // SET_RAM_Y_ADDRESS_COUNTER
EPD_10IN2b_SendData(Ystart & 0xFF);
EPD_10IN2b_SendData((Ystart>>8) & 0x03);
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
void EPD_10IN2b_Init(void)
{
EPD_10IN2b_Reset();
DEV_Delay_ms(100);
EPD_10IN2b_ReadBusy();
EPD_10IN2b_SendCommand(0x12); //SWRESET
EPD_10IN2b_ReadBusy();
EPD_10IN2b_SendCommand(0x0C); //set soft start
EPD_10IN2b_SendData(0xAE);
EPD_10IN2b_SendData(0xC7);
EPD_10IN2b_SendData(0xC3);
EPD_10IN2b_SendData(0xC0);
EPD_10IN2b_SendData(0x80);
EPD_10IN2b_SendCommand(0x01); // drive output control
EPD_10IN2b_SendData(0xA7); // Y
EPD_10IN2b_SendData(0x02); // Y
EPD_10IN2b_SendData(0x00);
EPD_10IN2b_SendCommand(0x11); // data entry mode
EPD_10IN2b_SendData(0x03); // X-mode x+ y-
EPD_10IN2b_SetWindows(0, 0, EPD_10IN2b_WIDTH-1, EPD_10IN2b_HEIGHT-1);
EPD_10IN2b_SendCommand(0x3C); // Border Border setting
EPD_10IN2b_SendData(0x01);
EPD_10IN2b_SendCommand(0x18); // use the internal temperature sensor
EPD_10IN2b_SendData(0x80);
EPD_10IN2b_SendCommand(0x22);
EPD_10IN2b_SendData(0xB1);
EPD_10IN2b_SendCommand(0x20);
EPD_10IN2b_SetCursor(0, 0);
EPD_10IN2b_ReadBusy();
}
/******************************************************************************
function : Clear screen
parameter:
******************************************************************************/
void EPD_10IN2b_Clear(void)
{
UWORD i, j;
UWORD height = EPD_10IN2b_HEIGHT;
UWORD width = EPD_10IN2b_WIDTH/8;
EPD_10IN2b_SendCommand(0x24); //write RAM for black(0)/white (1)
for(i=0; i<height; i++)
{
for(j=0; j<width; j++)
EPD_10IN2b_SendData(0xff);
}
EPD_10IN2b_SendCommand(0x26); //write RAM for black(0)/white (1)
for(i=0; i<height; i++)
{
for(j=0; j<width; j++)
EPD_10IN2b_SendData(0x00);
}
EPD_10IN2b_TurnOnDisplay();
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void EPD_10IN2b_Display(UBYTE *Image, UBYTE *RedImage)
{
UWORD i, j;
UWORD height = EPD_10IN2b_HEIGHT;
UWORD width = EPD_10IN2b_WIDTH/8;
EPD_10IN2b_SendCommand(0x24); //write RAM for black(0)/white (1)
for(i=0; i<height; i++)
{
for(j=0; j<width; j++)
EPD_10IN2b_SendData(Image[j + i*width]);
}
EPD_10IN2b_SendCommand(0x26); //write RAM for black(0)/white (1)
for(i=0; i<height; i++)
{
for(j=0; j<width; j++)
EPD_10IN2b_SendData(~RedImage[j + i*width]);
}
EPD_10IN2b_TurnOnDisplay();
}
/******************************************************************************
function : Enter sleep mode
parameter:
******************************************************************************/
void EPD_10IN2b_Sleep(void)
{
EPD_10IN2b_SendCommand(0x10); //enter deep sleep
EPD_10IN2b_SendData(0x01);
DEV_Delay_ms(100);
}

View file

@ -0,0 +1,45 @@
/*****************************************************************************
* | File : EPD_10in2b.h
* | Author : Waveshare team
* | Function : 10.2inch b e-paper test demo
* | Info :
*----------------
* | This version: V1.0
* | Date : 2021-01-20
* | 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_10IN2b_H_
#define __EPD_10IN2b_H_
#include "DEV_Config.h"
// Display resolution
#define EPD_10IN2b_WIDTH 960
#define EPD_10IN2b_HEIGHT 640
void EPD_10IN2b_Init(void);
void EPD_10IN2b_Clear(void);
void EPD_10IN2b_Display(UBYTE *Image, UBYTE *RedImage);
void EPD_10IN2b_Sleep(void);
#endif

View file

@ -0,0 +1,229 @@
/*****************************************************************************
* | File : EPD_13in3.c
* | Author : Waveshare team
* | Function : 13.3inch e-paper
* | Info :
*----------------
* | This version: V1.0
* | Date : 2021-01-20
* | 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_13in3.h"
#include "Debug.h"
/******************************************************************************
function : Software reset
parameter:
******************************************************************************/
static void EPD_13IN3_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_13IN3_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_13IN3_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_13IN3_ReadBusy(void)
{
Debug("e-Paper busy\r\n");
while(1)
{ //=1 BUSY
if(DEV_Digital_Read(EPD_BUSY_PIN)==0)
break;
DEV_Delay_ms(20);
}
DEV_Delay_ms(20);
Debug("e-Paper busy release\r\n");
}
/******************************************************************************
function : Turn On Display
parameter:
******************************************************************************/
static void EPD_13IN3_TurnOnDisplay(void)
{
EPD_13IN3_SendCommand(0x22); //Display Update Control
EPD_13IN3_SendData(0xC7);
EPD_13IN3_SendCommand(0x20); //Activate Display Update Sequence
EPD_13IN3_ReadBusy();
}
/******************************************************************************
function : Setting the display window
parameter:
******************************************************************************/
static void EPD_13IN3_SetWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend)
{
EPD_13IN3_SendCommand(0x44); // SET_RAM_X_ADDRESS_START_END_POSITION
EPD_13IN3_SendData(Xstart & 0xFF);
EPD_13IN3_SendData((Xstart>>8) & 0x03);
EPD_13IN3_SendData(Xend & 0xFF);
EPD_13IN3_SendData((Xend>>8) & 0x03);
EPD_13IN3_SendCommand(0x45); // SET_RAM_Y_ADDRESS_START_END_POSITION
EPD_13IN3_SendData(Ystart & 0xFF);
EPD_13IN3_SendData((Ystart>>8) & 0x03);
EPD_13IN3_SendData(Yend & 0xFF);
EPD_13IN3_SendData((Yend>>8) & 0x03);
}
/******************************************************************************
function : Set Cursor
parameter:
******************************************************************************/
static void EPD_13IN3_SetCursor(UWORD Xstart, UWORD Ystart)
{
EPD_13IN3_SendCommand(0x4E); // SET_RAM_X_ADDRESS_COUNTER
EPD_13IN3_SendData(Xstart & 0xFF);
EPD_13IN3_SendData((Xstart>>8) & 0x03);
EPD_13IN3_SendCommand(0x4F); // SET_RAM_Y_ADDRESS_COUNTER
EPD_13IN3_SendData(Ystart & 0xFF);
EPD_13IN3_SendData((Ystart>>8) & 0x03);
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
void EPD_13IN3_Init(void)
{
EPD_13IN3_Reset();
DEV_Delay_ms(100);
EPD_13IN3_ReadBusy();
EPD_13IN3_SendCommand(0x12); //SWRESET
EPD_13IN3_ReadBusy();
EPD_13IN3_SendCommand(0x0C); //set soft start
EPD_13IN3_SendData(0xAE);
EPD_13IN3_SendData(0xC7);
EPD_13IN3_SendData(0xC3);
EPD_13IN3_SendData(0xC0);
EPD_13IN3_SendData(0x80);
EPD_13IN3_SendCommand(0x01); // drive output control
EPD_13IN3_SendData(0xA7); // Y
EPD_13IN3_SendData(0x02); // Y
EPD_13IN3_SendData(0x00);
EPD_13IN3_SendCommand(0x11); // data entry mode
EPD_13IN3_SendData(0x03); // X-mode x+ y-
EPD_13IN3_SetWindows(0, 0, EPD_13IN3_WIDTH-1, EPD_13IN3_HEIGHT-1);
EPD_13IN3_SendCommand(0x3C); // Border Border setting
EPD_13IN3_SendData(0x01);
EPD_13IN3_SendCommand(0x18); // use the internal temperature sensor
EPD_13IN3_SendData(0x80);
EPD_13IN3_SendCommand(0x22);
EPD_13IN3_SendData(0xB1);
EPD_13IN3_SendCommand(0x20);
EPD_13IN3_SetCursor(0, 0);
EPD_13IN3_ReadBusy();
}
/******************************************************************************
function : Clear screen
parameter:
******************************************************************************/
void EPD_13IN3_Clear(void)
{
UWORD i, j;
UWORD height = EPD_13IN3_HEIGHT;
UWORD width = EPD_13IN3_WIDTH/8;
EPD_13IN3_SendCommand(0x24); //write RAM for black(0)/white (1)
for(i=0; i<height; i++)
{
for(j=0; j<width; j++)
EPD_13IN3_SendData(0xff);
}
EPD_13IN3_TurnOnDisplay();
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void EPD_13IN3_Display(UBYTE *Image)
{
UWORD i, j;
UWORD height = EPD_13IN3_HEIGHT;
UWORD width = EPD_13IN3_WIDTH/8;
EPD_13IN3_SendCommand(0x24); //write RAM for black(0)/white (1)
for(i=0; i<height; i++)
{
for(j=0; j<width; j++)
EPD_13IN3_SendData(Image[j + i*width]);
}
EPD_13IN3_TurnOnDisplay();
}
/******************************************************************************
function : Enter sleep mode
parameter:
******************************************************************************/
void EPD_13IN3_Sleep(void)
{
EPD_13IN3_SendCommand(0x10); //enter deep sleep
EPD_13IN3_SendData(0x03);
DEV_Delay_ms(100);
}

View file

@ -0,0 +1,45 @@
/*****************************************************************************
* | File : EPD_13in3.h
* | Author : Waveshare team
* | Function : 13.3inch e-paper
* | Info :
*----------------
* | This version: V1.0
* | Date : 2021-01-20
* | 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_13IN3_H_
#define __EPD_13IN3_H_
#include "DEV_Config.h"
// Display resolution
#define EPD_13IN3_WIDTH 960
#define EPD_13IN3_HEIGHT 680
void EPD_13IN3_Init(void);
void EPD_13IN3_Clear(void);
void EPD_13IN3_Display(UBYTE *Image);
void EPD_13IN3_Sleep(void);
#endif

View file

@ -0,0 +1,173 @@
/*****************************************************************************
* | File : EPD_1in54_DES.c
* | Author : Waveshare team
* | Function : 1.54inch DES e-paper
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-01-13
* | 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_1in54_DES.h"
#include "Debug.h"
/******************************************************************************
function : Software reset
parameter:
******************************************************************************/
static void EPD_1IN54_DES_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_1IN54_DES_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_1IN54_DES_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_1IN54_DES_ReadBusy(void)
{
Debug("e-Paper busy\r\n");
while(1)
{ //=1 BUSY
EPD_1IN54_DES_SendCommand(0x71);
if(DEV_Digital_Read(EPD_BUSY_PIN)==1)
break;
DEV_Delay_ms(50);
}
DEV_Delay_ms(50);
Debug("e-Paper busy release\r\n");
}
/******************************************************************************
function : Turn On Display
parameter:
******************************************************************************/
static void EPD_1IN54_DES_TurnOnDisplay(void)
{
EPD_1IN54_DES_SendCommand(0x12); //Display Update Control
EPD_1IN54_DES_ReadBusy();
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
void EPD_1IN54_DES_Init(void)
{
EPD_1IN54_DES_Reset();
DEV_Delay_ms(100);
EPD_1IN54_DES_SendCommand(0x04); //SWRESET
EPD_1IN54_DES_ReadBusy();
EPD_1IN54_DES_SendCommand(0x00); //Driver output control
EPD_1IN54_DES_SendData(0x1f);
EPD_1IN54_DES_SendCommand(0x50);
EPD_1IN54_DES_SendData(0x97);
}
/******************************************************************************
function : Clear screen
parameter:
******************************************************************************/
void EPD_1IN54_DES_Clear(void)
{
UWORD i;
// EPD_1IN54_DES_SendCommand(0x10);
// for(i=0;i<2888;i++)
// {
// EPD_1IN54_DES_SendData(0xff);
// }
EPD_1IN54_DES_SendCommand(0x13);
for(i=0;i<2888;i++)
{
EPD_1IN54_DES_SendData(0xff);
}
EPD_1IN54_DES_TurnOnDisplay();
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void EPD_1IN54_DES_Display(UBYTE *Image)
{
UWORD i;
// EPD_1IN54_DES_SendCommand(0x10);
// for(i=0;i<2888;i++)
// {
// EPD_1IN54_DES_SendData(0xff);
// }
EPD_1IN54_DES_SendCommand(0x13);
for(i=0;i<2888;i++)
{
EPD_1IN54_DES_SendData(Image[i]);
}
EPD_1IN54_DES_TurnOnDisplay();
}
/******************************************************************************
function : Enter sleep mode
parameter:
******************************************************************************/
void EPD_1IN54_DES_Sleep(void)
{
EPD_1IN54_DES_SendCommand(0x50); //enter deep sleep
EPD_1IN54_DES_SendData(0xf7);
EPD_1IN54_DES_SendCommand(0x02);
EPD_1IN54_DES_ReadBusy();
EPD_1IN54_DES_SendCommand(0x07);
EPD_1IN54_DES_SendData(0xa5);
}

View file

@ -0,0 +1,45 @@
/*****************************************************************************
* | File : EPD_1in54_DES.h
* | Author : Waveshare team
* | Function : 1.54inch DES e-paper
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-01-13
* | 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_1IN54_DES_H_
#define __EPD_1IN54_DES_H_
#include "DEV_Config.h"
// Display resolution
#define EPD_1IN54_DES_WIDTH 152
#define EPD_1IN54_DES_HEIGHT 152
void EPD_1IN54_DES_Init(void);
void EPD_1IN54_DES_Clear(void);
void EPD_1IN54_DES_Display(UBYTE *Image);
void EPD_1IN54_DES_Sleep(void);
#endif

View file

@ -0,0 +1,173 @@
/*****************************************************************************
* | File : EPD_2in13_DES.c
* | Author : Waveshare team
* | Function : 2.13inch DES e-paper
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-01-13
* | 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_2in13_DES.h"
#include "Debug.h"
/******************************************************************************
function : Software reset
parameter:
******************************************************************************/
static void EPD_2IN13_DES_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_2IN13_DES_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_2IN13_DES_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_2IN13_DES_ReadBusy(void)
{
Debug("e-Paper busy\r\n");
while(1)
{ //=1 BUSY
EPD_2IN13_DES_SendCommand(0x71);
if(DEV_Digital_Read(EPD_BUSY_PIN)==1)
break;
DEV_Delay_ms(50);
}
DEV_Delay_ms(50);
Debug("e-Paper busy release\r\n");
}
/******************************************************************************
function : Turn On Display
parameter:
******************************************************************************/
static void EPD_2IN13_DES_TurnOnDisplay(void)
{
EPD_2IN13_DES_SendCommand(0x12); //Display Update Control
EPD_2IN13_DES_ReadBusy();
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
void EPD_2IN13_DES_Init(void)
{
EPD_2IN13_DES_Reset();
DEV_Delay_ms(100);
EPD_2IN13_DES_SendCommand(0x04); //SWRESET
EPD_2IN13_DES_ReadBusy();
EPD_2IN13_DES_SendCommand(0x00); //Driver output control
EPD_2IN13_DES_SendData(0x1f);
EPD_2IN13_DES_SendCommand(0x50);
EPD_2IN13_DES_SendData(0x97);
}
/******************************************************************************
function : Clear screen
parameter:
******************************************************************************/
void EPD_2IN13_DES_Clear(void)
{
UWORD i;
// EPD_2IN13_DES_SendCommand(0x10);
// for(i=0;i<2756;i++)
// {
// EPD_2IN13_DES_SendData(0xff);
// }
EPD_2IN13_DES_SendCommand(0x13);
for(i=0;i<2756;i++)
{
EPD_2IN13_DES_SendData(0xff);
}
EPD_2IN13_DES_TurnOnDisplay();
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void EPD_2IN13_DES_Display(UBYTE *Image)
{
UWORD i;
// EPD_2IN13_DES_SendCommand(0x10);
// for(i=0;i<2756;i++)
// {
// EPD_2IN13_DES_SendData(0xff);
// }
EPD_2IN13_DES_SendCommand(0x13);
for(i=0;i<2756;i++)
{
EPD_2IN13_DES_SendData(Image[i]);
}
EPD_2IN13_DES_TurnOnDisplay();
}
/******************************************************************************
function : Enter sleep mode
parameter:
******************************************************************************/
void EPD_2IN13_DES_Sleep(void)
{
EPD_2IN13_DES_SendCommand(0x50); //enter deep sleep
EPD_2IN13_DES_SendData(0xf7);
EPD_2IN13_DES_SendCommand(0x02);
EPD_2IN13_DES_ReadBusy();
EPD_2IN13_DES_SendCommand(0x07);
EPD_2IN13_DES_SendData(0xa5);
}

View file

@ -0,0 +1,45 @@
/*****************************************************************************
* | File : EPD_2in13_DES.h
* | Author : Waveshare team
* | Function : 2.13inch DES e-paper
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-01-13
* | 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_2IN13_DES_H_
#define __EPD_2IN13_DES_H_
#include "DEV_Config.h"
// Display resolution
#define EPD_2IN13_DES_WIDTH 104
#define EPD_2IN13_DES_HEIGHT 212
void EPD_2IN13_DES_Init(void);
void EPD_2IN13_DES_Clear(void);
void EPD_2IN13_DES_Display(UBYTE *Image);
void EPD_2IN13_DES_Sleep(void);
#endif

View file

@ -114,15 +114,17 @@ parameter:
******************************************************************************/
static void EPD_2in13_V3_SetWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend)
{
// Ystart = 295 - Ystart;
EPD_2in13_V3_SendCommand(0x44); // SET_RAM_X_ADDRESS_START_END_POSITION
EPD_2in13_V3_SendData((Xstart>>3) & 0xFF);
EPD_2in13_V3_SendData((Xend>>3) & 0xFF);
EPD_2in13_V3_SendCommand(0x45); // SET_RAM_Y_ADDRESS_START_END_POSITION
EPD_2in13_V3_SendData(Ystart & 0xFF);
EPD_2in13_V3_SendData((Ystart >> 8) & 0xFF);
EPD_2in13_V3_SendData(Yend & 0xFF);
EPD_2in13_V3_SendData((Yend >> 8) & 0xFF);
EPD_2in13_V3_SendData(Ystart & 0xFF);
EPD_2in13_V3_SendData((Ystart >> 8) & 0xFF);
}
/******************************************************************************
@ -131,6 +133,8 @@ parameter:
******************************************************************************/
static void EPD_2in13_V3_SetCursor(UWORD Xstart, UWORD Ystart)
{
Ystart = 295 - Ystart;
EPD_2in13_V3_SendCommand(0x4E); // SET_RAM_X_ADDRESS_COUNTER
EPD_2in13_V3_SendData(Xstart & 0xFF);
@ -155,13 +159,13 @@ void EPD_2in13_V3_Init(void)
EPD_2in13_V3_SendCommand(0x01); //Driver output control
EPD_2in13_V3_SendData(0x27);
EPD_2in13_V3_SendData(0x01);
EPD_2in13_V3_SendData(0x00);
EPD_2in13_V3_SendData(0x01);
EPD_2in13_V3_SendCommand(0x11); //data entry mode
EPD_2in13_V3_SendData(0x03);
EPD_2in13_V3_SetWindows(0, 0, EPD_2in13_V3_WIDTH-1, EPD_2in13_V3_HEIGHT-1);
EPD_2in13_V3_SendData(0x01);
EPD_2in13_V3_SetWindows(0, 0, EPD_2in13_V3_WIDTH-1, 296-1);
EPD_2in13_V3_SendCommand(0x3C); //BorderWavefrom
EPD_2in13_V3_SendData(0x05);
@ -171,7 +175,7 @@ void EPD_2in13_V3_Init(void)
EPD_2in13_V3_SendCommand(0x18); //Read built-in temperature sensor
EPD_2in13_V3_SendData(0x80);
EPD_2in13_V3_SetCursor(0, 0);
EPD_2in13_V3_ReadBusy();
}
@ -226,8 +230,8 @@ void EPD_2in13_V3_Display_Base(UBYTE *Image)
void EPD_2in13_V3_Display_Partial(UBYTE *Image)
{
UWORD i;
//Reset
//Reset
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(5);
DEV_Digital_Write(EPD_RST_PIN, 1);
@ -236,14 +240,14 @@ void EPD_2in13_V3_Display_Partial(UBYTE *Image)
EPD_2in13_V3_SendCommand(0x3C); //BorderWavefrom
EPD_2in13_V3_SendData(0x80);
EPD_2in13_V3_SetWindows(0, 0, EPD_2in13_V3_WIDTH-1, EPD_2in13_V3_HEIGHT-1);
EPD_2in13_V3_SetWindows(0, 0, EPD_2in13_V3_WIDTH-1, 296-1);
EPD_2in13_V3_SetCursor(0, 0);
EPD_2in13_V3_SendCommand(0x24); //Write Black and White image to RAM
for(i=0;i<4736;i++)
{
EPD_2in13_V3_SendData(Image[i]);
}
}
EPD_2in13_V3_TurnOnDisplay_Partial();
}

View file

@ -79,12 +79,48 @@ parameter:
static void EPD_2IN7B_V2_ReadBusy(void)
{
Debug("e-Paper busy\r\n");
while(DEV_Digital_Read(EPD_BUSY_PIN) == 0) { //0: busy, 1: idle
DEV_Delay_ms(100);
while(DEV_Digital_Read(EPD_BUSY_PIN) == 1) { //1: busy, 0: idle
DEV_Delay_ms(10);
}
Debug("e-Paper busy release\r\n");
}
static void EPD_2IN7B_V2_TurnOnDisplay(void)
{
EPD_2IN7B_V2_SendCommand(0x20);
EPD_2IN7B_V2_ReadBusy();
}
/******************************************************************************
function : Setting the display window
parameter:
******************************************************************************/
static void EPD_2IN7B_V2_SetWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend)
{
EPD_2IN7B_V2_SendCommand(0x44); // SET_RAM_X_ADDRESS_START_END_POSITION
EPD_2IN7B_V2_SendData((Xstart>>3) & 0xFF);
EPD_2IN7B_V2_SendData((Xend>>3) & 0xFF);
EPD_2IN7B_V2_SendCommand(0x45); // SET_RAM_Y_ADDRESS_START_END_POSITION
EPD_2IN7B_V2_SendData(Ystart & 0xFF);
EPD_2IN7B_V2_SendData((Ystart >> 8) & 0xFF);
EPD_2IN7B_V2_SendData(Yend & 0xFF);
EPD_2IN7B_V2_SendData((Yend >> 8) & 0xFF);
}
/******************************************************************************
function : Set Cursor
parameter:
******************************************************************************/
static void EPD_2IN7B_V2_SetCursor(UWORD Xstart, UWORD Ystart)
{
EPD_2IN7B_V2_SendCommand(0x4E); // SET_RAM_X_ADDRESS_COUNTER
EPD_2IN7B_V2_SendData(Xstart & 0xFF);
EPD_2IN7B_V2_SendCommand(0x4F); // SET_RAM_Y_ADDRESS_COUNTER
EPD_2IN7B_V2_SendData(Ystart & 0xFF);
EPD_2IN7B_V2_SendData((Ystart >> 8) & 0xFF);
}
/******************************************************************************
function : Initialize the e-Paper register
@ -95,55 +131,19 @@ void EPD_2IN7B_V2_Init(void)
EPD_2IN7B_V2_Reset();
EPD_2IN7B_V2_ReadBusy();
EPD_2IN7B_V2_SendCommand(0x4D);
EPD_2IN7B_V2_SendData(0xAA);
EPD_2IN7B_V2_SendCommand(0x87);
EPD_2IN7B_V2_SendData(0x28);
EPD_2IN7B_V2_SendCommand(0x84);
EPD_2IN7B_V2_SendData(0x00);
EPD_2IN7B_V2_SendCommand(0x83);
EPD_2IN7B_V2_SendData(0x05);
EPD_2IN7B_V2_SendCommand(0xA8);
EPD_2IN7B_V2_SendData(0xDF);
EPD_2IN7B_V2_SendCommand(0xA9);
EPD_2IN7B_V2_SendData(0x05);
EPD_2IN7B_V2_SendCommand(0xB1);
EPD_2IN7B_V2_SendData(0xE8);
EPD_2IN7B_V2_SendCommand(0xAB);
EPD_2IN7B_V2_SendData(0xA1);
EPD_2IN7B_V2_SendCommand(0xB9);
EPD_2IN7B_V2_SendData(0x10);
EPD_2IN7B_V2_SendCommand(0x88);
EPD_2IN7B_V2_SendData(0x80);
EPD_2IN7B_V2_SendCommand(0x90);
EPD_2IN7B_V2_SendData(0x02);
EPD_2IN7B_V2_SendCommand(0x86);
EPD_2IN7B_V2_SendData(0x15);
EPD_2IN7B_V2_SendCommand(0x91);
EPD_2IN7B_V2_SendData(0x8D);
EPD_2IN7B_V2_SendCommand(0x50);
EPD_2IN7B_V2_SendData(0x57);
EPD_2IN7B_V2_SendCommand(0xAA);
EPD_2IN7B_V2_SendData(0x0F);
EPD_2IN7B_V2_SendCommand(0x12);
EPD_2IN7B_V2_ReadBusy();
EPD_2IN7B_V2_SendCommand(0x00);
EPD_2IN7B_V2_SendData(0x8f);
EPD_2IN7B_V2_SendData(0x27);
EPD_2IN7B_V2_SendData(0x01);
EPD_2IN7B_V2_SendData(0x00);
EPD_2IN7B_V2_SendCommand(0x11);
EPD_2IN7B_V2_SendData(0x03);
EPD_2IN7B_V2_SetWindows(0, 0, EPD_2IN7B_V2_WIDTH-1, EPD_2IN7B_V2_HEIGHT-1);
EPD_2IN7B_V2_SetCursor(0, 0);
}
/******************************************************************************
@ -156,29 +156,21 @@ void EPD_2IN7B_V2_Clear(void)
Width = (EPD_2IN7B_V2_WIDTH % 8 == 0)? (EPD_2IN7B_V2_WIDTH / 8 ): (EPD_2IN7B_V2_WIDTH / 8 + 1);
Height = EPD_2IN7B_V2_HEIGHT;
EPD_2IN7B_V2_SendCommand(0x10);
EPD_2IN7B_V2_SendCommand(0x24);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_2IN7B_V2_SendData(0Xff);
}
}
EPD_2IN7B_V2_SendCommand(0x13);
EPD_2IN7B_V2_SendCommand(0x26);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_2IN7B_V2_SendData(0X00);
}
}
EPD_2IN7B_V2_SendCommand(0x04); // Power ON
EPD_2IN7B_V2_ReadBusy();
DEV_Delay_ms(10);
EPD_2IN7B_V2_SendCommand(0x12); // Display Refresh
EPD_2IN7B_V2_ReadBusy();
DEV_Delay_ms(10);
EPD_2IN7B_V2_SendCommand(0x02); // Power OFF
EPD_2IN7B_V2_ReadBusy();
DEV_Delay_ms(20);
EPD_2IN7B_V2_TurnOnDisplay();
}
/******************************************************************************
@ -191,30 +183,21 @@ void EPD_2IN7B_V2_Display(UBYTE *Imageblack, UBYTE *Imagered)
Width = (EPD_2IN7B_V2_WIDTH % 8 == 0)? (EPD_2IN7B_V2_WIDTH / 8 ): (EPD_2IN7B_V2_WIDTH / 8 + 1);
Height = EPD_2IN7B_V2_HEIGHT;
EPD_2IN7B_V2_SendCommand(0x10);
EPD_2IN7B_V2_SendCommand(0x24);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_2IN7B_V2_SendData(Imageblack[i + j * Width]);
}
}
EPD_2IN7B_V2_SendCommand(0x13);
EPD_2IN7B_V2_SendCommand(0x26);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_2IN7B_V2_SendData(~Imagered[i + j * Width]);
}
}
EPD_2IN7B_V2_SendCommand(0x04); // Power ON
EPD_2IN7B_V2_ReadBusy();
DEV_Delay_ms(10);
EPD_2IN7B_V2_SendCommand(0x12); // Display Refresh
EPD_2IN7B_V2_ReadBusy();
DEV_Delay_ms(10);
EPD_2IN7B_V2_SendCommand(0x02); // Power OFF
EPD_2IN7B_V2_ReadBusy();
DEV_Delay_ms(20);
EPD_2IN7B_V2_TurnOnDisplay();
}
/******************************************************************************
@ -223,6 +206,6 @@ parameter:
******************************************************************************/
void EPD_2IN7B_V2_Sleep(void)
{
EPD_2IN7B_V2_SendCommand(0x07); // Deep sleep
EPD_2IN7B_V2_SendData(0xA5);
EPD_2IN7B_V2_SendCommand(0x10); // Deep sleep
EPD_2IN7B_V2_SendData(0x01);
}

View file

@ -0,0 +1,173 @@
/*****************************************************************************
* | File : EPD_2in9_DES.c
* | Author : Waveshare team
* | Function : 2.9inch DES e-paper
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-01-13
* | 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_2in9_DES.h"
#include "Debug.h"
/******************************************************************************
function : Software reset
parameter:
******************************************************************************/
static void EPD_2IN9_DES_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_2IN9_DES_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_2IN9_DES_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_2IN9_DES_ReadBusy(void)
{
Debug("e-Paper busy\r\n");
while(1)
{ //=1 BUSY
EPD_2IN9_DES_SendCommand(0x71);
if(DEV_Digital_Read(EPD_BUSY_PIN)==1)
break;
DEV_Delay_ms(50);
}
DEV_Delay_ms(50);
Debug("e-Paper busy release\r\n");
}
/******************************************************************************
function : Turn On Display
parameter:
******************************************************************************/
static void EPD_2IN9_DES_TurnOnDisplay(void)
{
EPD_2IN9_DES_SendCommand(0x12); //Display Update Control
EPD_2IN9_DES_ReadBusy();
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
void EPD_2IN9_DES_Init(void)
{
EPD_2IN9_DES_Reset();
DEV_Delay_ms(100);
EPD_2IN9_DES_SendCommand(0x04); //SWRESET
EPD_2IN9_DES_ReadBusy();
EPD_2IN9_DES_SendCommand(0x00); //Driver output control
EPD_2IN9_DES_SendData(0x1f);
EPD_2IN9_DES_SendCommand(0x50);
EPD_2IN9_DES_SendData(0x97);
}
/******************************************************************************
function : Clear screen
parameter:
******************************************************************************/
void EPD_2IN9_DES_Clear(void)
{
UWORD i;
// EPD_2IN9_DES_SendCommand(0x10);
// for(i=0;i<4736;i++)
// {
// EPD_2IN9_DES_SendData(0xff);
// }
EPD_2IN9_DES_SendCommand(0x13);
for(i=0;i<4736;i++)
{
EPD_2IN9_DES_SendData(0xff);
}
EPD_2IN9_DES_TurnOnDisplay();
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void EPD_2IN9_DES_Display(UBYTE *Image)
{
UWORD i;
// EPD_2IN9_DES_SendCommand(0x10);
// for(i=0;i<4736;i++)
// {
// EPD_2IN9_DES_SendData(0xff);
// }
EPD_2IN9_DES_SendCommand(0x13);
for(i=0;i<4736;i++)
{
EPD_2IN9_DES_SendData(Image[i]);
}
EPD_2IN9_DES_TurnOnDisplay();
}
/******************************************************************************
function : Enter sleep mode
parameter:
******************************************************************************/
void EPD_2IN9_DES_Sleep(void)
{
EPD_2IN9_DES_SendCommand(0x50); //enter deep sleep
EPD_2IN9_DES_SendData(0xf7);
EPD_2IN9_DES_SendCommand(0x02);
EPD_2IN9_DES_ReadBusy();
EPD_2IN9_DES_SendCommand(0x07);
EPD_2IN9_DES_SendData(0xa5);
}

View file

@ -0,0 +1,45 @@
/*****************************************************************************
* | File : EPD_2in9_DES.h
* | Author : Waveshare team
* | Function : 2.9inch DES e-paper
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-01-13
* | 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_2IN9_DES_H_
#define __EPD_2IN9_DES_H_
#include "DEV_Config.h"
// Display resolution
#define EPD_2IN9_DES_WIDTH 128
#define EPD_2IN9_DES_HEIGHT 296
void EPD_2IN9_DES_Init(void);
void EPD_2IN9_DES_Clear(void);
void EPD_2IN9_DES_Display(UBYTE *Image);
void EPD_2IN9_DES_Sleep(void);
#endif

View file

@ -111,14 +111,13 @@ void EPD_2IN9_V2_ReadBusy(void)
Debug("e-Paper busy release\r\n");
}
static void _EPD_2IN9_V2_LUT(void)
{
static void EPD_2IN9_V2_LUT(void)
{
UBYTE count;
EPD_2IN9_V2_SendCommand(0x32);
for(count=0; count<153; count++)
EPD_2IN9_V2_SendData(_WF_PARTIAL_2IN9[count]);
EPD_2IN9_V2_ReadBusy();
}
/******************************************************************************
@ -134,14 +133,6 @@ static void EPD_2IN9_V2_TurnOnDisplay(void)
}
static void EPD_2IN9_V2_TurnOnDisplay_Partial(void)
{
EPD_2IN9_V2_SendCommand(0x22); //Display Update Control
EPD_2IN9_V2_SendData(0xFF);
EPD_2IN9_V2_SendCommand(0x20); //Activate Display Update Sequence
EPD_2IN9_V2_ReadBusy();
}
static void _EPD_2IN9_V2_TurnOnDisplay_Partial(void)
{
EPD_2IN9_V2_SendCommand(0x22); //Display Update Control
EPD_2IN9_V2_SendData(0x0F);
@ -190,47 +181,23 @@ void EPD_2IN9_V2_Init(void)
DEV_Delay_ms(100);
EPD_2IN9_V2_ReadBusy();
EPD_2IN9_V2_SendCommand(0x12); //SWRESET
EPD_2IN9_V2_ReadBusy();
EPD_2IN9_V2_SendCommand(0x12); // soft reset
EPD_2IN9_V2_ReadBusy();
EPD_2IN9_V2_SendCommand(0x01); //Driver output control
EPD_2IN9_V2_SendData(0x27);
EPD_2IN9_V2_SendData(0x01);
EPD_2IN9_V2_SendData(0x00);
EPD_2IN9_V2_SendCommand(0x11); //data entry mode
EPD_2IN9_V2_SendData(0x03);
EPD_2IN9_V2_SetWindows(0, 0, EPD_2IN9_V2_WIDTH-1, EPD_2IN9_V2_HEIGHT-1);
EPD_2IN9_V2_SendCommand(0x3C); //BorderWavefrom
EPD_2IN9_V2_SendData(0x05);
EPD_2IN9_V2_SendCommand(0x21); // Display update control
EPD_2IN9_V2_SendData(0x00);
EPD_2IN9_V2_SendData(0x80);
EPD_2IN9_V2_SendCommand(0x18); //Read built-in temperature sensor
EPD_2IN9_V2_SendData(0x80);
EPD_2IN9_V2_SetCursor(0, 0);
EPD_2IN9_V2_ReadBusy();
}
void _EPD_2IN9_V2_Init(void)
{
EPD_2IN9_V2_Reset();
DEV_Delay_ms(100);
EPD_2IN9_V2_ReadBusy();
EPD_2IN9_V2_SendCommand(0x12); // soft reset
EPD_2IN9_V2_ReadBusy();
EPD_2IN9_V2_SendCommand(0x11); //data entry mode
EPD_2IN9_V2_SendData(0x03);
EPD_2IN9_V2_SetWindows(0, 0, EPD_2IN9_V2_WIDTH-1, EPD_2IN9_V2_HEIGHT-1);
EPD_2IN9_V2_SetCursor(0, 0);
EPD_2IN9_V2_ReadBusy();
}
@ -292,31 +259,7 @@ void EPD_2IN9_V2_Display_Partial(UBYTE *Image)
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(10);
EPD_2IN9_V2_SendCommand(0x3C); //BorderWavefrom
EPD_2IN9_V2_SendData(0x80);
EPD_2IN9_V2_SetWindows(0, 0, EPD_2IN9_V2_WIDTH-1, EPD_2IN9_V2_HEIGHT-1);
EPD_2IN9_V2_SetCursor(0, 0);
EPD_2IN9_V2_SendCommand(0x24); //Write Black and White image to RAM
for(i=0;i<4736;i++)
{
EPD_2IN9_V2_SendData(Image[i]);
}
EPD_2IN9_V2_TurnOnDisplay_Partial();
}
void _EPD_2IN9_V2_Display_Partial(UBYTE *Image)
{
UWORD i;
//Reset
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(5);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(10);
_EPD_2IN9_V2_LUT();
EPD_2IN9_V2_LUT();
EPD_2IN9_V2_SendCommand(0x37);
EPD_2IN9_V2_SendData(0x00);
EPD_2IN9_V2_SendData(0x00);
@ -345,7 +288,7 @@ void _EPD_2IN9_V2_Display_Partial(UBYTE *Image)
{
EPD_2IN9_V2_SendData(Image[i]);
}
_EPD_2IN9_V2_TurnOnDisplay_Partial();
EPD_2IN9_V2_TurnOnDisplay_Partial();
}
/******************************************************************************

View file

@ -38,12 +38,10 @@
#define EPD_2IN9_V2_HEIGHT 296
void EPD_2IN9_V2_Init(void);
void _EPD_2IN9_V2_Init(void);
void EPD_2IN9_V2_Clear(void);
void EPD_2IN9_V2_Display(UBYTE *Image);
void EPD_2IN9_V2_Display_Base(UBYTE *Image);
void EPD_2IN9_V2_Display_Partial(UBYTE *Image);
void _EPD_2IN9_V2_Display_Partial(UBYTE *Image);
void EPD_2IN9_V2_Sleep(void);
#endif

View file

@ -552,6 +552,9 @@ void EPD_3IN7_1Gray_Display_Part(const UBYTE *Image, UWORD Xstart, UWORD Ystart,
Width = (Xend-Xstart)%8 == 0 ? (Xend-Xstart)/8 : (Xend-Xstart)/8+1;
UWORD IMAGE_COUNTER = Width * (Yend-Ystart);
Xend -= 1;
Yend -= 1;
EPD_3IN7_SendCommand(0x44);
EPD_3IN7_SendData(Xstart & 0xff);
EPD_3IN7_SendData((Xstart>>8) & 0x03);
@ -563,13 +566,20 @@ void EPD_3IN7_1Gray_Display_Part(const UBYTE *Image, UWORD Xstart, UWORD Ystart,
EPD_3IN7_SendData(Yend & 0xff);
EPD_3IN7_SendData((Yend>>8) & 0x03);
EPD_3IN7_SendCommand(0x4E); // SET_RAM_X_ADDRESS_COUNTER
EPD_3IN7_SendData(Xstart & 0xFF);
EPD_3IN7_SendCommand(0x4F); // SET_RAM_Y_ADDRESS_COUNTER
EPD_3IN7_SendData(Ystart & 0xFF);
EPD_3IN7_SendData((Ystart >> 8) & 0xFF);
EPD_3IN7_SendCommand(0x24);
for (i = 0; i < IMAGE_COUNTER; i++)
{
EPD_3IN7_SendData(Image[i]);
}
EPD_3IN7_Load_LUT(2);
EPD_3IN7_Load_LUT(3);
EPD_3IN7_SendCommand(0x20);
EPD_3IN7_ReadBusy_HIGH();
}

View file

@ -39,7 +39,7 @@ 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(5);
DEV_Delay_ms(2);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
}
@ -74,17 +74,20 @@ function:
******************************************************************************/
static void EPD_4IN01F_BusyHigh(void)// If BUSYN=0 then waiting
{
printf("e-Paper busy \r\n");
while(!(DEV_Digital_Read(EPD_BUSY_PIN)))
DEV_Delay_ms(500);
printf("e-Paper busy release \r\n");
printf("BusyHigh \r\n");
while(!(DEV_Digital_Read(EPD_BUSY_PIN))) {
DEV_Delay_ms(50);
}
printf("BusyHigh Release \r\n" );
}
static void EPD_4IN01F_BusyLow(void)// If BUSYN=1 then waiting
{
printf("e-Paper busy \r\n");
while(DEV_Digital_Read(EPD_BUSY_PIN))
DEV_Delay_ms(500);
printf("e-Paper busy release \r\n");
printf("BusyLow \r\n");
while(DEV_Digital_Read(EPD_BUSY_PIN)) {
DEV_Delay_ms(50);
}
printf("BusyLow Release \r\n");
}
/******************************************************************************
@ -140,13 +143,36 @@ void EPD_4IN01F_Clear(UBYTE color)
for(int j=0; j<EPD_4IN01F_WIDTH/2; j++)
EPD_4IN01F_SendData((color<<4)|color);
}
DEV_Delay_ms(500);
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);
// DEV_Delay_ms(500);
}
void EPD_4IN01F_ReClear(void)
{
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_HEIGHT; i++) {
for(int j=0; j<EPD_4IN01F_WIDTH/2; j++)
EPD_4IN01F_SendData(0x77);
}
DEV_Delay_ms(500);
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);
}
/******************************************************************************
@ -165,16 +191,16 @@ void EPD_4IN01F_Show7Block(void)
EPD_4IN01F_SendData(0x01);
EPD_4IN01F_SendData(0x90);
EPD_4IN01F_SendCommand(0x10);
for(i=0; i<224; i++) {
for(i=0; i<EPD_4IN01F_HEIGHT/2; i++) {
for(k = 0 ; k < 4; k ++) {
for(j = 0 ; j < 75; j ++) {
for(j = 0 ; j < EPD_4IN01F_WIDTH/8; j ++) {
EPD_4IN01F_SendData((Color_seven[k]<<4) |Color_seven[k]);
}
}
}
for(i=0; i<224; i++) {
for(i=0; i<EPD_4IN01F_HEIGHT/2; i++) {
for(k = 4 ; k < 8; k ++) {
for(j = 0 ; j < 75; j ++) {
for(j = 0 ; j < EPD_4IN01F_WIDTH/8; j ++) {
EPD_4IN01F_SendData((Color_seven[k]<<4) |Color_seven[k]);
}
}
@ -185,7 +211,7 @@ void EPD_4IN01F_Show7Block(void)
EPD_4IN01F_BusyHigh();
EPD_4IN01F_SendCommand(0x02); //0x02
EPD_4IN01F_BusyLow();
DEV_Delay_ms(200);
// DEV_Delay_ms(200);
}
/******************************************************************************
@ -195,7 +221,7 @@ function:
void EPD_4IN01F_Display(const UBYTE *image)
{
unsigned long i, j;
UBYTE k = 0;
// UBYTE k = 0;
EPD_4IN01F_SendCommand(0x61);//Set Resolution setting
EPD_4IN01F_SendData(0x02);
EPD_4IN01F_SendData(0x80);
@ -205,12 +231,12 @@ void EPD_4IN01F_Display(const UBYTE *image)
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)]);
printf("0x%x, ", image[j+((EPD_4IN01F_WIDTH/2)*i)]);
k++;
if(k == 16) {
printf("\n");
k = 0;
}
// printf("0x%x, ", image[j+((EPD_4IN01F_WIDTH/2)*i)]);
// k++;
// if(k == 16) {
// printf("\n");
// k = 0;
// }
}
}
EPD_4IN01F_SendCommand(0x04);//0x04
@ -219,7 +245,7 @@ void EPD_4IN01F_Display(const UBYTE *image)
EPD_4IN01F_BusyHigh();
EPD_4IN01F_SendCommand(0x02); //0x02
EPD_4IN01F_BusyLow();
DEV_Delay_ms(200);
// DEV_Delay_ms(200);
}
void EPD_4IN01F_Display_part(const UBYTE *image, UWORD xstart, UWORD ystart,
@ -255,7 +281,7 @@ void EPD_4IN01F_Display_part(const UBYTE *image, UWORD xstart, UWORD ystart,
EPD_4IN01F_BusyHigh();
EPD_4IN01F_SendCommand(0x02); //0x02
EPD_4IN01F_BusyLow();
DEV_Delay_ms(200);
// DEV_Delay_ms(200);
}
/******************************************************************************
@ -264,7 +290,7 @@ function:
******************************************************************************/
void EPD_4IN01F_Sleep(void)
{
DEV_Delay_ms(100);
// DEV_Delay_ms(100);
EPD_4IN01F_SendCommand(0x07);
EPD_4IN01F_SendData(0xA5);
}

View file

@ -49,6 +49,7 @@ Color Index
#define EPD_4IN01F_HEIGHT 400
void EPD_4IN01F_Clear(UBYTE color);
void EPD_4IN01F_ReClear(void);
void EPD_4IN01F_Sleep(void);
void EPD_Init(void);
void EPD_4IN01F_Show7Block(void);

View file

@ -0,0 +1,226 @@
/*****************************************************************************
* | File : EPD_4in37b.c
* | Author : Waveshare team
* | Function : 4.37inch e-paper b
* | Info :
*----------------
* | This version: V1.0
* | Date : 2021-01-07
* | 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_4in37b.h"
#include "Debug.h"
/******************************************************************************
function : Software reset
parameter:
******************************************************************************/
static void EPD_4IN37B_Reset(void)
{
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(2);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
}
/******************************************************************************
function : send command
parameter:
Reg : Command register
******************************************************************************/
static void EPD_4IN37B_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_4IN37B_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:
******************************************************************************/
static void EPD_4IN37B_ReadBusy(void)
{
Debug("e-Paper busy\r\n");
DEV_Delay_ms(50);
while(DEV_Digital_Read(EPD_BUSY_PIN) == 0) { //LOW: idle, HIGH: busy
DEV_Delay_ms(10);
}
DEV_Delay_ms(50);
Debug("e-Paper busy release\r\n");
}
/******************************************************************************
function : Turn On Display
parameter:
******************************************************************************/
static void EPD_4IN37B_TurnOnDisplay(void)
{
EPD_4IN37B_SendCommand(0x12);
EPD_4IN37B_ReadBusy();
}
/******************************************************************************
function : Setting the display window
parameter:
******************************************************************************/
static void EPD_4IN37B_SetWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend)
{
EPD_4IN37B_SendCommand(0x90);
EPD_4IN37B_SendData(Xstart & 0xf8);
EPD_4IN37B_SendData(Xend | 0x07);
EPD_4IN37B_SendData((Ystart >> 8) & 0x01);
EPD_4IN37B_SendData(Ystart & 0xFF);
EPD_4IN37B_SendData((Yend >> 8) & 0x01);
EPD_4IN37B_SendData(Yend & 0xFF);
EPD_4IN37B_SendData(0x01);
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
void EPD_4IN37B_Init(void)
{
EPD_4IN37B_Reset();
EPD_4IN37B_SendCommand(0x04);//soft reset
EPD_4IN37B_ReadBusy();
EPD_4IN37B_SendCommand(0X00); //PANNEL SETTING
EPD_4IN37B_SendData(0x0F); //KW-3f KWR-2F BWROTP 0f BWOTP 1f
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void EPD_4IN37B_Display(UBYTE *ImageBlack, UBYTE*ImageRed)
{
UWORD Width, Height;
Width = (EPD_4IN37B_WIDTH % 8 == 0)? (EPD_4IN37B_WIDTH / 8 ): (EPD_4IN37B_WIDTH / 8 + 1);
Height = EPD_4IN37B_HEIGHT;
EPD_4IN37B_SendCommand(0x10);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_4IN37B_SendData(ImageBlack[i + j * Width]);
}
}
EPD_4IN37B_SendCommand(0x13);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_4IN37B_SendData(~ImageRed[i + j * Width]);
}
}
EPD_4IN37B_TurnOnDisplay();
}
void EPD_4IN37B_Display_Part(UBYTE *ImageBlack, UBYTE *ImageRed, UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend)
{
UWORD Width, Height;
Width = Xend - Xstart;
Height = Yend - Ystart;
Width = (Width % 8 == 0)? (Width / 8 ): (Width / 8 + 1);
if(Xstart % 8 != 0) {
Xstart += 8;
if(Xstart > Xend) {
printf("Xstart must be a multiple of 8 and not more than Xend \r\n");
return;
}
}
EPD_4IN37B_SetWindows(Xstart, Ystart, Xend-1, Yend-1);
EPD_4IN37B_SendCommand(0x91);
EPD_4IN37B_SendCommand(0x10);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_4IN37B_SendData(ImageBlack[i + j * Width]);
}
}
EPD_4IN37B_SendCommand(0x13);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_4IN37B_SendData(~ImageRed[i + j * Width]);
}
}
EPD_4IN37B_SendCommand(0x92);
EPD_4IN37B_TurnOnDisplay();
}
/******************************************************************************
function : Clear screen
parameter:
******************************************************************************/
void EPD_4IN37B_Clear(void)
{
UWORD Width, Height;
Width = (EPD_4IN37B_WIDTH % 8 == 0)? (EPD_4IN37B_WIDTH / 8 ): (EPD_4IN37B_WIDTH / 8 + 1);
Height = EPD_4IN37B_HEIGHT;
EPD_4IN37B_SendCommand(0x10);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_4IN37B_SendData(0xff);
}
}
EPD_4IN37B_SendCommand(0x13);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_4IN37B_SendData(0x00);
}
}
EPD_4IN37B_TurnOnDisplay();
}
/******************************************************************************
function : Enter sleep mode
parameter:
******************************************************************************/
void EPD_4IN37B_Sleep(void)
{
EPD_4IN37B_SendCommand(0x02);
DEV_Delay_ms(100);
EPD_4IN37B_SendCommand(0x07);
EPD_4IN37B_SendData(0xa5);
}

View file

@ -0,0 +1,45 @@
/*****************************************************************************
* | File : EPD_4in37b.c
* | Author : Waveshare team
* | Function : 4.37inch e-paper b
* | Info :
*----------------
* | This version: V1.0
* | Date : 2021-01-07
* | 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_4IN37B_H_
#define __EPD_4IN37B_H_
#include "DEV_Config.h"
// Display resolution
#define EPD_4IN37B_WIDTH 176
#define EPD_4IN37B_HEIGHT 480
void EPD_4IN37B_Init(void);
void EPD_4IN37B_Display(UBYTE *ImageBlack, UBYTE*ImageRed);
void EPD_4IN37B_Display_Part(UBYTE *ImageBlack, UBYTE*ImageRed, UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend);
void EPD_4IN37B_Clear(void);
void EPD_4IN37B_Sleep(void);
#endif

View file

@ -0,0 +1,218 @@
/*****************************************************************************
* | File : EPD_5in84.c
* | Author : Waveshare team
* | Function : 5.84inch e-paper
* | Info :
*----------------
* | This version: V1.0
* | Date : 2021-01-08
* | 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_5in84.h"
#include "Debug.h"
/******************************************************************************
function : Software reset
parameter:
******************************************************************************/
static void EPD_5in84_Reset(void)
{
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(3);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
}
/******************************************************************************
function : send command
parameter:
Reg : Command register
******************************************************************************/
static void EPD_5in84_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_5in84_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:
******************************************************************************/
static void EPD_5in84_ReadBusy(void)
{
Debug("e-Paper busy\r\n");
do {
EPD_5in84_SendCommand(0x71);
DEV_Delay_ms(10);
}
while(!DEV_Digital_Read(EPD_BUSY_PIN));
Debug("e-Paper busy release\r\n");
}
/******************************************************************************
function : Turn On Display
parameter:
******************************************************************************/
static void EPD_5in84_TurnOnDisplay(void)
{
EPD_5in84_SendCommand(0x12); //DISPLAY REFRESH
DEV_Delay_ms(100); //!!!The delay here is necessary, 200uS at least!!!
EPD_5in84_ReadBusy(); //waiting for the electronic paper IC to release the idle signal
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
void EPD_5in84_Init(void)
{
EPD_5in84_Reset();
EPD_5in84_SendCommand(0x61); // Resolution setting
EPD_5in84_SendData(0x03);
EPD_5in84_SendData(0x00);
EPD_5in84_SendData(0x01);
EPD_5in84_SendData(0x00);
EPD_5in84_SendCommand(0x00);
EPD_5in84_SendData(0xdf);
EPD_5in84_SendCommand(0xF8); // Enter FITI Command
EPD_5in84_SendData(0x60);
EPD_5in84_SendData(0xA5);
EPD_5in84_SendCommand(0xF8); // Enter FITI Command
EPD_5in84_SendData(0x89);
EPD_5in84_SendData(0xA5);
EPD_5in84_SendCommand(0xF8);
EPD_5in84_SendData(0x76);
EPD_5in84_SendData(0x1F);
EPD_5in84_SendCommand(0xF8); //boost constant on time
EPD_5in84_SendData(0x7E);
EPD_5in84_SendData(0x31);
EPD_5in84_SendCommand(0xF8);
EPD_5in84_SendData(0xB8);
EPD_5in84_SendData(0x80);
EPD_5in84_SendCommand(0xF8); //vgl=> GND:08, HZ:00[default]
EPD_5in84_SendData(0x92);
EPD_5in84_SendData(0x00);
EPD_5in84_SendCommand(0xF8); //VCOM(2frme off)=> GND:01(0x88=06)[default], HZ:11
EPD_5in84_SendData(0x87);
EPD_5in84_SendData(0x01);
EPD_5in84_SendCommand(0xF8); //r_vcom_init_sel
EPD_5in84_SendData(0x88);
EPD_5in84_SendData(0x06);
EPD_5in84_SendCommand(0xF8);
EPD_5in84_SendData(0xA8);
EPD_5in84_SendData(0x30);
EPD_5in84_SendCommand(0xF8);
EPD_5in84_SendData(0xE8);
EPD_5in84_SendData(0x88);
EPD_5in84_SendCommand(0x04); //power on
EPD_5in84_ReadBusy();
}
/******************************************************************************
function : Clear screen
parameter:
******************************************************************************/
void EPD_5in84_Clear(void)
{
UWORD Width, Height, i;
Width = (EPD_5in84_WIDTH % 8 == 0)? (EPD_5in84_WIDTH / 8 ): (EPD_5in84_WIDTH / 8 + 1);
Height = EPD_5in84_HEIGHT;
// EPD_5in84_SendCommand(0x10);
// for(i=0; i<Width*Height; i++) {
// EPD_5in84_SendData(0x00);
// }
EPD_5in84_SendCommand(0x13);
for(i=0; i<Width*Height; i++) {
EPD_5in84_SendData(0xff);
}
EPD_5in84_TurnOnDisplay();
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void EPD_5in84_Display(UBYTE *Image)
{
UWORD Width, Height, i, j;
Width = (EPD_5in84_WIDTH % 8 == 0)? (EPD_5in84_WIDTH / 8 ): (EPD_5in84_WIDTH / 8 + 1);
Height = EPD_5in84_HEIGHT;
// EPD_5in84_SendCommand(0x10);
// for(i=0;i<Height;i++) {
// for(j=0; j<Width; j++) {
// EPD_5in84_SendData(0x00);
// }
// }
EPD_5in84_SendCommand(0x13);
for(i=0;i<Height;i++) {
for(j=0; j<Width; j++) {
EPD_5in84_SendData(Image[i*Width + j]);
}
}
EPD_5in84_TurnOnDisplay();
}
/******************************************************************************
function : Enter sleep mode
parameter:
******************************************************************************/
void EPD_5in84_Sleep(void)
{
EPD_5in84_SendCommand(0X02); //power off
EPD_5in84_ReadBusy(); //waiting for the electronic paper IC to release the idle signal
EPD_5in84_SendCommand(0X07); //deep sleep
EPD_5in84_SendData(0xA5);
}

View file

@ -0,0 +1,44 @@
/*****************************************************************************
* | File : EPD_5in84.h
* | Author : Waveshare team
* | Function : 5.84inch e-paper
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-01-08
* | 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_5in84_H_
#define __EPD_5in84_H_
#include "DEV_Config.h"
// Display resolution
#define EPD_5in84_WIDTH 768
#define EPD_5in84_HEIGHT 256
void EPD_5in84_Init(void);
void EPD_5in84_Clear(void);
void EPD_5in84_Display(UBYTE *Image);
void EPD_5in84_Sleep(void);
#endif

View file

@ -82,9 +82,8 @@ static void EPD_WaitUntilIdle(void)
EPD_SendCommand(0x71);
DEV_Delay_ms(20);
}while(!(DEV_Digital_Read(EPD_BUSY_PIN)));
DEV_Delay_ms(100);
DEV_Delay_ms(20);
Debug("e-Paper busy release\r\n");
}