Add the STM32 program: 1.64inch e-Paper (G), 3inch e-Paper (G), 7.3inch e-Paper (G) and 3.52inch e-Paper

This commit is contained in:
SSYYL 2022-07-28 18:08:09 +08:00
commit 34affe04fe
25 changed files with 11800 additions and 1161 deletions

View file

@ -0,0 +1,239 @@
/*****************************************************************************
* | File : EPD_1in64_g.c
* | Author : Waveshare team
* | Function : 1.64inchg e-paper (G)
* | Info :
*----------------
* | This version: V1.0
* | Date : 2022-07-22
* | 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_1in64g.h"
#include "Debug.h"
/******************************************************************************
function : Software reset
parameter:
******************************************************************************/
static void EPD_1IN64G_Reset(void)
{
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(20);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(1);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(20);
}
/******************************************************************************
function : send command
parameter:
Reg : Command register
******************************************************************************/
static void EPD_1IN64G_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_1IN64G_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_1IN64G_ReadBusyH(void)
{
Debug("e-Paper busy H\r\n");
while(!DEV_Digital_Read(EPD_BUSY_PIN)) { //LOW: idle, HIGH: busy
DEV_Delay_ms(5);
}
Debug("e-Paper busy H release\r\n");
}
static void EPD_1IN64G_ReadBusyL(void)
{
Debug("e-Paper busy L\r\n");
while(DEV_Digital_Read(EPD_BUSY_PIN)) { //LOW: idle, HIGH: busy
DEV_Delay_ms(5);
}
Debug("e-Paper busy L release\r\n");
}
/******************************************************************************
function : Turn On Display
parameter:
******************************************************************************/
static void EPD_1IN64G_TurnOnDisplay(void)
{
EPD_1IN64G_SendCommand(0x12); // DISPLAY_REFRESH
EPD_1IN64G_SendData(0x01);
EPD_1IN64G_ReadBusyH();
EPD_1IN64G_SendCommand(0x02); // POWER_OFF
EPD_1IN64G_SendData(0X00);
EPD_1IN64G_ReadBusyH();
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
void EPD_1IN64G_Init(void)
{
EPD_1IN64G_Reset();
EPD_1IN64G_SendCommand(0x66);
EPD_1IN64G_SendData(0x49);
EPD_1IN64G_SendData(0x55);
EPD_1IN64G_SendData(0x13);
EPD_1IN64G_SendData(0x5D);
EPD_1IN64G_SendCommand(0x66);
EPD_1IN64G_SendData(0x49);
EPD_1IN64G_SendData(0x55);
EPD_1IN64G_SendCommand(0xB0);
EPD_1IN64G_SendData(0x03);//1 boost 20211113
EPD_1IN64G_SendCommand(0x00);
EPD_1IN64G_SendData(0x4F);
EPD_1IN64G_SendData(0x6B);
EPD_1IN64G_SendCommand(0x03);
EPD_1IN64G_SendData(0x00);
EPD_1IN64G_SendCommand(0xF0);
EPD_1IN64G_SendData(0xF6);
EPD_1IN64G_SendData(0x0D);
EPD_1IN64G_SendData(0x00);
EPD_1IN64G_SendData(0x00);
EPD_1IN64G_SendData(0x00);
//20220303
EPD_1IN64G_SendCommand(0x06);
EPD_1IN64G_SendData(0xCF);
EPD_1IN64G_SendData(0xDF);
EPD_1IN64G_SendData(0x0F);
EPD_1IN64G_SendCommand(0x41);
EPD_1IN64G_SendData(0x00);
EPD_1IN64G_SendCommand(0x50);
EPD_1IN64G_SendData(0x30);
EPD_1IN64G_SendCommand(0x60);
EPD_1IN64G_SendData(0x0C);
EPD_1IN64G_SendData(0x05);
EPD_1IN64G_SendCommand(0x61);
EPD_1IN64G_SendData(0xA8);
EPD_1IN64G_SendData(0x00);
EPD_1IN64G_SendData(0xA8);
EPD_1IN64G_SendCommand(0x84);
EPD_1IN64G_SendData(0x01);
}
/******************************************************************************
function : Clear screen
parameter:
******************************************************************************/
void EPD_1IN64G_Clear(UBYTE color)
{
UWORD Width, Height;
Width = (EPD_1IN64G_WIDTH % 4 == 0)? (EPD_1IN64G_WIDTH / 4 ): (EPD_1IN64G_WIDTH / 4 + 1);
Height = EPD_1IN64G_HEIGHT;
EPD_1IN64G_SendCommand(0x68);
EPD_1IN64G_SendData(0x01);
EPD_1IN64G_SendCommand(0x04);
EPD_1IN64G_ReadBusyH();
EPD_1IN64G_SendCommand(0x10);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
for(UBYTE k = 0; k < 4; k++) {
EPD_1IN64G_SendData(color);
}
}
}
EPD_1IN64G_SendCommand(0x68);
EPD_1IN64G_SendData(0x00);
EPD_1IN64G_TurnOnDisplay();
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void EPD_1IN64G_Display(UBYTE *Image)
{
UWORD Width, Height;
Width = (EPD_1IN64G_WIDTH % 4 == 0)? (EPD_1IN64G_WIDTH / 4 ): (EPD_1IN64G_WIDTH / 4 + 1);
Height = EPD_1IN64G_HEIGHT;
EPD_1IN64G_SendCommand(0x68);
EPD_1IN64G_SendData(0x01);
EPD_1IN64G_SendCommand(0x04);
EPD_1IN64G_ReadBusyH();
EPD_1IN64G_SendCommand(0x10);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_1IN64G_SendData(Image[i + j * Width]);
}
}
EPD_1IN64G_TurnOnDisplay();
}
/******************************************************************************
function : Enter sleep mode
parameter:
******************************************************************************/
void EPD_1IN64G_Sleep(void)
{
EPD_1IN64G_SendCommand(0x02); // POWER_OFF
EPD_1IN64G_SendData(0X00);
EPD_1IN64G_SendCommand(0x07); // DEEP_SLEEP
EPD_1IN64G_SendData(0XA5);
}

