| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 | /****************************************************************************** | File      	:  	EPD_2in9_DES.c* | Author      :   Waveshare team* | Function    :   2.9inch DES e-paper* | Info        :*----------------* |	This version:   V1.0* | Date        :   2020-01-13* | Info        :* -----------------------------------------------------------------------------## Permission is hereby granted, free of charge, to any person obtaining a copy# of this software and associated documnetation files (the "Software"), to deal# in the Software without restriction, including without limitation the rights# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell# copies of the Software, and to permit persons to  whom the Software is# furished to do so, subject to the following conditions:## The above copyright notice and this permission notice shall be included in# all copies or substantial portions of the Software.## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN# THE SOFTWARE.#******************************************************************************/#include "EPD_2in9_DES.h"#include "Debug.h"/******************************************************************************function :	Software resetparameter:******************************************************************************/static void EPD_2IN9_DES_Reset(void){    DEV_Digital_Write(EPD_RST_PIN, 1);    DEV_Delay_ms(100);    DEV_Digital_Write(EPD_RST_PIN, 0);    DEV_Delay_ms(2);    DEV_Digital_Write(EPD_RST_PIN, 1);    DEV_Delay_ms(100);}/******************************************************************************function :	send commandparameter:     Reg : Command register******************************************************************************/static void EPD_2IN9_DES_SendCommand(UBYTE Reg){    DEV_Digital_Write(EPD_DC_PIN, 0);    DEV_Digital_Write(EPD_CS_PIN, 0);    DEV_SPI_WriteByte(Reg);    DEV_Digital_Write(EPD_CS_PIN, 1);}/******************************************************************************function :	send dataparameter:    Data : Write data******************************************************************************/static void EPD_2IN9_DES_SendData(UBYTE Data){    DEV_Digital_Write(EPD_DC_PIN, 1);    DEV_Digital_Write(EPD_CS_PIN, 0);    DEV_SPI_WriteByte(Data);    DEV_Digital_Write(EPD_CS_PIN, 1);}/******************************************************************************function :	Wait until the busy_pin goes LOWparameter:******************************************************************************/void EPD_2IN9_DES_ReadBusy(void){    Debug("e-Paper busy\r\n");	while(1)	{	 //=1 BUSY		EPD_2IN9_DES_SendCommand(0x71);		if(DEV_Digital_Read(EPD_BUSY_PIN)==1) 			break;		DEV_Delay_ms(50);	}	DEV_Delay_ms(50);    Debug("e-Paper busy release\r\n");}/******************************************************************************function :	Turn On Displayparameter:******************************************************************************/static void EPD_2IN9_DES_TurnOnDisplay(void){	EPD_2IN9_DES_SendCommand(0x12); //Display Update Control	EPD_2IN9_DES_ReadBusy();}/******************************************************************************function :	Initialize the e-Paper registerparameter:******************************************************************************/void EPD_2IN9_DES_Init(void){	EPD_2IN9_DES_Reset();	DEV_Delay_ms(100); 	EPD_2IN9_DES_SendCommand(0x04);  //SWRESET	EPD_2IN9_DES_ReadBusy();   	EPD_2IN9_DES_SendCommand(0x00); //Driver output control      	EPD_2IN9_DES_SendData(0x1f);		EPD_2IN9_DES_SendCommand(0x50);	EPD_2IN9_DES_SendData(0x97);}/******************************************************************************function :	Clear screenparameter:******************************************************************************/void EPD_2IN9_DES_Clear(void){	UWORD i;	// EPD_2IN9_DES_SendCommand(0x10);	// for(i=0;i<4736;i++)	// {		// EPD_2IN9_DES_SendData(0xff);	// }	EPD_2IN9_DES_SendCommand(0x13);	for(i=0;i<4736;i++)	{		EPD_2IN9_DES_SendData(0xff);	}	EPD_2IN9_DES_TurnOnDisplay();}/******************************************************************************function :	Sends the image buffer in RAM to e-Paper and displaysparameter:******************************************************************************/void EPD_2IN9_DES_Display(UBYTE *Image){	UWORD i;		// EPD_2IN9_DES_SendCommand(0x10);	// for(i=0;i<4736;i++)	// {		// EPD_2IN9_DES_SendData(0xff);	// }	EPD_2IN9_DES_SendCommand(0x13);	for(i=0;i<4736;i++)	{		EPD_2IN9_DES_SendData(Image[i]);	}	EPD_2IN9_DES_TurnOnDisplay();	}/******************************************************************************function :	Enter sleep modeparameter:******************************************************************************/void EPD_2IN9_DES_Sleep(void){	EPD_2IN9_DES_SendCommand(0x50); //enter deep sleep	EPD_2IN9_DES_SendData(0xf7); 	EPD_2IN9_DES_SendCommand(0x02);	EPD_2IN9_DES_ReadBusy();	EPD_2IN9_DES_SendCommand(0x07);	EPD_2IN9_DES_SendData(0xa5);}
 |