2020.05.22

This commit is contained in:
wangkg 2020-05-22 18:29:01 +08:00
commit 853a3a4632
224 changed files with 26246 additions and 3145 deletions

View file

@ -0,0 +1,194 @@
/*****************************************************************************
* | File : EPD_1in54b_V2.h
* | Author : Waveshare team
* | Function : 1.54inch e-paper b V2
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-04-02
* | 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_1in54b_V2.h"
#include "Debug.h"
/******************************************************************************
function : Software reset
parameter:
******************************************************************************/
static void EPD_1IN54B_V2_Reset(void)
{
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(100);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(10);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(100);
}
/******************************************************************************
function : send command
parameter:
Reg : Command register
******************************************************************************/
static void EPD_1IN54B_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_1IN54B_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:
******************************************************************************/
static void EPD_1IN54B_V2_ReadBusy(void)
{
Debug("e-Paper busy\r\n");
while(1) {
if(DEV_Digital_Read(EPD_BUSY_PIN) == 0)
break;
}
DEV_Delay_ms(200);
Debug("e-Paper busy release\r\n");
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
void EPD_1IN54B_V2_Init(void)
{
EPD_1IN54B_V2_Reset();
EPD_1IN54B_V2_ReadBusy();
EPD_1IN54B_V2_SendCommand(0x12); //SWRESET
EPD_1IN54B_V2_ReadBusy();
EPD_1IN54B_V2_SendCommand(0x01); //Driver output control
EPD_1IN54B_V2_SendData(0xC7);
EPD_1IN54B_V2_SendData(0x00);
EPD_1IN54B_V2_SendData(0x01);
EPD_1IN54B_V2_SendCommand(0x11); //data entry mode
EPD_1IN54B_V2_SendData(0x01);
EPD_1IN54B_V2_SendCommand(0x44); //set Ram-X address start/end position
EPD_1IN54B_V2_SendData(0x00);
EPD_1IN54B_V2_SendData(0x18); //0x18-->(24+1)*8=200
EPD_1IN54B_V2_SendCommand(0x45); //set Ram-Y address start/end position
EPD_1IN54B_V2_SendData(0xC7); //0xC7-->(199+1)=200
EPD_1IN54B_V2_SendData(0x00);
EPD_1IN54B_V2_SendData(0x00);
EPD_1IN54B_V2_SendData(0x00);
EPD_1IN54B_V2_SendCommand(0x3C); //BorderWavefrom
EPD_1IN54B_V2_SendData(0x05);
EPD_1IN54B_V2_SendCommand(0x18); //Read built-in temperature sensor
EPD_1IN54B_V2_SendData(0x80);
EPD_1IN54B_V2_SendCommand(0x4E); // set RAM x address count to 0;
EPD_1IN54B_V2_SendData(0x00);
EPD_1IN54B_V2_SendCommand(0x4F); // set RAM y address count to 0X199;
EPD_1IN54B_V2_SendData(0xC7);
EPD_1IN54B_V2_SendData(0x00);
EPD_1IN54B_V2_ReadBusy();
}
/******************************************************************************
function : Clear screen
parameter:
******************************************************************************/
void EPD_1IN54B_V2_Clear(void)
{
unsigned int i;
EPD_1IN54B_V2_SendCommand(0x24); //write RAM for black(0)/white (1)
for(i=0;i<5000;i++)
{
EPD_1IN54B_V2_SendData(0xff);
}
EPD_1IN54B_V2_SendCommand(0x26); //write RAM for black(0)/white (1)
for(i=0;i<5000;i++)
{
EPD_1IN54B_V2_SendData(0x00);
}
EPD_1IN54B_V2_SendCommand(0x22); //Display Update Control
EPD_1IN54B_V2_SendData(0xF7);
EPD_1IN54B_V2_SendCommand(0x20); //Activate Display Update Sequence
EPD_1IN54B_V2_ReadBusy();
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void EPD_1IN54B_V2_Display(const UBYTE *blackimage, const UBYTE *redimage)
{
UWORD Width, Height;
Width = (EPD_1IN54B_V2_WIDTH % 8 == 0)? (EPD_1IN54B_V2_WIDTH / 8 ): (EPD_1IN54B_V2_WIDTH / 8 + 1);
Height = EPD_1IN54B_V2_HEIGHT;
unsigned int i;
EPD_1IN54B_V2_SendCommand(0x24); //write RAM for black(0)/white (1)
for(i=0;i<Width * Height;i++)
{
EPD_1IN54B_V2_SendData(blackimage[i]);
}
EPD_1IN54B_V2_SendCommand(0x26); //write RAM for black(0)/white (1)
for(i=0;i<Width * Height;i++)
{
EPD_1IN54B_V2_SendData(~redimage[i]);
}
EPD_1IN54B_V2_SendCommand(0x22); //Display Update Control
EPD_1IN54B_V2_SendData(0xF7);
EPD_1IN54B_V2_SendCommand(0x20); //Activate Display Update Sequence
EPD_1IN54B_V2_ReadBusy();
}
/******************************************************************************
function : Enter sleep mode
parameter:
******************************************************************************/
void EPD_1IN54B_V2_Sleep(void)
{
EPD_1IN54B_V2_SendCommand(0x10); //enter deep sleep
EPD_1IN54B_V2_SendData(0x01);
DEV_Delay_ms(100);
}

View file

@ -0,0 +1,45 @@
/*****************************************************************************
* | File : EPD_1in54b_V2.h
* | Author : Waveshare team
* | Function : 1.54inch e-paper b V2
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-04-02
* | 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_1IN54B_V2_H_
#define __EPD_1IN54B_V2_H_
#include "DEV_Config.h"
// Display resolution
#define EPD_1IN54B_V2_WIDTH 200
#define EPD_1IN54B_V2_HEIGHT 200
void EPD_1IN54B_V2_Init(void);
void EPD_1IN54B_V2_Clear(void);
void EPD_1IN54B_V2_Display(const UBYTE *blackimage, const UBYTE *redimage);
void EPD_1IN54B_V2_Sleep(void);
#endif

View file

@ -354,6 +354,10 @@ parameter:
******************************************************************************/
void EPD_2IN13_V2_Sleep(void)
{
EPD_2IN13_V2_SendCommand(0x22); //POWER OFF
EPD_2IN13_V2_SendData(0xC3);
EPD_2IN13_V2_SendCommand(0x20);
EPD_2IN13_V2_SendCommand(0x10); //enter deep sleep
EPD_2IN13_V2_SendData(0x01);
DEV_Delay_ms(100);

View file

@ -0,0 +1,197 @@
/*****************************************************************************
* | File : EPD_2in13b_V2.c
* | Author : Waveshare team
* | Function : 2.13inch e-paper b V2
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-04-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_2in13b_V2.h"
#include "Debug.h"
//元太屏
/******************************************************************************
function : Software reset
parameter:
******************************************************************************/
static void EPD_2IN13B_V2_Reset(void)
{
DEV_Digital_Write(EPD_CS_PIN, 1);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(1000);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(10);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(10);
}
/******************************************************************************
function : send command
parameter:
Reg : Command register
******************************************************************************/
static void EPD_2IN13B_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_2IN13B_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_2IN13B_V2_ReadBusy(void)
{
UBYTE busy;
Debug("e-Paper busy\r\n");
do{
EPD_2IN13B_V2_SendCommand(0x71);
busy = DEV_Digital_Read(EPD_BUSY_PIN);
busy =!(busy & 0x01);
}while(busy);
Debug("e-Paper busy release\r\n");
DEV_Delay_ms(200);
}
/******************************************************************************
function : Turn On Display
parameter:
******************************************************************************/
static void EPD_2IN13B_V2_TurnOnDisplay(void)
{
EPD_2IN13B_V2_SendCommand(0x12); //DISPLAY REFRESH
DEV_Delay_ms(100);
EPD_2IN13B_V2_ReadBusy();
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
void EPD_2IN13B_V2_Init(void)
{
EPD_2IN13B_V2_Reset();
DEV_Delay_ms(10);
EPD_2IN13B_V2_SendCommand(0x04);
EPD_2IN13B_V2_ReadBusy();//waiting for the electronic paper IC to release the idle signal
EPD_2IN13B_V2_SendCommand(0x00);//panel setting
EPD_2IN13B_V2_SendData(0x0f);//LUT from OTP128x296
EPD_2IN13B_V2_SendData(0x89);//Temperature sensor, boost and other related timing settings
EPD_2IN13B_V2_SendCommand(0x61);//resolution setting
EPD_2IN13B_V2_SendData (0x68);
EPD_2IN13B_V2_SendData (0x00);
EPD_2IN13B_V2_SendData (0xD4);
EPD_2IN13B_V2_SendCommand(0X50);//VCOM AND DATA INTERVAL SETTING
EPD_2IN13B_V2_SendData(0x77);//WBmode:VBDF 17|D7 VBDW 97 VBDB 57
//WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7;
}
/******************************************************************************
function : Clear screen
parameter:
******************************************************************************/
void EPD_2IN13B_V2_Clear(void)
{
UWORD Width = (EPD_2IN13B_V2_WIDTH % 8 == 0)? (EPD_2IN13B_V2_WIDTH / 8 ): (EPD_2IN13B_V2_WIDTH / 8 + 1);
UWORD Height = EPD_2IN13B_V2_HEIGHT;
//send black data
EPD_2IN13B_V2_SendCommand(0x10);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_2IN13B_V2_SendData(0xFF);
}
}
//send red data
EPD_2IN13B_V2_SendCommand(0x13);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_2IN13B_V2_SendData(0xFF);
}
}
EPD_2IN13B_V2_TurnOnDisplay();
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void EPD_2IN13B_V2_Display(const UBYTE *blackimage, const UBYTE *ryimage)
{
UWORD Width, Height;
Width = (EPD_2IN13B_V2_WIDTH % 8 == 0)? (EPD_2IN13B_V2_WIDTH / 8 ): (EPD_2IN13B_V2_WIDTH / 8 + 1);
Height = EPD_2IN13B_V2_HEIGHT;
EPD_2IN13B_V2_SendCommand(0x10);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_2IN13B_V2_SendData(blackimage[i + j * Width]);
}
}
EPD_2IN13B_V2_SendCommand(0x13);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_2IN13B_V2_SendData(ryimage[i + j * Width]);
}
}
EPD_2IN13B_V2_TurnOnDisplay();
}
/******************************************************************************
function : Enter sleep mode
parameter:
******************************************************************************/
void EPD_2IN13B_V2_Sleep(void)
{
EPD_2IN13B_V2_SendCommand(0X50);
EPD_2IN13B_V2_SendData(0xf7);
EPD_2IN13B_V2_SendCommand(0X02); //power off
EPD_2IN13B_V2_ReadBusy(); //waiting for the electronic paper IC to release the idle signal
EPD_2IN13B_V2_SendCommand(0X07); //deep sleep
EPD_2IN13B_V2_SendData(0xA5);
}