View file

@ -0,0 +1,32 @@
/*****************************************************************************
* | File : EPD_1in64g.h
* | Author : Waveshare team
* | Function : 1.64inch e-paper (G)
* | Info :
*----------------
* | This version: V1.0
* | Date : 2022-07-14
* | Info :
* -----------------------------------------------------------------------------
******************************************************************************/
#ifndef __EPD_1IN64G_H_
#define __EPD_1IN64G_H_
#include "DEV_Config.h"
// Display resolution
#define EPD_1IN64G_WIDTH 168
#define EPD_1IN64G_HEIGHT 168
//colour
#define EPD_1IN64G_BLACK 0x00
#define EPD_1IN64G_WHITE 0x55
#define EPD_1IN64G_YELLOW 0xAA
#define EPD_1IN64G_RED 0xFF
void EPD_1IN64G_Init(void);
void EPD_1IN64G_Clear(UBYTE color);
void EPD_1IN64G_Display(UBYTE *Image);
void EPD_1IN64G_Sleep(void);
#endif

View file

@ -0,0 +1,220 @@
/*****************************************************************************
* | File : EPD_3in0_g.c
* | Author : Waveshare team
* | Function : 3inch e-paper (G)
* | Info :
*----------------
* | This version: V1.0
* | Date : 2022-07-15
* | 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_3in0g.h"
#include "Debug.h"
/******************************************************************************
function : Software reset
parameter:
******************************************************************************/
static void EPD_3IN0G_Reset(void)
{
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(20);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(2);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(20);
}
/******************************************************************************
function : send command
parameter:
Reg : Command register
******************************************************************************/
static void EPD_3IN0G_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_3IN0G_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_3IN0G_ReadBusyH(void)
{
Debug("e-Paper busy H\r\n");
while(!DEV_Digital_Read(EPD_BUSY_PIN)) { //LOW: idle, HIGH: busy
DEV_Delay_ms(5);
}
Debug("e-Paper busy H release\r\n");
}
static void EPD_3IN0G_ReadBusyL(void)
{
Debug("e-Paper busy L\r\n");
while(DEV_Digital_Read(EPD_BUSY_PIN)) { //LOW: idle, HIGH: busy
DEV_Delay_ms(5);
}
Debug("e-Paper busy L release\r\n");
}
/******************************************************************************
function : Turn On Display
parameter:
******************************************************************************/
static void EPD_3IN0G_TurnOnDisplay(void)
{
EPD_3IN0G_SendCommand(0x12); // DISPLAY_REFRESH
EPD_3IN0G_SendData(0x00);
EPD_3IN0G_ReadBusyH();
EPD_3IN0G_SendCommand(0x02); // POWER_OFF
EPD_3IN0G_SendData(0X00);
EPD_3IN0G_ReadBusyH();
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
void EPD_3IN0G_Init(void)
{
EPD_3IN0G_Reset();
EPD_3IN0G_SendCommand(0x66);
EPD_3IN0G_SendData(0x49);
EPD_3IN0G_SendData(0x55);
EPD_3IN0G_SendData(0x13);
EPD_3IN0G_SendData(0x5D);
EPD_3IN0G_SendData(0x05);
EPD_3IN0G_SendData(0x10);
EPD_3IN0G_SendCommand(0xB0);
EPD_3IN0G_SendData(0x00);//1 boost
EPD_3IN0G_SendCommand(0x01);
EPD_3IN0G_SendData(0x0F);
EPD_3IN0G_SendData(0x00);
EPD_3IN0G_SendCommand(0x00);
EPD_3IN0G_SendData(0x4F);
EPD_3IN0G_SendData(0x6B);
EPD_3IN0G_SendCommand(0x06);
EPD_3IN0G_SendData(0xD7);
EPD_3IN0G_SendData(0xDE);
EPD_3IN0G_SendData(0x12);
EPD_3IN0G_SendCommand(0x61);
EPD_3IN0G_SendData(0x00);
EPD_3IN0G_SendData(0xA8);
EPD_3IN0G_SendData(0x01);
EPD_3IN0G_SendData(0x90);
EPD_3IN0G_SendCommand(0x50);
EPD_3IN0G_SendData(0x37);
EPD_3IN0G_SendCommand(0x60);
EPD_3IN0G_SendData(0x0C);
EPD_3IN0G_SendData(0x05);
EPD_3IN0G_SendCommand(0xE3);
EPD_3IN0G_SendData(0xFF);
EPD_3IN0G_SendCommand(0x84);
EPD_3IN0G_SendData(0x00);
}
/******************************************************************************
function : Clear screen
parameter:
******************************************************************************/
void EPD_3IN0G_Clear(UBYTE color)
{
UWORD Width, Height;
Width = (EPD_3IN0G_WIDTH % 4 == 0)? (EPD_3IN0G_WIDTH / 4 ): (EPD_3IN0G_WIDTH / 4 + 1);
Height = EPD_3IN0G_HEIGHT;
EPD_3IN0G_SendCommand(0x04);
EPD_3IN0G_ReadBusyH();
EPD_3IN0G_SendCommand(0x10);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_3IN0G_SendData(color);
}
}
EPD_3IN0G_TurnOnDisplay();
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void EPD_3IN0G_Display(UBYTE *Image)
{
UWORD Width, Height;
Width = (EPD_3IN0G_WIDTH % 4 == 0)? (EPD_3IN0G_WIDTH / 4 ): (EPD_3IN0G_WIDTH / 4 + 1);
Height = EPD_3IN0G_HEIGHT;
EPD_3IN0G_SendCommand(0x04);
EPD_3IN0G_ReadBusyH();
EPD_3IN0G_SendCommand(0x10);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_3IN0G_SendData(Image[i + j * Width]);
}
}
EPD_3IN0G_TurnOnDisplay();
}
/******************************************************************************
function : Enter sleep mode
parameter:
******************************************************************************/
void EPD_3IN0G_Sleep(void)
{
EPD_3IN0G_SendCommand(0x02); // POWER_OFF
EPD_3IN0G_SendData(0X00);
EPD_3IN0G_SendCommand(0x07); // DEEP_SLEEP
EPD_3IN0G_SendData(0XA5);
}

