2020-09-03

This commit is contained in:
wangkg 2020-09-04 15:30:45 +08:00
commit 751a9fb93f
570 changed files with 50854 additions and 16474 deletions

View file

@ -88,11 +88,11 @@ parameter:
static void EPD_1IN54C_Reset(void)
{
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(10);
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(10);
DEV_Delay_ms(100);
}
/******************************************************************************

View file

@ -1,7 +1,7 @@
/*****************************************************************************
* | File : EPD_2in13b_V2.c
* | File : EPD_2in13b_V3.c
* | Author : Waveshare team
* | Function : 2.13inch e-paper b V2
* | Function : 2.13inch e-paper b V3
* | Info :
*----------------
* | This version: V1.0
@ -28,14 +28,14 @@
# THE SOFTWARE.
#
******************************************************************************/
#include "EPD_2in13b_V2.h"
#include "EPD_2in13b_V3.h"
#include "Debug.h"
//元太屏
/******************************************************************************
function : Software reset
parameter:
******************************************************************************/
static void EPD_2IN13B_V2_Reset(void)
static void EPD_2IN13B_V3_Reset(void)
{
DEV_Digital_Write(EPD_CS_PIN, 1);
@ -52,7 +52,7 @@ function : send command
parameter:
Reg : Command register
******************************************************************************/
static void EPD_2IN13B_V2_SendCommand(UBYTE Reg)
static void EPD_2IN13B_V3_SendCommand(UBYTE Reg)
{
DEV_Digital_Write(EPD_DC_PIN, 0);
@ -66,7 +66,7 @@ function : send data
parameter:
Data : Write data
******************************************************************************/
static void EPD_2IN13B_V2_SendData(UBYTE Data)
static void EPD_2IN13B_V3_SendData(UBYTE Data)
{
DEV_Digital_Write(EPD_DC_PIN, 1);
DEV_Digital_Write(EPD_CS_PIN, 0);
@ -78,12 +78,12 @@ static void EPD_2IN13B_V2_SendData(UBYTE Data)
function : Wait until the busy_pin goes LOW
parameter:
******************************************************************************/
void EPD_2IN13B_V2_ReadBusy(void)
void EPD_2IN13B_V3_ReadBusy(void)
{
UBYTE busy;
Debug("e-Paper busy\r\n");
do{
EPD_2IN13B_V2_SendCommand(0x71);
EPD_2IN13B_V3_SendCommand(0x71);
busy = DEV_Digital_Read(EPD_BUSY_PIN);
busy =!(busy & 0x01);
}while(busy);
@ -95,36 +95,36 @@ void EPD_2IN13B_V2_ReadBusy(void)
function : Turn On Display
parameter:
******************************************************************************/
static void EPD_2IN13B_V2_TurnOnDisplay(void)
static void EPD_2IN13B_V3_TurnOnDisplay(void)
{
EPD_2IN13B_V2_SendCommand(0x12); //DISPLAY REFRESH
EPD_2IN13B_V3_SendCommand(0x12); //DISPLAY REFRESH
DEV_Delay_ms(100);
EPD_2IN13B_V2_ReadBusy();
EPD_2IN13B_V3_ReadBusy();
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
void EPD_2IN13B_V2_Init(void)
void EPD_2IN13B_V3_Init(void)
{
EPD_2IN13B_V2_Reset();
EPD_2IN13B_V3_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_V3_SendCommand(0x04);
EPD_2IN13B_V3_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_V3_SendCommand(0x00);//panel setting
EPD_2IN13B_V3_SendData(0x0f);//LUT from OTP128x296
EPD_2IN13B_V3_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_V3_SendCommand(0x61);//resolution setting
EPD_2IN13B_V3_SendData (0x68);
EPD_2IN13B_V3_SendData (0x00);
EPD_2IN13B_V3_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
EPD_2IN13B_V3_SendCommand(0X50);//VCOM AND DATA INTERVAL SETTING
EPD_2IN13B_V3_SendData(0x77);//WBmode:VBDF 17|D7 VBDW 97 VBDB 57
//WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7;
}
@ -132,66 +132,66 @@ void EPD_2IN13B_V2_Init(void)
function : Clear screen
parameter:
******************************************************************************/
void EPD_2IN13B_V2_Clear(void)
void EPD_2IN13B_V3_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;
UWORD Width = (EPD_2IN13B_V3_WIDTH % 8 == 0)? (EPD_2IN13B_V3_WIDTH / 8 ): (EPD_2IN13B_V3_WIDTH / 8 + 1);
UWORD Height = EPD_2IN13B_V3_HEIGHT;
//send black data
EPD_2IN13B_V2_SendCommand(0x10);
EPD_2IN13B_V3_SendCommand(0x10);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_2IN13B_V2_SendData(0xFF);
EPD_2IN13B_V3_SendData(0xFF);
}
}
//send red data
EPD_2IN13B_V2_SendCommand(0x13);
EPD_2IN13B_V3_SendCommand(0x13);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_2IN13B_V2_SendData(0xFF);
EPD_2IN13B_V3_SendData(0xFF);
}
}
EPD_2IN13B_V2_TurnOnDisplay();
EPD_2IN13B_V3_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)
void EPD_2IN13B_V3_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;
Width = (EPD_2IN13B_V3_WIDTH % 8 == 0)? (EPD_2IN13B_V3_WIDTH / 8 ): (EPD_2IN13B_V3_WIDTH / 8 + 1);
Height = EPD_2IN13B_V3_HEIGHT;
EPD_2IN13B_V2_SendCommand(0x10);
EPD_2IN13B_V3_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_V3_SendData(blackimage[i + j * Width]);
}
}
EPD_2IN13B_V2_SendCommand(0x13);
EPD_2IN13B_V3_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_V3_SendData(ryimage[i + j * Width]);
}
}
EPD_2IN13B_V2_TurnOnDisplay();
EPD_2IN13B_V3_TurnOnDisplay();
}
/******************************************************************************
function : Enter sleep mode
parameter:
******************************************************************************/
void EPD_2IN13B_V2_Sleep(void)
void EPD_2IN13B_V3_Sleep(void)
{
EPD_2IN13B_V2_SendCommand(0X50);
EPD_2IN13B_V2_SendData(0xf7);
EPD_2IN13B_V3_SendCommand(0X50);
EPD_2IN13B_V3_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);
EPD_2IN13B_V3_SendCommand(0X02); //power off
EPD_2IN13B_V3_ReadBusy(); //waiting for the electronic paper IC to release the idle signal
EPD_2IN13B_V3_SendCommand(0X07); //deep sleep
EPD_2IN13B_V3_SendData(0xA5);
}