View file

@ -0,0 +1,45 @@
/*****************************************************************************
* | File : EPD_2in13b_V2.h
* | Author : Waveshare team
* | Function : 2.13inch e-paper b V2
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-04-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_2IN13B_V2_H_
#define __EPD_2IN13B_V2_H_
#include "DEV_Config.h"
// Display resolution
#define EPD_2IN13B_V2_WIDTH 104
#define EPD_2IN13B_V2_HEIGHT 212
void EPD_2IN13B_V2_Init(void);
void EPD_2IN13B_V2_Clear(void);
void EPD_2IN13B_V2_Display(const UBYTE *blackimage, const UBYTE *ryimage);
void EPD_2IN13B_V2_Sleep(void);
#endif

View file

@ -0,0 +1,188 @@
/*****************************************************************************
* | File : EPD_2in9b_V2.c
* | Author : Waveshare team
* | Function : 2.9inch e-paper b V2
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-04-12
* | 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_2in9b_V2.h"
#include "Debug.h"
/******************************************************************************
function : Software reset
parameter:
******************************************************************************/
static void EPD_2IN9B_V2_Reset(void)
{
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(10);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
}
/******************************************************************************
function : send command
parameter:
Reg : Command register
******************************************************************************/
static void EPD_2IN9B_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_2IN9B_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_2IN9B_V2_ReadBusy(void)
{
Debug("e-Paper busy\r\n");
UBYTE busy;
do
{
EPD_2IN9B_V2_SendCommand(0x71);
busy = DEV_Digital_Read(EPD_BUSY_PIN);
busy =!(busy & 0x01);
}
while(busy);
Debug("e-Paper busy release\r\n");
DEV_Delay_ms(200);
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
void EPD_2IN9B_V2_Init(void)
{
EPD_2IN9B_V2_Reset();
EPD_2IN9B_V2_Reset();
EPD_2IN9B_V2_SendCommand(0x04);
EPD_2IN9B_V2_ReadBusy();//waiting for the electronic paper IC to release the idle signal
EPD_2IN9B_V2_SendCommand(0x00);//panel setting
EPD_2IN9B_V2_SendData(0x0f);//LUT from OTP128x296
EPD_2IN9B_V2_SendData(0x89);//Temperature sensor, boost and other related timing settings
EPD_2IN9B_V2_SendCommand(0x61);//resolution setting
EPD_2IN9B_V2_SendData (0x80);
EPD_2IN9B_V2_SendData (0x01);
EPD_2IN9B_V2_SendData (0x28);
EPD_2IN9B_V2_SendCommand(0X50);//VCOM AND DATA INTERVAL SETTING
EPD_2IN9B_V2_SendData(0x77);//WBmode:VBDF 17|D7 VBDW 97 VBDB 57
//WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7
}
/******************************************************************************
function : Clear screen
parameter:
******************************************************************************/
void EPD_2IN9B_V2_Clear(void)
{
UWORD Width = (EPD_2IN9B_V2_WIDTH % 8 == 0)? (EPD_2IN9B_V2_WIDTH / 8 ): (EPD_2IN9B_V2_WIDTH / 8 + 1);
UWORD Height = EPD_2IN9B_V2_HEIGHT;
//send black data
EPD_2IN9B_V2_SendCommand(0x10);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_2IN9B_V2_SendData(0xFF);
}
}
//send red data
EPD_2IN9B_V2_SendCommand(0x13);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_2IN9B_V2_SendData(0xFF);
}
}
EPD_2IN9B_V2_SendCommand(0x12);
EPD_2IN9B_V2_ReadBusy();
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void EPD_2IN9B_V2_Display(const UBYTE *blackimage, const UBYTE *ryimage)
{
UWORD Width, Height;
Width = (EPD_2IN9B_V2_WIDTH % 8 == 0)? (EPD_2IN9B_V2_WIDTH / 8 ): (EPD_2IN9B_V2_WIDTH / 8 + 1);
Height = EPD_2IN9B_V2_HEIGHT;
EPD_2IN9B_V2_SendCommand(0x10);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_2IN9B_V2_SendData(blackimage[i + j * Width]);
}
}
EPD_2IN9B_V2_SendCommand(0x92);
EPD_2IN9B_V2_SendCommand(0x13);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_2IN9B_V2_SendData(ryimage[i + j * Width]);
}
}
EPD_2IN9B_V2_SendCommand(0x92);
EPD_2IN9B_V2_SendCommand(0x12);
EPD_2IN9B_V2_ReadBusy();
}
/******************************************************************************
function : Enter sleep mode
parameter:
******************************************************************************/
void EPD_2IN9B_V2_Sleep(void)
{
EPD_2IN9B_V2_SendCommand(0x02); // POWER_OFF
EPD_2IN9B_V2_ReadBusy();
EPD_2IN9B_V2_SendCommand(0x07); // DEEP_SLEEP
EPD_2IN9B_V2_SendData(0xA5); // check code
}

