diff --git a/EPD/DEV_Config.c b/EPD/DEV_Config.c index 75dafe4..cb535f7 100644 --- a/EPD/DEV_Config.c +++ b/EPD/DEV_Config.c @@ -74,9 +74,9 @@ void DEV_SPI_WriteByte(UBYTE value) UBYTE DEV_SPI_ReadByte(void) { - UBYTE value; - nrf_drv_spi_transfer(&spi, NULL, 0, &value, 1); - return value; + UBYTE value; + nrf_drv_spi_transfer(&spi, NULL, 0, &value, 1); + return value; } void DEV_Module_Exit(void) diff --git a/EPD/EPD_4in2.c b/EPD/EPD_4in2.c index 5ab20cb..5f87e90 100644 --- a/EPD/EPD_4in2.c +++ b/EPD/EPD_4in2.c @@ -8,66 +8,6 @@ * | Date : 2019-06-13 * | Info : * ----------------------------------------------------------------------------- -* V3.0(2019-06-13): -* 1.Change: -* lut_vcomDC[] => EPD_4IN2_lut_vcomDC[] -* lut_ww[] => EPD_4IN2_lut_ww[] -* lut_bw[] => EPD_4IN2_lut_bw[] -* lut_wb[] => EPD_4IN2_lut_wb[] -* lut_bb[] => EPD_4IN2_lut_bb[] -* EPD_Reset() => EPD_4IN2_Reset() -* EPD_SendCommand() => EPD_4IN2_SendCommand() -* EPD_SendData() => EPD_4IN2_SendData() -* EPD_WaitUntilIdle() => EPD_4IN2_ReadBusy() -* EPD_SetFullReg() => EPD_4IN2_SetFullReg() -* EPD_SetPartReg() => EPD_4IN2_SetPartReg() -* EPD_TurnOnDisplay() => EPD_4IN2_TurnOnDisplay() -* EPD_Init() => EPD_4IN2_Init() -* EPD_Clear() => EPD_4IN2_Clear() -* EPD_Display() => EPD_4IN2_Display() -* EPD_Sleep() => EPD_4IN2_Sleep() -* 2.remove commands define: -* #define PANEL_SETTING 0x00 -* #define POWER_SETTING 0x01 -* #define POWER_OFF 0x02 -* #define POWER_OFF_SEQUENCE_SETTING 0x03 -* #define POWER_ON 0x04 -* #define POWER_ON_MEASURE 0x05 -* #define BOOSTER_SOFT_START 0x06 -* #define DEEP_SLEEP 0x07 -* #define DATA_START_TRANSMISSION_1 0x10 -* #define DATA_STOP 0x11 -* #define DISPLAY_REFRESH 0x12 -* #define DATA_START_TRANSMISSION_2 0x13 -* #define VCOM_LUT 0x20 -* #define W2W_LUT 0x21 -* #define B2W_LUT 0x22 -* #define W2B_LUT 0x23 -* #define B2B_LUT 0x24 -* #define PLL_CONTROL 0x30 -* #define TEMPERATURE_SENSOR_CALIBRATION 0x40 -* #define TEMPERATURE_SENSOR_SELECTION 0x41 -* #define TEMPERATURE_SENSOR_WRITE 0x42 -* #define TEMPERATURE_SENSOR_READ 0x43 -* #define VCOM_AND_DATA_INTERVAL_SETTING 0x50 -* #define LOW_POWER_DETECTION 0x51 -* #define TCON_SETTING 0x60 -* #define RESOLUTION_SETTING 0x61 -* #define GET_STATUS 0x71 -* #define AUTO_MEASURE_VCOM 0x80 -* #define READ_VCOM_VALUE 0x81 -* #define VCM_DC_SETTING 0x82 -* #define PARTIAL_WINDOW 0x90 -* #define PARTIAL_IN 0x91 -* #define PARTIAL_OUT 0x92 -* #define PROGRAM_MODE 0xA0 -* #define ACTIVE_PROGRAM 0xA1 -* #define READ_OTP_DATA 0xA2 -* #define POWER_SAVING 0xE3 -* V2.0(2018-10-30): -* 1.Remove:ImageBuff[EPD_HEIGHT * EPD_WIDTH / 8] -* 2.Change:EPD_Display(UBYTE *Image) -* Need to pass parameters: pointer to cached data # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documnetation files (the "Software"), to deal @@ -137,118 +77,6 @@ static const unsigned char EPD_4IN2_lut_bb[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; -/******************************partial screen update LUT*********************************/ -const unsigned char EPD_4IN2_Partial_lut_vcom1[] ={ - 0x00, 0x01, 0x20, 0x01, 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, -}; - -const unsigned char EPD_4IN2_Partial_lut_ww1[] ={ - 0x00, 0x01, 0x20, 0x01, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -const unsigned char EPD_4IN2_Partial_lut_bw1[] ={ - 0x20, 0x01, 0x20, 0x01, 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, -}; - -const unsigned char EPD_4IN2_Partial_lut_wb1[] ={ - 0x10, 0x01, 0x20, 0x01, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -const unsigned char EPD_4IN2_Partial_lut_bb1[] ={ - 0x00, 0x01,0x20, 0x01, 0x00, 0x01, - 0x00, 0x00,0x00, 0x00, 0x00, 0x00, - 0x00, 0x00,0x00, 0x00, 0x00, 0x00, - 0x00, 0x00,0x00, 0x00, 0x00, 0x00, - 0x00, 0x00,0x00, 0x00, 0x00, 0x00, - 0x00, 0x00,0x00, 0x00, 0x00, 0x00, - 0x00, 0x00,0x00, 0x00, 0x00, 0x00, -}; - - -/******************************gray*********************************/ -//0~3 gray -const unsigned char EPD_4IN2_4Gray_lut_vcom[] = -{ - 0x00 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01, - 0x60 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01, - 0x00 ,0x14 ,0x00 ,0x00 ,0x00 ,0x01, - 0x00 ,0x13 ,0x0A ,0x01 ,0x00 ,0x01, - 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00, - 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00, - 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 - -}; -//R21 -const unsigned char EPD_4IN2_4Gray_lut_ww[] ={ - 0x40 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01, - 0x90 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01, - 0x10 ,0x14 ,0x0A ,0x00 ,0x00 ,0x01, - 0xA0 ,0x13 ,0x01 ,0x00 ,0x00 ,0x01, - 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00, - 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00, - 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00, -}; -//R22H r -const unsigned char EPD_4IN2_4Gray_lut_bw[] ={ - 0x40 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01, - 0x90 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01, - 0x00 ,0x14 ,0x0A ,0x00 ,0x00 ,0x01, - 0x99 ,0x0C ,0x01 ,0x03 ,0x04 ,0x01, - 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00, - 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00, - 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00, -}; -//R23H w -const unsigned char EPD_4IN2_4Gray_lut_wb[] ={ - 0x40 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01, - 0x90 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01, - 0x00 ,0x14 ,0x0A ,0x00 ,0x00 ,0x01, - 0x99 ,0x0B ,0x04 ,0x04 ,0x01 ,0x01, - 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00, - 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00, - 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00, -}; -//R24H b -const unsigned char EPD_4IN2_4Gray_lut_bb[] ={ - 0x80 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01, - 0x90 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01, - 0x20 ,0x14 ,0x0A ,0x00 ,0x00 ,0x01, - 0x50 ,0x13 ,0x01 ,0x00 ,0x00 ,0x01, - 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00, - 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00, - 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00, -}; - /****************************************************************************** function : Software reset parameter: @@ -312,7 +140,7 @@ void EPD_4IN2_ReadBusy(void) function : Turn On Display parameter: ******************************************************************************/ -static void EPD_4IN2_TurnOnDisplay(void) +void EPD_4IN2_TurnOnDisplay(void) { EPD_4IN2_SendCommand(0x12); DEV_Delay_ms(100); @@ -346,60 +174,7 @@ static void EPD_4IN2_SetLut(void) for(count=0;count<36;count++) {EPD_4IN2_SendData(EPD_4IN2_lut_bb[count]);} } -static void EPD_4IN2_Partial_SetLut(void) -{ - unsigned int count; - EPD_4IN2_SendCommand(0x20); - for(count=0;count<44;count++) - {EPD_4IN2_SendData(EPD_4IN2_Partial_lut_vcom1[count]);} - EPD_4IN2_SendCommand(0x21); - for(count=0;count<42;count++) - {EPD_4IN2_SendData(EPD_4IN2_Partial_lut_ww1[count]);} - - EPD_4IN2_SendCommand(0x22); - for(count=0;count<42;count++) - {EPD_4IN2_SendData(EPD_4IN2_Partial_lut_bw1[count]);} - - EPD_4IN2_SendCommand(0x23); - for(count=0;count<42;count++) - {EPD_4IN2_SendData(EPD_4IN2_Partial_lut_wb1[count]);} - - EPD_4IN2_SendCommand(0x24); - for(count=0;count<42;count++) - {EPD_4IN2_SendData(EPD_4IN2_Partial_lut_bb1[count]);} -} - -//LUT download -static void EPD_4IN2_4Gray_lut(void) -{ - unsigned int count; - { - EPD_4IN2_SendCommand(0x20); //vcom - for(count=0;count<42;count++) - {EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_vcom[count]);} - - EPD_4IN2_SendCommand(0x21); //red not use - for(count=0;count<42;count++) - {EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_ww[count]);} - - EPD_4IN2_SendCommand(0x22); //bw r - for(count=0;count<42;count++) - {EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_bw[count]);} - - EPD_4IN2_SendCommand(0x23); //wb w - for(count=0;count<42;count++) - {EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_wb[count]);} - - EPD_4IN2_SendCommand(0x24); //bb b - for(count=0;count<42;count++) - {EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_bb[count]);} - - EPD_4IN2_SendCommand(0x25); //vcom - for(count=0;count<42;count++) - {EPD_4IN2_SendData(EPD_4IN2_4Gray_lut_ww[count]);} - } -} /****************************************************************************** function : Initialize the e-Paper register parameter: @@ -444,43 +219,6 @@ void EPD_4IN2_Init(void) EPD_4IN2_SetLut(); } -void EPD_4IN2_Init_4Gray(void) -{ - EPD_4IN2_Reset(); - EPD_4IN2_SendCommand(0x01); //POWER SETTING - EPD_4IN2_SendData (0x03); - EPD_4IN2_SendData (0x00); //VGH=20V,VGL=-20V - EPD_4IN2_SendData (0x2b); //VDH=15V - EPD_4IN2_SendData (0x2b); //VDL=-15V - EPD_4IN2_SendData (0x13); - - EPD_4IN2_SendCommand(0x06); //booster soft start - EPD_4IN2_SendData (0x17); //A - EPD_4IN2_SendData (0x17); //B - EPD_4IN2_SendData (0x17); //C - - EPD_4IN2_SendCommand(0x04); - EPD_4IN2_ReadBusy(); - - EPD_4IN2_SendCommand(0x00); //panel setting - EPD_4IN2_SendData(0x3f); //KW-3f KWR-2F BWROTP 0f BWOTP 1f - - EPD_4IN2_SendCommand(0x30); //PLL setting - EPD_4IN2_SendData (0x3c); //100hz - - EPD_4IN2_SendCommand(0x61); //resolution setting - EPD_4IN2_SendData (0x01); //400 - EPD_4IN2_SendData (0x90); - EPD_4IN2_SendData (0x01); //300 - EPD_4IN2_SendData (0x2c); - - EPD_4IN2_SendCommand(0x82); //vcom_DC setting - EPD_4IN2_SendData (0x12); - - EPD_4IN2_SendCommand(0X50); //VCOM AND DATA INTERVAL SETTING - EPD_4IN2_SendData(0x97); -} - /****************************************************************************** function : Clear screen parameter: @@ -530,41 +268,6 @@ void EPD_4IN2_Display(UBYTE *Image) EPD_4IN2_TurnOnDisplay(); } -/****************************************************************************** -function : Sends the image buffer in RAM to e-Paper and displays -parameter: -******************************************************************************/ -void EPD_4IN2_Display_Half(UBYTE *Image, UBYTE Region) -{ - UWORD Width, Height; - Width = (EPD_4IN2_WIDTH % 8 == 0)? (EPD_4IN2_WIDTH / 8 ): (EPD_4IN2_WIDTH / 8 + 1); - Height = EPD_4IN2_HEIGHT; - - if(Region == 1){ - EPD_4IN2_SendCommand(0x13); - for (UWORD j = 0; j < Height/2; j++) { - for (UWORD i = 0; i < Width; i++) { - EPD_4IN2_SendData(Image[i + j * Width]); - } - } - }else if(Region == 2){ - for (UWORD j = 0; j < Height/2; j++) { - for (UWORD i = 0; i < Width; i++) { - EPD_4IN2_SendData(Image[i + j * Width]); - } - } - } -} - -/****************************************************************************** -function : Sends the image buffer in RAM to e-Paper and displays -parameter: -******************************************************************************/ -void EPD_4IN2_UpdateDisplay(void) -{ - EPD_4IN2_TurnOnDisplay(); -} - /****************************************************************************** function : Enter sleep mode parameter: diff --git a/EPD/EPD_4in2.h b/EPD/EPD_4in2.h index afb5de7..da5fb29 100644 --- a/EPD/EPD_4in2.h +++ b/EPD/EPD_4in2.h @@ -8,66 +8,6 @@ * | Date : 2019-06-13 * | Info : * ----------------------------------------------------------------------------- -* V3.0(2019-06-13): -* 1.Change: -* lut_vcomDC[] => EPD_4IN2_lut_vcomDC[] -* lut_ww[] => EPD_4IN2_lut_ww[] -* lut_bw[] => EPD_4IN2_lut_bw[] -* lut_wb[] => EPD_4IN2_lut_wb[] -* lut_bb[] => EPD_4IN2_lut_bb[] -* EPD_Reset() => EPD_4IN2_Reset() -* EPD_SendCommand() => EPD_4IN2_SendCommand() -* EPD_SendData() => EPD_4IN2_SendData() -* EPD_WaitUntilIdle() => EPD_4IN2_ReadBusy() -* EPD_SetFullReg() => EPD_4IN2_SetFullReg() -* EPD_SetPartReg() => EPD_4IN2_SetPartReg() -* EPD_TurnOnDisplay() => EPD_4IN2_TurnOnDisplay() -* EPD_Init() => EPD_4IN2_Init() -* EPD_Clear() => EPD_4IN2_Clear() -* EPD_Display() => EPD_4IN2_Display() -* EPD_Sleep() => EPD_4IN2_Sleep() -* 2.remove commands define: -* #define PANEL_SETTING 0x00 -* #define POWER_SETTING 0x01 -* #define POWER_OFF 0x02 -* #define POWER_OFF_SEQUENCE_SETTING 0x03 -* #define POWER_ON 0x04 -* #define POWER_ON_MEASURE 0x05 -* #define BOOSTER_SOFT_START 0x06 -* #define DEEP_SLEEP 0x07 -* #define DATA_START_TRANSMISSION_1 0x10 -* #define DATA_STOP 0x11 -* #define DISPLAY_REFRESH 0x12 -* #define DATA_START_TRANSMISSION_2 0x13 -* #define VCOM_LUT 0x20 -* #define W2W_LUT 0x21 -* #define B2W_LUT 0x22 -* #define W2B_LUT 0x23 -* #define B2B_LUT 0x24 -* #define PLL_CONTROL 0x30 -* #define TEMPERATURE_SENSOR_CALIBRATION 0x40 -* #define TEMPERATURE_SENSOR_SELECTION 0x41 -* #define TEMPERATURE_SENSOR_WRITE 0x42 -* #define TEMPERATURE_SENSOR_READ 0x43 -* #define VCOM_AND_DATA_INTERVAL_SETTING 0x50 -* #define LOW_POWER_DETECTION 0x51 -* #define TCON_SETTING 0x60 -* #define RESOLUTION_SETTING 0x61 -* #define GET_STATUS 0x71 -* #define AUTO_MEASURE_VCOM 0x80 -* #define READ_VCOM_VALUE 0x81 -* #define VCM_DC_SETTING 0x82 -* #define PARTIAL_WINDOW 0x90 -* #define PARTIAL_IN 0x91 -* #define PARTIAL_OUT 0x92 -* #define PROGRAM_MODE 0xA0 -* #define ACTIVE_PROGRAM 0xA1 -* #define READ_OTP_DATA 0xA2 -* #define POWER_SAVING 0xE3 -* V2.0(2018-10-30): -* 1.Remove:ImageBuff[EPD_HEIGHT * EPD_WIDTH / 8] -* 2.Change:EPD_Display(UBYTE *Image) -* Need to pass parameters: pointer to cached data # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documnetation files (the "Software"), to deal @@ -101,8 +41,9 @@ void EPD_4IN2_Init(void); void EPD_4IN2_Clear(void); void EPD_4IN2_Display(UBYTE *Image); void EPD_4IN2_Sleep(void); -void EPD_4IN2_UpdateDisplay(void); + void EPD_4IN2_SendCommand(UBYTE Reg); void EPD_4IN2_SendData(UBYTE Data); +void EPD_4IN2_TurnOnDisplay(void); #endif diff --git a/EPD/EPD_4in2_V2.c b/EPD/EPD_4in2_V2.c index 2e86df2..249b965 100644 --- a/EPD/EPD_4in2_V2.c +++ b/EPD/EPD_4in2_V2.c @@ -30,43 +30,6 @@ ******************************************************************************/ #include "EPD_4in2_V2.h" -const unsigned char LUT_ALL[233]={ -0x01, 0x0A, 0x1B, 0x0F, 0x03, 0x01, 0x01, -0x05, 0x0A, 0x01, 0x0A, 0x01, 0x01, 0x01, -0x05, 0x08, 0x03, 0x02, 0x04, 0x01, 0x01, -0x01, 0x04, 0x04, 0x02, 0x00, 0x01, 0x01, -0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, -0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, -0x01, 0x0A, 0x1B, 0x0F, 0x03, 0x01, 0x01, -0x05, 0x4A, 0x01, 0x8A, 0x01, 0x01, 0x01, -0x05, 0x48, 0x03, 0x82, 0x84, 0x01, 0x01, -0x01, 0x84, 0x84, 0x82, 0x00, 0x01, 0x01, -0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, -0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, -0x01, 0x0A, 0x1B, 0x8F, 0x03, 0x01, 0x01, -0x05, 0x4A, 0x01, 0x8A, 0x01, 0x01, 0x01, -0x05, 0x48, 0x83, 0x82, 0x04, 0x01, 0x01, -0x01, 0x04, 0x04, 0x02, 0x00, 0x01, 0x01, -0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, -0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, -0x01, 0x8A, 0x1B, 0x8F, 0x03, 0x01, 0x01, -0x05, 0x4A, 0x01, 0x8A, 0x01, 0x01, 0x01, -0x05, 0x48, 0x83, 0x02, 0x04, 0x01, 0x01, -0x01, 0x04, 0x04, 0x02, 0x00, 0x01, 0x01, -0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, -0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, -0x01, 0x8A, 0x9B, 0x8F, 0x03, 0x01, 0x01, -0x05, 0x4A, 0x01, 0x8A, 0x01, 0x01, 0x01, -0x05, 0x48, 0x03, 0x42, 0x04, 0x01, 0x01, -0x01, 0x04, 0x04, 0x42, 0x00, 0x01, 0x01, -0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, -0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x02, 0x00, 0x00, 0x07, 0x17, 0x41, 0xA8, -0x32, 0x30, -}; - /****************************************************************************** function : Software reset parameter: @@ -122,7 +85,7 @@ void EPD_4IN2_V2_ReadBusy(void) function : Turn On Display parameter: ******************************************************************************/ -static void EPD_4IN2_V2_TurnOnDisplay(void) +void EPD_4IN2_V2_TurnOnDisplay(void) { EPD_4IN2_V2_SendCommand(0x22); EPD_4IN2_V2_SendData(0xF7); @@ -130,30 +93,6 @@ static void EPD_4IN2_V2_TurnOnDisplay(void) EPD_4IN2_V2_ReadBusy(); } -static void EPD_4IN2_V2_TurnOnDisplay_Fast(void) -{ - EPD_4IN2_V2_SendCommand(0x22); - EPD_4IN2_V2_SendData(0xC7); - EPD_4IN2_V2_SendCommand(0x20); - EPD_4IN2_V2_ReadBusy(); -} - -static void EPD_4IN2_V2_TurnOnDisplay_Partial(void) -{ - EPD_4IN2_V2_SendCommand(0x22); - EPD_4IN2_V2_SendData(0xFF); - EPD_4IN2_V2_SendCommand(0x20); - EPD_4IN2_V2_ReadBusy(); -} - -static void EPD_4IN2_V2_TurnOnDisplay_4Gray(void) -{ - EPD_4IN2_V2_SendCommand(0x22); - EPD_4IN2_V2_SendData(0xCF); - EPD_4IN2_V2_SendCommand(0x20); - EPD_4IN2_V2_ReadBusy(); -} - /****************************************************************************** function : Setting the display window parameter: @@ -185,36 +124,6 @@ static void EPD_4IN2_V2_SetCursor(UWORD Xstart, UWORD Ystart) EPD_4IN2_V2_SendData((Ystart >> 8) & 0xFF); } -//LUT download -static void EPD_4IN2_V2_4Gray_lut(void) -{ - unsigned char i; - - //WS byte 0~152, the content of VS[nX-LUTm], TP[nX], RP[n], SR[nXY], FR[n] and XON[nXY] - EPD_4IN2_V2_SendCommand(0x32); - for(i=0;i<227;i++) - { - EPD_4IN2_V2_SendData(LUT_ALL[i]); - } - //WS byte 153, the content of Option for LUT end - EPD_4IN2_V2_SendCommand(0x3F); - EPD_4IN2_V2_SendData(LUT_ALL[i++]); - - //WS byte 154, the content of gate leve - EPD_4IN2_V2_SendCommand(0x03); - EPD_4IN2_V2_SendData(LUT_ALL[i++]);//VGH - - //WS byte 155~157, the content of source level - EPD_4IN2_V2_SendCommand(0x04); - EPD_4IN2_V2_SendData(LUT_ALL[i++]);//VSH1 - EPD_4IN2_V2_SendData(LUT_ALL[i++]);//VSH2 - EPD_4IN2_V2_SendData(LUT_ALL[i++]);//VSL - - //WS byte 158, the content of VCOM level - EPD_4IN2_V2_SendCommand(0x2c); - EPD_4IN2_V2_SendData(LUT_ALL[i++]);//VCOM -} - /****************************************************************************** function : Initialize the e-Paper register parameter: @@ -249,88 +158,6 @@ void EPD_4IN2_V2_Init(void) EPD_4IN2_V2_ReadBusy(); } -/****************************************************************************** -function : Initialize Fast the e-Paper register -parameter: -******************************************************************************/ -void EPD_4IN2_V2_Init_Fast(UBYTE Mode) -{ - EPD_4IN2_V2_Reset(); - - EPD_4IN2_V2_ReadBusy(); - EPD_4IN2_V2_SendCommand(0x12); // soft reset - EPD_4IN2_V2_ReadBusy(); - - EPD_4IN2_V2_SendCommand(0x21); - EPD_4IN2_V2_SendData(0x40); - EPD_4IN2_V2_SendData(0x00); - - EPD_4IN2_V2_SendCommand(0x3C); - EPD_4IN2_V2_SendData(0x05); - - if(Mode == Seconds_1_5S) - { - //1.5s - EPD_4IN2_V2_SendCommand(0x1A); // Write to temperature register - EPD_4IN2_V2_SendData(0x6E); - } - else if(Mode == Seconds_1S) - { - //1s - EPD_4IN2_V2_SendCommand(0x1A); // Write to temperature register - EPD_4IN2_V2_SendData(0x5A); - } - - EPD_4IN2_V2_SendCommand(0x22); // Load temperature value - EPD_4IN2_V2_SendData(0x91); - EPD_4IN2_V2_SendCommand(0x20); - EPD_4IN2_V2_ReadBusy(); - - EPD_4IN2_V2_SendCommand(0x11); // data entry mode - EPD_4IN2_V2_SendData(0x03); // X-mode - - EPD_4IN2_V2_SetWindows(0, 0, EPD_4IN2_V2_WIDTH-1, EPD_4IN2_V2_HEIGHT-1); - - EPD_4IN2_V2_SetCursor(0, 0); - - EPD_4IN2_V2_ReadBusy(); -} - - -void EPD_4IN2_V2_Init_4Gray(void) -{ - EPD_4IN2_V2_Reset(); - - EPD_4IN2_V2_SendCommand(0x12); //SWRESET - EPD_4IN2_V2_ReadBusy(); - - EPD_4IN2_V2_SendCommand(0x21); - EPD_4IN2_V2_SendData(0x00); - EPD_4IN2_V2_SendData(0x00); - - EPD_4IN2_V2_SendCommand(0x3C); - EPD_4IN2_V2_SendData(0x03); - - EPD_4IN2_V2_SendCommand(0x0C); //BTST - EPD_4IN2_V2_SendData(0x8B);//8B - EPD_4IN2_V2_SendData(0x9C);//9C - EPD_4IN2_V2_SendData(0xA4);//96 A4 - EPD_4IN2_V2_SendData(0x0F);//0F - - // EPD_4IN2_V2_SendCommand(0x01); // 驱动输出控制 drive output control - // EPD_4IN2_V2_SendData(0x2B); // Y 的低字节 - // EPD_4IN2_V2_SendData(0x01); // Y 的高字节 - // EPD_4IN2_V2_SendData(0x00); - - EPD_4IN2_V2_4Gray_lut(); //LUT - - EPD_4IN2_V2_SendCommand(0x11); // data entry mode - EPD_4IN2_V2_SendData(0x03); // X-mode - - EPD_4IN2_V2_SetWindows(0, 0, EPD_4IN2_V2_WIDTH-1, EPD_4IN2_V2_HEIGHT-1); - - EPD_4IN2_V2_SetCursor(0, 0); -} /****************************************************************************** function : Clear screen parameter: @@ -357,49 +184,6 @@ void EPD_4IN2_V2_Clear(void) EPD_4IN2_V2_TurnOnDisplay(); } -/****************************************************************************** -function : Sends the image buffer in RAM to e-Paper and displays -parameter: -******************************************************************************/ -void EPD_4IN2_V2_Display_Half(UBYTE *Image, UBYTE Region) -{ - UWORD Width, Height; - Width = (EPD_4IN2_V2_WIDTH % 8 == 0)? (EPD_4IN2_V2_WIDTH / 8 ): (EPD_4IN2_V2_WIDTH / 8 + 1); - Height = EPD_4IN2_V2_HEIGHT; - - if(Region == 1){ - EPD_4IN2_V2_SendCommand(0x24); - for (UWORD j = 0; j < Height/2; j++) { - for (UWORD i = 0; i < Width; i++) { - EPD_4IN2_V2_SendData(Image[i + j * Width]); - } - } - - EPD_4IN2_V2_SendCommand(0x26); - for (UWORD j = 0; j < Height/2; j++) { - for (UWORD i = 0; i < Width; i++) { - EPD_4IN2_V2_SendData(Image[i + j * Width]); - } - } - } - else if(Region == 2){ - EPD_4IN2_V2_SendCommand(0x24); - for (UWORD j = 0; j < Height/2; j++) { - for (UWORD i = 0; i < Width; i++) { - EPD_4IN2_V2_SendData(Image[i + j * Width]); - } - } - - EPD_4IN2_V2_SendCommand(0x26); - for (UWORD j = 0; j < Height/2; j++) { - for (UWORD i = 0; i < Width; i++) { - EPD_4IN2_V2_SendData(Image[i + j * Width]); - } - } - EPD_4IN2_V2_TurnOnDisplay(); - } -} - /****************************************************************************** function : Sends the image buffer in RAM to e-Paper and displays parameter: @@ -426,189 +210,6 @@ void EPD_4IN2_V2_Display(UBYTE *Image) EPD_4IN2_V2_TurnOnDisplay(); } -/****************************************************************************** -function : Sends the image buffer in RAM to e-Paper and fast displays -parameter: -******************************************************************************/ -void EPD_4IN2_V2_Display_Fast(UBYTE *Image) -{ - UWORD Width, Height; - Width = (EPD_4IN2_V2_WIDTH % 8 == 0)? (EPD_4IN2_V2_WIDTH / 8 ): (EPD_4IN2_V2_WIDTH / 8 + 1); - Height = EPD_4IN2_V2_HEIGHT; - - EPD_4IN2_V2_SendCommand(0x24); - for (UWORD j = 0; j < Height; j++) { - for (UWORD i = 0; i < Width; i++) { - EPD_4IN2_V2_SendData(Image[i + j * Width]); - } - } - - EPD_4IN2_V2_SendCommand(0x26); - for (UWORD j = 0; j < Height; j++) { - for (UWORD i = 0; i < Width; i++) { - EPD_4IN2_V2_SendData(Image[i + j * Width]); - } - } - EPD_4IN2_V2_TurnOnDisplay_Fast(); -} - - -void EPD_4IN2_V2_Display_4Gray(UBYTE *Image) -{ - UDOUBLE i,j,k,m; - UBYTE temp1,temp2,temp3; -/****Color display description**** - white gray2 gray1 black -0x10| 01 01 00 00 -0x13| 01 00 01 00 -*********************************/ - EPD_4IN2_V2_SendCommand(0x24); - // EPD_4IN2_HEIGHT - // EPD_4IN2_WIDTH - for(m = 0; m Xend % 8) || Xstart % 8 + Xend % 8 == 0 || (Xend - Xstart)%8 == 0) - { - Xstart = Xstart / 8 ; - Xend = Xend / 8; - } - else - { - Xstart = Xstart / 8 ; - Xend = Xend % 8 == 0 ? Xend / 8 : Xend / 8 + 1; - } - - - UWORD i, Width; - Width = Xend - Xstart; - UWORD IMAGE_COUNTER = Width * (Yend-Ystart); - - Xend -= 1; - Yend -= 1; - - EPD_4IN2_V2_SendCommand(0x3C); //BorderWavefrom, - EPD_4IN2_V2_SendData(0x80); - - EPD_4IN2_V2_SendCommand(0x21); - EPD_4IN2_V2_SendData(0x00); - EPD_4IN2_V2_SendData(0x00); - - EPD_4IN2_V2_SendCommand(0x3C); - EPD_4IN2_V2_SendData(0x80); - - EPD_4IN2_V2_SendCommand(0x44); // set RAM x address start/end, in page 35 - EPD_4IN2_V2_SendData(Xstart & 0xff); // RAM x address start at 00h; - EPD_4IN2_V2_SendData(Xend & 0xff); // RAM x address end at 0fh(15+1)*8->128 - EPD_4IN2_V2_SendCommand(0x45); // set RAM y address start/end, in page 35 - EPD_4IN2_V2_SendData(Ystart & 0xff); // RAM y address start at 0127h; - EPD_4IN2_V2_SendData((Ystart>>8) & 0x01); // RAM y address start at 0127h; - EPD_4IN2_V2_SendData(Yend & 0xff); // RAM y address end at 00h; - EPD_4IN2_V2_SendData((Yend>>8) & 0x01); - - EPD_4IN2_V2_SendCommand(0x4E); // set RAM x address count to 0; - EPD_4IN2_V2_SendData(Xstart & 0xff); - EPD_4IN2_V2_SendCommand(0x4F); // set RAM y address count to 0X127; - EPD_4IN2_V2_SendData(Ystart & 0xff); - EPD_4IN2_V2_SendData((Ystart>>8) & 0x01); - - EPD_4IN2_V2_SendCommand(0x24); - for (i = 0; i < IMAGE_COUNTER; i++) { - EPD_4IN2_V2_SendData(Image[i]); - } - - EPD_4IN2_V2_TurnOnDisplay_Partial(); -} - -void EPD_4IN2_V2_UpdateDisplay(void) -{ - EPD_4IN2_V2_TurnOnDisplay(); -} - /****************************************************************************** function : Enter sleep mode parameter: diff --git a/EPD/EPD_4in2_V2.h b/EPD/EPD_4in2_V2.h index e327d39..b47fdce 100644 --- a/EPD/EPD_4in2_V2.h +++ b/EPD/EPD_4in2_V2.h @@ -41,16 +41,12 @@ #define Seconds_1S 1 void EPD_4IN2_V2_Init(void); -void EPD_4IN2_V2_Init_Fast(UBYTE Mode); -void EPD_4IN2_V2_Init_4Gray(void); void EPD_4IN2_V2_Clear(void); -void EPD_4IN2_V2_Display_Half(UBYTE *Image, UBYTE Region); void EPD_4IN2_V2_Display(UBYTE *Image); -void EPD_4IN2_V2_Display_Fast(UBYTE *Image); -void EPD_4IN2_V2_Display_4Gray(UBYTE *Image); -void EPD_4IN2_V2_PartialDisplay(UBYTE *Image, UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend); void EPD_4IN2_V2_Sleep(void); + void EPD_4IN2_V2_SendCommand(UBYTE Reg); void EPD_4IN2_V2_SendData(UBYTE Data); -void EPD_4IN2_V2_UpdateDisplay(void); +void EPD_4IN2_V2_TurnOnDisplay(void); + #endif diff --git a/EPD/EPD_4in2b_V2.c b/EPD/EPD_4in2b_V2.c index 7ed1b98..fdbb54f 100644 --- a/EPD/EPD_4in2b_V2.c +++ b/EPD/EPD_4in2b_V2.c @@ -86,7 +86,7 @@ void EPD_4IN2B_V2_ReadBusy(void) function : Turn On Display parameter: ******************************************************************************/ -static void EPD_4IN2B_V2_TurnOnDisplay(void) +void EPD_4IN2B_V2_TurnOnDisplay(void) { EPD_4IN2B_V2_SendCommand(0x12); // DISPLAY_REFRESH DEV_Delay_ms(100); @@ -162,49 +162,6 @@ void EPD_4IN2B_V2_Display(const UBYTE *blackimage, const UBYTE *ryimage) EPD_4IN2B_V2_TurnOnDisplay(); } -/****************************************************************************** -function : Sends the image buffer in RAM to e-Paper and displays -parameter: -******************************************************************************/ -void EPD_4IN2B_V2_Display_Half(const UBYTE *blackimage, UBYTE Region) -{ - UWORD Width, Height; - Width = (EPD_4IN2B_V2_WIDTH % 8 == 0)? (EPD_4IN2B_V2_WIDTH / 8 ): (EPD_4IN2B_V2_WIDTH / 8 + 1); - Height = EPD_4IN2B_V2_HEIGHT; - - if(Region == 1){ - EPD_4IN2B_V2_SendCommand(0x10); - for (UWORD j = 0; j < Height/2; j++) { - for (UWORD i = 0; i < Width; i++) { - EPD_4IN2B_V2_SendData(blackimage[i + j * Width]); - } - } - }else if(Region == 2){ - for (UWORD j = 0; j < Height/2; j++) { - for (UWORD i = 0; i < Width; i++) { - EPD_4IN2B_V2_SendData(blackimage[i + j * Width]); - } - } - }else if(Region == 3){ - EPD_4IN2B_V2_SendCommand(0x13); - for (UWORD j = 0; j < Height/2; j++) { - for (UWORD i = 0; i < Width; i++) { - EPD_4IN2B_V2_SendData(blackimage[i + j * Width]); - } - } - }else if(Region == 4){ - for (UWORD j = 0; j < Height/2; j++) { - for (UWORD i = 0; i < Width; i++) { - EPD_4IN2B_V2_SendData(blackimage[i + j * Width]); - } - } - } -} - -void EPD_4IN2B_V2_UpdateDisplay(void) -{ - EPD_4IN2B_V2_TurnOnDisplay(); -} /****************************************************************************** function : Enter sleep mode parameter: diff --git a/EPD/EPD_4in2b_V2.h b/EPD/EPD_4in2b_V2.h index 35097fd..bfbdfdf 100644 --- a/EPD/EPD_4in2b_V2.h +++ b/EPD/EPD_4in2b_V2.h @@ -40,8 +40,9 @@ void EPD_4IN2B_V2_Init(void); void EPD_4IN2B_V2_Clear(void); void EPD_4IN2B_V2_Display(const UBYTE *blackimage, const UBYTE *ryimage); void EPD_4IN2B_V2_Sleep(void); -void EPD_4IN2B_V2_Display_Half(const UBYTE *blackimage, UBYTE Region); -void EPD_4IN2B_V2_UpdateDisplay(void); + void EPD_4IN2B_V2_SendCommand(UBYTE Reg); void EPD_4IN2B_V2_SendData(UBYTE Data); +void EPD_4IN2B_V2_TurnOnDisplay(void); + #endif diff --git a/EPD/EPD_ble.c b/EPD/EPD_ble.c index 33dd034..69cd4e2 100644 --- a/EPD/EPD_ble.c +++ b/EPD/EPD_ble.c @@ -37,13 +37,13 @@ static pstorage_handle_t m_flash_handle; static epd_driver_t epd_drivers[] = { {EPD_DRIVER_4IN2, EPD_4IN2_Init, EPD_4IN2_Clear, EPD_4IN2_SendCommand, EPD_4IN2_SendData, - EPD_4IN2_UpdateDisplay, EPD_4IN2_Sleep}, + EPD_4IN2_TurnOnDisplay, EPD_4IN2_Sleep}, {EPD_DRIVER_4IN2_V2, EPD_4IN2_V2_Init, EPD_4IN2_V2_Clear, EPD_4IN2_V2_SendCommand, EPD_4IN2_V2_SendData, - EPD_4IN2_V2_UpdateDisplay, EPD_4IN2_V2_Sleep}, + EPD_4IN2_V2_TurnOnDisplay, EPD_4IN2_V2_Sleep}, {EPD_DRIVER_4IN2B_V2, EPD_4IN2B_V2_Init, EPD_4IN2B_V2_Clear, EPD_4IN2B_V2_SendCommand, EPD_4IN2B_V2_SendData, - EPD_4IN2B_V2_UpdateDisplay, EPD_4IN2B_V2_Sleep}, + EPD_4IN2B_V2_TurnOnDisplay, EPD_4IN2B_V2_Sleep}, }; static epd_driver_t *epd_driver_get(uint8_t id)