diff --git a/EPD/EPD_4in2.c b/EPD/EPD_4in2.c index 5f87e90..0ed857b 100644 --- a/EPD/EPD_4in2.c +++ b/EPD/EPD_4in2.c @@ -228,8 +228,7 @@ void EPD_4IN2_Clear(void) UWORD Width, Height; Width = (EPD_4IN2_WIDTH % 8 == 0)? (EPD_4IN2_WIDTH / 8 ): (EPD_4IN2_WIDTH / 8 + 1); Height = EPD_4IN2_HEIGHT; - EPD_4IN2_SendCommand(0x92); - EPD_4IN2_SetLut(); + EPD_4IN2_SendCommand(0x10); for (UWORD j = 0; j < Height; j++) { for (UWORD i = 0; i < Width; i++) { @@ -256,8 +255,14 @@ void EPD_4IN2_Display(UBYTE *Image) UWORD Width, Height; Width = (EPD_4IN2_WIDTH % 8 == 0)? (EPD_4IN2_WIDTH / 8 ): (EPD_4IN2_WIDTH / 8 + 1); Height = EPD_4IN2_HEIGHT; - EPD_4IN2_SendCommand(0x92); - EPD_4IN2_SetLut(); + + EPD_4IN2_SendCommand(0x10); + for (UWORD j = 0; j < Height; j++) { + for (UWORD i = 0; i < Width; i++) { + EPD_4IN2_SendData(0x00); + } + } + EPD_4IN2_SendCommand(0x13); for (UWORD j = 0; j < Height; j++) { for (UWORD i = 0; i < Width; i++) { diff --git a/EPD/EPD_Test.c b/EPD/EPD_Test.c new file mode 100644 index 0000000..95251f1 --- /dev/null +++ b/EPD/EPD_Test.c @@ -0,0 +1,160 @@ +#include "EPD_Test.h" +#include "EPD_4in2.h" + +const unsigned char EPD_4IN2_4Gray_lut_vcom[] = +{ + 0x00 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01, + 0x60 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01, + 0x00 ,0x14 ,0x00 ,0x00 ,0x00 ,0x01, + 0x00 ,0x13 ,0x0A ,0x01 ,0x00 ,0x01, + 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00, + 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00, + 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 +}; + +const unsigned char EPD_4IN2_4Gray_lut_ww[] ={ + 0x40 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01, + 0x90 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01, + 0x10 ,0x14 ,0x0A ,0x00 ,0x00 ,0x01, + 0xA0 ,0x13 ,0x01 ,0x00 ,0x00 ,0x01, + 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00, + 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00, + 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00, +}; + +const unsigned char EPD_4IN2_4Gray_lut_bw[] ={ + 0x40 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01, + 0x90 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01, + 0x00 ,0x14 ,0x0A ,0x00 ,0x00 ,0x01, + 0x99 ,0x0C ,0x01 ,0x03 ,0x04 ,0x01, + 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00, + 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00, + 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00, +}; + +const unsigned char EPD_4IN2_4Gray_lut_wb[] ={ + 0x40 ,0x0A ,0x00 ,0x00 ,0x00 ,0x01, + 0x90 ,0x14 ,0x14 ,0x00 ,0x00 ,0x01, + 0x00 ,0x14 ,0x0A ,0x00 ,0x00 ,0x01, + 0x99 ,0x0B ,0x04 ,0x04 ,0x01 ,0x01, + 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00, + 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00, + 0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00, +}; + +const unsigned char EPD_4IN2_4Gray_lut_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, +}; + +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]);} +} + +static void drawNormal(void) +{ + UWORD Width, Height; + Width = (EPD_4IN2_WIDTH % 8 == 0)? (EPD_4IN2_WIDTH / 8 ): (EPD_4IN2_WIDTH / 8 + 1); + Height = EPD_4IN2_HEIGHT; + + EPD_4IN2_SendCommand(0x10); + for (UWORD j = 0; j < Height; j++) { + for (UWORD i = 0; i < Width; i++) { + EPD_4IN2_SendData(0xFF); + } + } + + EPD_4IN2_SendCommand(0x13); + for (UWORD j = 0; j < Height; j++) { + for (UWORD i = 0; i < Width; i++) { + EPD_4IN2_SendData(((j + 1)*2 > Height) ? 0x00 : 0xFF); + } + } + + EPD_4IN2_TurnOnDisplay(); +} + +static void draw4Gray(void) +{ + UWORD Width, Height; + Width = (EPD_4IN2_WIDTH % 8 == 0)? (EPD_4IN2_WIDTH / 8 ): (EPD_4IN2_WIDTH / 8 + 1); + Height = EPD_4IN2_HEIGHT; + + EPD_4IN2_SendCommand(0x10); + for (UWORD i = 0; i < Width * Height; i++) { + UWORD idx = (i % 50) / 12; + if (idx > 3) idx = 3; + if (idx == 0 || idx == 1) { + EPD_4IN2_SendData(0x00); + } else if (idx == 2 || idx == 3) { + EPD_4IN2_SendData(0xFF); + } + } + + EPD_4IN2_SendCommand(0x13); + for (UWORD i = 0; i < Width * Height; i++) { + UWORD idx = (i % 50) / 12; + if (idx > 3) idx = 3; + if (idx == 0 || idx == 2) { + EPD_4IN2_SendData(0x00); + } else if (idx == 1 || idx == 3) { + EPD_4IN2_SendData(0xFF); + } + } + + EPD_4IN2_4Gray_lut(); + EPD_4IN2_TurnOnDisplay(); +} + +void EPD_4in2_test(void) +{ + DEV_Module_Init(); + + EPD_4IN2_Init(); + EPD_4IN2_Clear(); + DEV_Delay_ms(500); + + drawNormal(); + DEV_Delay_ms(3000); + + EPD_4IN2_Clear(); + DEV_Delay_ms(500); + + draw4Gray(); + DEV_Delay_ms(500); + + EPD_4IN2_Sleep(); + DEV_Delay_ms(500); + DEV_Module_Exit(); +} + diff --git a/EPD/EPD_Test.h b/EPD/EPD_Test.h new file mode 100644 index 0000000..dd37fdb --- /dev/null +++ b/EPD/EPD_Test.h @@ -0,0 +1,3 @@ +#include "DEV_Config.h" + +void EPD_4in2_test(void); diff --git a/Keil/EPD.uvprojx b/Keil/EPD.uvprojx index 6ca5a42..012ba9b 100644 --- a/Keil/EPD.uvprojx +++ b/Keil/EPD.uvprojx @@ -408,6 +408,62 @@ EPD + + EPD_Test.c + 1 + ..\EPD\EPD_Test.c + + + 2 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + 2 + 2 + 2 + + + + + + + + + + DEV_Config.c 1 @@ -955,6 +1011,11 @@ EPD + + EPD_Test.c + 1 + ..\EPD\EPD_Test.c + DEV_Config.c 1 @@ -1502,6 +1563,11 @@ EPD + + EPD_Test.c + 1 + ..\EPD\EPD_Test.c + DEV_Config.c 1 diff --git a/main.c b/main.c index 22b0eba..56eabc9 100644 --- a/main.c +++ b/main.c @@ -27,6 +27,9 @@ #include "app_error.h" #include "app_timer.h" #include "EPD_ble.h" +#ifdef DEBUG +#include "EPD_Test.h" +#endif #define IS_SRVC_CHANGED_CHARACT_PRESENT 1 /**< Include or not the service_changed characteristic. if not enabled, the server's database cannot be changed for the lifetime of the device*/ @@ -386,6 +389,10 @@ int main(void) NRF_LOG_PRINTF("done.\n"); +#ifdef DEBUG + EPD_4in2_test(); +#endif + for (;;) { power_manage();