View file

@ -0,0 +1,32 @@
/*****************************************************************************
* | File : EPD_3in0g.h
* | Author : Waveshare team
* | Function : 3inch e-paper (G)
* | Info :
*----------------
* | This version: V1.0
* | Date : 2022-07-15
* | Info :
* -----------------------------------------------------------------------------
******************************************************************************/
#ifndef __EPD_3IN0G_H_
#define __EPD_3IN0G_H_
#include "DEV_Config.h"
// Display resolution
#define EPD_3IN0G_WIDTH 168
#define EPD_3IN0G_HEIGHT 400
//colour
#define EPD_3IN0G_BLACK 0x00
#define EPD_3IN0G_WHITE 0x55
#define EPD_3IN0G_YELLOW 0xAA
#define EPD_3IN0G_RED 0xFF
void EPD_3IN0G_Init(void);
void EPD_3IN0G_Clear(UBYTE color);
void EPD_3IN0G_Display(UBYTE *Image);
void EPD_3IN0G_Sleep(void);
#endif

View file

@ -0,0 +1,588 @@
/*****************************************************************************
* | File : EPD_3IN52.C
* | Author : Waveshare team
* | Function : 3.52inch e-paper
* | Info :
*----------------
* | This version: V1.0
* | Date : 2022-05-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_3in52.h"
#include "Debug.h"
//GC 0.9S
static const UBYTE EPD_3IN52_lut_R20_GC[] =
{
0x01,0x0f,0x0f,0x0f,0x01,0x01,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
};
static const UBYTE EPD_3IN52_lut_R21_GC[] =
{
0x01,0x4f,0x8f,0x0f,0x01,0x01,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
};
static const UBYTE EPD_3IN52_lut_R22_GC[] =
{
0x01,0x0f,0x8f,0x0f,0x01,0x01,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
};
static const UBYTE EPD_3IN52_lut_R23_GC[] =
{
0x01,0x4f,0x8f,0x4f,0x01,0x01,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
};
static const UBYTE EPD_3IN52_lut_R24_GC[] =
{
0x01,0x0f,0x8f,0x4f,0x01,0x01,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
};
// DU 0.3s
static const UBYTE EPD_3IN52_lut_R20_DU[] =
{
0x01,0x0f,0x01,0x00,0x00,0x01,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
};
static const UBYTE EPD_3IN52_lut_R21_DU[] =
{
0x01,0x0f,0x01,0x00,0x00,0x01,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
};
static const UBYTE EPD_3IN52_lut_R22_DU[] =
{
0x01,0x8f,0x01,0x00,0x00,0x01,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
};
static const UBYTE EPD_3IN52_lut_R23_DU[] =
{
0x01,0x4f,0x01,0x00,0x00,0x01,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
};
static const UBYTE EPD_3IN52_lut_R24_DU[] =
{
0x01,0x0f,0x01,0x00,0x00,0x01,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
};
//
static const UBYTE EPD_3IN52_lut_vcom[] =
{
0x01,0x19,0x19,0x19,0x19,0x01,0x01,
0x01,0x19,0x19,0x19,0x01,0x01,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
};
static const UBYTE EPD_3IN52_lut_ww[] =
{
0x01,0x59,0x99,0x59,0x99,0x01,0x01,
0x01,0x59,0x99,0x19,0x01,0x01,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
};
static const UBYTE EPD_3IN52_lut_bw[] =
{
0x01,0x59,0x99,0x59,0x99,0x01,0x01,
0x01,0x59,0x99,0x19,0x01,0x01,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
};
static const UBYTE EPD_3IN52_lut_wb[] =
{
0x01,0x19,0x99,0x59,0x99,0x01,0x01,
0x01,0x59,0x99,0x59,0x01,0x01,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
};
static const UBYTE EPD_3IN52_lut_bb[] =
{
0x01,0x19,0x99,0x59,0x99,0x01,0x01,
0x01,0x59,0x99,0x59,0x01,0x01,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
};
unsigned char EPD_3IN52_Flag = 0;
/******************************************************************************
function : Software reset
parameter:
******************************************************************************/
void EPD_3IN52_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
******************************************************************************/
void EPD_3IN52_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
******************************************************************************/
void EPD_3IN52_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 : Read Busy
parameter:
******************************************************************************/
void EPD_3IN52_ReadBusy(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");
}
/**
* @brief
*
*/
void EPD_3IN52_lut(void)
{
UBYTE count;
EPD_3IN52_SendCommand(0x20); // vcom
for(count = 0; count < 42 ; count++)
{
EPD_3IN52_SendData(EPD_3IN52_lut_vcom[count]);
}
EPD_3IN52_SendCommand(0x21); // ww --
for(count = 0; count < 42 ; count++)
{
EPD_3IN52_SendData(EPD_3IN52_lut_ww[count]);
}
EPD_3IN52_SendCommand(0x22); // bw r
for(count = 0; count < 42 ; count++)
{
EPD_3IN52_SendData(EPD_3IN52_lut_bw[count]);
}
EPD_3IN52_SendCommand(0x23); // wb w
for(count = 0; count < 42 ; count++)
{
EPD_3IN52_SendData(EPD_3IN52_lut_bb[count]);
}
EPD_3IN52_SendCommand(0x24); // bb b
for(count = 0; count < 42 ; count++)
{
EPD_3IN52_SendData(EPD_3IN52_lut_wb[count]);
}
}
/**
* @brief
*
*/
void EPD_3IN52_refresh(void)
{
EPD_3IN52_SendCommand(0x17);
EPD_3IN52_SendData(0xA5);
EPD_3IN52_ReadBusy();
DEV_Delay_ms(200);
}
// LUT download
void EPD_3IN52_lut_GC(void)
{
UBYTE count;
EPD_3IN52_SendCommand(0x20); // vcom
for(count = 0; count < 56 ; count++)
{
EPD_3IN52_SendData(EPD_3IN52_lut_R20_GC[count]);
}
EPD_3IN52_SendCommand(0x21); // red not use
for(count = 0; count < 42 ; count++)
{
EPD_3IN52_SendData(EPD_3IN52_lut_R21_GC[count]);
}
EPD_3IN52_SendCommand(0x24); // bb b
for(count = 0; count < 42 ; count++)
{
EPD_3IN52_SendData(EPD_3IN52_lut_R24_GC[count]);
}
if(EPD_3IN52_Flag == 0)
{
EPD_3IN52_SendCommand(0x22); // bw r
for(count = 0; count < 56 ; count++)
{
EPD_3IN52_SendData(EPD_3IN52_lut_R22_GC[count]);
}
EPD_3IN52_SendCommand(0x23); // wb w
for(count = 0; count < 42 ; count++)
{
EPD_3IN52_SendData(EPD_3IN52_lut_R23_GC[count]);
}
EPD_3IN52_Flag = 1;
}
else
{
EPD_3IN52_SendCommand(0x22); // bw r
for(count = 0; count < 56 ; count++)
{
EPD_3IN52_SendData(EPD_3IN52_lut_R23_GC[count]);
}
EPD_3IN52_SendCommand(0x23); // wb w
for(count = 0; count < 42 ; count++)
{
EPD_3IN52_SendData(EPD_3IN52_lut_R22_GC[count]);
}
EPD_3IN52_Flag = 0;
}
}
// LUT download
void EPD_3IN52_lut_DU(void)
{
UBYTE count;
EPD_3IN52_SendCommand(0x20); // vcom
for(count = 0; count < 56 ; count++)
{
EPD_3IN52_SendData(EPD_3IN52_lut_R20_DU[count]);
}
EPD_3IN52_SendCommand(0x21); // red not use
for(count = 0; count < 42 ; count++)
{
EPD_3IN52_SendData(EPD_3IN52_lut_R21_DU[count]);
}
EPD_3IN52_SendCommand(0x24); // bb b
for(count = 0; count < 42 ; count++)
{
EPD_3IN52_SendData(EPD_3IN52_lut_R24_DU[count]);
}
if(EPD_3IN52_Flag == 0)
{
EPD_3IN52_SendCommand(0x22); // bw r
for(count = 0; count < 56 ; count++)
{
EPD_3IN52_SendData(EPD_3IN52_lut_R22_DU[count]);
}
EPD_3IN52_SendCommand(0x23); // wb w
for(count = 0; count < 42 ; count++)
{
EPD_3IN52_SendData(EPD_3IN52_lut_R23_DU[count]);
}
EPD_3IN52_Flag = 1;
}
else
{
EPD_3IN52_SendCommand(0x22); // bw r
for(count = 0; count < 56 ; count++)
{
EPD_3IN52_SendData(EPD_3IN52_lut_R23_DU[count]);
}
EPD_3IN52_SendCommand(0x23); // wb w
for(count = 0; count < 42 ; count++)
{
EPD_3IN52_SendData(EPD_3IN52_lut_R22_DU[count]);
}
EPD_3IN52_Flag = 0;
}
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
void EPD_3IN52_Init(void)
{
EPD_3IN52_Flag = 0;
EPD_3IN52_Reset();
EPD_3IN52_SendCommand(0x00); // panel setting PSR
EPD_3IN52_SendData(0xFF); // RES1 RES0 REG KW/R UD SHL SHD_N RST_N
EPD_3IN52_SendData(0x01); // x x x VCMZ TS_AUTO TIGE NORG VC_LUTZ
EPD_3IN52_SendCommand(0x01); // POWER SETTING PWR
EPD_3IN52_SendData(0x03); // x x x x x x VDS_EN VDG_EN
EPD_3IN52_SendData(0x10); // x x x VCOM_SLWE VGH[3:0] VGH=20V, VGL=-20V
EPD_3IN52_SendData(0x3F); // x x VSH[5:0] VSH = 15V
EPD_3IN52_SendData(0x3F); // x x VSL[5:0] VSL=-15V
EPD_3IN52_SendData(0x03); // OPTEN VDHR[6:0] VHDR=6.4V
// T_VDS_OFF[1:0] 00=1 frame; 01=2 frame; 10=3 frame; 11=4 frame
EPD_3IN52_SendCommand(0x06); // booster soft start BTST
EPD_3IN52_SendData(0x37); // BT_PHA[7:0]
EPD_3IN52_SendData(0x3D); // BT_PHB[7:0]
EPD_3IN52_SendData(0x3D); // x x BT_PHC[5:0]
EPD_3IN52_SendCommand(0x60); // TCON setting TCON
EPD_3IN52_SendData(0x22); // S2G[3:0] G2S[3:0] non-overlap = 12
EPD_3IN52_SendCommand(0x82); // VCOM_DC setting VDCS
EPD_3IN52_SendData(0x07); // x VDCS[6:0] VCOM_DC value= -1.9v 00~3f,0x12=-1.9v
EPD_3IN52_SendCommand(0x30);
EPD_3IN52_SendData(0x09);
EPD_3IN52_SendCommand(0xe3); // power saving PWS
EPD_3IN52_SendData(0x88); // VCOM_W[3:0] SD_W[3:0]
EPD_3IN52_SendCommand(0x61); // resoultion setting
EPD_3IN52_SendData(0xf0); // HRES[7:3] 0 0 0
EPD_3IN52_SendData(0x01); // x x x x x x x VRES[8]
EPD_3IN52_SendData(0x68); // VRES[7:0]
EPD_3IN52_SendCommand(0x50);
EPD_3IN52_SendData(0xB7);
}
void EPD_3IN52_display(UBYTE* picData)
{
UWORD i;
EPD_3IN52_SendCommand(0x13); //Transfer new data
for(i=0;i<(EPD_3IN52_WIDTH*EPD_3IN52_HEIGHT/8);i++)
{
EPD_3IN52_SendData(*picData);
picData++;
}
}
void EPD_3IN52_display_NUM(UBYTE NUM)
{
UWORD row, column;
// UWORD pcnt = 0;
EPD_3IN52_SendCommand(0x13); //Transfer new data
for(column=0; column<EPD_3IN52_HEIGHT; column++)
{
for(row=0; row<EPD_3IN52_WIDTH/8; row++)
{
switch (NUM)
{
case EPD_3IN52_WHITE:
EPD_3IN52_SendData(0xFF);
break;
case EPD_3IN52_BLACK:
EPD_3IN52_SendData(0x00);
break;
case EPD_3IN52_Source_Line:
EPD_3IN52_SendData(0xAA);
break;
case EPD_3IN52_Gate_Line:
if(column%2)
EPD_3IN52_SendData(0xff); //An odd number of Gate line
else
EPD_3IN52_SendData(0x00); //The even line Gate
break;
case EPD_3IN52_Chessboard:
if(row>=(EPD_3IN52_WIDTH/8/2)&&column>=(EPD_3IN52_HEIGHT/2))
EPD_3IN52_SendData(0xff);
else if(row<(EPD_3IN52_WIDTH/8/2)&&column<(EPD_3IN52_HEIGHT/2))
EPD_3IN52_SendData(0xff);
else
EPD_3IN52_SendData(0x00);
break;
case EPD_3IN52_LEFT_BLACK_RIGHT_WHITE:
if(row>=(EPD_3IN52_WIDTH/8/2))
EPD_3IN52_SendData(0xff);
else
EPD_3IN52_SendData(0x00);
break;
case EPD_3IN52_UP_BLACK_DOWN_WHITE:
if(column>=(EPD_3IN52_HEIGHT/2))
EPD_3IN52_SendData(0xFF);
else
EPD_3IN52_SendData(0x00);
break;
case EPD_3IN52_Frame:
if(column==0||column==(EPD_3IN52_HEIGHT-1))
EPD_3IN52_SendData(0x00);
else if(row==0)
EPD_3IN52_SendData(0x7F);
else if(row==(EPD_3IN52_WIDTH/8-1))
EPD_3IN52_SendData(0xFE);
else
EPD_3IN52_SendData(0xFF);
break;
case EPD_3IN52_Crosstalk:
if((row>=(EPD_3IN52_WIDTH/8/3)&&row<=(EPD_3IN52_WIDTH/8/3*2)&&column<=(EPD_3IN52_HEIGHT/3))||(row>=(EPD_3IN52_WIDTH/8/3)&&row<=(EPD_3IN52_WIDTH/8/3*2)&&column>=(EPD_3IN52_HEIGHT/3*2)))
EPD_3IN52_SendData(0x00);
else
EPD_3IN52_SendData(0xFF);
break;
case EPD_3IN52_Image:
//EPD_3IN52_SendData(gImage_1[pcnt++]);
break;
default:
break;
}
}
}
}
/******************************************************************************
function : Clear screen
parameter:
******************************************************************************/
void EPD_3IN52_Clear(void)
{
UWORD i;
EPD_3IN52_SendCommand(0x13); //Transfer new data
for(i=0;i<(EPD_3IN52_WIDTH*EPD_3IN52_HEIGHT/8);i++)
{
EPD_3IN52_SendData(0xFF);
}
EPD_3IN52_lut_GC();
EPD_3IN52_refresh();
}
/******************************************************************************
function : Enter sleep mode
parameter:
******************************************************************************/
void EPD_3IN52_sleep(void)
{
EPD_3IN52_SendCommand(0X07); //deep sleep
EPD_3IN52_SendData(0xA5);
}

View file

@ -0,0 +1,70 @@
/*****************************************************************************
* | File : EPD_3IN52.h
* | Author : Waveshare team
* | Function : 3.52inch e-paper
* | Info :
*----------------
* | This version: V1.0
* | Date : 2022-05-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_3IN52_H_
#define __EPD_3IN52_H_
#include "DEV_Config.h"
// Display resolution
#define EPD_3IN52_WIDTH 240
#define EPD_3IN52_HEIGHT 360
#define LUTGC_TEST //
#define LUTDU_TEST //
#define EPD_3IN52_WHITE 0xFF //
#define EPD_3IN52_BLACK 0x00 //
#define EPD_3IN52_Source_Line 0xAA //
#define EPD_3IN52_Gate_Line 0x55 //
#define EPD_3IN52_UP_BLACK_DOWN_WHITE 0xF0 //
#define EPD_3IN52_LEFT_BLACK_RIGHT_WHITE 0x0F //
#define EPD_3IN52_Frame 0x01 //
#define EPD_3IN52_Crosstalk 0x02 //
#define EPD_3IN52_Chessboard 0x03 //
#define EPD_3IN52_Image 0x04 //
extern unsigned char EPD_3IN52_Flag;
void EPD_3IN52_SendCommand(UBYTE Reg);
void EPD_3IN52_SendData(UBYTE Data);
void EPD_3IN52_refresh(void);
void EPD_3IN52_lut_GC(void);
void EPD_3IN52_lut_DU(void);
void EPD_3IN52_Init(void);
void EPD_3IN52_display(UBYTE* picData);
void EPD_3IN52_display_NUM(UBYTE NUM);
void EPD_3IN52_Clear(void);
void EPD_3IN52_sleep(void);
#endif

View file

@ -0,0 +1,268 @@
/*****************************************************************************
* | File : EPD_7in3g.c
* | Author : Waveshare team
* | Function : 7.3inch e-paper (G)
* | Info :
*----------------
* | This version: V1.0
* | Date : 2022-07-22
* | 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_7in3g.h"
#include "Debug.h"
/******************************************************************************
function : Software reset
parameter:
******************************************************************************/
static void EPD_7IN3G_Reset(void)
{
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(20);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(2);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(20);
}
/******************************************************************************
function : send command
parameter:
Reg : Command register
******************************************************************************/
static void EPD_7IN3G_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_7IN3G_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_7IN3G_ReadBusyH(void)
{
Debug("e-Paper busy H\r\n");
while(!DEV_Digital_Read(EPD_BUSY_PIN)) { //LOW: idle, HIGH: busy
DEV_Delay_ms(5);
}
Debug("e-Paper busy H release\r\n");
}
static void EPD_7IN3G_ReadBusyL(void)
{
Debug("e-Paper busy L\r\n");
while(DEV_Digital_Read(EPD_BUSY_PIN)) { //LOW: idle, HIGH: busy
DEV_Delay_ms(5);
}
Debug("e-Paper busy L release\r\n");
}
/******************************************************************************
function : Turn On Display
parameter:
******************************************************************************/
static void EPD_7IN3G_TurnOnDisplay(void)
{
EPD_7IN3G_SendCommand(0x12); // DISPLAY_REFRESH
EPD_7IN3G_SendData(0x00);
EPD_7IN3G_ReadBusyH();
EPD_7IN3G_SendCommand(0x02); // POWER_OFF
EPD_7IN3G_SendData(0X00);
EPD_7IN3G_ReadBusyH();
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
void EPD_7IN3G_Init(void)
{
EPD_7IN3G_Reset();
EPD_7IN3G_ReadBusyH();
DEV_Delay_ms(30);
EPD_7IN3G_SendCommand(0xAA);
EPD_7IN3G_SendData(0x49);
EPD_7IN3G_SendData(0x55);
EPD_7IN3G_SendData(0x20);
EPD_7IN3G_SendData(0x08);
EPD_7IN3G_SendData(0x09);
EPD_7IN3G_SendData(0x18);
EPD_7IN3G_SendCommand(0x01);
EPD_7IN3G_SendData(0x3F);
EPD_7IN3G_SendCommand(0x00);
EPD_7IN3G_SendData(0x4F);
EPD_7IN3G_SendData(0x69);
EPD_7IN3G_SendCommand(0x05);
EPD_7IN3G_SendData(0x40);
EPD_7IN3G_SendData(0x1F);
EPD_7IN3G_SendData(0x1F);
EPD_7IN3G_SendData(0x2C);
EPD_7IN3G_SendCommand(0x08);
EPD_7IN3G_SendData(0x6F);
EPD_7IN3G_SendData(0x1F);
EPD_7IN3G_SendData(0x1F);
EPD_7IN3G_SendData(0x22);
//===================
//20211212
//First setting
EPD_7IN3G_SendCommand(0x06);
EPD_7IN3G_SendData(0x6F);
EPD_7IN3G_SendData(0x1F);
EPD_7IN3G_SendData(0x14);
EPD_7IN3G_SendData(0x14);
//===================
EPD_7IN3G_SendCommand(0x03);
EPD_7IN3G_SendData(0x00);
EPD_7IN3G_SendData(0x54);
EPD_7IN3G_SendData(0x00);
EPD_7IN3G_SendData(0x44);
EPD_7IN3G_SendCommand(0x60);
EPD_7IN3G_SendData(0x02);
EPD_7IN3G_SendData(0x00);
//Please notice that PLL must be set for version 2 IC
EPD_7IN3G_SendCommand(0x30);
EPD_7IN3G_SendData(0x08);
EPD_7IN3G_SendCommand(0x50);
EPD_7IN3G_SendData(0x3F);
EPD_7IN3G_SendCommand(0x61);
EPD_7IN3G_SendData(0x03);
EPD_7IN3G_SendData(0x20);
EPD_7IN3G_SendData(0x01);
EPD_7IN3G_SendData(0xE0);
EPD_7IN3G_SendCommand(0xE3);
EPD_7IN3G_SendData(0x2F);
EPD_7IN3G_SendCommand(0x84);
EPD_7IN3G_SendData(0x01);
}
/******************************************************************************
function : Clear screen
parameter:
******************************************************************************/
void EPD_7IN3G_Clear(UBYTE color)
{
UWORD Width, Height;
Width = (EPD_7IN3G_WIDTH % 4 == 0)? (EPD_7IN3G_WIDTH / 4 ): (EPD_7IN3G_WIDTH / 4 + 1);
Height = EPD_7IN3G_HEIGHT;
EPD_7IN3G_SendCommand(0x04);
EPD_7IN3G_ReadBusyH();
EPD_7IN3G_SendCommand(0x10);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_7IN3G_SendData(color);
}
}
EPD_7IN3G_TurnOnDisplay();
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void EPD_7IN3G_Display(UBYTE *Image)
{
UWORD Width, Height;
Width = (EPD_7IN3G_WIDTH % 4 == 0)? (EPD_7IN3G_WIDTH / 4 ): (EPD_7IN3G_WIDTH / 4 + 1);
Height = EPD_7IN3G_HEIGHT;
EPD_7IN3G_SendCommand(0x04);
EPD_7IN3G_ReadBusyH();
EPD_7IN3G_SendCommand(0x10);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_7IN3G_SendData(Image[i + j * Width]);
}
}
EPD_7IN3G_TurnOnDisplay();
}
void EPD_7IN3G_Display_part(UBYTE *Image, UWORD xstart, UWORD ystart, UWORD image_width, UWORD image_heigh)
{
UWORD Width, Height;
Width = (EPD_7IN3G_WIDTH % 4 == 0)? (EPD_7IN3G_WIDTH / 4 ): (EPD_7IN3G_WIDTH / 4 + 1);
Height = EPD_7IN3G_HEIGHT;
EPD_7IN3G_SendCommand(0x04);
EPD_7IN3G_ReadBusyH();
EPD_7IN3G_SendCommand(0x10);
for (UWORD i = 0; i < Height; i++) {
for (UWORD j = 0; j < Width; j++) {
if(i<image_heigh+ystart && i>=ystart && j<(image_width+xstart)/4 && j>=xstart/4) {
EPD_7IN3G_SendData(Image[(j-xstart/4) + (image_width/4*(i-ystart))]);
}
else
EPD_7IN3G_SendData(0x55);
}
}
EPD_7IN3G_TurnOnDisplay();
}
/******************************************************************************
function : Enter sleep mode
parameter:
******************************************************************************/
void EPD_7IN3G_Sleep(void)
{
EPD_7IN3G_SendCommand(0x02); // POWER_OFF
EPD_7IN3G_SendData(0X00);
EPD_7IN3G_SendCommand(0x07); // DEEP_SLEEP
EPD_7IN3G_SendData(0XA5);
}

View file

@ -0,0 +1,53 @@
/*****************************************************************************
* | File : EPD_7in3g.h
* | Author : Waveshare team
* | Function : 7.3inchg e-paper (G)
* | Info :
*----------------
* | This version: V1.0
* | Date : 2022-07-22
* | 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_7IN3G_H_
#define __EPD_7IN3G_H_
#include "DEV_Config.h"
// Display resolution
#define EPD_7IN3G_WIDTH 800
#define EPD_7IN3G_HEIGHT 480
//colour
#define EPD_7IN3G_BLACK 0x00
#define EPD_7IN3G_WHITE 0x55
#define EPD_7IN3G_YELLOW 0xAA
#define EPD_7IN3G_RED 0xFF
void EPD_7IN3G_Init(void);
void EPD_7IN3G_Clear(UBYTE color);
void EPD_7IN3G_Display(UBYTE *Image);
void EPD_7IN3G_Display_part(UBYTE *Image, UWORD xstart, UWORD ystart, UWORD image_width, UWORD image_heigh);
void EPD_7IN3G_Sleep(void);
#endif