View file

@ -1,7 +1,7 @@
/*****************************************************************************
* | File : EPD_2in13b_V2.h
* | File : EPD_2in13b_V3.h
* | Author : Waveshare team
* | Function : 2.13inch e-paper b V2
* | Function : 2.13inch e-paper b V3
* | Info :
*----------------
* | This version: V1.0
@ -28,18 +28,18 @@
# THE SOFTWARE.
#
******************************************************************************/
#ifndef __EPD_2IN13B_V2_H_
#define __EPD_2IN13B_V2_H_
#ifndef __EPD_2IN13B_V3_H_
#define __EPD_2IN13B_V3_H_
#include "DEV_Config.h"
// Display resolution
#define EPD_2IN13B_V2_WIDTH 104
#define EPD_2IN13B_V2_HEIGHT 212
#define EPD_2IN13B_V3_WIDTH 104
#define EPD_2IN13B_V3_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);
void EPD_2IN13B_V3_Init(void);
void EPD_2IN13B_V3_Clear(void);
void EPD_2IN13B_V3_Display(const UBYTE *blackimage, const UBYTE *ryimage);
void EPD_2IN13B_V3_Sleep(void);
#endif

View file

@ -0,0 +1,259 @@
/*****************************************************************************
* | File : EPD_2in66.c
* | Author : Waveshare team
* | Function : 2.66inch e-paper
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-07-29
* | 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_2in66.h"
#include "Debug.h"
const unsigned char WF_PARTIAL[159] ={
0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x40,0x40,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x0A,0x00,0x00,0x00,0x00,0x00,0x02,0x01,0x00,0x00,
0x00,0x00,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,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,0x22,0x22,0x22,0x22,0x22,0x22,
0x00,0x00,0x00,0x22,0x17,0x41,0xB0,0x32,0x36,
};
/******************************************************************************
function : Software reset
parameter:
******************************************************************************/
static void EPD_2IN66_Reset(void)
{
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(20);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
}
/******************************************************************************
function : send command
parameter:
Reg : Command register
******************************************************************************/
static void EPD_2IN66_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_2IN66_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_2IN66_ReadBusy(void)
{
Debug("e-Paper busy\r\n");
DEV_Delay_ms(100);
while(DEV_Digital_Read(EPD_BUSY_PIN) == 1) { //LOW: idle, HIGH: busy
DEV_Delay_ms(100);
}
DEV_Delay_ms(100);
Debug("e-Paper busy release\r\n");
}
/******************************************************************************
function : Turn On Display
parameter:
******************************************************************************/
static void EPD_2IN66_TurnOnDisplay(void)
{
EPD_2IN66_SendCommand(0x20);
EPD_2IN66_ReadBusy();
}
/******************************************************************************
function : Send LUT
parameter:
******************************************************************************/
static void EPD_2IN66_SetLUA(void)
{
UWORD count;
EPD_2IN66_SendCommand(0x32);
for(count=0;count<153;count++){
EPD_2IN66_SendData(WF_PARTIAL[count]);
}
EPD_2IN66_ReadBusy();
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
void EPD_2IN66_Init(void)
{
EPD_2IN66_Reset();
EPD_2IN66_ReadBusy();
EPD_2IN66_SendCommand(0x12);//soft reset
EPD_2IN66_ReadBusy();
/* Y increment, X increment */
EPD_2IN66_SendCommand(0x11);
EPD_2IN66_SendData(0x03);
/* Set RamX-address Start/End position */
EPD_2IN66_SendCommand(0x44);
EPD_2IN66_SendData(0x01);
EPD_2IN66_SendData((EPD_2IN66_WIDTH % 8 == 0)? (EPD_2IN66_WIDTH / 8 ): (EPD_2IN66_WIDTH / 8 + 1) );
/* Set RamY-address Start/End position */
EPD_2IN66_SendCommand(0x45);
EPD_2IN66_SendData(0);
EPD_2IN66_SendData(0);
EPD_2IN66_SendData((EPD_2IN66_HEIGHT&0xff));
EPD_2IN66_SendData((EPD_2IN66_HEIGHT&0x100)>>8);
EPD_2IN66_ReadBusy();
}
/******************************************************************************
function : Initialize the e-Paper register(Partial display)
parameter:
******************************************************************************/
void EPD_2IN66_Init_Partial(void)
{
EPD_2IN66_Reset();
EPD_2IN66_ReadBusy();
EPD_2IN66_SendCommand(0x12);//soft reset
EPD_2IN66_ReadBusy();
EPD_2IN66_SetLUA();
EPD_2IN66_SendCommand(0x37);
EPD_2IN66_SendData(0x00);
EPD_2IN66_SendData(0x00);
EPD_2IN66_SendData(0x00);
EPD_2IN66_SendData(0x00);
EPD_2IN66_SendData(0x00);
EPD_2IN66_SendData(0x40);
EPD_2IN66_SendData(0x00);
EPD_2IN66_SendData(0x00);
EPD_2IN66_SendData(0x00);
EPD_2IN66_SendData(0x00);
/* Y increment, X increment */
EPD_2IN66_SendCommand(0x11);
EPD_2IN66_SendData(0x03);
/* Set RamX-address Start/End position */
EPD_2IN66_SendCommand(0x44);
EPD_2IN66_SendData(0x01);
EPD_2IN66_SendData((EPD_2IN66_WIDTH % 8 == 0)? (EPD_2IN66_WIDTH / 8 ): (EPD_2IN66_WIDTH / 8 + 1) );
/* Set RamY-address Start/End position */
EPD_2IN66_SendCommand(0x45);
EPD_2IN66_SendData(0);
EPD_2IN66_SendData(0);
EPD_2IN66_SendData((EPD_2IN66_HEIGHT&0xff));
EPD_2IN66_SendData((EPD_2IN66_HEIGHT&0x100)>>8);
EPD_2IN66_SendCommand(0x3C);
EPD_2IN66_SendData(0x80);
EPD_2IN66_SendCommand(0x22);
EPD_2IN66_SendData(0xcf);
EPD_2IN66_SendCommand(0x20);
EPD_2IN66_ReadBusy();
}
/******************************************************************************
function : Clear screen
parameter:
******************************************************************************/
void EPD_2IN66_Clear(void)
{
UWORD Width, Height;
Width = (EPD_2IN66_WIDTH % 8 == 0)? (EPD_2IN66_WIDTH / 8 ): (EPD_2IN66_WIDTH / 8 + 1);
Height = EPD_2IN66_HEIGHT;
EPD_2IN66_SendCommand(0x24);
for (UWORD j = 0; j <=Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_2IN66_SendData(0xff);
}
}
EPD_2IN66_TurnOnDisplay();
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void EPD_2IN66_Display(UBYTE *Image)
{
UWORD Width, Height;
Width = (EPD_2IN66_WIDTH % 8 == 0)? (EPD_2IN66_WIDTH / 8 ): (EPD_2IN66_WIDTH / 8 + 1);
Height = EPD_2IN66_HEIGHT;
UDOUBLE Addr = 0;
// UDOUBLE Offset = ImageName;
EPD_2IN66_SendCommand(0x24);
for (UWORD j = 0; j <Height; j++) {
for (UWORD i = 0; i <Width; i++) {
Addr = i + j * Width;
EPD_2IN66_SendData(Image[Addr]);
}
}
EPD_2IN66_TurnOnDisplay();
}
/******************************************************************************
function : Enter sleep mode
parameter:
******************************************************************************/
void EPD_2IN66_Sleep(void)
{
EPD_2IN66_SendCommand(0x10);
EPD_2IN66_SendData(0x01);
//EPD_2IN66_ReadBusy();
}

View file

@ -0,0 +1,46 @@
/*****************************************************************************
* | File : EPD_2in66.h
* | Author : Waveshare team
* | Function : 2.66inch e-paper
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-07-29
* | 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_2IN66_H_
#define __EPD_2IN66_H_
#include "DEV_Config.h"
// Display resolution
#define EPD_2IN66_WIDTH 152
#define EPD_2IN66_HEIGHT 296
void EPD_2IN66_Init(void);
void EPD_2IN66_Init_Partial(void);
void EPD_2IN66_Clear(void);
void EPD_2IN66_Display(UBYTE *Image);
void EPD_2IN66_Sleep(void);
#endif

View file

@ -104,7 +104,7 @@ static void EPD_2IN9_Reset(void)
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(200);
DEV_Delay_ms(10);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
}

View file

@ -5,7 +5,7 @@
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-04-12
* | Date : 2020-07-03
* | Info :
* -----------------------------------------------------------------------------
#
@ -40,7 +40,7 @@ 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_Delay_ms(5);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
}
@ -97,7 +97,6 @@ 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
@ -155,6 +154,7 @@ void EPD_2IN9B_V2_Display(const UBYTE *blackimage, const UBYTE *ryimage)
Width = (EPD_2IN9B_V2_WIDTH % 8 == 0)? (EPD_2IN9B_V2_WIDTH / 8 ): (EPD_2IN9B_V2_WIDTH / 8 + 1);
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++) {
@ -163,6 +163,7 @@ void EPD_2IN9B_V2_Display(const UBYTE *blackimage, const UBYTE *ryimage)
}
EPD_2IN9B_V2_SendCommand(0x92);
//send red data
EPD_2IN9B_V2_SendCommand(0x13);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {

View file

@ -93,7 +93,7 @@ static void EPD_2IN9BC_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_Delay_ms(1);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
}

View file

@ -165,7 +165,7 @@ static void EPD_2IN9D_Reset(void)
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(200);
DEV_Delay_ms(10);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
}

View file

@ -0,0 +1,585 @@
/*****************************************************************************
* | File : EPD_3IN7.C
* | Author : Waveshare team
* | Function : 3.7inch e-paper
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-07-17
* | 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_3in7.h"
#include "Debug.h"
static const UBYTE lut_4Gray_GC[] =
{
0x2A,0x06,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//1
0x28,0x06,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//2
0x20,0x06,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//3
0x14,0x06,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//4
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//5
0x00,0x02,0x02,0x0A,0x00,0x00,0x00,0x08,0x08,0x02,//6
0x00,0x02,0x02,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,//7
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//8
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//9
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//10
0x22,0x22,0x22,0x22,0x22
};
static const UBYTE lut_1Gray_GC[] =
{
0x2A,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//1
0x05,0x2A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//2
0x2A,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//3
0x05,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//4
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//5
0x00,0x02,0x03,0x0A,0x00,0x02,0x06,0x0A,0x05,0x00,//6
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//7
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//8
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//9
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//10
0x22,0x22,0x22,0x22,0x22
};
static const UBYTE lut_1Gray_DU[] =
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//1
0x01,0x2A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x0A,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//3
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//5
0x00,0x00,0x05,0x05,0x00,0x05,0x03,0x05,0x05,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//7
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//9
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x22,0x22,0x22,0x22,0x22
};
static const UBYTE lut_1Gray_A2[] =
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //1
0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //2
0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //3
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //4
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //5
0x00,0x00,0x03,0x05,0x00,0x00,0x00,0x00,0x00,0x00, //6
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //7
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //8
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //9
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //10
0x22,0x22,0x22,0x22,0x22
};
/******************************************************************************
function : Software reset
parameter:
******************************************************************************/
static void EPD_3IN7_Reset(void)
{
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(300);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(3);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(300);
}
/******************************************************************************
function : send command
parameter:
Reg : Command register
******************************************************************************/
static void EPD_3IN7_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_3IN7_SendData(UBYTE Data)
{
DEV_Digital_Write(EPD_DC_PIN, 1);
DEV_Digital_Write(EPD_CS_PIN, 0);
DEV_SPI_WriteByte(Data);
DEV_Digital_Write(EPD_CS_PIN, 1);
}
static void EPD_3IN7_ReadBusy_HIGH(void)
{
Debug("e-Paper busy\r\n");
UBYTE busy;
do {
busy = DEV_Digital_Read(EPD_BUSY_PIN);
} while(busy);
DEV_Delay_ms(200);
Debug("e-Paper busy release\r\n");
}
/******************************************************************************
function : set the look-up tables
parameter:
******************************************************************************/
void EPD_3IN7_Load_LUT(UBYTE lut)
{
UWORD i;
EPD_3IN7_SendCommand(0x32);
for (i = 0; i < 105; i++)
{
if(lut == 0)
EPD_3IN7_SendData(lut_4Gray_GC[i]);
else if(lut == 1)
EPD_3IN7_SendData(lut_1Gray_GC[i]);
else if(lut == 2)
EPD_3IN7_SendData(lut_1Gray_DU[i]);
else if(lut == 3)
EPD_3IN7_SendData(lut_1Gray_A2[i]);
else
Debug("There is no such lut \r\n");
}
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
void EPD_3IN7_4Gray_Init(void)
{
EPD_3IN7_Reset();
EPD_3IN7_SendCommand(0x12);
DEV_Delay_ms(300);
EPD_3IN7_SendCommand(0x46);
EPD_3IN7_SendData(0xF7);
EPD_3IN7_ReadBusy_HIGH();
EPD_3IN7_SendCommand(0x47);
EPD_3IN7_SendData(0xF7);
EPD_3IN7_ReadBusy_HIGH();
EPD_3IN7_SendCommand(0x01); // setting gaet number
EPD_3IN7_SendData(0xDF);
EPD_3IN7_SendData(0x01);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendCommand(0x03); // set gate voltage
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendCommand(0x04); // set source voltage
EPD_3IN7_SendData(0x41);
EPD_3IN7_SendData(0xA8);
EPD_3IN7_SendData(0x32);
EPD_3IN7_SendCommand(0x11); // set data entry sequence
EPD_3IN7_SendData(0x03);
EPD_3IN7_SendCommand(0x3C); // set border
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendCommand(0x0C); // set booster strength
EPD_3IN7_SendData(0xAE);
EPD_3IN7_SendData(0xC7);
EPD_3IN7_SendData(0xC3);
EPD_3IN7_SendData(0xC0);
EPD_3IN7_SendData(0xC0);
EPD_3IN7_SendCommand(0x18); // set internal sensor on
EPD_3IN7_SendData(0x80);
EPD_3IN7_SendCommand(0x2C); // set vcom value
EPD_3IN7_SendData(0x44);
EPD_3IN7_SendCommand(0x37); // set display option, these setting turn on previous function
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendCommand(0x44); // setting X direction start/end position of RAM
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x17);
EPD_3IN7_SendData(0x01);
EPD_3IN7_SendCommand(0x45); // setting Y direction start/end position of RAM
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0xDF);
EPD_3IN7_SendData(0x01);
EPD_3IN7_SendCommand(0x22); // Display Update Control 2
EPD_3IN7_SendData(0xCF);
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
void EPD_3IN7_1Gray_Init(void)
{
EPD_3IN7_Reset();
EPD_3IN7_SendCommand(0x12);
DEV_Delay_ms(300);
EPD_3IN7_SendCommand(0x46);
EPD_3IN7_SendData(0xF7);
EPD_3IN7_ReadBusy_HIGH();
EPD_3IN7_SendCommand(0x47);
EPD_3IN7_SendData(0xF7);
EPD_3IN7_ReadBusy_HIGH();
EPD_3IN7_SendCommand(0x01); // setting gaet number
EPD_3IN7_SendData(0xDF);
EPD_3IN7_SendData(0x01);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendCommand(0x03); // set gate voltage
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendCommand(0x04); // set source voltage
EPD_3IN7_SendData(0x41);
EPD_3IN7_SendData(0xA8);
EPD_3IN7_SendData(0x32);
EPD_3IN7_SendCommand(0x11); // set data entry sequence
EPD_3IN7_SendData(0x03);
EPD_3IN7_SendCommand(0x3C); // set border
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendCommand(0x0C); // set booster strength
EPD_3IN7_SendData(0xAE);
EPD_3IN7_SendData(0xC7);
EPD_3IN7_SendData(0xC3);
EPD_3IN7_SendData(0xC0);
EPD_3IN7_SendData(0xC0);
EPD_3IN7_SendCommand(0x18); // set internal sensor on
EPD_3IN7_SendData(0x80);
EPD_3IN7_SendCommand(0x2C); // set vcom value
EPD_3IN7_SendData(0x44);
EPD_3IN7_SendCommand(0x37); // set display option, these setting turn on previous function
EPD_3IN7_SendData(0x00); //can switch 1 gray or 4 gray
EPD_3IN7_SendData(0xFF);
EPD_3IN7_SendData(0xFF);
EPD_3IN7_SendData(0xFF);
EPD_3IN7_SendData(0xFF);
EPD_3IN7_SendData(0x4F);
EPD_3IN7_SendData(0xFF);
EPD_3IN7_SendData(0xFF);
EPD_3IN7_SendData(0xFF);
EPD_3IN7_SendData(0xFF);
EPD_3IN7_SendCommand(0x44); // setting X direction start/end position of RAM
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x17);
EPD_3IN7_SendData(0x01);
EPD_3IN7_SendCommand(0x45); // setting Y direction start/end position of RAM
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0xDF);
EPD_3IN7_SendData(0x01);
EPD_3IN7_SendCommand(0x22); // Display Update Control 2
EPD_3IN7_SendData(0xCF);
}
/******************************************************************************
function : Clear screen
parameter:
******************************************************************************/
void EPD_3IN7_4Gray_Clear(void)
{
UWORD Width, Height;
Width = (EPD_3IN7_WIDTH % 8 == 0)? (EPD_3IN7_WIDTH / 8 ): (EPD_3IN7_WIDTH / 8 + 1);
Height = EPD_3IN7_HEIGHT;
EPD_3IN7_SendCommand(0x49);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendCommand(0x4E);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendCommand(0x4F);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendCommand(0x24);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_3IN7_SendData(0xff);
}
}
EPD_3IN7_SendCommand(0x4E);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendCommand(0x4F);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendCommand(0x26);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_3IN7_SendData(0xff);
}
}
EPD_3IN7_Load_LUT(0);
EPD_3IN7_SendCommand(0x22);
EPD_3IN7_SendData(0xC7);
EPD_3IN7_SendCommand(0x20);
EPD_3IN7_ReadBusy_HIGH();
}
/******************************************************************************
function : Clear screen
parameter:
******************************************************************************/
void EPD_3IN7_1Gray_Clear(void)
{
UWORD i;
UWORD IMAGE_COUNTER = EPD_3IN7_WIDTH * EPD_3IN7_HEIGHT / 8;
EPD_3IN7_SendCommand(0x4E);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendCommand(0x4F);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendCommand(0x24);
for (i = 0; i < IMAGE_COUNTER; i++)
{
EPD_3IN7_SendData(0xff);
}
EPD_3IN7_Load_LUT(2);
EPD_3IN7_SendCommand(0x20);
EPD_3IN7_ReadBusy_HIGH();
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void EPD_3IN7_4Gray_Display(const UBYTE *Image)
{
UDOUBLE i,j,k;
UBYTE temp1,temp2,temp3;
EPD_3IN7_SendCommand(0x49);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendCommand(0x4E);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendCommand(0x4F);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendCommand(0x24);
for(i=0;i<16800;i++){
temp3=0;
for(j=0; j<2; j++) {
temp1 = Image[i*2+j];
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)
temp3 |= 0x00; //gray1
else //0x40
temp3 |= 0x01; //gray2
temp3 <<= 1;
temp1 <<= 2;
temp2 = temp1&0xC0 ;
if(temp2 == 0xC0) //white
temp3 |= 0x01;
else if(temp2 == 0x00) //black
temp3 |= 0x00;
else if(temp2 == 0x80)
temp3 |= 0x00; //gray1
else //0x40
temp3 |= 0x01; //gray2
if(j!=1 || k!=1)
temp3 <<= 1;
temp1 <<= 2;
}
}
EPD_3IN7_SendData(temp3);
}
// new data
EPD_3IN7_SendCommand(0x4E);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendCommand(0x4F);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendCommand(0x26);
for(i=0; i<16800; i++) {
temp3=0;
for(j=0; j<2; j++) {
temp1 = Image[i*2+j];
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)
temp3 |= 0x01; //gray1
else //0x40
temp3 |= 0x00; //gray2
temp3 <<= 1;
temp1 <<= 2;
temp2 = temp1&0xC0 ;
if(temp2 == 0xC0) //white
temp3 |= 0x01;
else if(temp2 == 0x00) //black
temp3 |= 0x00;
else if(temp2 == 0x80)
temp3 |= 0x01; //gray1
else //0x40
temp3 |= 0x00; //gray2
if(j!=1 || k!=1)
temp3 <<= 1;
temp1 <<= 2;
}
}
EPD_3IN7_SendData(temp3);
}
EPD_3IN7_Load_LUT(0);
EPD_3IN7_SendCommand(0x22);
EPD_3IN7_SendData(0xC7);
EPD_3IN7_SendCommand(0x20);
EPD_3IN7_ReadBusy_HIGH();
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void EPD_3IN7_1Gray_Display(const UBYTE *Image)
{
UWORD i;
UWORD IMAGE_COUNTER = EPD_3IN7_WIDTH * EPD_3IN7_HEIGHT / 8;
EPD_3IN7_SendCommand(0x4E);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendCommand(0x4F);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendCommand(0x24);
for (i = 0; i < IMAGE_COUNTER; i++)
{
EPD_3IN7_SendData(Image[i]);
}
EPD_3IN7_Load_LUT(2);
EPD_3IN7_SendCommand(0x20);
EPD_3IN7_ReadBusy_HIGH();
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void EPD_3IN7_1Gray_Display_Part(const UBYTE *Image, UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend)
{
UWORD i, Width;
Width = (Xend-Xstart)%8 == 0 ? (Xend-Xstart)/8 : (Xend-Xstart)/8+1;
UWORD IMAGE_COUNTER = Width * (Yend-Ystart);
EPD_3IN7_SendCommand(0x44);
EPD_3IN7_SendData(Xstart & 0xff);
EPD_3IN7_SendData((Xstart>>8) & 0x03);
EPD_3IN7_SendData(Xend & 0xff);
EPD_3IN7_SendData((Xend>>8) & 0x03);
EPD_3IN7_SendCommand(0x45);
EPD_3IN7_SendData(Ystart & 0xff);
EPD_3IN7_SendData((Ystart>>8) & 0x03);
EPD_3IN7_SendData(Yend & 0xff);
EPD_3IN7_SendData((Yend>>8) & 0x03);
EPD_3IN7_SendCommand(0x24);
for (i = 0; i < IMAGE_COUNTER; i++)
{
EPD_3IN7_SendData(Image[i]);
}
EPD_3IN7_Load_LUT(2);
EPD_3IN7_SendCommand(0x20);
EPD_3IN7_ReadBusy_HIGH();
}
/******************************************************************************
function : Enter sleep mode
parameter:
******************************************************************************/
void EPD_3IN7_Sleep(void)
{
EPD_3IN7_SendCommand(0X50);
EPD_3IN7_SendData(0xf7);
EPD_3IN7_SendCommand(0X02); //power off
EPD_3IN7_SendCommand(0X07); //deep sleep
EPD_3IN7_SendData(0xA5);
}

View file

@ -0,0 +1,51 @@
/*****************************************************************************
* | File : EPD_3IN7.h
* | Author : Waveshare team
* | Function : 3.7inch e-paper
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-07-17
* | 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_3IN7_H_
#define __EPD_3IN7_H_
#include "DEV_Config.h"
// Display resolution
#define EPD_3IN7_WIDTH 280
#define EPD_3IN7_HEIGHT 480
void EPD_3IN7_4Gray_Clear(void);
void EPD_3IN7_4Gray_Init(void);
void EPD_3IN7_4Gray_Display(const UBYTE *Image);
void EPD_3IN7_1Gray_Clear(void);
void EPD_3IN7_1Gray_Init(void);
void EPD_3IN7_1Gray_Display(const UBYTE *Image);
void EPD_3IN7_1Gray_Display_Part(const UBYTE *Image, UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend);
void EPD_3IN7_Sleep(void);
#endif

View file

@ -558,9 +558,8 @@ void EPD_4IN2_Display(UBYTE *Image)
void EPD_4IN2_PartialDisplay(UWORD X_start,UWORD Y_start,UWORD X_end,UWORD Y_end, UBYTE *Image)
{
UWORD Width, Height;
UWORD Width;
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);

View file

@ -93,7 +93,7 @@ static void EPD_4IN2BC_Reset(void)
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(200);
DEV_Delay_ms(5);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
}

View file

@ -0,0 +1,265 @@
/*****************************************************************************
* | File : EPD_5in65f.c
* | Author : Waveshare team
* | Function : 5.65inch e-paper
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-07-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_5in65f.h"
/******************************************************************************
function : Software reset
parameter:
******************************************************************************/
static void EPD_5IN65F_Reset(void)
{
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(1);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
}
/******************************************************************************
function : send command
parameter:
Reg : Command register
******************************************************************************/
static void EPD_5IN65F_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_5IN65F_SendData(UBYTE Data)
{
DEV_Digital_Write(EPD_DC_PIN, 1);
DEV_Digital_Write(EPD_CS_PIN, 0);
DEV_SPI_WriteByte(Data);
DEV_Digital_Write(EPD_CS_PIN, 1);
}
static void EPD_5IN65F_BusyHigh(void)// If BUSYN=0 then waiting
{
while(!(DEV_Digital_Read(EPD_BUSY_PIN)));
}
static void EPD_5IN65F_BusyLow(void)// If BUSYN=1 then waiting
{
while(DEV_Digital_Read(EPD_BUSY_PIN));
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
void EPD_5IN65F_Init(void)
{
EPD_5IN65F_Reset();
EPD_5IN65F_BusyHigh();
EPD_5IN65F_SendCommand(0x00);
EPD_5IN65F_SendData(0xEF);
EPD_5IN65F_SendData(0x08);
EPD_5IN65F_SendCommand(0x01);
EPD_5IN65F_SendData(0x37);
EPD_5IN65F_SendData(0x00);
EPD_5IN65F_SendData(0x23);
EPD_5IN65F_SendData(0x23);
EPD_5IN65F_SendCommand(0x03);
EPD_5IN65F_SendData(0x00);
EPD_5IN65F_SendCommand(0x06);
EPD_5IN65F_SendData(0xC7);
EPD_5IN65F_SendData(0xC7);
EPD_5IN65F_SendData(0x1D);
EPD_5IN65F_SendCommand(0x30);
EPD_5IN65F_SendData(0x3C);
EPD_5IN65F_SendCommand(0x40);
EPD_5IN65F_SendData(0x00);
EPD_5IN65F_SendCommand(0x50);
EPD_5IN65F_SendData(0x37);
EPD_5IN65F_SendCommand(0x60);
EPD_5IN65F_SendData(0x22);
EPD_5IN65F_SendCommand(0x61);
EPD_5IN65F_SendData(0x02);
EPD_5IN65F_SendData(0x58);
EPD_5IN65F_SendData(0x01);
EPD_5IN65F_SendData(0xC0);
EPD_5IN65F_SendCommand(0xE3);
EPD_5IN65F_SendData(0xAA);
DEV_Delay_ms(100);
EPD_5IN65F_SendCommand(0x50);
EPD_5IN65F_SendData(0x37);
}
/******************************************************************************
function : Clear screen
parameter:
******************************************************************************/
void EPD_5IN65F_Clear(UBYTE color)
{
EPD_5IN65F_SendCommand(0x61);//Set Resolution setting
EPD_5IN65F_SendData(0x02);
EPD_5IN65F_SendData(0x58);
EPD_5IN65F_SendData(0x01);
EPD_5IN65F_SendData(0xC0);
EPD_5IN65F_SendCommand(0x10);
for(int i=0; i<EPD_5IN65F_WIDTH/2; i++) {
for(int j=0; j<EPD_5IN65F_HEIGHT; j++)
EPD_5IN65F_SendData((color<<4)|color);
}
EPD_5IN65F_SendCommand(0x04);//0x04
EPD_5IN65F_BusyHigh();
EPD_5IN65F_SendCommand(0x12);//0x12
EPD_5IN65F_BusyHigh();
EPD_5IN65F_SendCommand(0x02); //0x02
EPD_5IN65F_BusyLow();
DEV_Delay_ms(500);
}
/******************************************************************************
function : show 7 kind of color block
parameter:
******************************************************************************/
void EPD_5IN65F_Show7Block(void)
{
unsigned long i,j,k;
unsigned char const Color_seven[8] =
{EPD_5IN65F_BLACK,EPD_5IN65F_BLUE,EPD_5IN65F_GREEN,EPD_5IN65F_ORANGE,
EPD_5IN65F_RED,EPD_5IN65F_YELLOW,EPD_5IN65F_WHITE,EPD_5IN65F_WHITE};
EPD_5IN65F_SendCommand(0x61);//Set Resolution setting
EPD_5IN65F_SendData(0x02);
EPD_5IN65F_SendData(0x58);
EPD_5IN65F_SendData(0x01);
EPD_5IN65F_SendData(0xC0);
EPD_5IN65F_SendCommand(0x10);
for(i=0; i<224; i++) {
for(k = 0 ; k < 4; k ++) {
for(j = 0 ; j < 75; j ++) {
EPD_5IN65F_SendData((Color_seven[k]<<4) |Color_seven[k]);
}
}
}
for(i=0; i<224; i++) {
for(k = 4 ; k < 8; k ++) {
for(j = 0 ; j < 75; j ++) {
EPD_5IN65F_SendData((Color_seven[k]<<4) |Color_seven[k]);
}
}
}
EPD_5IN65F_SendCommand(0x04);//0x04
EPD_5IN65F_BusyHigh();
EPD_5IN65F_SendCommand(0x12);//0x12
EPD_5IN65F_BusyHigh();
EPD_5IN65F_SendCommand(0x02); //0x02
EPD_5IN65F_BusyLow();
DEV_Delay_ms(200);
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void EPD_5IN65F_Display(const UBYTE *image)
{
unsigned long i,j;
EPD_5IN65F_SendCommand(0x61);//Set Resolution setting
EPD_5IN65F_SendData(0x02);
EPD_5IN65F_SendData(0x58);
EPD_5IN65F_SendData(0x01);
EPD_5IN65F_SendData(0xC0);
EPD_5IN65F_SendCommand(0x10);
for(i=0; i<EPD_5IN65F_HEIGHT; i++) {
for(j=0; j<EPD_5IN65F_WIDTH/2; j++)
EPD_5IN65F_SendData(image[j+((EPD_5IN65F_WIDTH/2)*i)]);
}
EPD_5IN65F_SendCommand(0x04);//0x04
EPD_5IN65F_BusyHigh();
EPD_5IN65F_SendCommand(0x12);//0x12
EPD_5IN65F_BusyHigh();
EPD_5IN65F_SendCommand(0x02); //0x02
EPD_5IN65F_BusyLow();
DEV_Delay_ms(200);
}
/******************************************************************************
function : Sends the part image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void EPD_5IN65F_Display_part(const UBYTE *image, UWORD xstart, UWORD ystart,
UWORD image_width, UWORD image_heigh)
{
unsigned long i,j;
EPD_5IN65F_SendCommand(0x61);//Set Resolution setting
EPD_5IN65F_SendData(0x02);
EPD_5IN65F_SendData(0x58);
EPD_5IN65F_SendData(0x01);
EPD_5IN65F_SendData(0xC0);
EPD_5IN65F_SendCommand(0x10);
for(i=0; i<EPD_5IN65F_HEIGHT; i++) {
for(j=0; j< EPD_5IN65F_WIDTH/2; j++) {
if(i<image_heigh+ystart && i>=ystart && j<(image_width+xstart)/2 && j>=xstart/2) {
EPD_5IN65F_SendData(image[(j-xstart/2) + (image_width/2*(i-ystart))]);
}
else {
EPD_5IN65F_SendData(0x11);
}
}
}
EPD_5IN65F_SendCommand(0x04);//0x04
EPD_5IN65F_BusyHigh();
EPD_5IN65F_SendCommand(0x12);//0x12
EPD_5IN65F_BusyHigh();
EPD_5IN65F_SendCommand(0x02); //0x02
EPD_5IN65F_BusyLow();
DEV_Delay_ms(200);
}
/******************************************************************************
function : Enter sleep mode
parameter:
******************************************************************************/
void EPD_5IN65F_Sleep(void)
{
DEV_Delay_ms(100);
EPD_5IN65F_SendCommand(0x07);
EPD_5IN65F_SendData(0xA5);
DEV_Delay_ms(100);
DEV_Digital_Write(EPD_RST_PIN, 0); // Reset
}

View file

@ -0,0 +1,61 @@
/*****************************************************************************
* | File : EPD_5in65f.h
* | Author : Waveshare team
* | Function : 5.65inch e-paper
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-07-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_5IN65F_H__
#define __EPD_5IN65F_H__
#include "DEV_Config.h"
/**********************************
Color Index
**********************************/
#define EPD_5IN65F_BLACK 0x0 /// 000
#define EPD_5IN65F_WHITE 0x1 /// 001
#define EPD_5IN65F_GREEN 0x2 /// 010
#define EPD_5IN65F_BLUE 0x3 /// 011
#define EPD_5IN65F_RED 0x4 /// 100
#define EPD_5IN65F_YELLOW 0x5 /// 101
#define EPD_5IN65F_ORANGE 0x6 /// 110
#define EPD_5IN65F_CLEAN 0x7 /// 111 unavailable Afterimage
#define EPD_5IN65F_WIDTH 600
#define EPD_5IN65F_HEIGHT 448
void EPD_5IN65F_Clear(UBYTE color);
void EPD_5IN65F_Show7Block(void);
void EPD_5IN65F_Sleep(void);
void EPD_5IN65F_Display(const UBYTE *image);
void EPD_5IN65F_Init(void);
void EPD_5IN65F_Display_part(const UBYTE *image, UWORD xstart, UWORD ystart, UWORD image_width, UWORD image_heigh);
#endif

View file

@ -0,0 +1,312 @@
/*****************************************************************************
* | File : EPD_5in83b_V2.c
* | Author : Waveshare team
* | Function : Electronic paper driver
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-07-04
* | 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_5in83b_V2.h"
#include "Debug.h"
/******************************************************************************
function : Software reset
parameter:
******************************************************************************/
static void EPD_5IN83B_V2_Reset(void)
{
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(1);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
}
/******************************************************************************
function : send command
parameter:
Reg : Command register
******************************************************************************/
static void EPD_5IN83B_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_5IN83B_V2_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_5IN83B_V2_WaitUntilIdle(void)
{
Debug("e-Paper busy\r\n");
UBYTE busy;
do
{
EPD_5IN83B_V2_SendCommand(0x71);
busy = DEV_Digital_Read(EPD_BUSY_PIN);
busy =!(busy & 0x01);
}
while(busy);
DEV_Delay_ms(200);
Debug("e-Paper busy release\r\n");
}
/******************************************************************************
function : Turn On Display
parameter:
******************************************************************************/
static void EPD_5IN83B_V2_TurnOnDisplay(void)
{
EPD_5IN83B_V2_SendCommand(0x12); //DISPLAY REFRESH
DEV_Delay_ms(100); //!!!The delay here is necessary, 200uS at least!!!
EPD_5IN83B_V2_WaitUntilIdle(); //waiting for the electronic paper IC to release the idle signal
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
UBYTE EPD_5IN83B_V2_Init(void)
{
EPD_5IN83B_V2_Reset();
EPD_5IN83B_V2_WaitUntilIdle();
EPD_5IN83B_V2_SendCommand(0x01); //POWER SETTING
EPD_5IN83B_V2_SendData (0x07);
EPD_5IN83B_V2_SendData (0x07); //VGH=20V,VGL=-20V
EPD_5IN83B_V2_SendData (0x3f); //VDH=15V
EPD_5IN83B_V2_SendData (0x3f); //VDL=-15V
EPD_5IN83B_V2_SendCommand(0x04); //POWER ON
DEV_Delay_ms(100);
EPD_5IN83B_V2_WaitUntilIdle(); //waiting for the electronic paper IC to release the idle signal
EPD_5IN83B_V2_SendCommand(0X00); //PANNEL SETTING
EPD_5IN83B_V2_SendData(0x0F); //KW-3f KWR-2F BWROTP 0f BWOTP 1f
EPD_5IN83B_V2_SendCommand(0x61); //tres
EPD_5IN83B_V2_SendData (0x02); //source 648
EPD_5IN83B_V2_SendData (0x88);
EPD_5IN83B_V2_SendData (0x01); //gate 480
EPD_5IN83B_V2_SendData (0xe0);
EPD_5IN83B_V2_SendCommand(0X15);
EPD_5IN83B_V2_SendData(0x00);
EPD_5IN83B_V2_SendCommand(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_5IN83B_V2_SendData(0x11);
EPD_5IN83B_V2_SendData(0x07);
EPD_5IN83B_V2_SendCommand(0X60); //TCON SETTING
EPD_5IN83B_V2_SendData(0x22);
return 0;
}
/******************************************************************************
function : Clear screen
parameter:
******************************************************************************/
void EPD_5IN83B_V2_Clear(void)
{
UWORD Width, Height;
Width =(EPD_5IN83B_V2_WIDTH % 8 == 0)?(EPD_5IN83B_V2_WIDTH / 8 ):(EPD_5IN83B_V2_WIDTH / 8 + 1);
Height = EPD_5IN83B_V2_HEIGHT;
UWORD i;
EPD_5IN83B_V2_SendCommand(0x10);
for(i=0; i<Width*Height; i++) {
EPD_5IN83B_V2_SendData(0xff);
}
EPD_5IN83B_V2_SendCommand(0x13);
for(i=0; i<Width*Height; i++) {
EPD_5IN83B_V2_SendData(0x00);
}
EPD_5IN83B_V2_TurnOnDisplay();
}
/******************************************************************************
function : Clear screen
parameter:
******************************************************************************/
void EPD_5IN83B_V2_Clear_C(UBYTE color)
{
UWORD Width, Height;
Width =(EPD_5IN83B_V2_WIDTH % 8 == 0)?(EPD_5IN83B_V2_WIDTH / 8 ):(EPD_5IN83B_V2_WIDTH / 8 + 1);
Height = EPD_5IN83B_V2_HEIGHT;
UWORD i;
if(color == 0) {
EPD_5IN83B_V2_SendCommand(0x10);
for(i=0; i<Width*Height; i++) {
EPD_5IN83B_V2_SendData(0xff);
}
EPD_5IN83B_V2_SendCommand(0x13);
for(i=0; i<Width*Height; i++) {
EPD_5IN83B_V2_SendData(0x00);
}
}
else if(color == 1) {
EPD_5IN83B_V2_SendCommand(0x10);
for(i=0; i<Width*Height; i++) {
EPD_5IN83B_V2_SendData(0xff);
}
EPD_5IN83B_V2_SendCommand(0x13);
for(i=0; i<Width*Height; i++) {
EPD_5IN83B_V2_SendData(0xff);
}
}
else if(color == 2) {
EPD_5IN83B_V2_SendCommand(0x10);
for(i=0; i<Width*Height; i++) {
EPD_5IN83B_V2_SendData(0x00);
}
EPD_5IN83B_V2_SendCommand(0x13);
for(i=0; i<Width*Height; i++) {
EPD_5IN83B_V2_SendData(0x00);
}
}
EPD_5IN83B_V2_TurnOnDisplay();
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void EPD_5IN83B_V2_Display(const UBYTE *blackimage, const UBYTE *ryimage)
{
UDOUBLE Width, Height;
Width =(EPD_5IN83B_V2_WIDTH % 8 == 0)?(EPD_5IN83B_V2_WIDTH / 8 ):(EPD_5IN83B_V2_WIDTH / 8 + 1);
Height = EPD_5IN83B_V2_HEIGHT;
//send black data
EPD_5IN83B_V2_SendCommand(0x10);
for (UDOUBLE j = 0; j < Height; j++) {
for (UDOUBLE i = 0; i < Width; i++) {
EPD_5IN83B_V2_SendData(blackimage[i + j * Width]);
}
}
//send red data
EPD_5IN83B_V2_SendCommand(0x13);
for (UDOUBLE j = 0; j < Height; j++) {
for (UDOUBLE i = 0; i < Width; i++) {
EPD_5IN83B_V2_SendData(~ryimage[i + j * Width]);
}
}
EPD_5IN83B_V2_TurnOnDisplay();
}
void EPD_5IN83B_V2_DisplayPicture(const UBYTE *blackimage,UBYTE Block)
{
UDOUBLE Width, Height;
Width =(EPD_5IN83B_V2_WIDTH % 8 == 0)?(EPD_5IN83B_V2_WIDTH / 8 ):(EPD_5IN83B_V2_WIDTH / 8 + 1);
Height = EPD_5IN83B_V2_HEIGHT;
if(Block == 0){
EPD_5IN83B_V2_SendCommand(0x10);
for (UDOUBLE j = 0; j < Height/4; j++) {
for (UDOUBLE i = 0; i < Width; i++) {
EPD_5IN83B_V2_SendData(blackimage[i + j * Width]);
}
}
}else if(Block == 1){
for (UDOUBLE j = 0; j < Height/4; j++) {
for (UDOUBLE i = 0; i < Width; i++) {
EPD_5IN83B_V2_SendData(blackimage[i + j * Width]);
}
}
}else if(Block == 2){
for (UDOUBLE j = 0; j < Height/4; j++) {
for (UDOUBLE i = 0; i < Width; i++) {
EPD_5IN83B_V2_SendData(blackimage[i + j * Width]);
}
}
}else if(Block == 3){
for (UDOUBLE j = 0; j < Height/4; j++) {
for (UDOUBLE i = 0; i < Width; i++) {
EPD_5IN83B_V2_SendData(blackimage[i + j * Width]);
}
}
}
else if(Block == 4){
EPD_5IN83B_V2_SendCommand(0x13);
for (UDOUBLE j = 0; j < Height/4; j++) {
for (UDOUBLE i = 0; i < Width; i++) {
EPD_5IN83B_V2_SendData(~blackimage[i + j * Width]);
}
}
}else if(Block == 5){
for (UDOUBLE j = 0; j < Height/4; j++) {
for (UDOUBLE i = 0; i < Width; i++) {
EPD_5IN83B_V2_SendData(~blackimage[i + j * Width]);
}
}
}else if(Block == 6){
for (UDOUBLE j = 0; j < Height/4; j++) {
for (UDOUBLE i = 0; i < Width; i++) {
EPD_5IN83B_V2_SendData(~blackimage[i + j * Width]);
}
}
}else if(Block == 7){
for (UDOUBLE j = 0; j < Height/4; j++) {
for (UDOUBLE i = 0; i < Width; i++) {
EPD_5IN83B_V2_SendData(~blackimage[i + j * Width]);
}
}
EPD_5IN83B_V2_TurnOnDisplay();
}
}
/******************************************************************************
function : Enter sleep mode
parameter:
******************************************************************************/
void EPD_5IN83B_V2_Sleep(void)
{
EPD_5IN83B_V2_SendCommand(0X02); //power off
EPD_5IN83B_V2_WaitUntilIdle(); //waiting for the electronic paper IC to release the idle signal
EPD_5IN83B_V2_SendCommand(0X07); //deep sleep
EPD_5IN83B_V2_SendData(0xA5);
}

View file

@ -0,0 +1,47 @@
/*****************************************************************************
* | File : EPD_5in83b_V2.h
* | Author : Waveshare team
* | Function : Electronic paper driver
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-07-04
* | 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_5IN83B_V2_h_
#define _EPD_5IN83B_V2_h_
#include "DEV_Config.h"
// Display resolution
#define EPD_5IN83B_V2_WIDTH 648
#define EPD_5IN83B_V2_HEIGHT 480
UBYTE EPD_5IN83B_V2_Init(void);
void EPD_5IN83B_V2_Clear(void);
void EPD_5IN83B_V2_Display(const UBYTE *blackimage, const UBYTE *ryimage);
void EPD_5IN83B_V2_Sleep(void);
void EPD_5IN83B_V2_DisplayPicture(const UBYTE *blackimage,UBYTE Block);
void EPD_5IN83B_V2_Clear_C(UBYTE color);
#endif

View file

@ -229,7 +229,6 @@ void EPD_7IN5_HD_WritePicture(const UBYTE *blackimage, UBYTE Block)
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]);

View file

@ -33,7 +33,6 @@
#include "DEV_Config.h"
// Display resolution
#define EPD_7IN5_HD_WIDTH 880
#define EPD_7IN5_HD_HEIGHT 528