diff --git a/lib/lib_display/Epaper_29-gemu-1.0/epd2in9.cpp b/lib/lib_display/Epaper_29-gemu-1.0/epd2in9.cpp index 434a14b89..96b83645e 100644 --- a/lib/lib_display/Epaper_29-gemu-1.0/epd2in9.cpp +++ b/lib/lib_display/Epaper_29-gemu-1.0/epd2in9.cpp @@ -28,6 +28,8 @@ #include "epd2in9.h" +#define EPD_29_V2 + Epd::Epd(int16_t width, int16_t height) : Paint(width,height) { } @@ -126,6 +128,32 @@ int Epd::Init(const unsigned char* lut) { width = EPD_WIDTH; height = EPD_HEIGHT; +#ifdef EPD_29_V2 + /* EPD hardware init start */ + WaitUntilIdle(); + SendCommand(0x12); //SWRESET + WaitUntilIdle(); + + SendCommand(0x01); //Driver output control + SendData(0x27); + SendData(0x01); + SendData(0x00); + + SendCommand(0x11); //data entry mode + SendData(0x03); + + SetMemoryArea(0, 0, width-1, height-1); + + SendCommand(0x21); // Display update control + SendData(0x00); + SendData(0x80); + + SetMemoryPointer(0, 0); + WaitUntilIdle(); + + SetLut_by_host(lut_full_update); + +#else /* EPD hardware init start */ this->lut = lut; Reset(); @@ -146,6 +174,7 @@ int Epd::Init(const unsigned char* lut) { SendCommand(DATA_ENTRY_MODE_SETTING); SendData(0x03); // X increment; Y increment SetLut(this->lut); +#endif /* EPD hardware init end */ return 0; } @@ -172,6 +201,11 @@ void Epd::SendData(unsigned char data) { * @brief: Wait until the busy_pin goes LOW */ void Epd::WaitUntilIdle(void) { + +#ifdef EPD_29_V2 + delay(100); +#endif + return; //while(DigitalRead(busy_pin) == HIGH) { //LOW: idle, HIGH: busy // DelayMs(100); @@ -190,6 +224,34 @@ void Epd::Reset(void) { //delay(200); } +#ifdef EPD_29_V2 +void Epd::SetLut(const unsigned char *lut) { + unsigned char count; + SendCommand(0x32); + for(count=0; count<153; count++) + SendData(lut[count]); + WaitUntilIdle(); +} + + +void Epd::SetLut_by_host(const unsigned char *lut) { + SetLut((unsigned char *)lut); + SendCommand(0x3f); + SendData(*(lut+153)); + SendCommand(0x03); // gate voltage + SendData(*(lut+154)); + SendCommand(0x04); // source voltage + SendData(*(lut+155)); // VSH + SendData(*(lut+156)); // VSH2 + SendData(*(lut+157)); // VSL + SendCommand(0x2c); // VCOM + SendData(*(lut+158)); +} +#else + +void Epd::SetLut_by_host(const unsigned char *lut) { + +} /** * @brief: set the look-up table register */ @@ -201,6 +263,7 @@ void Epd::SetLut(const unsigned char* lut) { SendData(this->lut[i]); } } +#endif /** * @brief: put an image buffer to the frame memory. @@ -310,6 +373,23 @@ void Epd::DisplayFrame(void) { WaitUntilIdle(); } + +#ifdef EPD_29_V2 +/** + * @brief: private function to specify the memory area for data R/W + */ +void Epd::SetMemoryArea(int x_start, int y_start, int x_end, int y_end) { + SendCommand(0x44); + /* x point must be the multiple of 8 or the last 3 bits will be ignored */ + SendData((x_start >> 3) & 0xFF); + SendData((x_end >> 3) & 0xFF); + SendCommand(0x45); + SendData(y_start & 0xFF); + SendData((y_start >> 8) & 0xFF); + SendData(y_end & 0xFF); + SendData((y_end >> 8) & 0xFF); +} +#else /** * @brief: private function to specify the memory area for data R/W */ @@ -324,7 +404,24 @@ void Epd::SetMemoryArea(int x_start, int y_start, int x_end, int y_end) { SendData(y_end & 0xFF); SendData((y_end >> 8) & 0xFF); } +#endif + +#ifdef EPD_29_V2 + +/** + * @brief: private function to specify the start point for data R/W + */ +void Epd::SetMemoryPointer(int x, int y) { + SendCommand(0x4E); + /* x point must be the multiple of 8 or the last 3 bits will be ignored */ + SendData((x >> 3) & 0xFF); + SendCommand(0x4F); + SendData(y & 0xFF); + SendData((y >> 8) & 0xFF); + WaitUntilIdle(); +} +#else /** * @brief: private function to specify the start point for data R/W */ @@ -337,6 +434,7 @@ void Epd::SetMemoryPointer(int x, int y) { SendData((y >> 8) & 0xFF); WaitUntilIdle(); } +#endif /** * @brief: After this command is transmitted, the chip would enter the @@ -349,6 +447,56 @@ void Epd::Sleep() { WaitUntilIdle(); } +#ifdef EPD_29_V2 + +const unsigned char lut_part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1, +0xA, 0xA, 0x0, 0xA, 0xA, 0x0, 0x1, +0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, +0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, +0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, +0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, +0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, +0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, +0x14, 0x8, 0x0, 0x1, 0x0, 0x0, 0x1, +0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, +0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, +0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, +0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x0, 0x0, 0x0, +0x22, 0x17, 0x41, 0x0, 0x32, 0x36 +}; + +#else + const unsigned char lut_full_update[] = { 0x02, 0x02, 0x01, 0x11, 0x12, 0x12, 0x22, 0x22, @@ -364,7 +512,7 @@ const unsigned char lut_partial_update[] = 0x00, 0x00, 0x00, 0x00, 0x13, 0x14, 0x44, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - +#endif // EPD_29_V2 #define PIN_OUT_SET 0x60000304 #define PIN_OUT_CLEAR 0x60000308 diff --git a/lib/lib_display/Epaper_29-gemu-1.0/epd2in9.h b/lib/lib_display/Epaper_29-gemu-1.0/epd2in9.h index bf0863cd0..3be3071ec 100644 --- a/lib/lib_display/Epaper_29-gemu-1.0/epd2in9.h +++ b/lib/lib_display/Epaper_29-gemu-1.0/epd2in9.h @@ -106,6 +106,8 @@ private: void SetLut(const unsigned char* lut); void SetMemoryArea(int x_start, int y_start, int x_end, int y_end); void SetMemoryPointer(int x, int y); + void SetLut_by_host(const unsigned char* lut); + //void fastSPIwrite(uint8_t d,uint8_t dc); }; diff --git a/tasmota/displaydesc/ST7262_rgb16_display.ini b/tasmota/displaydesc/ST7262_rgb16_display.ini index 413af0bb1..80b210600 100644 --- a/tasmota/displaydesc/ST7262_rgb16_display.ini +++ b/tasmota/displaydesc/ST7262_rgb16_display.ini @@ -1,5 +1,9 @@ :H,ST7262,800,480,16,RGB,40,41,39,42,2,15,16,4,45,48,47,21,14,8,3,46,9,1,5,6,7,14 :S,2,1,1,0,40,20 :V,0,8,4,8,0,8,4,8,1 -:TI1,5a,*,*,-1,38 +:0,00 +:1,01 +:2,02 +:3,03 +:TI1,5d,*,*,-1,38 #