View file

@ -0,0 +1,45 @@
/*****************************************************************************
* | File : EPD_2in9b V2.h
* | Author : Waveshare team
* | Function : 2.9inch e-paper b V2
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-04-12
* | 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_2IN9B_V2_H_
#define __EPD_2IN9B_V2_H_
#include "DEV_Config.h"
// Display resolution
#define EPD_2IN9B_V2_WIDTH 128
#define EPD_2IN9B_V2_HEIGHT 296
void EPD_2IN9B_V2_Init(void);
void EPD_2IN9B_V2_Clear(void);
void EPD_2IN9B_V2_Display(const UBYTE *blackimage, const UBYTE *ryimage);
void EPD_2IN9B_V2_Sleep(void);
#endif

View file

@ -159,104 +159,108 @@ static const unsigned char EPD_4IN2_lut_bb[] = {
};
/******************************partial screen update LUT*********************************/
const unsigned char EPD_4IN2_Partial_lut_vcom1[] ={
0x00 ,0x19 ,0x01 ,0x00 ,0x00 ,0x01,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00, };
const unsigned char EPD_4IN2_Partial_lut_vcom1[] = {
0x00 ,0x19 ,0x01 ,0x00 ,0x00 ,0x01,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00,
};
const unsigned char EPD_4IN2_Partial_lut_ww1[] ={
0x00 ,0x19 ,0x01 ,0x00 ,0x00 ,0x01,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,};
const unsigned char EPD_4IN2_Partial_lut_ww1[] = {
0x00 ,0x19 ,0x01 ,0x00 ,0x00 ,0x01,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
};
const unsigned char EPD_4IN2_Partial_lut_bw1[] ={
0x80 ,0x19 ,0x01 ,0x00 ,0x00 ,0x01,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00, };
const unsigned char EPD_4IN2_Partial_lut_bw1[] = {
0x80 ,0x19 ,0x01 ,0x00 ,0x00 ,0x01,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
};
const unsigned char EPD_4IN2_Partial_lut_wb1[] ={
0x40 ,0x19 ,0x01 ,0x00 ,0x00 ,0x01,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00, };
const unsigned char EPD_4IN2_Partial_lut_wb1[] = {
0x40 ,0x19 ,0x01 ,0x00 ,0x00 ,0x01,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
};
const unsigned char EPD_4IN2_Partial_lut_bb1[] ={
0x00 ,0x19 ,0x01 ,0x00 ,0x00 ,0x01,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00, };
const unsigned char EPD_4IN2_Partial_lut_bb1[] = {
0x00 ,0x19 ,0x01 ,0x00 ,0x00 ,0x01,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
};
/******************************gray*********************************/
//0~3 gray
const unsigned char EPD_4IN2_4Gray_lut_vcom[] =
{
0x00 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01,
0x60 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01,
0x00 ,0x14 ,0x00 ,0x00 ,0x00 ,0x01,
0x00 ,0x13 ,0x0A ,0x01 ,0x00 ,0x01,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00
const unsigned char EPD_4IN2_4Gray_lut_vcom[] = {
0x00 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01,
0x60 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01,
0x00 ,0x14 ,0x00 ,0x00 ,0x00 ,0x01,
0x00 ,0x13 ,0x0A ,0x01 ,0x00 ,0x01,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00
};
//R21
const unsigned char EPD_4IN2_4Gray_lut_ww[] ={
0x40 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01,
0x90 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01,
0x10 ,0x14 ,0x0A ,0x00 ,0x00 ,0x01,
0xA0 ,0x13 ,0x01 ,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_4IN2_4Gray_lut_ww[] = {
0x40 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01,
0x90 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01,
0x10 ,0x14 ,0x0A ,0x00 ,0x00 ,0x01,
0xA0 ,0x13 ,0x01 ,0x00 ,0x00 ,0x01,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
};
//R22H r
const unsigned char EPD_4IN2_4Gray_lut_bw[] ={
0x40 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01,
0x90 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01,
0x00 ,0x14 ,0x0A ,0x00 ,0x00 ,0x01,
0x99 ,0x0C ,0x01 ,0x03 ,0x04 ,0x01,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
const unsigned char EPD_4IN2_4Gray_lut_bw[] = {
0x40 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01,
0x90 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01,
0x00 ,0x14 ,0x0A ,0x00 ,0x00 ,0x01,
0x99 ,0x0C ,0x01 ,0x03 ,0x04 ,0x01,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
};
//R23H w
const unsigned char EPD_4IN2_4Gray_lut_wb[] ={
0x40 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01,
0x90 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01,
0x00 ,0x14 ,0x0A ,0x00 ,0x00 ,0x01,
0x99 ,0x0B ,0x04 ,0x04 ,0x01 ,0x01,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
const unsigned char EPD_4IN2_4Gray_lut_wb[] = {
0x40 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01,
0x90 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01,
0x00 ,0x14 ,0x0A ,0x00 ,0x00 ,0x01,
0x99 ,0x0B ,0x04 ,0x04 ,0x01 ,0x01,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
};
//R24H b
const unsigned char EPD_4IN2_4Gray_lut_bb[] ={
0x80 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01,
0x90 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01,
0x20 ,0x14 ,0x0A ,0x00 ,0x00 ,0x01,
0x50 ,0x13 ,0x01 ,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_4IN2_4Gray_lut_bb[] = {
0x80 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01,
0x90 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01,
0x20 ,0x14 ,0x0A ,0x00 ,0x00 ,0x01,
0x50 ,0x13 ,0x01 ,0x00 ,0x00 ,0x01,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,
};
@ -307,9 +311,9 @@ parameter:
void EPD_4IN2_ReadBusy(void)
{
Debug("e-Paper busy\r\n");
EPD_4IN2_SendCommand(0x71);
EPD_4IN2_SendCommand(0x71);
while(DEV_Digital_Read(EPD_BUSY_PIN) == 0) { //LOW: idle, HIGH: busy
EPD_4IN2_SendCommand(0x71);
EPD_4IN2_SendCommand(0x71);
DEV_Delay_ms(100);
}
Debug("e-Paper busy release\r\n");
@ -361,57 +365,68 @@ static void EPD_4IN2_SetLut(void)
static void EPD_4IN2_Partial_SetLut(void)
{
unsigned int count;
EPD_4IN2_SendCommand(0x20);
for(count=0;count<44;count++)
{EPD_4IN2_SendData(EPD_4IN2_Partial_lut_vcom1[count]);}
unsigned int count;
EPD_4IN2_SendCommand(0x20);
for(count=0; count<44; count++) {
EPD_4IN2_SendData(EPD_4IN2_Partial_lut_vcom1[count]);
}
EPD_4IN2_SendCommand(0x21);
for(count=0;count<42;count++)
{EPD_4IN2_SendData(EPD_4IN2_Partial_lut_ww1[count]);}
EPD_4IN2_SendCommand(0x22);
for(count=0;count<42;count++)
{EPD_4IN2_SendData(EPD_4IN2_Partial_lut_bw1[count]);}
EPD_4IN2_SendCommand(0x21);
for(count=0; count<42; count++) {
EPD_4IN2_SendData(EPD_4IN2_Partial_lut_ww1[count]);
}
EPD_4IN2_SendCommand(0x23);
for(count=0;count<42;count++)
{EPD_4IN2_SendData(EPD_4IN2_Partial_lut_wb1[count]);}
EPD_4IN2_SendCommand(0x22);
for(count=0; count<42; count++) {
EPD_4IN2_SendData(EPD_4IN2_Partial_lut_bw1[count]);
}
EPD_4IN2_SendCommand(0x24);
for(count=0;count<42;count++)
{EPD_4IN2_SendData(EPD_4IN2_Partial_lut_bb1[count]);}
EPD_4IN2_SendCommand(0x23);
for(count=0; count<42; count++) {
EPD_4IN2_SendData(EPD_4IN2_Partial_lut_wb1[count]);
}
EPD_4IN2_SendCommand(0x24);
for(count=0; count<42; count++) {
EPD_4IN2_SendData(EPD_4IN2_Partial_lut_bb1[count]);
}
}
//LUT download
static void EPD_4IN2_4Gray_lut(void)
{
unsigned int count;
{
EPD_4IN2_SendCommand(0x20); //vcom
for(count=0;count<42;count++)
{EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_vcom[count]);}
EPD_4IN2_SendCommand(0x21); //red not use
for(count=0;count<42;count++)
{EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_ww[count]);}
unsigned int count;
{
EPD_4IN2_SendCommand(0x20); //vcom
for(count=0; count<42; count++) {
EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_vcom[count]);
}
EPD_4IN2_SendCommand(0x22); //bw r
for(count=0;count<42;count++)
{EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_bw[count]);}
EPD_4IN2_SendCommand(0x21); //red not use
for(count=0; count<42; count++) {
EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_ww[count]);
}
EPD_4IN2_SendCommand(0x23); //wb w
for(count=0;count<42;count++)
{EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_wb[count]);}
EPD_4IN2_SendCommand(0x22); //bw r
for(count=0; count<42; count++) {
EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_bw[count]);
}
EPD_4IN2_SendCommand(0x24); //bb b
for(count=0;count<42;count++)
{EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_bb[count]);}
EPD_4IN2_SendCommand(0x23); //wb w
for(count=0; count<42; count++) {
EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_wb[count]);
}
EPD_4IN2_SendCommand(0x25); //vcom
for(count=0;count<42;count++)
{EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_ww[count]);}
}
EPD_4IN2_SendCommand(0x24); //bb b
for(count=0; count<42; count++) {
EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_bb[count]);
}
EPD_4IN2_SendCommand(0x25); //vcom
for(count=0; count<42; count++) {
EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_ww[count]);
}
}
}
/******************************************************************************
function : Initialize the e-Paper register
@ -459,39 +474,39 @@ void EPD_4IN2_Init(void)
void EPD_4IN2_Init_4Gray(void)
{
EPD_4IN2_Reset();
EPD_4IN2_SendCommand(0x01); //POWER SETTING
EPD_4IN2_SendData (0x03);
EPD_4IN2_SendData (0x00); //VGH=20V,VGL=-20V
EPD_4IN2_SendData (0x2b); //VDH=15V
EPD_4IN2_SendData (0x2b); //VDL=-15V
EPD_4IN2_SendData (0x13);
EPD_4IN2_Reset();
EPD_4IN2_SendCommand(0x01); //POWER SETTING
EPD_4IN2_SendData (0x03);
EPD_4IN2_SendData (0x00); //VGH=20V,VGL=-20V
EPD_4IN2_SendData (0x2b); //VDH=15V
EPD_4IN2_SendData (0x2b); //VDL=-15V
EPD_4IN2_SendData (0x13);
EPD_4IN2_SendCommand(0x06); //booster soft start
EPD_4IN2_SendData (0x17); //A
EPD_4IN2_SendData (0x17); //B
EPD_4IN2_SendData (0x17); //C
EPD_4IN2_SendCommand(0x06); //booster soft start
EPD_4IN2_SendData (0x17); //A
EPD_4IN2_SendData (0x17); //B
EPD_4IN2_SendData (0x17); //C
EPD_4IN2_SendCommand(0x04);
EPD_4IN2_ReadBusy();
EPD_4IN2_SendCommand(0x04);
EPD_4IN2_ReadBusy();
EPD_4IN2_SendCommand(0x00); //panel setting
EPD_4IN2_SendData(0x3f); //KW-3f KWR-2F BWROTP 0f BWOTP 1f
EPD_4IN2_SendCommand(0x00); //panel setting
EPD_4IN2_SendData(0x3f); //KW-3f KWR-2F BWROTP 0f BWOTP 1f
EPD_4IN2_SendCommand(0x30); //PLL setting
EPD_4IN2_SendData (0x3c); //100hz
EPD_4IN2_SendCommand(0x30); //PLL setting
EPD_4IN2_SendData (0x3c); //100hz
EPD_4IN2_SendCommand(0x61); //resolution setting
EPD_4IN2_SendData (0x01); //400
EPD_4IN2_SendData (0x90);
EPD_4IN2_SendData (0x01); //300
EPD_4IN2_SendData (0x2c);
EPD_4IN2_SendCommand(0x61); //resolution setting
EPD_4IN2_SendData (0x01); //400
EPD_4IN2_SendData (0x90);
EPD_4IN2_SendData (0x01); //300
EPD_4IN2_SendData (0x2c);
EPD_4IN2_SendCommand(0x82); //vcom_DC setting
EPD_4IN2_SendData (0x12);
EPD_4IN2_SendCommand(0x82); //vcom_DC setting
EPD_4IN2_SendData (0x12);
EPD_4IN2_SendCommand(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_4IN2_SendData(0x97);
EPD_4IN2_SendCommand(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_4IN2_SendData(0x97);
}
/******************************************************************************
function : Clear screen
@ -516,8 +531,8 @@ void EPD_4IN2_Clear(void)
EPD_4IN2_SendData(0xFF);
}
}
EPD_4IN2_SendCommand(0x12); //DISPLAY REFRESH
DEV_Delay_ms(10);
EPD_4IN2_SendCommand(0x12); //DISPLAY REFRESH
DEV_Delay_ms(10);
EPD_4IN2_TurnOnDisplay();
}
@ -537,91 +552,88 @@ void EPD_4IN2_Display(UBYTE *Image)
EPD_4IN2_SendData(Image[i + j * Width]);
}
}
EPD_4IN2_TurnOnDisplay();
}
void EPD_4IN2_PartialDisplay(UWORD X_start,UWORD Y_start,UWORD X_end,UWORD Y_end, UBYTE *Image)
{
UWORD Width, Height;
UWORD Width, Height;
Width = (EPD_4IN2_WIDTH % 8 == 0)? (EPD_4IN2_WIDTH / 8 ): (EPD_4IN2_WIDTH / 8 + 1);
Height = EPD_4IN2_HEIGHT;
X_start = (X_start % 8 == 0)? (X_start): (X_start/8*8+8);
X_end = (X_end % 8 == 0)? (X_end): (X_end/8*8+8);
EPD_4IN2_SendCommand(0X50);
EPD_4IN2_SendData(0xf7);
DEV_Delay_ms(100);
EPD_4IN2_SendCommand(0x82); //vcom_DC setting
EPD_4IN2_SendData (0x08);
EPD_4IN2_SendCommand(0X50);
EPD_4IN2_SendData(0x47);
EPD_4IN2_Partial_SetLut();
EPD_4IN2_SendCommand(0x91); //This command makes the display enter partial mode
EPD_4IN2_SendCommand(0x90); //resolution setting
EPD_4IN2_SendData ((X_start)/256);
EPD_4IN2_SendData ((X_start)%256); //x-start
EPD_4IN2_SendData ((X_end )/256);
EPD_4IN2_SendData ((X_end )%256-1); //x-end
X_start = (X_start % 8 == 0)? (X_start): (X_start/8*8+8);
X_end = (X_end % 8 == 0)? (X_end): (X_end/8*8+8);
EPD_4IN2_SendData (Y_start/256);
EPD_4IN2_SendData (Y_start%256); //y-start
EPD_4IN2_SendCommand(0X50);
EPD_4IN2_SendData(0xf7);
DEV_Delay_ms(100);
EPD_4IN2_SendData (Y_end/256);
EPD_4IN2_SendData (Y_end%256-1); //y-end
EPD_4IN2_SendData (0x28);
EPD_4IN2_SendCommand(0x82); //vcom_DC setting
EPD_4IN2_SendData (0x08);
EPD_4IN2_SendCommand(0X50);
EPD_4IN2_SendData(0x47);
EPD_4IN2_Partial_SetLut();
EPD_4IN2_SendCommand(0x91); //This command makes the display enter partial mode
EPD_4IN2_SendCommand(0x90); //resolution setting
EPD_4IN2_SendData ((X_start)/256);
EPD_4IN2_SendData ((X_start)%256); //x-start
EPD_4IN2_SendCommand(0x10); //writes Old data to SRAM for programming
EPD_4IN2_SendData ((X_end )/256);
EPD_4IN2_SendData ((X_end )%256-1); //x-end
EPD_4IN2_SendData (Y_start/256);
EPD_4IN2_SendData (Y_start%256); //y-start
EPD_4IN2_SendData (Y_end/256);
EPD_4IN2_SendData (Y_end%256-1); //y-end
EPD_4IN2_SendData (0x28);
EPD_4IN2_SendCommand(0x10); //writes Old data to SRAM for programming
for (UWORD j = 0; j < Y_end - Y_start; j++) {
for (UWORD i = 0; i < (X_end - X_start)/8; i++) {
EPD_4IN2_SendData(Image[(Y_start + j)*Width + X_start/8 + i]);
}
}
EPD_4IN2_SendCommand(0x13); //writes New data to SRAM.
EPD_4IN2_SendCommand(0x13); //writes New data to SRAM.
for (UWORD j = 0; j < Y_end - Y_start; j++) {
for (UWORD i = 0; i < (X_end - X_start)/8; i++) {
EPD_4IN2_SendData(~Image[(Y_start + j)*Width + X_start/8 + i]);
}
}
EPD_4IN2_SendCommand(0x12); //DISPLAY REFRESH
DEV_Delay_ms(10); //The delay here is necessary, 200uS at least!!!
EPD_4IN2_TurnOnDisplay();
EPD_4IN2_SendCommand(0x12); //DISPLAY REFRESH
DEV_Delay_ms(10); //The delay here is necessary, 200uS at least!!!
EPD_4IN2_TurnOnDisplay();
}
void EPD_4IN2_4GrayDisplay(const UBYTE *Image)
{
UDOUBLE i,j,k;
UBYTE temp1,temp2,temp3;
/****Color display description****
white gray1 gray2 black
0x10| 01 01 00 00
0x13| 01 00 01 00
*********************************/
EPD_4IN2_SendCommand(0x10);
/****Color display description****
white gray1 gray2 black
0x10| 01 01 00 00
0x13| 01 00 01 00
*********************************/
EPD_4IN2_SendCommand(0x10);
for(i=0;i<15000;i++) //5808*4 46464
{
for(i=0; i<15000; i++) { //5808*4 46464
temp3=0;
for(j=0;j<2;j++)
{
for(j=0; j<2; j++) {
temp1 = Image[i*2+j];
for(k=0;k<2;k++)
{
for(k=0; k<2; k++) {
temp2 = temp1&0xC0 ;
if(temp2 == 0xC0)
temp3 |= 0x01;//white
else if(temp2 == 0x00)
temp3 |= 0x00; //black
else if(temp2 == 0x80)
else if(temp2 == 0x80)
temp3 |= 0x01; //gray1
else //0x40
temp3 |= 0x00; //gray2
temp3 <<= 1;
temp3 <<= 1;
temp1 <<= 2;
temp2 = temp1&0xC0 ;
if(temp2 == 0xC0) //white
@ -631,37 +643,34 @@ void EPD_4IN2_4GrayDisplay(const UBYTE *Image)
else if(temp2 == 0x80)
temp3 |= 0x01; //gray1
else //0x40
temp3 |= 0x00; //gray2
if(j!=1 || k!=1)
temp3 |= 0x00; //gray2
if(j!=1 || k!=1)
temp3 <<= 1;
temp1 <<= 2;
}
}
EPD_4IN2_SendData(temp3);
}
EPD_4IN2_SendData(temp3);
}
// new data
EPD_4IN2_SendCommand(0x13);
for(i=0;i<15000;i++) //5808*4 46464
{
EPD_4IN2_SendCommand(0x13);
for(i=0; i<15000; i++) { //5808*4 46464
temp3=0;
for(j=0;j<2;j++)
{
for(j=0; j<2; j++) {
temp1 = Image[i*2+j];
for(k=0;k<2;k++)
{
for(k=0; k<2; k++) {
temp2 = temp1&0xC0 ;
if(temp2 == 0xC0)
temp3 |= 0x01;//white
else if(temp2 == 0x00)
temp3 |= 0x00; //black
else if(temp2 == 0x80)
else if(temp2 == 0x80)
temp3 |= 0x00; //gray1
else //0x40
temp3 |= 0x01; //gray2
temp3 <<= 1;
temp3 <<= 1;
temp1 <<= 2;
temp2 = temp1&0xC0 ;
if(temp2 == 0xC0) //white
@ -671,17 +680,17 @@ void EPD_4IN2_4GrayDisplay(const UBYTE *Image)
else if(temp2 == 0x80)
temp3 |= 0x00; //gray1
else //0x40
temp3 |= 0x01; //gray2
if(j!=1 || k!=1)
temp3 |= 0x01; //gray2
if(j!=1 || k!=1)
temp3 <<= 1;
temp1 <<= 2;
}
}
EPD_4IN2_SendData(temp3);
}
EPD_4IN2_SendData(temp3);
}
EPD_4IN2_4Gray_lut();
EPD_4IN2_TurnOnDisplay();
}

View file

@ -0,0 +1,293 @@
/*****************************************************************************
* | File : EPD_7in5_HD.c
* | Author : Waveshare team
* | Function : Electronic paper driver
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-04-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_7in5_HD.h"
#include "Debug.h"
/******************************************************************************
function : Software reset
parameter:
******************************************************************************/
static void EPD_7IN5_HD_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_7IN5_HD_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_7IN5_HD_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_7IN5_HD_WaitUntilIdle(void)
{
Debug("e-Paper busy\r\n");
do{
DEV_Delay_ms(10);
}while(DEV_Digital_Read(EPD_BUSY_PIN) == 1);
DEV_Delay_ms(200);
Debug("e-Paper busy release\r\n");
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
void EPD_7IN5_HD_Init(void)
{
EPD_7IN5_HD_Reset();
EPD_7IN5_HD_WaitUntilIdle();
EPD_7IN5_HD_SendCommand(0x12); //SWRESET
EPD_7IN5_HD_WaitUntilIdle();
EPD_7IN5_HD_SendCommand(0x46); // Auto Write Red RAM
EPD_7IN5_HD_SendData(0xf7);
EPD_7IN5_HD_WaitUntilIdle();
EPD_7IN5_HD_SendCommand(0x47); // Auto Write B/W RAM
EPD_7IN5_HD_SendData(0xf7);
EPD_7IN5_HD_WaitUntilIdle();
EPD_7IN5_HD_SendCommand(0x0C); // Soft start setting
EPD_7IN5_HD_SendData(0xAE);
EPD_7IN5_HD_SendData(0xC7);
EPD_7IN5_HD_SendData(0xC3);
EPD_7IN5_HD_SendData(0xC0);
EPD_7IN5_HD_SendData(0x40);
EPD_7IN5_HD_SendCommand(0x01); // Set MUX as 527
EPD_7IN5_HD_SendData(0xAF);
EPD_7IN5_HD_SendData(0x02);
EPD_7IN5_HD_SendData(0x01);//0x01
EPD_7IN5_HD_SendCommand(0x11); // Data entry mode
EPD_7IN5_HD_SendData(0x01);
EPD_7IN5_HD_SendCommand(0x44);
EPD_7IN5_HD_SendData(0x00); // RAM x address start at 0
EPD_7IN5_HD_SendData(0x00);
EPD_7IN5_HD_SendData(0x6F);
EPD_7IN5_HD_SendData(0x03);
EPD_7IN5_HD_SendCommand(0x45);
EPD_7IN5_HD_SendData(0xAF);
EPD_7IN5_HD_SendData(0x02);
EPD_7IN5_HD_SendData(0x00);
EPD_7IN5_HD_SendData(0x00);
EPD_7IN5_HD_SendCommand(0x3C); // VBD
EPD_7IN5_HD_SendData(0x05); // LUT1, for white
EPD_7IN5_HD_SendCommand(0x18);
EPD_7IN5_HD_SendData(0X80);
EPD_7IN5_HD_SendCommand(0x22);
EPD_7IN5_HD_SendData(0XB1); //Load Temperature and waveform setting.
EPD_7IN5_HD_SendCommand(0x20);
EPD_7IN5_HD_WaitUntilIdle();
EPD_7IN5_HD_SendCommand(0x4E); // set RAM x address count to 0;
EPD_7IN5_HD_SendData(0x00);
EPD_7IN5_HD_SendData(0x00);
EPD_7IN5_HD_SendCommand(0x4F);
EPD_7IN5_HD_SendData(0x00);
EPD_7IN5_HD_SendData(0x00);
// return 0;
}
/******************************************************************************
function : Clear screen
parameter:
******************************************************************************/
void EPD_7IN5_HD_Clear(void)
{
UDOUBLE Width, Height;
Width =(EPD_7IN5_HD_WIDTH % 8 == 0)?(EPD_7IN5_HD_WIDTH / 8 ):(EPD_7IN5_HD_WIDTH / 8 + 1);
Height = EPD_7IN5_HD_HEIGHT;
EPD_7IN5_HD_SendCommand(0x4F);
EPD_7IN5_HD_SendData(0x00);
EPD_7IN5_HD_SendData(0x00);
EPD_7IN5_HD_SendCommand(0x24);
UDOUBLE i;
for(i=0; i<58080; i++) {
EPD_7IN5_HD_SendData(0xff);
}
EPD_7IN5_HD_SendCommand(0x26);
for(i=0; i<Height*Width; i++){
EPD_7IN5_HD_SendData(0xff);
}
EPD_7IN5_HD_SendCommand(0x22);
EPD_7IN5_HD_SendData(0xF7);//Load LUT from MCU(0x32)
EPD_7IN5_HD_SendCommand(0x20);
DEV_Delay_ms(10);
EPD_7IN5_HD_WaitUntilIdle();
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void EPD_7IN5_HD_Display(const UBYTE *blackimage)
{
UDOUBLE Width, Height;
Width =(EPD_7IN5_HD_WIDTH % 8 == 0)?(EPD_7IN5_HD_WIDTH / 8 ):(EPD_7IN5_HD_WIDTH / 8 + 1);
Height = EPD_7IN5_HD_HEIGHT;
EPD_7IN5_HD_SendCommand(0x4F);
EPD_7IN5_HD_SendData(0x00);
EPD_7IN5_HD_SendData(0x00);
EPD_7IN5_HD_SendCommand(0x24);
UDOUBLE i;
for (UDOUBLE j = 0; j < Height; j++) {
for (UDOUBLE i = 0; i < Width; i++) {
EPD_7IN5_HD_SendData(blackimage[i + j * Width]);
}
}
EPD_7IN5_HD_SendCommand(0x26);
for(i=0; i<Height*Width; i++) {
EPD_7IN5_HD_SendData(0xff);
}
EPD_7IN5_HD_SendCommand(0x22);
EPD_7IN5_HD_SendData(0xF7);//Load LUT from MCU(0x32)
EPD_7IN5_HD_SendCommand(0x20);
DEV_Delay_ms(10);
EPD_7IN5_HD_WaitUntilIdle();
}
void EPD_7IN5_HD_WritePicture(const UBYTE *blackimage, UBYTE Block)
{
UDOUBLE Width, Height;
Width =(EPD_7IN5_HD_WIDTH % 8 == 0)?(EPD_7IN5_HD_WIDTH / 8 ):(EPD_7IN5_HD_WIDTH / 8 + 1);
Height = EPD_7IN5_HD_HEIGHT;
if(Block == 0){
EPD_7IN5_HD_SendCommand(0x4F);
EPD_7IN5_HD_SendData(0x00);
EPD_7IN5_HD_SendData(0x00);
EPD_7IN5_HD_SendCommand(0x24);
UDOUBLE i;
for (UDOUBLE j = 0; j < Height/2; j++) {
for (UDOUBLE i = 0; i < Width; i++) {
EPD_7IN5_HD_SendData(blackimage[i + j * Width]);
}
}
}else if(Block == 1){
for (UDOUBLE j = 0; j < Height/2; j++) {
for (UDOUBLE i = 0; i < Width; i++) {
EPD_7IN5_HD_SendData(blackimage[i + j * Width]);
}
}
EPD_7IN5_HD_SendCommand(0x22);
EPD_7IN5_HD_SendData(0xF7);//Load LUT from MCU(0x32)
EPD_7IN5_HD_SendCommand(0x20);
DEV_Delay_ms(10);
EPD_7IN5_HD_WaitUntilIdle();
}
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter: image_width and start_X :Must be a multiple of 8
******************************************************************************/
void EPD_7IN5_HD_DisplayImage(const UBYTE *blackimage,UDOUBLE start_X, UDOUBLE start_Y, UDOUBLE image_width, UDOUBLE image_high)
{
UDOUBLE Width, Height;
Width =(EPD_7IN5_HD_WIDTH % 8 == 0)?(EPD_7IN5_HD_WIDTH / 8 ):(EPD_7IN5_HD_WIDTH / 8 + 1);
Height = EPD_7IN5_HD_HEIGHT;
EPD_7IN5_HD_SendCommand(0x4F);
EPD_7IN5_HD_SendData(0x00);
EPD_7IN5_HD_SendData(0x00);
//send black data
EPD_7IN5_HD_SendCommand(0x24);
for (UDOUBLE j = 0; j < Height; j++) {
for (UDOUBLE i = 0; i < Width; i++) {
if((i>=start_X/8) && (i<(start_X+image_width)/8) && (j>=start_Y) && (j<(start_Y+image_high))){
EPD_7IN5_HD_SendData(~blackimage[i-start_X/8 + (j - start_Y) * image_width/8]);
}else{
EPD_7IN5_HD_SendData(0xff);
}
}
}
EPD_7IN5_HD_SendCommand(0x22);
EPD_7IN5_HD_SendData(0xF7);//Load LUT from MCU(0x32)
EPD_7IN5_HD_SendCommand(0x20);
DEV_Delay_ms(10);
EPD_7IN5_HD_WaitUntilIdle();
}
/******************************************************************************
function : Enter sleep mode
parameter:
******************************************************************************/
void EPD_7IN5_HD_Sleep(void)
{
EPD_7IN5_HD_SendCommand(0x10);
EPD_7IN5_HD_SendData(0x01);
}

View file

@ -0,0 +1,48 @@
/*****************************************************************************
* | File : EPD_7in5_HD.h
* | Author : Waveshare team
* | Function : Electronic paper driver
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-04-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_7IN5_HD_H_
#define _EPD_7IN5_HD_H_
#include "DEV_Config.h"
// Display resolution
#define EPD_7IN5_HD_WIDTH 880
#define EPD_7IN5_HD_HEIGHT 528
void EPD_7IN5_HD_Init(void);
void EPD_7IN5_HD_Clear(void);
void EPD_7IN5_HD_ClearBlack(void);
void EPD_7IN5_HD_Display(const UBYTE *blackimage);
void EPD_7IN5_HD_Sleep(void);
void EPD_7IN5_HD_WritePicture(const UBYTE *blackimage, UBYTE Block);
void EPD_7IN5_HD_DisplayImage(const UBYTE *blackimage,UDOUBLE start_X, UDOUBLE start_Y, UDOUBLE image_width, UDOUBLE image_high);
#endif

View file

@ -0,0 +1,363 @@
/*****************************************************************************
* | File : EPD_7IN5B_HD_7in5.c
* | Author : Waveshare team
* | Function : Electronic paper driver
* | Info :
*----------------
* | This version: HD.0
* | Date : 2018-11-09
* | 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_7in5b_HD.h"
#include "Debug.h"
/******************************************************************************
function : Software reset
parameter:
******************************************************************************/
static void EPD_7IN5B_HD_Reset(void)
{
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(10);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
}
/******************************************************************************
function : send command
parameter:
Reg : Command register
******************************************************************************/
static void EPD_7IN5B_HD_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_7IN5B_HD_SendData(UBYTE Data)
{
DEV_Digital_Write(EPD_CS_PIN, 0);
DEV_Digital_Write(EPD_DC_PIN, 1);
DEV_SPI_WriteByte(Data);
DEV_Digital_Write(EPD_CS_PIN, 1);
}
/******************************************************************************
function : Wait until the busy_pin goes LOW
parameter:
******************************************************************************/
void EPD_7IN5B_HD_WaitUntilIdle(void)
{
Debug("e-Paper busy\r\n");
while(DEV_Digital_Read(EPD_BUSY_PIN)){
//DEV_Delay_ms(10);
}
DEV_Delay_ms(200);
Debug("e-Paper busy release\r\n");
}
/******************************************************************************
function : Turn On Display
parameter:
******************************************************************************/
static void EPD_7IN5B_HD_TurnOnDisplay(void)
{
EPD_7IN5B_HD_SendCommand(0x22);
EPD_7IN5B_HD_SendData(0xC7); //Load LUT from MCU(0x32)
EPD_7IN5B_HD_SendCommand(0x20);
DEV_Delay_ms(200); //!!!The delay here is necessary, 200uS at least!!!
EPD_7IN5B_HD_WaitUntilIdle(); //waiting for the electronic paper IC to release the idle signal
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
UBYTE EPD_7IN5B_HD_Init(void)
{
EPD_7IN5B_HD_Reset();
EPD_7IN5B_HD_SendCommand(0x12); //SWRESET
EPD_7IN5B_HD_WaitUntilIdle(); //waiting for the electronic paper IC to release the idle signal
EPD_7IN5B_HD_SendCommand(0x46); // Auto Write RAM
EPD_7IN5B_HD_SendData(0xF7);
EPD_7IN5B_HD_WaitUntilIdle(); //waiting for the electronic paper IC to release the idle signal
EPD_7IN5B_HD_SendCommand(0x47); // Auto Write RAM
EPD_7IN5B_HD_SendData(0xF7);
EPD_7IN5B_HD_WaitUntilIdle(); //waiting for the electronic paper IC to release the idle signal
EPD_7IN5B_HD_SendCommand(0x0C); // Soft start setting
EPD_7IN5B_HD_SendData(0xAE);
EPD_7IN5B_HD_SendData(0xC7);
EPD_7IN5B_HD_SendData(0xC3);
EPD_7IN5B_HD_SendData(0xC0);
EPD_7IN5B_HD_SendData(0x40);
EPD_7IN5B_HD_SendCommand(0x01); // Set MUX as 527
EPD_7IN5B_HD_SendData(0xAF);
EPD_7IN5B_HD_SendData(0x02);
EPD_7IN5B_HD_SendData(0x01);
EPD_7IN5B_HD_SendCommand(0x11); // Data entry mode
EPD_7IN5B_HD_SendData(0x01);
EPD_7IN5B_HD_SendCommand(0x44);
EPD_7IN5B_HD_SendData(0x00); // RAM x address start at 0
EPD_7IN5B_HD_SendData(0x00);
EPD_7IN5B_HD_SendData(0x6F); // RAM x address end at 36Fh -> 879
EPD_7IN5B_HD_SendData(0x03);
EPD_7IN5B_HD_SendCommand(0x45);
EPD_7IN5B_HD_SendData(0xAF); // RAM y address start at 20Fh;
EPD_7IN5B_HD_SendData(0x02);
EPD_7IN5B_HD_SendData(0x00); // RAM y address end at 00h;
EPD_7IN5B_HD_SendData(0x00);
EPD_7IN5B_HD_SendCommand(0x3C); // VBD
EPD_7IN5B_HD_SendData(0x01); // LUT1, for white
EPD_7IN5B_HD_SendCommand(0x18);
EPD_7IN5B_HD_SendData(0X80);
EPD_7IN5B_HD_SendCommand(0x22);
EPD_7IN5B_HD_SendData(0XB1); //Load Temperature and waveform setting.
EPD_7IN5B_HD_SendCommand(0x20);
EPD_7IN5B_HD_WaitUntilIdle(); //waiting for the electronic paper IC to release the idle signal
EPD_7IN5B_HD_SendCommand(0x4E);
EPD_7IN5B_HD_SendData(0x00);
EPD_7IN5B_HD_SendData(0x00);
EPD_7IN5B_HD_SendCommand(0x4F);
EPD_7IN5B_HD_SendData(0xAF);
EPD_7IN5B_HD_SendData(0x02);
return 0;
}
/******************************************************************************
function : Clear screen
parameter:
******************************************************************************/
void EPD_7IN5B_HD_Clear(void)
{
UWORD Width, Height;
Width =(EPD_7IN5B_HD_WIDTH % 8 == 0)?(EPD_7IN5B_HD_WIDTH / 8 ):(EPD_7IN5B_HD_WIDTH / 8 + 1);
Height = EPD_7IN5B_HD_HEIGHT;
EPD_7IN5B_HD_SendCommand(0x4F);
EPD_7IN5B_HD_SendData(0xAf);
EPD_7IN5B_HD_SendData(0x02);
UWORD i;
EPD_7IN5B_HD_SendCommand(0x24);
for(i=0; i<Width*Height; i++) {
EPD_7IN5B_HD_SendData(0xff);
}
EPD_7IN5B_HD_SendCommand(0x26);
for(i=0; i<Width*Height; i++) {
EPD_7IN5B_HD_SendData(0x00);
}
EPD_7IN5B_HD_TurnOnDisplay();
}
void EPD_7IN5B_HD_ClearRed(void)
{
UWORD Width, Height;
Width =(EPD_7IN5B_HD_WIDTH % 8 == 0)?(EPD_7IN5B_HD_WIDTH / 8 ):(EPD_7IN5B_HD_WIDTH / 8 + 1);
Height = EPD_7IN5B_HD_HEIGHT;
UWORD i;
EPD_7IN5B_HD_SendCommand(0x4F);
EPD_7IN5B_HD_SendData(0xAF);
EPD_7IN5B_HD_SendData(0x02);
EPD_7IN5B_HD_SendCommand(0x24);
for(i=0; i<Width*Height; i++) {
EPD_7IN5B_HD_SendData(0xff);
}
EPD_7IN5B_HD_SendCommand(0x26);
for(i=0; i<Width*Height; i++) {
EPD_7IN5B_HD_SendData(0xff);
}
EPD_7IN5B_HD_TurnOnDisplay();
}
void EPD_7IN5B_HD_ClearBlack(void)
{
UWORD Width, Height;
Width =(EPD_7IN5B_HD_WIDTH % 8 == 0)?(EPD_7IN5B_HD_WIDTH / 8 ):(EPD_7IN5B_HD_WIDTH / 8 + 1);
Height = EPD_7IN5B_HD_HEIGHT;
UWORD i;
EPD_7IN5B_HD_SendCommand(0x4F);
EPD_7IN5B_HD_SendData(0xAF);
EPD_7IN5B_HD_SendData(0x02);
EPD_7IN5B_HD_SendCommand(0x24);
for(i=0; i<Width*Height; i++) {
EPD_7IN5B_HD_SendData(0x00);
}
EPD_7IN5B_HD_SendCommand(0x26);
for(i=0; i<Width*Height; i++) {
EPD_7IN5B_HD_SendData(0x00);
}
EPD_7IN5B_HD_TurnOnDisplay();
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void EPD_7IN5B_HD_Display(const UBYTE *blackimage, const UBYTE *ryimage)
{
UDOUBLE Width, Height;
Width =(EPD_7IN5B_HD_WIDTH % 8 == 0)?(EPD_7IN5B_HD_WIDTH / 8 ):(EPD_7IN5B_HD_WIDTH / 8 + 1);
Height = EPD_7IN5B_HD_HEIGHT;
EPD_7IN5B_HD_SendCommand(0x4F);
EPD_7IN5B_HD_SendData(0xAF);
EPD_7IN5B_HD_SendData(0x02);
//send black data
EPD_7IN5B_HD_SendCommand(0x24);
for (UDOUBLE j = 0; j < Height; j++) {
for (UDOUBLE i = 0; i < Width; i++) {
EPD_7IN5B_HD_SendData(blackimage[i + j * Width]);
}
}
//send red data
EPD_7IN5B_HD_SendCommand(0x26);
for (UDOUBLE j = 0; j < Height; j++) {
for (UDOUBLE i = 0; i < Width; i++) {
EPD_7IN5B_HD_SendData(~ryimage[i + j * Width]);
}
}
EPD_7IN5B_HD_TurnOnDisplay();
}
void EPD_7IN5B_HD_DisplayPicture(const UBYTE *blackimage,UBYTE Block)
{
UDOUBLE Width, Height;
Width =(EPD_7IN5B_HD_WIDTH % 8 == 0)?(EPD_7IN5B_HD_WIDTH / 8 ):(EPD_7IN5B_HD_WIDTH / 8 + 1);
Height = EPD_7IN5B_HD_HEIGHT;
if(Block == 0){
EPD_7IN5B_HD_SendCommand(0x4F);
EPD_7IN5B_HD_SendData(0xAF);
EPD_7IN5B_HD_SendData(0x02);
EPD_7IN5B_HD_SendCommand(0x24);
for (UDOUBLE j = 0; j < Height/2; j++) {
for (UDOUBLE i = 0; i < Width; i++) {
EPD_7IN5B_HD_SendData(blackimage[i + j * Width]);
}
}
}else if(Block == 1){
for (UDOUBLE j = 0; j < Height/2; j++) {
for (UDOUBLE i = 0; i < Width; i++) {
EPD_7IN5B_HD_SendData(blackimage[i + j * Width]);
}
}
}else if(Block == 2){
EPD_7IN5B_HD_SendCommand(0x26);
for (UDOUBLE j = 0; j < Height/2; j++) {
for (UDOUBLE i = 0; i < Width; i++) {
EPD_7IN5B_HD_SendData(~blackimage[i + j * Width]);
}
}
}else if(Block == 3){
for (UDOUBLE j = 0; j < Height/2; j++) {
for (UDOUBLE i = 0; i < Width; i++) {
EPD_7IN5B_HD_SendData(~blackimage[i + j * Width]);
}
}
EPD_7IN5B_HD_TurnOnDisplay();
}
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter: image_width and start_X :Must be a multiple of 8
******************************************************************************/
void EPD_7IN5B_HD_DisplayImage(const UBYTE *blackimage, const UBYTE *ryimage,UDOUBLE start_X, UDOUBLE start_Y, UDOUBLE image_width, UDOUBLE image_high)
{
UDOUBLE Width, Height;
Width =(EPD_7IN5B_HD_WIDTH % 8 == 0)?(EPD_7IN5B_HD_WIDTH / 8 ):(EPD_7IN5B_HD_WIDTH / 8 + 1);
Height = EPD_7IN5B_HD_HEIGHT;
EPD_7IN5B_HD_SendCommand(0x4F);
EPD_7IN5B_HD_SendData(0xAF);
EPD_7IN5B_HD_SendData(0x02);
//send black data
EPD_7IN5B_HD_SendCommand(0x24);
for (UDOUBLE j = 0; j < Height; j++) {
for (UDOUBLE i = 0; i < Width; i++) {
if((i>=start_X/8) && (i<(start_X+image_width)/8) && (j>=start_Y) && (j<(start_Y+image_high))){
EPD_7IN5B_HD_SendData(blackimage[i-start_X/8 + (j - start_Y) * image_width/8]);
}else{
EPD_7IN5B_HD_SendData(0xff);
}
}
}
//send red data
EPD_7IN5B_HD_SendCommand(0x26);
for (UDOUBLE j = 0; j < Height; j++) {
for (UDOUBLE i = 0; i < Width; i++) {
if((i>=start_X/8) && (i<(start_X+image_width)/8) && (j>=start_Y) && (j<(start_Y+image_high))){
EPD_7IN5B_HD_SendData(~ryimage[i-start_X/8 + (j - start_Y) * image_width/8]);
}else{
EPD_7IN5B_HD_SendData(0x00);
}
}
}
EPD_7IN5B_HD_TurnOnDisplay();
}
/******************************************************************************
function : Enter sleep mode
parameter:
******************************************************************************/
void EPD_7IN5B_HD_Sleep(void)
{
EPD_7IN5B_HD_SendCommand(0x10); //deep sleep
EPD_7IN5B_HD_SendData(0x01);
}

View file

@ -0,0 +1,51 @@
/*****************************************************************************
* | File : EPD_7in5_HD.h
* | Author : Waveshare team
* | Function : Electronic paper driver
* | Info :
*----------------
* | This version: EPD_7in5_HD.0
* | Date : 2020-04-27
* | Info :
* 1.Remove:ImageBuff[EPD_HEIGHT * EPD_WIDTH / 8]
* 2.Change:EPD_Display(UBYTE *Image)
* Need to pass parameters: pointer to cached data
#
# 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_7IN5B_HD_H_
#define _EPD_7IN5B_HD_H_
#include "DEV_Config.h"
// Display resolution
#define EPD_7IN5B_HD_WIDTH 880
#define EPD_7IN5B_HD_HEIGHT 528
UBYTE EPD_7IN5B_HD_Init(void);
void EPD_7IN5B_HD_Clear(void);
void EPD_7IN5B_HD_ClearRed(void);
void EPD_7IN5B_HD_ClearBlack(void);
void EPD_7IN5B_HD_Display(const UBYTE *blackimage, const UBYTE *ryimage);
void EPD_7IN5B_HD_Sleep(void);
void EPD_7IN5B_HD_DisplayPicture(const UBYTE *blackimage,UBYTE Block);
void EPD_7IN5B_HD_DisplayImage(const UBYTE *blackimage, const UBYTE *ryimage,UDOUBLE start_X, UDOUBLE start_Y, UDOUBLE image_width, UDOUBLE image_high);
#endif

View file

@ -136,6 +136,12 @@ UBYTE EPD_7IN5B_V2_Init(void)
EPD_7IN5B_V2_SendCommand(0X60); //TCON SETTING
EPD_7IN5B_V2_SendData(0x22);
EPD_7IN5B_V2_SendCommand(0X82);
EPD_7IN5B_V2_SendData(0x08);
EPD_7IN5B_V2_SendCommand(0X30);
EPD_7IN5B_V2_SendData(0x06);
return 0;
}