From 138fb46a28380a6c196a60f2ca954361e2cf4eb2 Mon Sep 17 00:00:00 2001 From: Yattien <36767821+Yattien@users.noreply.github.com> Date: Mon, 27 Apr 2020 14:29:45 +0200 Subject: [PATCH] updated waveshare code, cosmetical changes --- CHANGELOG.md | 2 +- ESPEInk_ESP8266.ino | 4 +- README.md | 2 +- css.h | 288 ++++++------- epd.h | 105 +++-- epd1in54.h | 43 ++ epd2in13.h | 358 ++++++++-------- epd2in66.h | 95 +++++ epd2in7.h | 342 ++++++++-------- epd2in9.h | 488 +++++++++++----------- epd3in7.h | 177 ++++++++ epd4in2.h | 284 ++++++------- epd5in65f.h | 96 +++++ epd5in83.h | 115 +++--- epd7in5_HD.h | 189 +++++++++ html.h | 149 +++---- scripts.h | 972 +++++++++++++++++++++++--------------------- 17 files changed, 2234 insertions(+), 1475 deletions(-) create mode 100644 epd2in66.h create mode 100644 epd3in7.h create mode 100644 epd5in65f.h create mode 100644 epd7in5_HD.h diff --git a/CHANGELOG.md b/CHANGELOG.md index 62c5490..0b1dc8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Version v17 -- Fix display 2in13 V2 is reset if no data available +- Updated waveshare code to version 29.20.2020 ## Version v16 diff --git a/ESPEInk_ESP8266.ino b/ESPEInk_ESP8266.ino index b5f3607..32aa173 100644 --- a/ESPEInk_ESP8266.ino +++ b/ESPEInk_ESP8266.ino @@ -107,7 +107,7 @@ void getConfig() { } } } else { - Serial.println(" Failed to mount FS."); + Serial.println(" Failed to mount FS (probably initial start), continuing w/o config..."); } } @@ -132,7 +132,7 @@ void setupWifi() { requestMqttParameters(&wifiManager); initAccessPointName(); if (!wifiManager.autoConnect(accessPointName)) { - Serial.println("failed to connect, resetting"); + Serial.println(" Failed to connect, resetting."); WiFi.disconnect(); delay(1000); ESP.restart(); diff --git a/README.md b/README.md index be9d49b..938b863 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Erweiterung des ESP8266-Waveshare-Treibers um Wifi-Einrichtungsassistent, Deepsl ![GitHub issues](https://img.shields.io/github/issues-raw/Yattien/ESPEInk_ESP8266) # Waveshare-Treiberversion -[28.02.2020](https://www.waveshare.com/wiki/File:E-Paper_ESP8266_Driver_Board_Code.7z) +[29.10.2020](https://www.waveshare.com/wiki/File:E-Paper_ESP8266_Driver_Board_Code.7z) # Installation Das fertige Image kann per OTA (siehe auch OTA-Beispiel-Sketche) oder auch per [`esptool`](https://github.com/espressif/esptool) auf den ESP8266 geladen werden. diff --git a/css.h b/css.h index 57f23b4..67c9f1b 100644 --- a/css.h +++ b/css.h @@ -1,145 +1,145 @@ -/** - ****************************************************************************** - * @file css.h - * @author Waveshare Team - * @version V1.0.0 - * @date 23-January-2018 - * @brief This file describes the sending of Cascade Style Sheet to a client - * - ****************************************************************************** - */ -extern ESP8266WebServer server; -void sendCSS() -{ -server.send(200, "text/css", -".menu_button {\r\n" -"width: 100%;\r\n" -"height: 30px;\r\n" -"border-radius: 4px;\r\n" -"text-align: center;\r\n" -"cursor: pointer;\r\n" -"display: block;\r\n" -"margin-bottom:5px;\r\n" -"font: 14px/30px Tahoma;\r\n" -"transition: all 0.18s ease-in-out;\r\n" -"border: 1px solid #4FD666;\r\n" -"background: linear-gradient(to top right, #3EC97A, #69EA49 20%, rgba(255, 255, 255, 0) 80%, rgba(255, 255, 255, 0)) top right/500% 500%;\r\n" -"color: green;\r\n" -"}\r\n" - -".menu_button:hover {\r\n" -"color: white;\r\n" -"background-position: bottom left;\r\n" -"}\r\n" - -".hidden_input {\r\n" -"width: 0.1px;\r\n" -"height: 0.1px;\r\n" -"opacity: 0;\r\n" -"overflow: hidden;\r\n" -"position: absolute;\r\n" -"z-index: -1;\r\n" -"}\r\n" - -".imgBox\r\n" -"{\r\n" -"border: 2px dashed green;\r\n" -"border-radius: 8px;\r\n" -"background: lightyellow;\r\n" -"background-repeat: no-repeat;\r\n" -"text-align: center;\r\n" -"margin-top:10px;\r\n" -"}\r\n" - -".mesBox {\r\n" -"margin: 100px 70px;\r\n" -"color: green;\r\n" -"font-size: 25px;\r\n" -"font-family: Verdana, Arial, sans-serif;\r\n" -"}\r\n" - -".header_back\r\n" -"{\r\n" -"width:100%;\r\n" -"height:100px;\r\n" -"background:#EEEEEE;\r\n" -"}\r\n" - -".content_back\r\n" -"{\r\n" -"width:100%;\r\n" -"background:#EEEEEE;\r\n" -"}\r\n" - -".footer_back\r\n" -"{\r\n" -"width:100%;\r\n" -"height:100px;\r\n" -"background:#EEEEEE;\r\n" -"}\r\n" - -".header_face\r\n" -"{\r\n" -"width:1024px;\r\n" -"height:100px;\r\n" -"margin:0 auto;\r\n" -"background:#CCFFCC;\r\n" -"}\r\n" - -".content_face\r\n" -"{\r\n" -"width:1024px;\r\n" -"height:100%;\r\n" -"margin:0 auto;\r\n" -"background:#FFFFFF;\r\n" -"}\r\n" - -".footer_face\r\n" -"{\r\n" -"width:1024px;\r\n" -"height:100%;\r\n" -"margin:0 auto;\r\n" -"background:#CCFFCC;\r\n" -"}\r\n" - -".menu_bar\r\n" -"{\r\n" -"border-right:1px solid #4FD666;\r\n" -"background:#EEFFEE;\r\n" -"vertical-align:top;\r\n" -"padding:15px;\r\n" -"width:200px;\r\n" -"height:100%\r\n" -"}\r\n" - -".content_body\r\n" -"{\r\n" -"vertical-align:top;\r\n" -"text-align:center;\r\n" -"height:100%;\r\n" -"padding:30px;\r\n" -"padding-left:15px;\r\n" -"}\r\n" - -".title\r\n" -"{\r\n" -"color:green;\r\n" -"font-size:32px;\r\n" -"font-family: arial;\r\n" -"}\r\n" - -".comment\r\n" -"{\r\n" -"width:100%;\r\n" -"color:green;\r\n" -"font-size:16px;\r\n" -"font-style:italic;\r\n" -"font-family: arial;\r\n" -"text-align:center;\r\n" -"}\r\n" - -".nud\r\n" -"{\r\n" -"width:70px;\r\n" -"}\r\n"); +/** + ****************************************************************************** + * @file css.h + * @author Waveshare Team + * @version V1.0.0 + * @date 23-January-2018 + * @brief This file describes the sending of Cascade Style Sheet to a client + * + ****************************************************************************** + */ +extern ESP8266WebServer server; +void sendCSS() +{ +server.send(200, "text/css", +".menu_button {\r\n" +"width: 100%;\r\n" +"height: 30px;\r\n" +"border-radius: 4px;\r\n" +"text-align: center;\r\n" +"cursor: pointer;\r\n" +"display: block;\r\n" +"margin-bottom:5px;\r\n" +"font: 14px/30px Tahoma;\r\n" +"transition: all 0.18s ease-in-out;\r\n" +"border: 1px solid #4FD666;\r\n" +"background: linear-gradient(to top right, #3EC97A, #69EA49 20%, rgba(255, 255, 255, 0) 80%, rgba(255, 255, 255, 0)) top right/500% 500%;\r\n" +"color: green;\r\n" +"}\r\n" + +".menu_button:hover {\r\n" +"color: white;\r\n" +"background-position: bottom left;\r\n" +"}\r\n" + +".hidden_input {\r\n" +"width: 0.1px;\r\n" +"height: 0.1px;\r\n" +"opacity: 0;\r\n" +"overflow: hidden;\r\n" +"position: absolute;\r\n" +"z-index: -1;\r\n" +"}\r\n" + +".imgBox\r\n" +"{\r\n" +"border: 2px dashed green;\r\n" +"border-radius: 8px;\r\n" +"background: lightyellow;\r\n" +"background-repeat: no-repeat;\r\n" +"text-align: center;\r\n" +"margin-top:10px;\r\n" +"}\r\n" + +".mesBox {\r\n" +"margin: 100px 70px;\r\n" +"color: green;\r\n" +"font-size: 25px;\r\n" +"font-family: Verdana, Arial, sans-serif;\r\n" +"}\r\n" + +".header_back\r\n" +"{\r\n" +"width:100%;\r\n" +"height:100px;\r\n" +"background:#EEEEEE;\r\n" +"}\r\n" + +".content_back\r\n" +"{\r\n" +"width:100%;\r\n" +"background:#EEEEEE;\r\n" +"}\r\n" + +".footer_back\r\n" +"{\r\n" +"width:100%;\r\n" +"height:100px;\r\n" +"background:#EEEEEE;\r\n" +"}\r\n" + +".header_face\r\n" +"{\r\n" +"width:1024px;\r\n" +"height:100px;\r\n" +"margin:0 auto;\r\n" +"background:#CCFFCC;\r\n" +"}\r\n" + +".content_face\r\n" +"{\r\n" +"width:1024px;\r\n" +"height:100%;\r\n" +"margin:0 auto;\r\n" +"background:#FFFFFF;\r\n" +"}\r\n" + +".footer_face\r\n" +"{\r\n" +"width:1024px;\r\n" +"height:100%;\r\n" +"margin:0 auto;\r\n" +"background:#CCFFCC;\r\n" +"}\r\n" + +".menu_bar\r\n" +"{\r\n" +"border-right:1px solid #4FD666;\r\n" +"background:#EEFFEE;\r\n" +"vertical-align:top;\r\n" +"padding:15px;\r\n" +"width:200px;\r\n" +"height:100%\r\n" +"}\r\n" + +".content_body\r\n" +"{\r\n" +"vertical-align:top;\r\n" +"text-align:center;\r\n" +"height:100%;\r\n" +"padding:30px;\r\n" +"padding-left:15px;\r\n" +"}\r\n" + +".title\r\n" +"{\r\n" +"color:green;\r\n" +"font-size:32px;\r\n" +"font-family: arial;\r\n" +"}\r\n" + +".comment\r\n" +"{\r\n" +"width:100%;\r\n" +"color:green;\r\n" +"font-size:16px;\r\n" +"font-style:italic;\r\n" +"font-family: arial;\r\n" +"text-align:center;\r\n" +"}\r\n" + +".nud\r\n" +"{\r\n" +"width:70px;\r\n" +"}\r\n"); } diff --git a/epd.h b/epd.h index b1ed9b4..a55f210 100644 --- a/epd.h +++ b/epd.h @@ -30,10 +30,10 @@ extern ESP8266WebServer server; /* SPI pin definition --------------------------------------------------------*/ // SPI pin definition -#define CS_PIN 15 // D8 -#define RST_PIN 2 // D4 -#define DC_PIN 4 // D2 -#define BUSY_PIN 5 // D1 +#define CS_PIN 15 +#define RST_PIN 2 +#define DC_PIN 4 +#define BUSY_PIN 5 /* Pin level definition ------------------------------------------------------*/ #define LOW 0 @@ -94,6 +94,13 @@ void EPD_WaitUntilIdle() delay(100); } +/* Waiting the e-Paper is ready for further instructions ---------------------*/ +void EPD_WaitUntilIdle_high() +{ + //1: busy, 0: idle + while(digitalRead(BUSY_PIN) == 1) delay(100); +} + /* Send a one-argument command -----------------------------------------------*/ void EPD_Send_1(byte c, byte v1) { @@ -183,9 +190,13 @@ void EPD_Reset() #include "epd2in13.h" #include "epd2in9.h" #include "epd2in7.h" +#include "epd2in66.h" +#include "epd3in7.h" #include "epd4in2.h" +#include "epd5in65f.h" #include "epd5in83.h" #include "epd7in5.h" +#include "epd7in5_HD.h" int EPD_dispIndex; // The index of the e-Paper's type int EPD_dispX, EPD_dispY; // Current pixel's coordinates (for 2.13 only) @@ -405,6 +416,35 @@ void EPD_loadE() } } +/* Image data loading function for 5.65f e-Paper -----------------------------*/ +void EPD_loadG() +{ + Serial.print("\r\n EPD_loadG"); + int index = 0; + String p = server.arg(0); + + // Get the length of the image data begin + int DataLength = p.length() - 8; + + // Enumerate all of image data bytes + while (index < DataLength) + { + // Get current byte from obtained image data + int value = ((int)p[index] - 'a') + (((int)p[index + 1] - 'a') << 4); + + // Switch the positions of the two 4-bits pixels + // Black:0b000;White:0b001;Green:0b010;Blue:0b011;Red:0b100;Yellow:0b101;Orange:0b110; + int A = (value ) & 0x07; + int B = (value >> 4) & 0x07; + + // Write the data into e-Paper's memory + EPD_SendData((byte)(A << 4) + B); + + // Increment the current byte index on 2 characters + index += 2; + } +} + /* Show image and turn to deep sleep mode (a-type, 4.2 and 2.7 e-Paper) ------*/ void EPD_showA() { @@ -503,30 +543,39 @@ struct EPD_dispInfo /* Array of sets describing the usage of e-Papers ----------------------------*/ EPD_dispInfo EPD_dispMass[] = { - {EPD_Init_1in54, EPD_loadA, -1, 0, EPD_showA, "1.54 inch"}, // a 0 - {EPD_Init_1in54b, EPD_loadB, 0x13, EPD_loadA, EPD_showB, "1.54 inch b"}, // b 1 - {EPD_Init_1in54c, EPD_loadA, 0x13, EPD_loadA, EPD_showB, "1.54 inch c"}, // c 2 - {EPD_Init_2in13, EPD_loadC, -1, 0, EPD_showA, "2.13 inch"}, // d 3 - {EPD_Init_2in13b, EPD_loadA, 0x13, EPD_loadA, EPD_showB, "2.13 inch b"}, // e 4 - {EPD_Init_2in13b, EPD_loadA, 0x13, EPD_loadA, EPD_showB, "2.13 inch c"}, // f 5 - {EPD_Init_2in13d, EPD_loadA, -1, 0, EPD_showD, "2.13 inch d"}, // g 6 - {EPD_Init_2in7, EPD_loadA, -1, 0, EPD_showB, "2.7 inch"}, // h 7 - {EPD_Init_2in7b, EPD_loadA, 0x13, EPD_loadA, EPD_showB, "2.7 inch b"}, // i 8 - {EPD_Init_2in9, EPD_loadA, -1, 0, EPD_showA, "2.9 inch"}, // j 9 - {EPD_Init_2in9b, EPD_loadA, 0x13, EPD_loadA, EPD_showB, "2.9 inch b"}, // k 10 - {EPD_Init_2in9b, EPD_loadA, 0x13, EPD_loadA, EPD_showB, "2.9 inch c"}, // l 11 - {EPD_Init_2in9d, EPD_loadA, -1, 0, EPD_2IN9D_Show, "2.9 inch d"}, // l 12 - {EPD_Init_4in2, EPD_loadA, -1, 0, EPD_showB, "4.2 inch"}, // m 13 - {EPD_Init_4in2b, EPD_loadA, 0x13, EPD_loadA, EPD_showB, "4.2 inch b"}, // n 14 - {EPD_Init_4in2b, EPD_loadA, 0x13, EPD_loadA, EPD_showB, "4.2 inch c"}, // o 15 - {EPD_5in83__init, EPD_loadD, -1, 0, EPD_showC, "5.83 inch"}, // p 16 - {EPD_5in83b__init, EPD_loadE, -1, 0, EPD_showC, "5.83 inch b"}, // q 17 - {EPD_5in83b__init, EPD_loadE, -1, 0, EPD_showC, "5.83 inch c"}, // r 18 - {EPD_7in5__init, EPD_loadD, -1, 0, EPD_showC, "7.5 inch"}, // s 19 - {EPD_7in5__init, EPD_loadE, -1, 0, EPD_showC, "7.5 inch b"}, // t 20 - {EPD_7in5__init, EPD_loadE, -1, 0, EPD_showC, "7.5 inch c"}, // u 21 - {EPD_7in5_V2_init, EPD_loadAFilp, -1, 0, EPD_7IN5_V2_Show, "7.5 inch V2"}, // w 22 - {EPD_7in5B_V2_Init, EPD_loadA, 0x13, EPD_loadAFilp, EPD_7IN5_V2_Show, "7.5 inch B V2 "} // x 23 + {EPD_Init_1in54, EPD_loadA, -1, 0, EPD_showA, "1.54 inch"}, // a 0 + {EPD_Init_1in54b, EPD_loadB,0x13, EPD_loadA, EPD_showB, "1.54 inch b"}, // b 1 + {EPD_Init_1in54c, EPD_loadA,0x13, EPD_loadA, EPD_showB, "1.54 inch c"}, // c 2 + {EPD_Init_2in13, EPD_loadC, -1, 0, EPD_showA, "2.13 inch"}, // d 3 + {EPD_Init_2in13b, EPD_loadA,0x13, EPD_loadA, EPD_showB, "2.13 inch b"}, // e 4 + {EPD_Init_2in13b, EPD_loadA,0x13, EPD_loadA, EPD_showB, "2.13 inch c"}, // f 5 + {EPD_Init_2in13d, EPD_loadA, -1, 0, EPD_showD, "2.13 inch d"}, // g 6 + {EPD_Init_2in7, EPD_loadA, -1, 0, EPD_showB, "2.7 inch"}, // h 7 + {EPD_Init_2in7b, EPD_loadA,0x13, EPD_loadA, EPD_showB, "2.7 inch b"}, // i 8 + {EPD_Init_2in9, EPD_loadA, -1, 0, EPD_showA, "2.9 inch"}, // j 9 + {EPD_Init_2in9b, EPD_loadA,0x13, EPD_loadA, EPD_showB, "2.9 inch b"}, // k 10 + {EPD_Init_2in9b, EPD_loadA,0x13, EPD_loadA, EPD_showB, "2.9 inch c"}, // l 11 + {EPD_Init_2in9d, EPD_loadA, -1, 0, EPD_2IN9D_Show, "2.9 inch d"}, // l 12 + {EPD_Init_4in2, EPD_loadA, -1, 0, EPD_showB, "4.2 inch"}, // m 13 + {EPD_Init_4in2b, EPD_loadA,0x13, EPD_loadA, EPD_showB, "4.2 inch b"}, // n 14 + {EPD_Init_4in2b, EPD_loadA,0x13, EPD_loadA, EPD_showB, "4.2 inch c"}, // o 15 + {EPD_5in83__init, EPD_loadD, -1, 0, EPD_showC, "5.83 inch"}, // p 16 + {EPD_5in83b__init, EPD_loadE, -1, 0, EPD_showC, "5.83 inch b"}, // q 17 + {EPD_5in83b__init, EPD_loadE, -1, 0, EPD_showC, "5.83 inch c"}, // r 18 + {EPD_7in5__init, EPD_loadD, -1, 0, EPD_showC, "7.5 inch"}, // s 19 + {EPD_7in5__init, EPD_loadE, -1, 0, EPD_showC, "7.5 inch b"}, // t 20 + {EPD_7in5__init, EPD_loadE, -1, 0, EPD_showC, "7.5 inch c"}, // u 21 + {EPD_7in5_V2_init, EPD_loadAFilp,-1, 0, EPD_7IN5_V2_Show, "7.5 inch V2"}, // w 22 + {EPD_7in5B_V2_Init, EPD_loadA,0x13, EPD_loadAFilp, EPD_7IN5_V2_Show, "7.5 inch B V2 "}, // x 23 + {EPD_7IN5B_HD_init, EPD_loadA,0X26, EPD_loadAFilp, EPD_7IN5B_HD_Show, "7.5 inch B HD "}, // y 24 + {EPD_5IN65F_init, EPD_loadG, -1, 0, EPD_5IN65F_Show, "5.65 inch F " }, // z 25 + {EPD_7IN5_HD_init, EPD_loadA, -1, 0, EPD_7IN5_HD_Show, "7.5 inch HD" }, // A 26 + {EPD_3IN7_1Gray_Init, EPD_loadA, -1, 0, EPD_3IN7_1Gray_Show,"3.7 inch" }, // 27 + {EPD_2IN66_Init, EPD_loadA, -1, 0, EPD_2IN66_Show, "2.66 inch" }, // 28 + {EPD_5in83b_V2_init, EPD_loadA,0x13, EPD_loadAFilp, EPD_showC, "5.83 inch B V2"}, // 29 + {EPD_Init_2in9b_V2, EPD_loadA,0x13, EPD_loadA, EPD_showC, "2.9 inch B V2" }, // 30 + {EPD_1IN54B_V2_Init, EPD_loadA,0x26, EPD_loadAFilp, EPD_1IN54B_V2_Show, "1.54 inch B V2"}, // 31 + {EPD_2IN13B_V3_Init, EPD_loadA,0x13, EPD_loadA, EPD_2IN13B_V3_Show, "2.13 inch B V3"}, // 32 }; /* Initialization of an e-Paper ----------------------------------------------*/ diff --git a/epd1in54.h b/epd1in54.h index 4f6c96f..a2a8a4c 100644 --- a/epd1in54.h +++ b/epd1in54.h @@ -104,6 +104,49 @@ int EPD_Init_1in54b() return 0; } +int EPD_1IN54B_V2_Init(void) +{ + EPD_Reset(); + EPD_WaitUntilIdle_high(); + + EPD_SendCommand(0x12); //SWRESET + EPD_WaitUntilIdle_high(); + + EPD_Send_3(0x01, 0xc7, 0x00, 0x01); //Driver output control + + EPD_Send_1(0x11, 0x01); //data entry mode + + EPD_Send_2(0x44, 0x00, 0x18); //set Ram-X address start/end position + + EPD_Send_4(0x45, 0xc7, 0x00, 0x00, 0x00); //set Ram-Y address start/end position + + EPD_Send_1(0x3C, 0x05); //BorderWavefrom + + EPD_Send_1(0x18, 0x80); //Read built-in temperature sensor + + EPD_Send_1(0x4E, 0x00); // set RAM x address count to 0; + + EPD_Send_2(0x4F, 0xc7, 0x00); // set RAM y address count to 0X199; + + EPD_WaitUntilIdle_high(); + + EPD_SendCommand(0x24); + delay(2); + return 0; +} + +void EPD_1IN54B_V2_Show(void) +{ + //refresh + EPD_Send_1(0x22, 0xf7); //Display Update Control + EPD_SendCommand(0x20); //Activate Display Update Sequence + EPD_WaitUntilIdle_high(); + + //sleep + EPD_Send_1(0x10, 0x01); //enter deep sleep + delay(2); +} + int EPD_Init_1in54c() { EPD_Reset(); diff --git a/epd2in13.h b/epd2in13.h index efab1af..9dfb516 100644 --- a/epd2in13.h +++ b/epd2in13.h @@ -1,164 +1,196 @@ -/** - ****************************************************************************** - * @file edp2in13.h - * @author Waveshare Team - * @version V1.0.0 - * @date 23-January-2018 - * @brief This file describes initialisation of e-Papers: - * 2.13, - * 2.13b and 2.13c, - * 2.13d. - * - ****************************************************************************** - */ - -unsigned char lut_full_2in13[] = { - 0x22, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x11, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 -}; -const unsigned char lut_full_2in3v2[] = { - 0x80,0x60,0x40,0x00,0x00,0x00,0x00, //LUT0: BB: VS 0 ~7 - 0x10,0x60,0x20,0x00,0x00,0x00,0x00, //LUT1: BW: VS 0 ~7 - 0x80,0x60,0x40,0x00,0x00,0x00,0x00, //LUT2: WB: VS 0 ~7 - 0x10,0x60,0x20,0x00,0x00,0x00,0x00, //LUT3: WW: VS 0 ~7 - 0x00,0x00,0x00,0x00,0x00,0x00,0x00, //LUT4: VCOM: VS 0 ~7 - - 0x03,0x03,0x00,0x00,0x02, // TP0 A~D RP0 - 0x09,0x09,0x00,0x00,0x02, // TP1 A~D RP1 - 0x03,0x03,0x00,0x00,0x02, // TP2 A~D RP2 - 0x00,0x00,0x00,0x00,0x00, // TP3 A~D RP3 - 0x00,0x00,0x00,0x00,0x00, // TP4 A~D RP4 - 0x00,0x00,0x00,0x00,0x00, // TP5 A~D RP5 - 0x00,0x00,0x00,0x00,0x00, // TP6 A~D RP6 - - 0x15,0x41,0xA8,0x32,0x30,0x0A, -}; - -const unsigned char lut_vcomDC_2in13d[] = { - 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x60, 0x28, 0x28, 0x00, 0x00, - 0x01, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x12, 0x12, 0x00, - 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -const unsigned char lut_ww_2in13d[] = { - 0x40, 0x08, 0x00, 0x00, 0x00, 0x02, 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, 0x40, 0x14, - 0x00, 0x00, 0x00, 0x01, 0xA0, 0x12, 0x12, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -const unsigned char lut_bw_2in13d[] = { - 0x40, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x0F, 0x0F, 0x00, 0x00, 0x03, 0x40, 0x0A, - 0x01, 0x00, 0x00, 0x01, 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -const unsigned char lut_wb_2in13d[] = { - 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, 0x80, 0x14, - 0x00, 0x00, 0x00, 0x01, 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -const unsigned char lut_bb_2in13d[] = { - 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, 0x80, 0x14, - 0x00, 0x00, 0x00, 0x01, 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - - -int EPD_Init_2in13() -{ - int EPD2in13V = 2; - if(EPD2in13V == 1) { - Serial.print("\r\nEPD_Init_2in13 V1"); - EPD_Reset(); - EPD_Send_3(0x01, 249, 0, 0); // DRIVER_OUTPUT_CONTROL: LO(h-1), HI(h-1), GD = 0; SM = 0; TB = 0; - EPD_Send_3(0x0C, 0xD7, 0xD6, 0x9D);// BOOSTER_SOFT_START_CONTROL - EPD_Send_1(0x2C, 0xA8); // WRITE_VCOM_REGISTER: VCOM 7C - EPD_Send_1(0x3A, 0x1A); // SET_DUMMY_LINE_PERIOD: 4 dummy lines per gate - EPD_Send_1(0x3B, 0x08); // SET_GATE_TIME: 2us per line - EPD_Send_1(0x11, 0x03); // DATA_ENTRY_MODE_SETTING: X increment; Y increment - - EPD_lut(0x32, 30, &lut_full_2in13[0]); - return 0; - } else { - Serial.print("\r\nEPD_Init_2in13 V2"); - EPD_Reset(); - while (digitalRead(BUSY_PIN) == 1) delay(100); - EPD_SendCommand(0x12); - while (digitalRead(BUSY_PIN) == 1) delay(100); - EPD_Send_1(0x74, 0x54); - EPD_Send_1(0x7e, 0x3B); - EPD_Send_3(0x01, 0XF9, 0X00, 0X00); - EPD_Send_1(0X11, 0X01); - EPD_Send_2(0X44, 0X00, 0X0F); - EPD_Send_4(0x45, 0xF9, 0x00, 0x00, 0x00); - EPD_Send_1(0X3C, 0X03); - EPD_Send_1(0X2C, 0X55); - EPD_Send_1(0x03, lut_full_2in3v2[70]); - EPD_Send_3(0x04, lut_full_2in3v2[71], lut_full_2in3v2[72], lut_full_2in3v2[73]); - EPD_Send_1(0x3A, lut_full_2in3v2[74]); - EPD_Send_1(0x3B, lut_full_2in3v2[75]); - char count; - EPD_SendCommand(0x32); - for(count = 0; count < 70; count++) - EPD_SendData(lut_full_2in3v2[count]); - EPD_Send_1(0x4E, 0x00); - EPD_Send_2(0x4F, 0xF9, 0x00); - - int Width, Height; - Width = (122 % 8 == 0)? (122 / 8 ): (122 / 8 + 1); - Height = 250; - EPD_SendCommand(0x24); - for (int j = 0; j < Height; j++) { - for (int i = 0; i < Width; i++) { - EPD_SendData(0XFF); - } - } - EPD_SendCommand(0x22); - EPD_SendData(0xC7); - EPD_SendCommand(0x20); - while (digitalRead(BUSY_PIN) == 1) delay(100); - - return 0; - } -} - -int EPD_Init_2in13b() -{ - EPD_Reset(); - EPD_Send_3(0x06, 0x17, 0x17, 0x17);// BOOSTER_SOFT_START - EPD_SendCommand(0x04); // POWER_ON - EPD_WaitUntilIdle(); - - EPD_Send_1(0x00, 0x8F); // PANEL_SETTING - EPD_Send_1(0x50, 0x37); // VCOM_AND_DATA_INTERVAL_SETTING - EPD_Send_3(0x61, 0x68, 0, 0xD4); // TCON_RESOLUTION - - EPD_SendCommand(0x10); // DATA_START_TRANSMISSION_1 - delay(2); - return 0; -} - -int EPD_Init_2in13d() -{ - EPD_Reset(); - - EPD_Send_5(0x01, 0x03, 0x00, 0x2b, 0x2b, 0x03);//POWER SETTING - EPD_Send_3(0x06, 0x17, 0x17, 0x17); //BOOSTER_SOFT_START - EPD_SendCommand(0x04); //POWER_ON - EPD_WaitUntilIdle(); - EPD_Send_2(0x00, 0xbf, 0x0d); //PANEL_SETTINGS: LUT from OTP£¬128x296 - EPD_Send_1(0x30, 0x3a); //PLL_SETTINGS: 3a 100HZ, 29 150Hz, 39 200HZ, 31 171HZ, 3c 50hz - EPD_Send_3(0x61, 0x68, 0x00, 0xD4); //TCON_RESOLUTION - EPD_Send_1(0x82, 0x28); //VCOM_DC_SETTINGS - - EPD_SendCommand(0x10); - for (int j = 0; j < 212; j++) for (int i = 0; i < 13; i++) EPD_SendData(0); - delay(10); - - EPD_SendCommand(0x13); - return 0; +/** + ****************************************************************************** + * @file edp2in13.h + * @author Waveshare Team + * @version V1.0.0 + * @date 23-January-2018 + * @brief This file describes initialisation of e-Papers: + * 2.13, + * 2.13b and 2.13c, + * 2.13d. + * + ****************************************************************************** + */ + +unsigned char lut_full_2in13[] = { + 0x22, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x11, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 +}; +const unsigned char lut_full_2in3v2[] = { + 0x80,0x60,0x40,0x00,0x00,0x00,0x00, //LUT0: BB: VS 0 ~7 + 0x10,0x60,0x20,0x00,0x00,0x00,0x00, //LUT1: BW: VS 0 ~7 + 0x80,0x60,0x40,0x00,0x00,0x00,0x00, //LUT2: WB: VS 0 ~7 + 0x10,0x60,0x20,0x00,0x00,0x00,0x00, //LUT3: WW: VS 0 ~7 + 0x00,0x00,0x00,0x00,0x00,0x00,0x00, //LUT4: VCOM: VS 0 ~7 + + 0x03,0x03,0x00,0x00,0x02, // TP0 A~D RP0 + 0x09,0x09,0x00,0x00,0x02, // TP1 A~D RP1 + 0x03,0x03,0x00,0x00,0x02, // TP2 A~D RP2 + 0x00,0x00,0x00,0x00,0x00, // TP3 A~D RP3 + 0x00,0x00,0x00,0x00,0x00, // TP4 A~D RP4 + 0x00,0x00,0x00,0x00,0x00, // TP5 A~D RP5 + 0x00,0x00,0x00,0x00,0x00, // TP6 A~D RP6 + + 0x15,0x41,0xA8,0x32,0x30,0x0A, +}; + +const unsigned char lut_vcomDC_2in13d[] = { + 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x60, 0x28, 0x28, 0x00, 0x00, + 0x01, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x12, 0x12, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +const unsigned char lut_ww_2in13d[] = { + 0x40, 0x08, 0x00, 0x00, 0x00, 0x02, 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, 0x40, 0x14, + 0x00, 0x00, 0x00, 0x01, 0xA0, 0x12, 0x12, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +const unsigned char lut_bw_2in13d[] = { + 0x40, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x0F, 0x0F, 0x00, 0x00, 0x03, 0x40, 0x0A, + 0x01, 0x00, 0x00, 0x01, 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +const unsigned char lut_wb_2in13d[] = { + 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, 0x80, 0x14, + 0x00, 0x00, 0x00, 0x01, 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +const unsigned char lut_bb_2in13d[] = { + 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, 0x80, 0x14, + 0x00, 0x00, 0x00, 0x01, 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + + +int EPD_Init_2in13() +{ + int EPD2in13V = 2; + if(EPD2in13V == 1) { + Serial.print("\r\nEPD_Init_2in13 V1"); + EPD_Reset(); + EPD_Send_3(0x01, 249, 0, 0); // DRIVER_OUTPUT_CONTROL: LO(h-1), HI(h-1), GD = 0; SM = 0; TB = 0; + EPD_Send_3(0x0C, 0xD7, 0xD6, 0x9D);// BOOSTER_SOFT_START_CONTROL + EPD_Send_1(0x2C, 0xA8); // WRITE_VCOM_REGISTER: VCOM 7C + EPD_Send_1(0x3A, 0x1A); // SET_DUMMY_LINE_PERIOD: 4 dummy lines per gate + EPD_Send_1(0x3B, 0x08); // SET_GATE_TIME: 2us per line + EPD_Send_1(0x11, 0x03); // DATA_ENTRY_MODE_SETTING: X increment; Y increment + + EPD_lut(0x32, 30, &lut_full_2in13[0]); + return 0; + } else { + Serial.print("\r\nEPD_Init_2in13 V2"); + EPD_Reset(); + while (digitalRead(BUSY_PIN) == 1) delay(100); + EPD_SendCommand(0x12); + while (digitalRead(BUSY_PIN) == 1) delay(100); + EPD_Send_1(0x74, 0x54); + EPD_Send_1(0x7e, 0x3B); + EPD_Send_3(0x01, 0XF9, 0X00, 0X00); + EPD_Send_1(0X11, 0X01); + EPD_Send_2(0X44, 0X00, 0X0F); + EPD_Send_4(0x45, 0xF9, 0x00, 0x00, 0x00); + EPD_Send_1(0X3C, 0X03); + EPD_Send_1(0X2C, 0X55); + EPD_Send_1(0x03, lut_full_2in3v2[70]); + EPD_Send_3(0x04, lut_full_2in3v2[71], lut_full_2in3v2[72], lut_full_2in3v2[73]); + EPD_Send_1(0x3A, lut_full_2in3v2[74]); + EPD_Send_1(0x3B, lut_full_2in3v2[75]); + char count; + EPD_SendCommand(0x32); + for(count = 0; count < 70; count++) + EPD_SendData(lut_full_2in3v2[count]); + EPD_Send_1(0x4E, 0x00); + EPD_Send_2(0x4F, 0xF9, 0x00); + + int Width, Height; + Width = (122 % 8 == 0)? (122 / 8 ): (122 / 8 + 1); + Height = 250; + EPD_SendCommand(0x24); + for (int j = 0; j < Height; j++) { + for (int i = 0; i < Width; i++) { + EPD_SendData(0XFF); + } + } + EPD_SendCommand(0x22); + EPD_SendData(0xC7); + EPD_SendCommand(0x20); + while (digitalRead(BUSY_PIN) == 1) delay(100); + + return 0; + } +} + +int EPD_Init_2in13b() +{ + EPD_Reset(); + EPD_Send_3(0x06, 0x17, 0x17, 0x17);// BOOSTER_SOFT_START + EPD_SendCommand(0x04); // POWER_ON + EPD_WaitUntilIdle(); + + EPD_Send_1(0x00, 0x8F); // PANEL_SETTING + EPD_Send_1(0x50, 0x37); // VCOM_AND_DATA_INTERVAL_SETTING + EPD_Send_3(0x61, 0x68, 0, 0xD4); // TCON_RESOLUTION + + EPD_SendCommand(0x10); // DATA_START_TRANSMISSION_1 + delay(2); + return 0; +} + +int EPD_2IN13B_V3_Init(void) +{ + EPD_Reset(); + delay(10); + + EPD_SendCommand(0x04); + EPD_WaitUntilIdle();//waiting for the electronic paper IC to release the idle signal + + EPD_Send_2(0x00, 0x0f, 0x89);//panel setting + + EPD_Send_3(0x61, 0x68, 0x00, 0xd4);//resolution setting + + EPD_Send_1(0X50, 0x77);//VCOM AND DATA INTERVAL SETTING + + EPD_SendCommand(0x10); // DATA_START_TRANSMISSION_1 + delay(2); + return 0; +} + +void EPD_2IN13B_V3_Show() +{ + EPD_SendCommand(0x12); //DISPLAY REFRESH + delay(2); + EPD_WaitUntilIdle(); + + EPD_Send_1(0X50, 0xf7); + EPD_SendCommand(0X02); //power off + EPD_WaitUntilIdle(); //waiting for the electronic paper IC to release the idle signal + EPD_Send_1(0X07, 0xa5); //deep sleep +} + + +int EPD_Init_2in13d() +{ + EPD_Reset(); + + EPD_Send_5(0x01, 0x03, 0x00, 0x2b, 0x2b, 0x03);//POWER SETTING + EPD_Send_3(0x06, 0x17, 0x17, 0x17); //BOOSTER_SOFT_START + EPD_SendCommand(0x04); //POWER_ON + EPD_WaitUntilIdle(); + EPD_Send_2(0x00, 0xbf, 0x0d); //PANEL_SETTINGS: LUT from OTP£¬128x296 + EPD_Send_1(0x30, 0x3a); //PLL_SETTINGS: 3a 100HZ, 29 150Hz, 39 200HZ, 31 171HZ, 3c 50hz + EPD_Send_3(0x61, 0x68, 0x00, 0xD4); //TCON_RESOLUTION + EPD_Send_1(0x82, 0x28); //VCOM_DC_SETTINGS + + EPD_SendCommand(0x10); + for (int j = 0; j < 212; j++) for (int i = 0; i < 13; i++) EPD_SendData(0); + delay(10); + + EPD_SendCommand(0x13); + return 0; } diff --git a/epd2in66.h b/epd2in66.h new file mode 100644 index 0000000..f0f5a7e --- /dev/null +++ b/epd2in66.h @@ -0,0 +1,95 @@ +/***************************************************************************** +* | File : EPD_2in66.c +* | Author : Waveshare team +* | Function : 2.66inch e-paper +* | Info : +*---------------- +* | This version: V1.0 +* | Date : 2020-08-10 +* | 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. +# +******************************************************************************/ + +// Display resolution +#define EPD_2IN66_WIDTH 152 +#define EPD_2IN66_HEIGHT 296 + +/****************************************************************************** +function : Wait until the busy_pin goes LOW +parameter: +******************************************************************************/ +static void EPD_2IN66_ReadBusy(void) +{ + Serial.print("e-Paper busy\r\n"); + delay(100); + while(digitalRead(BUSY_PIN) == 1) { //LOW: idle, HIGH: busy + delay(100); + } + delay(100); + Serial.print("e-Paper busy release\r\n"); +} + + +/****************************************************************************** +function : Turn On Display +parameter: +******************************************************************************/ +static void EPD_2IN66_Show(void) +{ + EPD_SendCommand(0x20); + EPD_2IN66_ReadBusy(); + Serial.print("EPD_2IN66_Show END\r\n"); + + EPD_SendCommand(0x10);//sleep + EPD_SendData(0x01); +} + +/****************************************************************************** +function : Initialize the e-Paper register +parameter: +******************************************************************************/ +int EPD_2IN66_Init(void) +{ + EPD_Reset(); + EPD_2IN66_ReadBusy(); + EPD_SendCommand(0x12);//soft reset + EPD_2IN66_ReadBusy(); + /* Y increment, X increment */ + EPD_SendCommand(0x11); + EPD_SendData(0x03); + /* Set RamX-address Start/End position */ + EPD_SendCommand(0x44); + EPD_SendData(0x01); + EPD_SendData((EPD_2IN66_WIDTH % 8 == 0)? (EPD_2IN66_WIDTH / 8 ): (EPD_2IN66_WIDTH / 8 + 1) ); + /* Set RamY-address Start/End position */ + EPD_SendCommand(0x45); + EPD_SendData(0); + EPD_SendData(0); + EPD_SendData((EPD_2IN66_HEIGHT&0xff)); + EPD_SendData((EPD_2IN66_HEIGHT&0x100)>>8); + + EPD_2IN66_ReadBusy(); + + EPD_SendCommand(0x24);//show + + return 0; +} + diff --git a/epd2in7.h b/epd2in7.h index f34a005..ed09a14 100644 --- a/epd2in7.h +++ b/epd2in7.h @@ -1,172 +1,172 @@ -/** - ****************************************************************************** - * @file edp2in7.h - * @author Waveshare Team - * @version V1.0.0 - * @date 23-January-2018 - * @brief This file describes initialisation of 2.7 and 2.7b e-Papers - * - ****************************************************************************** - */ -unsigned char lut_dc_2in7[] = -{ - 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x05, 0x00, 0x32, 0x32, - 0x00, 0x00, 0x02, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x05, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -//R21H -unsigned char lut_ww_2in7[] = -{ - 0x50, 0x0F, 0x0F, 0x00, 0x00, 0x05, 0x60, 0x32, 0x32, 0x00, 0x00, 0x02, 0xA0, 0x0F, - 0x0F, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -//R22H r -unsigned char lut_bw_2in7[] = -{ - 0x50, 0x0F, 0x0F, 0x00, 0x00, 0x05, 0x60, 0x32, 0x32, 0x00, 0x00, 0x02, 0xA0, 0x0F, - 0x0F, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -//R24H b -unsigned char lut_bb_2in7[] = -{ - 0xA0, 0x0F, 0x0F, 0x00, 0x00, 0x05, 0x60, 0x32, 0x32, 0x00, 0x00, 0x02, 0x50, 0x0F, - 0x0F, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -//R23H w -unsigned char lut_wb_2in7[] = -{ - 0xA0, 0x0F, 0x0F, 0x00, 0x00, 0x05, 0x60, 0x32, 0x32, 0x00, 0x00, 0x02, 0x50, 0x0F, - 0x0F, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -int EPD_Init_2in7() -{ - EPD_Reset(); - - EPD_SendCommand(0x01);//POWER_SETTING - EPD_SendData(0x03); // VDS_EN, VDG_EN - EPD_SendData(0x00); // VCOM_HV, VGHL_LV[1], VGHL_LV[0] - EPD_SendData(0x2b); // VDH - EPD_SendData(0x2b); // VDL - EPD_SendData(0x09); // VDHR - - EPD_Send_3(0x06, 0x07, 0x07, 0x17);//BOOSTER_SOFT_START - - // Power optimization - EPD_Send_2(0xF8, 0x60, 0xA5); - EPD_Send_2(0xF8, 0x89, 0xA5); - EPD_Send_2(0xF8, 0x90, 0x00); - EPD_Send_2(0xF8, 0x93, 0x2A); - EPD_Send_2(0xF8, 0xA0, 0xA5); - EPD_Send_2(0xF8, 0xA1, 0x00); - EPD_Send_2(0xF8, 0x73, 0x41); - - EPD_Send_1(0x16, 0x00);//PARTIAL_DISPLAY_REFRESH - EPD_SendCommand(0x04);//POWER_ON - EPD_WaitUntilIdle(); - - EPD_Send_1(0x00, 0xAF);//PANEL_SETTING: KW-BF, KWR-AF, BWROTP 0f - EPD_Send_1(0x30, 0x3A);//PLL_CONTROL: 3A 100HZ, 29 150Hz, 39 200HZ, 31 171HZ - EPD_Send_1(0x82, 0x12);//VCM_DC_SETTING_REGISTER - delay(2); - - EPD_lut(0x20,44,&lut_dc_2in7[0]);// LUT_FOR_VCOM - EPD_lut(0x21,42,&lut_ww_2in7[0]);// LUT_WHITE_TO_WHITE - EPD_lut(0x22,42,&lut_bw_2in7[0]);// LUT_BLACK_TO_WHITE - EPD_lut(0x23,42,&lut_wb_2in7[0]);// LUT_WHITE_TO_BLACK - EPD_lut(0x24,42,&lut_bb_2in7[0]);// LUT_BLACK_TO_BLACK - - EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1 - delay(2); - for(int i = 0; i < 176*264; i++)EPD_SendData(0xFF);//Red channel - - EPD_SendCommand(0x13);//DATA_START_TRANSMISSION_2 - delay(2); - return 0; -} - -unsigned char lut_dc_2in7b[] = -{ - 0x00, 0x00, 0x00, 0x1A, 0x1A, 0x00, 0x00, 0x01, 0x00, 0x0A, 0x0A, - 0x00, 0x00, 0x08, 0x00, 0x0E, 0x01, 0x0E, 0x01, 0x10, 0x00, 0x0A, - 0x0A, 0x00, 0x00, 0x08, 0x00, 0x04, 0x10, 0x00, 0x00, 0x05, 0x00, - 0x03, 0x0E, 0x00, 0x00, 0x0A, 0x00, 0x23, 0x00, 0x00, 0x00, 0x01 -}; - -//R21H -unsigned char lut_ww_2in7b[] = -{ - 0x90, 0x1A, 0x1A, 0x00, 0x00, 0x01, 0x40, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0x84, 0x0E, - 0x01, 0x0E, 0x01, 0x10, 0x80, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0x00, 0x04, 0x10, 0x00, - 0x00, 0x05, 0x00, 0x03, 0x0E, 0x00, 0x00, 0x0A, 0x00, 0x23, 0x00, 0x00, 0x00, 0x01 -}; - -//R22H r -unsigned char lut_bw_2in7b[] = -{ - 0xA0, 0x1A, 0x1A, 0x00, 0x00, 0x01, 0x00, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0x84, 0x0E, - 0x01, 0x0E, 0x01, 0x10, 0x90, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0xB0, 0x04, 0x10, 0x00, - 0x00, 0x05, 0xB0, 0x03, 0x0E, 0x00, 0x00, 0x0A, 0xC0, 0x23, 0x00, 0x00, 0x00, 0x01 -}; - -//R23H w -unsigned char lut_bb_2in7b[] = -{ - 0x90, 0x1A, 0x1A, 0x00, 0x00, 0x01, 0x40, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0x84, 0x0E, - 0x01, 0x0E, 0x01, 0x10, 0x80, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0x00, 0x04, 0x10, 0x00, - 0x00, 0x05, 0x00, 0x03, 0x0E, 0x00, 0x00, 0x0A, 0x00, 0x23, 0x00, 0x00, 0x00, 0x01 -}; - -//R24H b -unsigned char lut_wb_2in7b[] = -{ - 0x90, 0x1A, 0x1A, 0x00, 0x00, 0x01, 0x20, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0x84, 0x0E, - 0x01, 0x0E, 0x01, 0x10, 0x10, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0x00, 0x04, 0x10, 0x00, - 0x00, 0x05, 0x00, 0x03, 0x0E, 0x00, 0x00, 0x0A, 0x00, 0x23, 0x00, 0x00, 0x00, 0x01 -}; - -int EPD_Init_2in7b() -{ - EPD_Reset(); - - EPD_SendCommand(0x04);//POWER_ON - EPD_WaitUntilIdle(); - - EPD_Send_1(0x00, 0xAF);//PANEL_SETTING - EPD_Send_1(0x30,0x3A);//PLL_CONTROL: 3A 100HZ, 29 150Hz, 39 200HZ, 31 171HZ - EPD_Send_5(0x01,0x03,0x00,0x2B,0x2B,0x09);//POWER_SETTING - EPD_Send_3(0x06,0x07,0x07,0x17);//BOOSTER_SOFT_START - - // Power optimization - EPD_Send_2(0xF8,0x60,0xA5); - EPD_Send_2(0xF8,0x89,0xA5); - EPD_Send_2(0xF8,0x90,0x00); - EPD_Send_2(0xF8,0x93,0x2A); - EPD_Send_2(0xF8,0x73,0x41); - - EPD_Send_1(0x82,0x2E);// VCM_DC_SETTING_REGISTER - EPD_Send_1(0x50,0xA7);// VCOM_AND_DATA_INTERVAL_SETTING - - EPD_lut(0x20,44,&lut_dc_2in7b[0]);// LUT_FOR_VCOM - EPD_lut(0x21,42,&lut_ww_2in7b[0]);// LUT_WHITE_TO_WHITE - EPD_lut(0x22,42,&lut_bw_2in7b[0]);// LUT_BLACK_TO_WHITE - EPD_lut(0x23,42,&lut_wb_2in7b[0]);// LUT_WHITE_TO_BLACK - EPD_lut(0x24,42,&lut_bb_2in7b[0]);// LUT_BLACK_TO_BLACK - - EPD_Send_4(0x61, 0, 176, 1, 8);// TCON_RESOLUTION: HI(W), LO(W), HI(H), LO(H) - EPD_Send_1(0x16, 0x00);//PARTIAL_DISPLAY_REFRESH); - - EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1 - delay(2); - - return 0; +/** + ****************************************************************************** + * @file edp2in7.h + * @author Waveshare Team + * @version V1.0.0 + * @date 23-January-2018 + * @brief This file describes initialisation of 2.7 and 2.7b e-Papers + * + ****************************************************************************** + */ +unsigned char lut_dc_2in7[] = +{ + 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x05, 0x00, 0x32, 0x32, + 0x00, 0x00, 0x02, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x05, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +//R21H +unsigned char lut_ww_2in7[] = +{ + 0x50, 0x0F, 0x0F, 0x00, 0x00, 0x05, 0x60, 0x32, 0x32, 0x00, 0x00, 0x02, 0xA0, 0x0F, + 0x0F, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +//R22H r +unsigned char lut_bw_2in7[] = +{ + 0x50, 0x0F, 0x0F, 0x00, 0x00, 0x05, 0x60, 0x32, 0x32, 0x00, 0x00, 0x02, 0xA0, 0x0F, + 0x0F, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +//R24H b +unsigned char lut_bb_2in7[] = +{ + 0xA0, 0x0F, 0x0F, 0x00, 0x00, 0x05, 0x60, 0x32, 0x32, 0x00, 0x00, 0x02, 0x50, 0x0F, + 0x0F, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +//R23H w +unsigned char lut_wb_2in7[] = +{ + 0xA0, 0x0F, 0x0F, 0x00, 0x00, 0x05, 0x60, 0x32, 0x32, 0x00, 0x00, 0x02, 0x50, 0x0F, + 0x0F, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +int EPD_Init_2in7() +{ + EPD_Reset(); + + EPD_SendCommand(0x01);//POWER_SETTING + EPD_SendData(0x03); // VDS_EN, VDG_EN + EPD_SendData(0x00); // VCOM_HV, VGHL_LV[1], VGHL_LV[0] + EPD_SendData(0x2b); // VDH + EPD_SendData(0x2b); // VDL + EPD_SendData(0x09); // VDHR + + EPD_Send_3(0x06, 0x07, 0x07, 0x17);//BOOSTER_SOFT_START + + // Power optimization + EPD_Send_2(0xF8, 0x60, 0xA5); + EPD_Send_2(0xF8, 0x89, 0xA5); + EPD_Send_2(0xF8, 0x90, 0x00); + EPD_Send_2(0xF8, 0x93, 0x2A); + EPD_Send_2(0xF8, 0xA0, 0xA5); + EPD_Send_2(0xF8, 0xA1, 0x00); + EPD_Send_2(0xF8, 0x73, 0x41); + + EPD_Send_1(0x16, 0x00);//PARTIAL_DISPLAY_REFRESH + EPD_SendCommand(0x04);//POWER_ON + EPD_WaitUntilIdle(); + + EPD_Send_1(0x00, 0xAF);//PANEL_SETTING: KW-BF, KWR-AF, BWROTP 0f + EPD_Send_1(0x30, 0x3A);//PLL_CONTROL: 3A 100HZ, 29 150Hz, 39 200HZ, 31 171HZ + EPD_Send_1(0x82, 0x12);//VCM_DC_SETTING_REGISTER + delay(2); + + EPD_lut(0x20,44,&lut_dc_2in7[0]);// LUT_FOR_VCOM + EPD_lut(0x21,42,&lut_ww_2in7[0]);// LUT_WHITE_TO_WHITE + EPD_lut(0x22,42,&lut_bw_2in7[0]);// LUT_BLACK_TO_WHITE + EPD_lut(0x23,42,&lut_wb_2in7[0]);// LUT_WHITE_TO_BLACK + EPD_lut(0x24,42,&lut_bb_2in7[0]);// LUT_BLACK_TO_BLACK + + EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1 + delay(2); + for(int i = 0; i < 176*264; i++)EPD_SendData(0xFF);//Red channel + + EPD_SendCommand(0x13);//DATA_START_TRANSMISSION_2 + delay(2); + return 0; +} + +unsigned char lut_dc_2in7b[] = +{ + 0x00, 0x00, 0x00, 0x1A, 0x1A, 0x00, 0x00, 0x01, 0x00, 0x0A, 0x0A, + 0x00, 0x00, 0x08, 0x00, 0x0E, 0x01, 0x0E, 0x01, 0x10, 0x00, 0x0A, + 0x0A, 0x00, 0x00, 0x08, 0x00, 0x04, 0x10, 0x00, 0x00, 0x05, 0x00, + 0x03, 0x0E, 0x00, 0x00, 0x0A, 0x00, 0x23, 0x00, 0x00, 0x00, 0x01 +}; + +//R21H +unsigned char lut_ww_2in7b[] = +{ + 0x90, 0x1A, 0x1A, 0x00, 0x00, 0x01, 0x40, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0x84, 0x0E, + 0x01, 0x0E, 0x01, 0x10, 0x80, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0x00, 0x04, 0x10, 0x00, + 0x00, 0x05, 0x00, 0x03, 0x0E, 0x00, 0x00, 0x0A, 0x00, 0x23, 0x00, 0x00, 0x00, 0x01 +}; + +//R22H r +unsigned char lut_bw_2in7b[] = +{ + 0xA0, 0x1A, 0x1A, 0x00, 0x00, 0x01, 0x00, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0x84, 0x0E, + 0x01, 0x0E, 0x01, 0x10, 0x90, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0xB0, 0x04, 0x10, 0x00, + 0x00, 0x05, 0xB0, 0x03, 0x0E, 0x00, 0x00, 0x0A, 0xC0, 0x23, 0x00, 0x00, 0x00, 0x01 +}; + +//R23H w +unsigned char lut_bb_2in7b[] = +{ + 0x90, 0x1A, 0x1A, 0x00, 0x00, 0x01, 0x40, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0x84, 0x0E, + 0x01, 0x0E, 0x01, 0x10, 0x80, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0x00, 0x04, 0x10, 0x00, + 0x00, 0x05, 0x00, 0x03, 0x0E, 0x00, 0x00, 0x0A, 0x00, 0x23, 0x00, 0x00, 0x00, 0x01 +}; + +//R24H b +unsigned char lut_wb_2in7b[] = +{ + 0x90, 0x1A, 0x1A, 0x00, 0x00, 0x01, 0x20, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0x84, 0x0E, + 0x01, 0x0E, 0x01, 0x10, 0x10, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0x00, 0x04, 0x10, 0x00, + 0x00, 0x05, 0x00, 0x03, 0x0E, 0x00, 0x00, 0x0A, 0x00, 0x23, 0x00, 0x00, 0x00, 0x01 +}; + +int EPD_Init_2in7b() +{ + EPD_Reset(); + + EPD_SendCommand(0x04);//POWER_ON + EPD_WaitUntilIdle(); + + EPD_Send_1(0x00, 0xAF);//PANEL_SETTING + EPD_Send_1(0x30,0x3A);//PLL_CONTROL: 3A 100HZ, 29 150Hz, 39 200HZ, 31 171HZ + EPD_Send_5(0x01,0x03,0x00,0x2B,0x2B,0x09);//POWER_SETTING + EPD_Send_3(0x06,0x07,0x07,0x17);//BOOSTER_SOFT_START + + // Power optimization + EPD_Send_2(0xF8,0x60,0xA5); + EPD_Send_2(0xF8,0x89,0xA5); + EPD_Send_2(0xF8,0x90,0x00); + EPD_Send_2(0xF8,0x93,0x2A); + EPD_Send_2(0xF8,0x73,0x41); + + EPD_Send_1(0x82,0x2E);// VCM_DC_SETTING_REGISTER + EPD_Send_1(0x50,0xA7);// VCOM_AND_DATA_INTERVAL_SETTING + + EPD_lut(0x20,44,&lut_dc_2in7b[0]);// LUT_FOR_VCOM + EPD_lut(0x21,42,&lut_ww_2in7b[0]);// LUT_WHITE_TO_WHITE + EPD_lut(0x22,42,&lut_bw_2in7b[0]);// LUT_BLACK_TO_WHITE + EPD_lut(0x23,42,&lut_wb_2in7b[0]);// LUT_WHITE_TO_BLACK + EPD_lut(0x24,42,&lut_bb_2in7b[0]);// LUT_BLACK_TO_BLACK + + EPD_Send_4(0x61, 0, 176, 1, 8);// TCON_RESOLUTION: HI(W), LO(W), HI(H), LO(H) + EPD_Send_1(0x16, 0x00);//PARTIAL_DISPLAY_REFRESH); + + EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1 + delay(2); + + return 0; } diff --git a/epd2in9.h b/epd2in9.h index 859f7d5..1d97bfe 100644 --- a/epd2in9.h +++ b/epd2in9.h @@ -1,237 +1,251 @@ -/** - ****************************************************************************** - * @file edp2in9.h - * @author Waveshare Team - * @version V1.0.0 - * @date 23-January-2018 - * @brief This file describes initialisation of 2.9 and 2.9b e-Papers - * - ****************************************************************************** - */ -int EPD_Init_2in9() -{ - EPD_Reset(); - EPD_Send_3(0x01, 39, 1, 0);//DRIVER_OUTPUT_CONTROL:LO(EPD_HEIGHT-1),HI(EPD_HEIGHT-1), GD = 0; SM = 0; TB = 0; - EPD_Send_3(0x0C, 0xD7, 0xD6, 0x9D);//BOOSTER_SOFT_START_CONTROL - EPD_Send_1(0x2C, 0xA8);//WRITE_VCOM_REGISTER:VCOM 7C - EPD_Send_1(0x3A, 0x1A);//SET_DUMMY_LINE_PERIOD: 4 dummy lines per gate - EPD_Send_1(0x3B, 0x08);//SET_GATE_TIME: 2us per line - EPD_Send_1(0x11, 0x03);//DATA_ENTRY_MODE_SETTING: X increment; Y increment - - EPD_Send_2(0x44, 0, 15);//SET_RAM_X_ADDRESS_START_END_POSITION: LO(x >> 3), HI ((w-1) >> 3) - EPD_Send_4(0x45, 0, 0, 45, 1);//SET_RAM_Y_ADDRESS_START_END_POSITION: LO(y), HI(y), LO(h - 1),HI(h - 1) - - EPD_Send_1(0x4E, 0);//SET_RAM_X_ADDRESS_COUNTER: LO(x >> 3) - EPD_Send_2(0x4F, 0, 0);//SET_RAM_Y_ADDRESS_COUNTER: LO(y), HI(y) - - EPD_lut(0x32, 30, &lut_full_mono[0]); - - EPD_SendCommand(0x24);//WRITE_RAM - delay(2); - return 0; -} - -int EPD_Init_2in9b() -{ - EPD_Reset(); - EPD_Send_4(0x01, 0x07, 0x00, 0x08, 0x00);//POWER_SETTING - EPD_Send_3(0x06, 0x17, 0x17, 0x17);//BOOSTER_SOFT_START - EPD_SendCommand(0x04);//POWER_ON - EPD_WaitUntilIdle(); - - EPD_Send_1(0x00, 0x8F);//PANEL_SETTING - EPD_Send_1(0x50, 0x77);//VCOM_AND_DATA_INTERVAL_SETTING; - EPD_Send_1(0x30, 0x39);//PLL_CONTROL - EPD_Send_3(0x61, 0x80, 0x01, 0x28);//TCON_RESOLUTION - EPD_Send_1(0x82, 0x0A);//VCM_DC_SETTING_REGISTER - - EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1 - delay(2); - return 0; -} - - - -/************************************************************************************/ -#define UBYTE uint8_t -#define UWORD uint16_t -#define UDOUBLE uint32_t - - -#define EPD_2IN9D_WIDTH 128 -#define EPD_2IN9D_HEIGHT 296 - -const unsigned char EPD_2IN9D_lut_vcomDC[] = { - 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x60, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, -}; -const unsigned char EPD_2IN9D_lut_ww[] = { - 0x40, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x40, 0x14, 0x00, 0x00, 0x00, 0x01, - 0xA0, 0x12, 0x12, 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_2IN9D_lut_bw[] = { - 0x40, 0x17, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x0F, 0x0F, 0x00, 0x00, 0x03, - 0x40, 0x0A, 0x01, 0x00, 0x00, 0x01, - 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; -const unsigned char EPD_2IN9D_lut_wb[] = { - 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x80, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x50, 0x12, 0x12, 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_2IN9D_lut_bb[] = { - 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, - 0x80, 0x14, 0x00, 0x00, 0x00, 0x01, - 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -void EPD_SetFullReg(void) -{ - EPD_SendCommand(0X50); //VCOM AND DATA INTERVAL SETTING - EPD_SendData(0xb7); //WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7 - - unsigned int count; - EPD_SendCommand(0x20); - for(count=0; count<44; count++) { - EPD_SendData(EPD_2IN9D_lut_vcomDC[count]); - } - - EPD_SendCommand(0x21); - for(count=0; count<42; count++) { - EPD_SendData(EPD_2IN9D_lut_ww[count]); - } - - EPD_SendCommand(0x22); - for(count=0; count<42; count++) { - EPD_SendData(EPD_2IN9D_lut_bw[count]); - } - - EPD_SendCommand(0x23); - for(count=0; count<42; count++) { - EPD_SendData(EPD_2IN9D_lut_wb[count]); - } - - EPD_SendCommand(0x24); - for(count=0; count<42; count++) { - EPD_SendData(EPD_2IN9D_lut_bb[count]); - } -} - -void EPD_2IN9D_ReadBusy(void) -{ - Serial.print("\r\ne-Paper busy"); - UBYTE busy; - do { - EPD_SendCommand(0x71); - busy = digitalRead(BUSY_PIN); - busy = !(busy & 0x01); - } while(busy); - delay(200); - Serial.print("\r\ne-Paper busy free"); -} - -void EPD_2IN9D_Show(void) -{ - Serial.print("\r\nEPD_2IN9D_Show"); - EPD_SetFullReg(); - EPD_SendCommand(0x12); //DISPLAY REFRESH - delay(10); //!!!The delay here is necessary, 200uS at least!!! - - EPD_2IN9D_ReadBusy(); - - // Sleep - EPD_SendCommand(0X50); - EPD_SendData(0xf7); - EPD_SendCommand(0X02); //power off - EPD_2IN9D_ReadBusy(); - EPD_SendCommand(0X07); //deep sleep - EPD_SendData(0xA5); -} - -void EPD_2IN9D_Clear(void) -{ - UWORD Width, Height; - Width = (EPD_2IN9D_WIDTH % 8 == 0)? (EPD_2IN9D_WIDTH / 8 ): (EPD_2IN9D_WIDTH / 8 + 1); - Height = EPD_2IN9D_HEIGHT; - - EPD_SendCommand(0x10); - for (UWORD j = 0; j < Height; j++) { - for (UWORD i = 0; i < Width; i++) { - EPD_SendData(0x00); - } - } - - EPD_SendCommand(0x13); - for (UWORD j = 0; j < Height; j++) { - for (UWORD i = 0; i < Width; i++) { - EPD_SendData(0xFF); - } - } - - // EPD_2IN9D_Show(); - EPD_SendCommand(0x13); -} - -int EPD_Init_2in9d() -{ - EPD_Reset(); - - EPD_SendCommand(0x01); //POWER SETTING - EPD_SendData(0x03); - EPD_SendData(0x00); - EPD_SendData(0x2b); - EPD_SendData(0x2b); - EPD_SendData(0x03); - - EPD_SendCommand(0x06); //boost soft start - EPD_SendData(0x17); //A - EPD_SendData(0x17); //B - EPD_SendData(0x17); //C - - EPD_SendCommand(0x04); - EPD_2IN9D_ReadBusy(); - - EPD_SendCommand(0x00); //panel setting - EPD_SendData(0xbf); //LUT from OTP,128x296 - EPD_SendData(0x0e); //VCOM to 0V fast - - EPD_SendCommand(0x30); //PLL setting - EPD_SendData(0x3a); // 3a 100HZ 29 150Hz 39 200HZ 31 171HZ - - EPD_SendCommand(0x61); //resolution setting - EPD_SendData(EPD_2IN9D_WIDTH); - EPD_SendData((EPD_2IN9D_HEIGHT >> 8) & 0xff); - EPD_SendData(EPD_2IN9D_HEIGHT & 0xff); - - EPD_SendCommand(0x82); //vcom_DC setting - EPD_SendData(0x28); - delay(2); - - EPD_2IN9D_Clear(); - - return 0; -} - +/** + ****************************************************************************** + * @file edp2in9.h + * @author Waveshare Team + * @version V1.0.0 + * @date 23-January-2018 + * @brief This file describes initialisation of 2.9 and 2.9b e-Papers + * + ****************************************************************************** + */ +int EPD_Init_2in9() +{ + EPD_Reset(); + EPD_Send_3(0x01, 39, 1, 0);//DRIVER_OUTPUT_CONTROL:LO(EPD_HEIGHT-1),HI(EPD_HEIGHT-1), GD = 0; SM = 0; TB = 0; + EPD_Send_3(0x0C, 0xD7, 0xD6, 0x9D);//BOOSTER_SOFT_START_CONTROL + EPD_Send_1(0x2C, 0xA8);//WRITE_VCOM_REGISTER:VCOM 7C + EPD_Send_1(0x3A, 0x1A);//SET_DUMMY_LINE_PERIOD: 4 dummy lines per gate + EPD_Send_1(0x3B, 0x08);//SET_GATE_TIME: 2us per line + EPD_Send_1(0x11, 0x03);//DATA_ENTRY_MODE_SETTING: X increment; Y increment + + EPD_Send_2(0x44, 0, 15);//SET_RAM_X_ADDRESS_START_END_POSITION: LO(x >> 3), HI ((w-1) >> 3) + EPD_Send_4(0x45, 0, 0, 45, 1);//SET_RAM_Y_ADDRESS_START_END_POSITION: LO(y), HI(y), LO(h - 1),HI(h - 1) + + EPD_Send_1(0x4E, 0);//SET_RAM_X_ADDRESS_COUNTER: LO(x >> 3) + EPD_Send_2(0x4F, 0, 0);//SET_RAM_Y_ADDRESS_COUNTER: LO(y), HI(y) + + EPD_lut(0x32, 30, &lut_full_mono[0]); + + EPD_SendCommand(0x24);//WRITE_RAM + delay(2); + return 0; +} + +int EPD_Init_2in9b() +{ + EPD_Reset(); + EPD_Send_4(0x01, 0x07, 0x00, 0x08, 0x00);//POWER_SETTING + EPD_Send_3(0x06, 0x17, 0x17, 0x17);//BOOSTER_SOFT_START + EPD_SendCommand(0x04);//POWER_ON + EPD_WaitUntilIdle(); + + EPD_Send_1(0x00, 0x8F);//PANEL_SETTING + EPD_Send_1(0x50, 0x77);//VCOM_AND_DATA_INTERVAL_SETTING; + EPD_Send_1(0x30, 0x39);//PLL_CONTROL + EPD_Send_3(0x61, 0x80, 0x01, 0x28);//TCON_RESOLUTION + EPD_Send_1(0x82, 0x0A);//VCM_DC_SETTING_REGISTER + + EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1 + delay(2); + return 0; +} + + +int EPD_Init_2in9b_V2() +{ + EPD_Reset(); + EPD_SendCommand(0x04);//POWER_ON + EPD_WaitUntilIdle(); + + EPD_Send_2(0x00, 0x0F, 0x89);//PANEL_SETTING + EPD_Send_3(0x61, 0x80, 0x01, 0x28);//TCON_RESOLUTION + EPD_Send_1(0x50, 0x77);//VCOM_AND_DATA_INTERVAL_SETTING; + + EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1 + delay(2); + return 0; +} + + +/************************************************************************************/ +#define UBYTE uint8_t +#define UWORD uint16_t +#define UDOUBLE uint32_t + + +#define EPD_2IN9D_WIDTH 128 +#define EPD_2IN9D_HEIGHT 296 + +const unsigned char EPD_2IN9D_lut_vcomDC[] = { + 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, + 0x60, 0x28, 0x28, 0x00, 0x00, 0x01, + 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x12, 0x12, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, +}; +const unsigned char EPD_2IN9D_lut_ww[] = { + 0x40, 0x08, 0x00, 0x00, 0x00, 0x02, + 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, + 0x40, 0x14, 0x00, 0x00, 0x00, 0x01, + 0xA0, 0x12, 0x12, 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_2IN9D_lut_bw[] = { + 0x40, 0x17, 0x00, 0x00, 0x00, 0x02, + 0x90, 0x0F, 0x0F, 0x00, 0x00, 0x03, + 0x40, 0x0A, 0x01, 0x00, 0x00, 0x01, + 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; +const unsigned char EPD_2IN9D_lut_wb[] = { + 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, + 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, + 0x80, 0x14, 0x00, 0x00, 0x00, 0x01, + 0x50, 0x12, 0x12, 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_2IN9D_lut_bb[] = { + 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, + 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, + 0x80, 0x14, 0x00, 0x00, 0x00, 0x01, + 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +void EPD_SetFullReg(void) +{ + EPD_SendCommand(0X50); //VCOM AND DATA INTERVAL SETTING + EPD_SendData(0xb7); //WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7 + + unsigned int count; + EPD_SendCommand(0x20); + for(count=0; count<44; count++) { + EPD_SendData(EPD_2IN9D_lut_vcomDC[count]); + } + + EPD_SendCommand(0x21); + for(count=0; count<42; count++) { + EPD_SendData(EPD_2IN9D_lut_ww[count]); + } + + EPD_SendCommand(0x22); + for(count=0; count<42; count++) { + EPD_SendData(EPD_2IN9D_lut_bw[count]); + } + + EPD_SendCommand(0x23); + for(count=0; count<42; count++) { + EPD_SendData(EPD_2IN9D_lut_wb[count]); + } + + EPD_SendCommand(0x24); + for(count=0; count<42; count++) { + EPD_SendData(EPD_2IN9D_lut_bb[count]); + } +} + +void EPD_2IN9D_ReadBusy(void) +{ + Serial.print("\r\ne-Paper busy"); + UBYTE busy; + do { + EPD_SendCommand(0x71); + busy = digitalRead(BUSY_PIN); + busy = !(busy & 0x01); + } while(busy); + delay(200); + Serial.print("\r\ne-Paper busy free"); +} + +void EPD_2IN9D_Show(void) +{ + Serial.print("\r\nEPD_2IN9D_Show"); + EPD_SetFullReg(); + EPD_SendCommand(0x12); //DISPLAY REFRESH + delay(10); //!!!The delay here is necessary, 200uS at least!!! + + EPD_2IN9D_ReadBusy(); + + // Sleep + EPD_SendCommand(0X50); + EPD_SendData(0xf7); + EPD_SendCommand(0X02); //power off + EPD_2IN9D_ReadBusy(); + EPD_SendCommand(0X07); //deep sleep + EPD_SendData(0xA5); +} + +void EPD_2IN9D_Clear(void) +{ + UWORD Width, Height; + Width = (EPD_2IN9D_WIDTH % 8 == 0)? (EPD_2IN9D_WIDTH / 8 ): (EPD_2IN9D_WIDTH / 8 + 1); + Height = EPD_2IN9D_HEIGHT; + + EPD_SendCommand(0x10); + for (UWORD j = 0; j < Height; j++) { + for (UWORD i = 0; i < Width; i++) { + EPD_SendData(0x00); + } + } + + EPD_SendCommand(0x13); + for (UWORD j = 0; j < Height; j++) { + for (UWORD i = 0; i < Width; i++) { + EPD_SendData(0xFF); + } + } + + // EPD_2IN9D_Show(); + EPD_SendCommand(0x13); +} + +int EPD_Init_2in9d() +{ + EPD_Reset(); + + EPD_SendCommand(0x01); //POWER SETTING + EPD_SendData(0x03); + EPD_SendData(0x00); + EPD_SendData(0x2b); + EPD_SendData(0x2b); + EPD_SendData(0x03); + + EPD_SendCommand(0x06); //boost soft start + EPD_SendData(0x17); //A + EPD_SendData(0x17); //B + EPD_SendData(0x17); //C + + EPD_SendCommand(0x04); + EPD_2IN9D_ReadBusy(); + + EPD_SendCommand(0x00); //panel setting + EPD_SendData(0xbf); //LUT from OTP,128x296 + EPD_SendData(0x0e); //VCOM to 0V fast + + EPD_SendCommand(0x30); //PLL setting + EPD_SendData(0x3a); // 3a 100HZ 29 150Hz 39 200HZ 31 171HZ + + EPD_SendCommand(0x61); //resolution setting + EPD_SendData(EPD_2IN9D_WIDTH); + EPD_SendData((EPD_2IN9D_HEIGHT >> 8) & 0xff); + EPD_SendData(EPD_2IN9D_HEIGHT & 0xff); + + EPD_SendCommand(0x82); //vcom_DC setting + EPD_SendData(0x28); + delay(2); + + EPD_2IN9D_Clear(); + + return 0; +} diff --git a/epd3in7.h b/epd3in7.h new file mode 100644 index 0000000..72514b9 --- /dev/null +++ b/epd3in7.h @@ -0,0 +1,177 @@ +/***************************************************************************** +* | File : EPD_3IN7.c +* | Author : Waveshare team +* | Function : 3.7inch e-paper +* | Info : +*---------------- +* | This version: V1.0 +* | Date : 2020-08-10 +* | 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. +# +******************************************************************************/ + +static const UBYTE lut_1Gray_GC[] = +{ +0x2A,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//1 +0x05,0x2A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//2 +0x2A,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//3 +0x05,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//4 +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//5 +0x00,0x02,0x03,0x0A,0x00,0x02,0x06,0x0A,0x05,0x00,//6 +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//7 +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//8 +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//9 +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//10 +0x22,0x22,0x22,0x22,0x22 +}; + +static void EPD_3IN7_ReadBusy_HIGH(void) +{ + Serial.print("e-Paper busy\r\n"); + UBYTE busy; + do { + busy = digitalRead(BUSY_PIN); + delay(100); + } while(busy); + Serial.print("e-Paper busy release\r\n"); +} + +/****************************************************************************** +function : set the look-up tables +parameter: +******************************************************************************/ +static void EPD_3IN7_Load_LUT(void) +{ + UWORD i; + EPD_SendCommand(0x32); + for (i = 0; i < 105; i++) + { + EPD_SendData(lut_1Gray_GC[i]); + } +} + +/****************************************************************************** +function : Initialize the e-Paper register +parameter: +******************************************************************************/ +int EPD_3IN7_1Gray_Init() +{ + EPD_Reset(); + + EPD_SendCommand(0x12); + delay(300); + + EPD_SendCommand(0x46); + EPD_SendData(0xF7); + EPD_3IN7_ReadBusy_HIGH(); + EPD_SendCommand(0x47); + EPD_SendData(0xF7); + EPD_3IN7_ReadBusy_HIGH(); + + EPD_SendCommand(0x01); // setting gaet number + EPD_SendData(0xDF); + EPD_SendData(0x01); + EPD_SendData(0x00); + + EPD_SendCommand(0x03); // set gate voltage + EPD_SendData(0x00); + + EPD_SendCommand(0x04); // set source voltage + EPD_SendData(0x41); + EPD_SendData(0xA8); + EPD_SendData(0x32); + + EPD_SendCommand(0x11); // set data entry sequence + EPD_SendData(0x03); + + EPD_SendCommand(0x3C); // set border + EPD_SendData(0x00); + + EPD_SendCommand(0x0C); // set booster strength + EPD_SendData(0xAE); + EPD_SendData(0xC7); + EPD_SendData(0xC3); + EPD_SendData(0xC0); + EPD_SendData(0xC0); + + EPD_SendCommand(0x18); // set internal sensor on + EPD_SendData(0x80); + + EPD_SendCommand(0x2C); // set vcom value + EPD_SendData(0x44); + + EPD_SendCommand(0x37); // set display option, these setting turn on previous function + EPD_SendData(0x00); //can switch 1 gray or 4 gray + EPD_SendData(0xFF); + EPD_SendData(0xFF); + EPD_SendData(0xFF); + EPD_SendData(0xFF); + EPD_SendData(0x4F); + EPD_SendData(0xFF); + EPD_SendData(0xFF); + EPD_SendData(0xFF); + EPD_SendData(0xFF); + + EPD_SendCommand(0x44); // setting X direction start/end position of RAM + EPD_SendData(0x00); + EPD_SendData(0x00); + EPD_SendData(0x17); + EPD_SendData(0x01); + + EPD_SendCommand(0x45); // setting Y direction start/end position of RAM + EPD_SendData(0x00); + EPD_SendData(0x00); + EPD_SendData(0xDF); + EPD_SendData(0x01); + + EPD_SendCommand(0x22); // Display Update Control 2 + EPD_SendData(0xCF); + + EPD_SendCommand(0x4E);//Set Resolution setting + EPD_SendData(0x00); + EPD_SendData(0x00); + EPD_SendCommand(0x4F); + EPD_SendData(0x00); + EPD_SendData(0x00); + + EPD_SendCommand(0x24);//begin write data to e-Paper + + return 0; +} + +/****************************************************************************** +function : Sends the image buffer in RAM to e-Paper and displays +parameter: +******************************************************************************/ +static void EPD_3IN7_1Gray_Show(void) +{ + EPD_3IN7_Load_LUT(); + EPD_SendCommand(0x20); + EPD_3IN7_ReadBusy_HIGH(); + Serial.print("EPD_3IN7_Show END\r\n"); + + EPD_SendCommand(0X50); + EPD_SendData(0xf7); + EPD_SendCommand(0X02); //power off + EPD_SendCommand(0X07); //deep sleep + EPD_SendData(0xA5); +} diff --git a/epd4in2.h b/epd4in2.h index 4cbdf60..2dee217 100644 --- a/epd4in2.h +++ b/epd4in2.h @@ -1,143 +1,143 @@ -/** - ****************************************************************************** - * @file edp4in2.h - * @author Waveshare Team - * @version V1.0.0 - * @date 23-January-2018 - * @brief This file describes initialisation of 4.2 and 4.2b e-Papers - * - ****************************************************************************** - */ - -unsigned char lut_dc_4in2[] = -{ - 0x00, 0x17, 0x00, 0x00, 0x00, 0x02, 0x00, 0x17, 0x17, 0x00, 0x00, - 0x02, 0x00, 0x0A, 0x01, 0x00, 0x00, 0x01, 0x00, 0x0E, 0x0E, 0x00, - 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -//R21H -unsigned char lut_ww_4in2[] = -{ - 0x40, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x40, 0x0A, - 0x01, 0x00, 0x00, 0x01, 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -//R22H r -unsigned char lut_bw_4in2[] = -{ - 0x40, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x40, 0x0A, - 0x01, 0x00, 0x00, 0x01, 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -//R24H b -unsigned char lut_bb_4in2[] = -{ - 0x80, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x80, 0x0A, - 0x01, 0x00, 0x00, 0x01, 0x50, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -//R23H w -unsigned char lut_wb_4in2[] = -{ - 0x80, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x80, 0x0A, - 0x01, 0x00, 0x00, 0x01, 0x50, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - - -int EPD_Init_4in2() -{ - EPD_Reset(); - - EPD_SendCommand(0x01);//POWER_SETTING - EPD_SendData(0x03); // VDS_EN, VDG_EN - EPD_SendData(0x00); // VCOM_HV, VGHL_LV[1], VGHL_LV[0] - EPD_SendData(0x2F); // VDH - EPD_SendData(0x2F); // VDL - EPD_SendData(0xFF); // VDHR - - EPD_Send_3(0x06, 0x17, 0x17, 0x17);//BOOSTER_SOFT_START - EPD_SendCommand(0x04);//POWER_ON - EPD_WaitUntilIdle(); - - EPD_Send_2(0x00, 0xBF, 0x0B);//PANEL_SETTING: // KW-BF KWR-AF BWROTP 0f - EPD_Send_1(0x30, 0x3C);//PLL_CONTROL: 3A 100HZ, 29 150Hz, 39 200HZ, 31 171HZ - - EPD_Send_4(0x61, 1, 144, 1, 44);// RESOLUTION_SETTING: HI(W), LO(W), HI(H), LO(H) - EPD_Send_1(0x82, 0x12);// VCM_DC_SETTING - EPD_Send_1(0x50, 0x97);// VCOM_AND_DATA_INTERVAL_SETTING: VBDF 17|D7 VBDW 97 VBDB 57 VBDF F7 VBDW 77 VBDB 37 VBDR B7 - - EPD_lut(0x20,44,&lut_dc_4in2[0]);// LUT_FOR_VCOM - EPD_lut(0x21,42,&lut_ww_4in2[0]);// LUT_WHITE_TO_WHITE - EPD_lut(0x22,42,&lut_bw_4in2[0]);// LUT_BLACK_TO_WHITE - EPD_lut(0x23,42,&lut_wb_4in2[0]);// LUT_WHITE_TO_BLACK - EPD_lut(0x24,42,&lut_bb_4in2[0]);// LUT_BLACK_TO_BLACK - - EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1 - delay(2); - for(int i = 0; i < 400*300; i++)EPD_SendData(0xFF);//Red channel - - EPD_SendCommand(0x13);//DATA_START_TRANSMISSION_2 - delay(2); - return 0; - -} - -unsigned char lut_dc_4in2b[] = -{ - 0x00, 0x17, 0x00, 0x00, 0x00, 0x02, 0x00, 0x17, 0x17, 0x00, 0x00, - 0x02, 0x00, 0x0A, 0x01, 0x00, 0x00, 0x01, 0x00, 0x0E, 0x0E, 0x00, - 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -//R21H -unsigned char lut_ww_4in2b[] = -{ - 0x40, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x40, 0x0A, - 0x01, 0x00, 0x00, 0x01, 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -//R22H r -unsigned char lut_bw_4in2b[] = -{ - 0x40, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x40, 0x0A, - 0x01, 0x00, 0x00, 0x01, 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -//R24H b -unsigned char lut_bb_4in2b[] = -{ - 0x80, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x80, 0x0A, - 0x01, 0x00, 0x00, 0x01, 0x50, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -//R23H w -unsigned char lut_wb_4in2b[] = -{ - 0x80, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x80, 0x0A, - 0x01, 0x00, 0x00, 0x01, 0x50, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -int EPD_Init_4in2b() -{ - EPD_Reset(); - EPD_Send_3(0x06,0x17,0x17,0x17);//BOOSTER_SOFT_START - EPD_SendCommand(0x04);//POWER_ON - EPD_WaitUntilIdle(); - EPD_Send_1(0x00, 0x0F);//PANEL_SETTING - EPD_Send_1(0x50,0xF7);// VCOM_AND_DATA_INTERVAL_SETTING - - EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1 - delay(2); - return 0; +/** + ****************************************************************************** + * @file edp4in2.h + * @author Waveshare Team + * @version V1.0.0 + * @date 23-January-2018 + * @brief This file describes initialisation of 4.2 and 4.2b e-Papers + * + ****************************************************************************** + */ + +unsigned char lut_dc_4in2[] = +{ + 0x00, 0x17, 0x00, 0x00, 0x00, 0x02, 0x00, 0x17, 0x17, 0x00, 0x00, + 0x02, 0x00, 0x0A, 0x01, 0x00, 0x00, 0x01, 0x00, 0x0E, 0x0E, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +//R21H +unsigned char lut_ww_4in2[] = +{ + 0x40, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x40, 0x0A, + 0x01, 0x00, 0x00, 0x01, 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +//R22H r +unsigned char lut_bw_4in2[] = +{ + 0x40, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x40, 0x0A, + 0x01, 0x00, 0x00, 0x01, 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +//R24H b +unsigned char lut_bb_4in2[] = +{ + 0x80, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x80, 0x0A, + 0x01, 0x00, 0x00, 0x01, 0x50, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +//R23H w +unsigned char lut_wb_4in2[] = +{ + 0x80, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x80, 0x0A, + 0x01, 0x00, 0x00, 0x01, 0x50, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + + +int EPD_Init_4in2() +{ + EPD_Reset(); + + EPD_SendCommand(0x01);//POWER_SETTING + EPD_SendData(0x03); // VDS_EN, VDG_EN + EPD_SendData(0x00); // VCOM_HV, VGHL_LV[1], VGHL_LV[0] + EPD_SendData(0x2F); // VDH + EPD_SendData(0x2F); // VDL + EPD_SendData(0xFF); // VDHR + + EPD_Send_3(0x06, 0x17, 0x17, 0x17);//BOOSTER_SOFT_START + EPD_SendCommand(0x04);//POWER_ON + EPD_WaitUntilIdle(); + + EPD_Send_2(0x00, 0xBF, 0x0B);//PANEL_SETTING: // KW-BF KWR-AF BWROTP 0f + EPD_Send_1(0x30, 0x3C);//PLL_CONTROL: 3A 100HZ, 29 150Hz, 39 200HZ, 31 171HZ + + EPD_Send_4(0x61, 1, 144, 1, 44);// RESOLUTION_SETTING: HI(W), LO(W), HI(H), LO(H) + EPD_Send_1(0x82, 0x12);// VCM_DC_SETTING + EPD_Send_1(0x50, 0x97);// VCOM_AND_DATA_INTERVAL_SETTING: VBDF 17|D7 VBDW 97 VBDB 57 VBDF F7 VBDW 77 VBDB 37 VBDR B7 + + EPD_lut(0x20,44,&lut_dc_4in2[0]);// LUT_FOR_VCOM + EPD_lut(0x21,42,&lut_ww_4in2[0]);// LUT_WHITE_TO_WHITE + EPD_lut(0x22,42,&lut_bw_4in2[0]);// LUT_BLACK_TO_WHITE + EPD_lut(0x23,42,&lut_wb_4in2[0]);// LUT_WHITE_TO_BLACK + EPD_lut(0x24,42,&lut_bb_4in2[0]);// LUT_BLACK_TO_BLACK + + EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1 + delay(2); + for(int i = 0; i < 400*300; i++)EPD_SendData(0xFF);//Red channel + + EPD_SendCommand(0x13);//DATA_START_TRANSMISSION_2 + delay(2); + return 0; + +} + +unsigned char lut_dc_4in2b[] = +{ + 0x00, 0x17, 0x00, 0x00, 0x00, 0x02, 0x00, 0x17, 0x17, 0x00, 0x00, + 0x02, 0x00, 0x0A, 0x01, 0x00, 0x00, 0x01, 0x00, 0x0E, 0x0E, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +//R21H +unsigned char lut_ww_4in2b[] = +{ + 0x40, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x40, 0x0A, + 0x01, 0x00, 0x00, 0x01, 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +//R22H r +unsigned char lut_bw_4in2b[] = +{ + 0x40, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x40, 0x0A, + 0x01, 0x00, 0x00, 0x01, 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +//R24H b +unsigned char lut_bb_4in2b[] = +{ + 0x80, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x80, 0x0A, + 0x01, 0x00, 0x00, 0x01, 0x50, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +//R23H w +unsigned char lut_wb_4in2b[] = +{ + 0x80, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x80, 0x0A, + 0x01, 0x00, 0x00, 0x01, 0x50, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +int EPD_Init_4in2b() +{ + EPD_Reset(); + EPD_Send_3(0x06,0x17,0x17,0x17);//BOOSTER_SOFT_START + EPD_SendCommand(0x04);//POWER_ON + EPD_WaitUntilIdle(); + EPD_Send_1(0x00, 0x0F);//PANEL_SETTING + EPD_Send_1(0x50,0xF7);// VCOM_AND_DATA_INTERVAL_SETTING + + EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1 + delay(2); + return 0; } diff --git a/epd5in65f.h b/epd5in65f.h new file mode 100644 index 0000000..62f131a --- /dev/null +++ b/epd5in65f.h @@ -0,0 +1,96 @@ +/** + ****************************************************************************** + * @file edp5in65.h + * @author Waveshare Team + * @version V1.0.0 + * @date 27-July-2020 + * @brief This file describes initialisation of 5.65f e-Papers + * + ****************************************************************************** + */ + +/***************************************************************************** + EPD_5IN65F +******************************************************************************/ + +static void EPD_5IN65F_BusyHigh(void)// If BUSYN=0 then waiting +{ + Serial.print("\r\ne-Paper busy\r\n"); + while(!(digitalRead(BUSY_PIN))) + delay(100); + Serial.print("e-Paper busy release\r\n"); +} + +static void EPD_5IN65F_BusyLow(void)// If BUSYN=1 then waiting +{ + Serial.print("\r\ne-Paper busy\r\n"); + while(digitalRead(BUSY_PIN)) + delay(100); + Serial.print("e-Paper busy release\r\n"); +} + +static void EPD_5IN65F_Show(void) +{ + EPD_SendCommand(0x04);//0x04 + EPD_5IN65F_BusyHigh(); + EPD_SendCommand(0x12);//0x12 + EPD_5IN65F_BusyHigh(); + EPD_SendCommand(0x02);//0x02 + EPD_5IN65F_BusyLow(); + delay(200); + Serial.print("EPD_5IN65F_Show END\r\n"); + + delay(100); + EPD_SendCommand(0x07);//sleep + EPD_SendData(0xA5); + delay(100); +} + +int EPD_5IN65F_init() +{ + EPD_Reset(); + + EPD_5IN65F_BusyHigh(); + EPD_SendCommand(0x00); + EPD_SendData(0xEF); + EPD_SendData(0x08); + EPD_SendCommand(0x01); + EPD_SendData(0x37); + EPD_SendData(0x00); + EPD_SendData(0x23); + EPD_SendData(0x23); + EPD_SendCommand(0x03); + EPD_SendData(0x00); + EPD_SendCommand(0x06); + EPD_SendData(0xC7); + EPD_SendData(0xC7); + EPD_SendData(0x1D); + EPD_SendCommand(0x30); + EPD_SendData(0x3C); + EPD_SendCommand(0x40); + EPD_SendData(0x00); + EPD_SendCommand(0x50); + EPD_SendData(0x37); + EPD_SendCommand(0x60); + EPD_SendData(0x22); + EPD_SendCommand(0x61); + EPD_SendData(0x02); + EPD_SendData(0x58); + EPD_SendData(0x01); + EPD_SendData(0xC0); + EPD_SendCommand(0xE3); + EPD_SendData(0xAA); + + delay(100); + EPD_SendCommand(0x50); + EPD_SendData(0x37); + + EPD_SendCommand(0x61);//Set Resolution setting + EPD_SendData(0x02); + EPD_SendData(0x58); + EPD_SendData(0x01); + EPD_SendData(0xC0); + EPD_SendCommand(0x10);//begin write data to e-Paper + + return 0; +} diff --git a/epd5in83.h b/epd5in83.h index ad0699f..e7d8d70 100644 --- a/epd5in83.h +++ b/epd5in83.h @@ -1,50 +1,67 @@ -/** - ****************************************************************************** - * @file edp5in83.h - * @author Waveshare Team - * @version V1.0.0 - * @date 8-September-2018 - * @brief This file describes initialisation of 5.83, 5.83b, 5.83c e-Papers - * - ****************************************************************************** - */ - -int EPD_5in83__init() -{ - EPD_Reset(); - EPD_Send_2(0x01, 0x37, 0x00); // POWER_SETTING - EPD_Send_2(0x00, 0xCF, 0x08); // PANEL_SETTING - EPD_Send_3(0x06, 0xC7, 0xCC, 0x28); // BOOSTER_SOFT_START - EPD_SendCommand(0x4); // POWER_ON - EPD_WaitUntilIdle(); - EPD_Send_1(0x30, 0x3C); // PLL_CONTROL - EPD_Send_1(0x41, 0x00); // TEMPERATURE_CALIBRATION - EPD_Send_1(0x50, 0x77); // VCOM_AND_DATA_INTERVAL_SETTING - EPD_Send_1(0x60, 0x22); // TCON_SETTING - EPD_Send_4(0x61, 0x02, 0x58, 0x01, 0xC0);// TCON_RESOLUTION - EPD_Send_1(0x82, 0x1E); // VCM_DC_SETTING: decide by LUT file - EPD_Send_1(0xE5, 0x03); // FLASH MODE - EPD_SendCommand(0x10); // DATA_START_TRANSMISSION_1 - delay(2); - return 0; -} - -int EPD_5in83b__init() -{ - EPD_Reset(); - EPD_Send_2(0x01, 0x37, 0x00); // POWER_SETTING - EPD_Send_2(0x00, 0xCF, 0x08); // PANEL_SETTING - EPD_Send_3(0x06, 0xC7, 0xCC, 0x28); // BOOSTER_SOFT_START - EPD_SendCommand(0x4); // POWER_ON - EPD_WaitUntilIdle(); - EPD_Send_1(0x30, 0x3A); // PLL_CONTROL - EPD_Send_1(0x41, 0x00); // TEMPERATURE_CALIBRATION - EPD_Send_1(0x50, 0x77); // VCOM_AND_DATA_INTERVAL_SETTING - EPD_Send_1(0x60, 0x22); // TCON_SETTING - EPD_Send_4(0x61, 0x02, 0x58, 0x01, 0xC0);// TCON_RESOLUTION - EPD_Send_1(0x82, 0x20); // VCM_DC_SETTING: decide by LUT file - EPD_Send_1(0xE5, 0x03); // FLASH MODE - EPD_SendCommand(0x10); // DATA_START_TRANSMISSION_1 - delay(2); - return 0; +/** + ****************************************************************************** + * @file edp5in83.h + * @author Waveshare Team + * @version V1.0.0 + * @date 8-September-2018 + * @brief This file describes initialisation of 5.83, 5.83b, 5.83c e-Papers + * + ****************************************************************************** + */ + +int EPD_5in83__init() +{ + EPD_Reset(); + EPD_Send_2(0x01, 0x37, 0x00); // POWER_SETTING + EPD_Send_2(0x00, 0xCF, 0x08); // PANEL_SETTING + EPD_Send_3(0x06, 0xC7, 0xCC, 0x28); // BOOSTER_SOFT_START + EPD_SendCommand(0x4); // POWER_ON + EPD_WaitUntilIdle(); + EPD_Send_1(0x30, 0x3C); // PLL_CONTROL + EPD_Send_1(0x41, 0x00); // TEMPERATURE_CALIBRATION + EPD_Send_1(0x50, 0x77); // VCOM_AND_DATA_INTERVAL_SETTING + EPD_Send_1(0x60, 0x22); // TCON_SETTING + EPD_Send_4(0x61, 0x02, 0x58, 0x01, 0xC0);// TCON_RESOLUTION + EPD_Send_1(0x82, 0x1E); // VCM_DC_SETTING: decide by LUT file + EPD_Send_1(0xE5, 0x03); // FLASH MODE + EPD_SendCommand(0x10); // DATA_START_TRANSMISSION_1 + delay(2); + return 0; +} + +int EPD_5in83b__init() +{ + EPD_Reset(); + EPD_Send_2(0x01, 0x37, 0x00); // POWER_SETTING + EPD_Send_2(0x00, 0xCF, 0x08); // PANEL_SETTING + EPD_Send_3(0x06, 0xC7, 0xCC, 0x28); // BOOSTER_SOFT_START + EPD_SendCommand(0x4); // POWER_ON + EPD_WaitUntilIdle(); + EPD_Send_1(0x30, 0x3A); // PLL_CONTROL + EPD_Send_1(0x41, 0x00); // TEMPERATURE_CALIBRATION + EPD_Send_1(0x50, 0x77); // VCOM_AND_DATA_INTERVAL_SETTING + EPD_Send_1(0x60, 0x22); // TCON_SETTING + EPD_Send_4(0x61, 0x02, 0x58, 0x01, 0xC0);// TCON_RESOLUTION + EPD_Send_1(0x82, 0x20); // VCM_DC_SETTING: decide by LUT file + EPD_Send_1(0xE5, 0x03); // FLASH MODE + EPD_SendCommand(0x10); // DATA_START_TRANSMISSION_1 + delay(2); + return 0; +} + +int EPD_5in83b_V2_init() +{ + EPD_Reset(); + EPD_Send_4(0x01, 0x07, 0x07, 0x3f, 0x3f); //POWER SETTING + EPD_SendCommand(0x04); //POWER ON + delay(100); + EPD_WaitUntilIdle(); //waiting for the electronic paper IC to release the idle signal + EPD_Send_1(0X00, 0x0F); //PANNEL SETTING + EPD_Send_4(0x61, 0x02, 0x88, 0x01, 0xe0); //tres + EPD_Send_1(0X15, 0x00); + EPD_Send_2(0X50, 0x11, 0x07); //VCOM AND DATA INTERVAL SETTING + EPD_Send_1(0X60, 0x22); //TCON SETTING + EPD_SendCommand(0x10); // DATA_START_TRANSMISSION_1 + delay(2); + return 0; } diff --git a/epd7in5_HD.h b/epd7in5_HD.h new file mode 100644 index 0000000..cba659e --- /dev/null +++ b/epd7in5_HD.h @@ -0,0 +1,189 @@ +/** + ****************************************************************************** + * @file edp7in5_HD.h + * @author Waveshare Team + * @version V1.0.0 + * @date 23-January-2018 + * @brief This file describes initialisation of 7.5 HD and 7.5b HD e-Papers + * + ****************************************************************************** + */ + + +void EPD_7IN5_HD_Readbusy(void) +{ + Serial.print("\r\ne-Paper busy\r\n"); + delay(200); + unsigned char busy; + do{ + delay(100); + busy = digitalRead(BUSY_PIN); + }while(busy); + delay(200); + Serial.print("e-Paper busy release\r\n"); +} + + +/***************************************************************************** + EPD_7IN5_HD +******************************************************************************/ + +static void EPD_7IN5_HD_Show(void) +{ + unsigned int i; + EPD_SendCommand(0x26); + for(i=0; i<880*528/8; i++) { + EPD_SendData(0xff); + } + EPD_SendCommand(0x22); + EPD_SendData(0xF7); + EPD_SendCommand(0x20); + delay(200); + EPD_7IN5_HD_Readbusy(); + Serial.print("EPD_7IN5_HD_Show END\r\n"); +} + +int EPD_7IN5_HD_init() +{ + EPD_Reset(); + + EPD_SendCommand(0x12); //SWRESET + EPD_7IN5_HD_Readbusy(); //waiting for the electronic paper IC to release the idle signal + + EPD_SendCommand(0x46); // Auto Write RAM + EPD_SendData(0xF7); + EPD_7IN5_HD_Readbusy(); //waiting for the electronic paper IC to release the idle signal + + EPD_SendCommand(0x47); // Auto Write RAM + EPD_SendData(0xF7); + EPD_7IN5_HD_Readbusy(); //waiting for the electronic paper IC to release the idle signal + + EPD_SendCommand(0x0C); // Soft start setting + EPD_SendData(0xAE); + EPD_SendData(0xC7); + EPD_SendData(0xC3); + EPD_SendData(0xC0); + EPD_SendData(0x40); + + EPD_SendCommand(0x01); // Set MUX as 527 + EPD_SendData(0xAF); + EPD_SendData(0x02); + EPD_SendData(0x01); + + EPD_SendCommand(0x11); // Data entry mode + EPD_SendData(0x01); + + EPD_SendCommand(0x44); + EPD_SendData(0x00); // RAM x address start at 0 + EPD_SendData(0x00); + EPD_SendData(0x6F); // RAM x address end at 36Fh -> 879 + EPD_SendData(0x03); + EPD_SendCommand(0x45); + EPD_SendData(0xAF); // RAM y address start at 20Fh; + EPD_SendData(0x02); + EPD_SendData(0x00); // RAM y address end at 00h; + EPD_SendData(0x00); + + EPD_SendCommand(0x3C); // VBD + EPD_SendData(0x01); // LUT1, for white + + EPD_SendCommand(0x18); + EPD_SendData(0X80); + EPD_SendCommand(0x22); + EPD_SendData(0XB1); //Load Temperature and waveform setting. + EPD_SendCommand(0x20); + EPD_7IN5_HD_Readbusy(); //waiting for the electronic paper IC to release the idle signal + + EPD_SendCommand(0x4E); + EPD_SendData(0x00); + EPD_SendData(0x00); + EPD_SendCommand(0x4F); + EPD_SendData(0x00); + EPD_SendData(0x00); + + EPD_SendCommand(0x4F); + EPD_SendData(0x00); + EPD_SendData(0x00); + EPD_SendCommand(0x24);//BLOCK + return 0; +} + +/***************************************************************************** + EPD_7IN5B_HD +******************************************************************************/ + + +static void EPD_7IN5B_HD_Show(void) +{ + EPD_SendCommand(0x22); + EPD_SendData(0xC7); + EPD_SendCommand(0x20); + delay(200); + EPD_7IN5_HD_Readbusy(); + Serial.print("EPD_7IN5B_HD_Show END\r\n"); +} + +int EPD_7IN5B_HD_init() +{ + EPD_Reset(); + + EPD_SendCommand(0x12); //SWRESET + EPD_7IN5_HD_Readbusy(); //waiting for the electronic paper IC to release the idle signal + + EPD_SendCommand(0x46); // Auto Write RAM + EPD_SendData(0xF7); + EPD_7IN5_HD_Readbusy(); //waiting for the electronic paper IC to release the idle signal + + EPD_SendCommand(0x47); // Auto Write RAM + EPD_SendData(0xF7); + EPD_7IN5_HD_Readbusy(); //waiting for the electronic paper IC to release the idle signal + + EPD_SendCommand(0x0C); // Soft start setting + EPD_SendData(0xAE); + EPD_SendData(0xC7); + EPD_SendData(0xC3); + EPD_SendData(0xC0); + EPD_SendData(0x40); + + EPD_SendCommand(0x01); // Set MUX as 527 + EPD_SendData(0xAF); + EPD_SendData(0x02); + EPD_SendData(0x01); + + EPD_SendCommand(0x11); // Data entry mode + EPD_SendData(0x01); + + EPD_SendCommand(0x44); + EPD_SendData(0x00); // RAM x address start at 0 + EPD_SendData(0x00); + EPD_SendData(0x6F); // RAM x address end at 36Fh -> 879 + EPD_SendData(0x03); + EPD_SendCommand(0x45); + EPD_SendData(0xAF); // RAM y address start at 20Fh; + EPD_SendData(0x02); + EPD_SendData(0x00); // RAM y address end at 00h; + EPD_SendData(0x00); + + EPD_SendCommand(0x3C); // VBD + EPD_SendData(0x01); // LUT1, for white + + EPD_SendCommand(0x18); + EPD_SendData(0X80); + EPD_SendCommand(0x22); + EPD_SendData(0XB1); //Load Temperature and waveform setting. + EPD_SendCommand(0x20); + EPD_7IN5_HD_Readbusy(); //waiting for the electronic paper IC to release the idle signal + + EPD_SendCommand(0x4E); + EPD_SendData(0x00); + EPD_SendData(0x00); + EPD_SendCommand(0x4F); + EPD_SendData(0xAF); + EPD_SendData(0x02); + + EPD_SendCommand(0x4F); + EPD_SendData(0xAf); + EPD_SendData(0x02); + EPD_SendCommand(0x24);//BLOCK + return 0; +} diff --git a/html.h b/html.h index 22d26cb..a06c6a5 100644 --- a/html.h +++ b/html.h @@ -1,75 +1,76 @@ -/** - ****************************************************************************** - * @file html.h - * @author Waveshare Team - * @version V1.0.0 - * @date 23-January-2018 - * @brief This file describes the sending of HTML-page to a client - * - ****************************************************************************** - */ -extern ESP8266WebServer server; -extern IPAddress myIP; - -void handleRoot() -{ -server.send(200, "text/html", -"\r\n" -"\r\n" -"\r\n" -"\r\n" -"PriceTag\r\n" -"\r\n" -"\r\n" -"\r\n" -"\r\n" -"\r\n" -"\r\n" -"\r\n" -"
\r\n" -"
\r\n" -"
\r\n" -"
\r\n" -"
\r\n" -"\r\n" -"\r\n" -"\r\n" -"\r\n" -"\r\n" -"\r\n" -"\r\n" -"\r\n" -"
\r\n" -"Original image
\r\n" -"\r\n" -"
\r\n" -"
\r\n" -"
Drop image here...
\r\n" -"
\r\n" -"
\r\n" -"
\r\n" -"
\r\n" -"
\r\n" -"
\r\n" -"\r\n" -"\r\n" -"\r\n"); +/** + ****************************************************************************** + * @file html.h + * @author Waveshare Team + * @version V1.0.0 + * @date 23-January-2018 + * @brief This file describes the sending of HTML-page to a client + * + ****************************************************************************** + */ +extern ESP8266WebServer server; +extern IPAddress myIP; + +void handleRoot() +{ +server.send(200, "text/html", +"\r\n" +"\r\n" +"\r\n" +"\r\n" +"\r\n" +"PriceTag\r\n" +"\r\n" +"\r\n" +"\r\n" +"\r\n" +"\r\n" +"\r\n" +"\r\n" +"
\r\n" +"
\r\n" +"
\r\n" +"
\r\n" +"
\r\n" +"\r\n" +"\r\n" +"\r\n" +"\r\n" +"\r\n" +"\r\n" +"\r\n" +"\r\n" +"
\r\n" +"Original image
\r\n" +"\r\n" +"
\r\n" +"
\r\n" +"
Drop image here...
\r\n" +"
\r\n" +"
\r\n" +"
\r\n" +"
\r\n" +"
\r\n" +"
\r\n" +"\r\n" +"\r\n" +"\r\n"); } diff --git a/scripts.h b/scripts.h index 87a2139..a275644 100644 --- a/scripts.h +++ b/scripts.h @@ -1,463 +1,509 @@ -/** - ****************************************************************************** - * @file scripts.h - * @author Waveshare Team - * @version V1.0.0 - * @date 23-January-2018 - * @brief This file describes the sending of JavaScript codes to a client - * - ****************************************************************************** - */ -extern ESP8266WebServer server; -void sendJS_A() -{ -server.send(200, "text/javascript", -"var srcBox,srcImg,dstImg;\r\n" -"var epdArr,epdInd,palArr;\r\n" -"var curPal;\r\n" -"function getElm(n){return document.getElementById(n);}\r\n" -"function setInn(n,i){ document.getElementById(n).innerHTML=i;}\r\n" - -"function processFiles(files){\r\n" - "var file=files[0];\r\n" - "var reader=new FileReader();\r\n" - "srcImg=new Image();\r\n" - "reader.onload=function(e){\r\n" - "setInn('srcBox','');\r\n" - "var img=getElm('imgView');\r\n" - "img.src=e.target.result;\r\n" - "srcImg.src=e.target.result;\r\n" - "};\r\n" - - "reader.readAsDataURL(file);\r\n" -"}\r\n" -//------------------------------------------- -"function drop(e){\r\n" - "e.stopPropagation();\r\n" - "e.preventDefault();\r\n" - "var files=e.dataTransfer.files;\r\n" - "processFiles(files);\r\n" -"}\r\n" -//------------------------------------------- -"function ignoreDrag(e){\r\n" - "e.stopPropagation();\r\n" - "e.preventDefault();\r\n" -"}\r\n" -//------------------------------------------- -"function getNud(nm,vl){\r\n" - "return ''+nm+':'+\r\n" - "'';\r\n" -"}\r\n" -//------------------------------------------- -"function Btn(nm,tx,fn){\r\n" - "return '
'+\r\n" - "'
';\r\n" -"}\r\n" -//------------------------------------------- -"function RB(vl,tx){\r\n" - "return ''+tx;\r\n" -"}\r\n" -//------------------------------------------- -"window.onload = function(){\r\n" - "srcBox = getElm('srcBox');\r\n" - "srcBox.ondragenter=ignoreDrag;\r\n" - "srcBox.ondragover=ignoreDrag;\r\n" - "srcBox.ondrop=drop;\r\n" - "srcImg=0;\r\n" - "epdInd=0;\r\n" - -"palArr=[[[0,0,0],[255,255,255]],\r\n" -"[[0,0,0],[255,255,255],[127,0,0]],\r\n" -"[[0,0,0],[255,255,255],[127,127,127]],\r\n" -"[[0,0,0],[255,255,255],[127,127,127],[127,0,0]],\r\n" -"[[0,0,0],[255,255,255]],\r\n" -"[[0,0,0],[255,255,255],[220,180,0]]];\r\n" - -"epdArr=[[200,200,0],[200,200,3],[152,152,5],\r\n" -"[122,250,0],[104,212,1],[104,212,5],[104,212,0],\r\n" -"[176,264,0],[176,264,1],\r\n" -"[128,296,0],[128,296,1],[128,296,5],[128,296,0],\r\n" -"[400,300,0],[400,300,1],[400,300,5],\r\n" -"[600,448,0],[600,448,1],[600,448,5],\r\n" -"[640,384,0],[640,384,1],[640,384,5],\r\n" -"[800,480,0],[800,480,1]];\r\n" - -"setInn('BT',\r\n" -"Btn(0,'Select image file','processFiles(this.files);')+\r\n" -"Btn(1,'Level: mono','procImg(true,false);')+\r\n" -"Btn(2,'Level: color','procImg(true,true);')+\r\n" -"Btn(3,'Dithering: mono','procImg(false,false);')+\r\n" -"Btn(4,'Dithering: color','procImg(false,true);')+\r\n" -"Btn(5,'Upload image','uploadImage();'));\r\n" - -"setInn('XY',getNud('x','0')+getNud('y','0'));\r\n" -"setInn('WH',getNud('w','200')+getNud('h','200'));\r\n" - -"setInn('RB',RB(0,'1.54 ')+RB(1,'1.54b')+RB(2,'1.54c')+\r\n" -"RB(3,'2.13 ')+RB(4,'2.13b')+RB(5,'2.13c
')+RB(6,'2.13d
')+\r\n" -"RB(7,'2.7  ')+RB(8,'2.7b 
')+\r\n" -"RB(9,'2.9  ')+RB(10,'2.9b ')+RB(11,'2.9c 
')+RB(12,'2.9d
')+\r\n" -"RB(13,'4.2  ')+RB(14,'4.2b ')+RB(15,'4.2c 
')+\r\n" -"RB(16,'5.83 ')+RB(17,'5.83b')+RB(18,'5.83c
')+\r\n" -"RB(19,'7.5  ')+RB(20,'7.5b ')+RB(21,'7.5c 
')+\r\n" -"RB(22,'7.5 V2')+RB(23,'7.5b V2
'));\r\n" -"}\r\n" -//------------------------------------------- -"function rbClick(index){\r\n" - "getElm('nud_w').value=""+epdArr[index][0];\r\n" - "getElm('nud_h').value=""+epdArr[index][1];\r\n" - "epdInd=index;\r\n" -"}\r\n"); -} - -void sendJS_B() -{ -server.send(200, "text/javascript", -"var source;\r\n" -"var dX, dY, dW, dH, sW, sH;\r\n" -//------------------------------------------- -"function getVal(p, i){\r\n" - "if((p.data[i]==0x00) && (p.data[i+1]==0x00))return 0;\r\n" - "if((p.data[i]==0xFF) && (p.data[i+1]==0xFF))return 1;\r\n" - "if((p.data[i]==0x7F) && (p.data[i+1]==0x7F))return 2;\r\n" - "return 3;\r\n" -"}\r\n" -//------------------------------------------- -"function setVal(p,i,c){\r\n" - "p.data[i]=curPal[c][0];\r\n" - "p.data[i+1]=curPal[c][1];\r\n" - "p.data[i+2]=curPal[c][2];\r\n" - "p.data[i+3]=255;\r\n" -"}\r\n" -//------------------------------------------- -"function addVal(c,r,g,b,k){\r\n" - "return[c[0]+(r*k)/32,c[1]+(g*k)/32,c[2]+(b*k)/32];\r\n" -"}\r\n" -//------------------------------------------- -"function getErr(r,g,b,stdCol){\r\n" - "r-=stdCol[0];\r\n" - "g-=stdCol[1];\r\n" - "b-=stdCol[2];\r\n" - "return r*r + g*g + b*b;\r\n" -"}\r\n" -//------------------------------------------- -"function getNear(r,g,b){\r\n" - "var ind=0;\r\n" - "var err=getErr(r,g,b,curPal[0]);\r\n" - "for (var i=1;iProcessed image
';\r\n" - "var canvas=getElm('canvas');\r\n" - "sW=srcImg.width;\r\n" - "sH=srcImg.height;\r\n" - "source=getElm('source');\r\n" - "source.width=sW;\r\n" - "source.height=sH;\r\n" - "source.getContext('2d').drawImage(srcImg,0,0,sW,sH);\r\n" - "dX=parseInt(getElm('nud_x').value);\r\n" - "dY=parseInt(getElm('nud_y').value);\r\n" - "dW=parseInt(getElm('nud_w').value);\r\n" - "dH=parseInt(getElm('nud_h').value);\r\n" - - "if((dW<3)||(dH<3)){\r\n" - "alert('Image is too small');\r\n" - "return;\r\n" - "}\r\n" - - "canvas.width=dW;\r\n" - "canvas.height=dH;\r\n" - "var index=0;\r\n" - "var pSrc=source.getContext('2d').getImageData(0,0,sW,sH);\r\n" - "var pDst=canvas.getContext('2d').getImageData(0,0,dW,dH);\r\n" - - "if(isLvl){\r\n" - "for (var j=0;j=sH)){\r\n" - "for (var i=0;i=sW)){\r\n" - "setVal(pDst,index,(i+j)%2==0?1:0);\r\n" - "index+=4;\r\n" - "continue;\r\n" - "}\r\n" - - "var pos=(y*sW+x)*4;\r\n" - "setVal(pDst,index,getNear(pSrc.data[pos],pSrc.data[pos+1],pSrc.data[pos+2]));\r\n" - "index+=4;\r\n" - "}\r\n" - "}\r\n" - "}else{\r\n" - "var aInd=0;\r\n" - "var bInd=1;\r\n" - "var errArr=new Array(2);\r\n" - "errArr[0]=new Array(dW);\r\n" - "errArr[1]=new Array(dW);\r\n" - - "for (var i=0;i=sH)){\r\n" - "for (var i=0;i=sW)){\r\n" - "setVal(pDst,index,(i+j)%2==0?1:0);\r\n" - "index+=4;\r\n" - "continue;\r\n" - "}\r\n" - - "var pos=(y*sW+x)*4;\r\n" - "var old=errArr[aInd][i];\r\n" - "var r=pSrc.data[pos ]+old[0];\r\n" - "var g=pSrc.data[pos+1]+old[1];\r\n" - "var b=pSrc.data[pos+2]+old[2];\r\n" - "var colVal = curPal[getNear(r,g,b)];\r\n" - "pDst.data[index++]=colVal[0];\r\n" - "pDst.data[index++]=colVal[1];\r\n" - "pDst.data[index++]=colVal[2];\r\n" - "pDst.data[index++]=255;\r\n" - "r=(r-colVal[0]);\r\n" - "g=(g-colVal[1]);\r\n" - "b=(b-colVal[2]);\r\n" - - "if (i==0){\r\n" - "errArr[bInd][i ]=addVal(errArr[bInd][i ],r,g,b,7.0);\r\n" - "errArr[bInd][i+1]=addVal(errArr[bInd][i+1],r,g,b,2.0);\r\n" - "errArr[aInd][i+1]=addVal(errArr[aInd][i+1],r,g,b,7.0);\r\n" - "}else if (i==dW-1){\r\n" - "errArr[bInd][i-1]=addVal(errArr[bInd][i-1],r,g,b,7.0);\r\n" - "errArr[bInd][i ]=addVal(errArr[bInd][i ],r,g,b,9.0);\r\n" - "}else{\r\n" - "errArr[bInd][i-1]=addVal(errArr[bInd][i-1],r,g,b,3.0);\r\n" - "errArr[bInd][i ]=addVal(errArr[bInd][i ],r,g,b,5.0);\r\n" - "errArr[bInd][i+1]=addVal(errArr[bInd][i+1],r,g,b,1.0);\r\n" - "errArr[aInd][i+1]=addVal(errArr[aInd][i+1],r,g,b,7.0);\r\n" - "}\r\n" - "}\r\n" - "}\r\n" - "}\r\n" - - "canvas.getContext('2d').putImageData(pDst,0,0);\r\n" -"}\r\n"); -} - -void sendJS_D() -{ -server.send(200, "text/javascript", -"var pxInd,stInd;\r\n" -"var dispW,dispH;\r\n" -"var xhReq,dispX;\r\n" -"var rqPrf,rqMsg;\r\n" - -"var prvPx,prvSt;\r\n" -"function ldPrv(){if(xhReq.status!=200){pxInd=prvPx;stInd=prvSt;}}\r\n" -"function svPrv(){prvPx=pxInd;prvSt=stInd;}\r\n" - -"function byteToStr(v){return String.fromCharCode((v & 0xF) + 97, ((v >> 4) & 0xF) + 97);}\r\n" -"function wordToStr(v){return byteToStr(v&0xFF) + byteToStr((v>>8)&0xFF);}\r\n" -//------------------------------------------- -"function u_send(cmd,next){\r\n" - "xhReq.open('POST',rqPrf+cmd, true);\r\n" - "xhReq.send();\r\n" - "if(next)stInd++;\r\n" - "return 0;\r\n" -"}\r\n" -//------------------------------------------- -"function u_next(){\r\n" - "lnInd=0;\r\n" - "pxInd=0;\r\n" - "u_send('NEXT',true);\r\n" -"}\r\n" -//------------------------------------------- -"function u_done(){\r\n" - "setInn('logTag','Complete!');\r\n" - "return u_send('SHOW',true);\r\n" -"}\r\n" -//------------------------------------------- -"function u_loadA(a,k1,k2){\r\n" - "var x=''+(k1+k2*pxInd/a.length);\r\n" - "if(x.length>5)x=x.substring(0,5);\r\n" - "setInn('logTag','Progress: '+x+'%');\r\n" - "xhReq.open('POST',rqPrf+'LOAD', true);\r\n" - "xhReq.send(rqMsg+wordToStr(rqMsg.length)+'LOAD');\r\n" - "if(pxInd>=a.length)stInd++;\r\n" - "return 0;\r\n" -"}\r\n" -//------------------------------------------- -"function u_loadB(a,k1,k2){\r\n" - "var x=''+(k1+k2*pxInd/a.length);\r\n" - "if(x.length>5)x=x.substring(0,5);\r\n" - "setInn('logTag','Progress: '+x+'%');\r\n" - "xhReq.open('POST',rqPrf+'LOAD', true);\r\n" - "xhReq.send(rqMsg+wordToStr(rqMsg.length)+'LOAD');\r\n" - "if(pxInd>=a.length)stInd++;\r\n" - "return 0;\r\n" -"}\r\n" -//------------------------------------------- -"function u_dataA(a,c,k1,k2)\r\n" -"{\r\n" - "rqMsg='';\r\n" - "svPrv();\r\n" - - "if(c==-1)\r\n" - "{\r\n" - "while((pxInd>i);\r\n" - "pxInd++;\r\n" - "}\r\n" - - "rqMsg += byteToStr(v);\r\n" - "}\r\n" - "}\r\n" - - "return u_loadA(a,k1,k2);\r\n" -"}\r\n" -//------------------------------------------- -"function u_dataB(a,k1,k2){\r\n" - "var x;\r\n" - "rqMsg='';\r\n" - "svPrv();\r\n" - - "while(rqMsg.length<1500)\r\n" - "{\r\n" - "x=0;\r\n" - - "while(x<122)\r\n" - "{\r\n" - "var v=0;\r\n" - "for (var i=0;(i<8)&&(x<122);i++,x++)if(a[pxInd++]!=0)v|=(128>>i);\r\n" - "rqMsg += byteToStr(v);\r\n" - "}\r\n" - "}\r\n" - - "return u_loadB(a,k1,k2);\r\n" -"}\r\n" -//------------------------------------------- -"function uploadImage(){\r\n" - "var c=getElm('canvas');\r\n" - "var w=dispW=c.width;\r\n" - "var h=dispH=c.height;\r\n" - "var p=c.getContext('2d').getImageData(0,0,w,h);\r\n" - "var a=new Array(w*h);\r\n" - "var i=0;\r\n" - "for(var y=0;y15 && epdInd < 22){\r\n" - "xhReq.onload=xhReq.onerror=function(){\r\n" - "ldPrv();\r\n" - "if(stInd==0)return u_dataA(a,-1,0,100);\r\n" - "if(stInd==1)return u_done();\r\n" - "};\r\n" - - "xhReq.open('POST',init, true);\r\n" - "xhReq.send(byteToStr(epdInd));\r\n" - "return 0;\r\n" - "}\r\n" - "else{\r\n" - "xhReq.onload=xhReq.onerror=function(){\r\n" - "ldPrv();\r\n" - "if(stInd==0&&epdInd==23)return u_dataA(a,0,0,100);\r\n" - "if(stInd==0)return u_dataA(a,(epdInd==1)||(epdInd==12)?-1:0,0,50);\r\n" - "if(stInd==1)return u_next();\r\n" - "if(stInd==2)return u_dataA(a,3,50,50);\r\n" - "if(stInd==3)return u_done();\r\n" - " };\r\n" - "xhReq.open('POST',init, true);\r\n" - "xhReq.send(byteToStr(epdInd));\r\n" - "return 0;\r\n" - "}\r\n" -"}\r\n"); -} +/** + ****************************************************************************** + * @file scripts.h + * @author Waveshare Team + * @version V1.0.0 + * @date 23-January-2018 + * @brief This file describes the sending of JavaScript codes to a client + * + ****************************************************************************** + */ +extern ESP8266WebServer server; +void sendJS_A() +{ +server.send(200, "text/javascript", +"var srcBox,srcImg,dstImg;\r\n" +"var epdArr,epdInd,palArr;\r\n" +"var curPal;\r\n" +"function getElm(n){return document.getElementById(n);}\r\n" +"function setInn(n,i){ document.getElementById(n).innerHTML=i;}\r\n" + +"function processFiles(files){\r\n" + "var file=files[0];\r\n" + "var reader=new FileReader();\r\n" + "srcImg=new Image();\r\n" + "reader.onload=function(e){\r\n" + "setInn('srcBox','');\r\n" + "var img=getElm('imgView');\r\n" + "img.src=e.target.result;\r\n" + "srcImg.src=e.target.result;\r\n" + "};\r\n" + + "reader.readAsDataURL(file);\r\n" +"}\r\n" +//------------------------------------------- +"function drop(e){\r\n" + "e.stopPropagation();\r\n" + "e.preventDefault();\r\n" + "var files=e.dataTransfer.files;\r\n" + "processFiles(files);\r\n" +"}\r\n" +//------------------------------------------- +"function ignoreDrag(e){\r\n" + "e.stopPropagation();\r\n" + "e.preventDefault();\r\n" +"}\r\n" +//------------------------------------------- +"function getNud(nm,vl){\r\n" + "return ''+nm+':'+\r\n" + "'';\r\n" +"}\r\n" +//------------------------------------------- +"function Btn(nm,tx,fn){\r\n" + "return '
'+\r\n" + "'
';\r\n" +"}\r\n" +//------------------------------------------- +"function RB(vl,tx){\r\n" + "return ''+tx;\r\n" +"}\r\n" +//------------------------------------------- +"window.onload = function(){\r\n" + "srcBox = getElm('srcBox');\r\n" + "srcBox.ondragenter=ignoreDrag;\r\n" + "srcBox.ondragover=ignoreDrag;\r\n" + "srcBox.ondrop=drop;\r\n" + "srcImg=0;\r\n" + "epdInd=0;\r\n" + +"palArr=[[[0,0,0],[255,255,255]],\r\n" +"[[0,0,0],[255,255,255],[127,0,0]],\r\n" +"[[0,0,0],[255,255,255],[127,127,127]],\r\n" +"[[0,0,0],[255,255,255],[127,127,127],[127,0,0]],\r\n" +"[[0,0,0],[255,255,255]],\r\n" +"[[0,0,0],[255,255,255],[220,180,0]],\r\n" +"[[0,0,0]],\r\n" +"[[0,0,0],[255,255,255],[0,255,0],[0,0,255],[255,0,0],[255,255,0],[255,128,0]]];\r\n"//5.65f 7-color E-Paper + +"epdArr=[[200,200,0],[200,200,3],[152,152,5],\r\n" +"[122,250,0],[104,212,1],[104,212,5],[104,212,0],\r\n" +"[176,264,0],[176,264,1],\r\n" +"[128,296,0],[128,296,1],[128,296,5],[128,296,0],\r\n" +"[400,300,0],[400,300,1],[400,300,5],\r\n" +"[600,448,0],[600,448,1],[600,448,5],\r\n" +"[640,384,0],[640,384,1],[640,384,5],\r\n" +"[800,480,0],[800,480,1],[880,528,1],\r\n" +"[600,448,7],[880,528,0],[280,480,0],\r\n" +"[152,296,0],[648,480,1],[128,296,1],\r\n" +"[200,200,1],[104,214,1]];\r\n" + +"setInn('BT',\r\n" +"Btn(0,'Select image file','processFiles(this.files);')+\r\n" +"Btn(1,'Level: mono','procImg(true,false);')+\r\n" +"Btn(2,'Level: color','procImg(true,true);')+\r\n" +"Btn(3,'Dithering: mono','procImg(false,false);')+\r\n" +"Btn(4,'Dithering: color','procImg(false,true);')+\r\n" +"Btn(5,'Upload image','uploadImage();'));\r\n" + +"setInn('XY',getNud('x','0')+getNud('y','0'));\r\n" +"setInn('WH',getNud('w','200')+getNud('h','200'));\r\n" + +"setInn('RB',RB(0,'1.54 ')+RB(1,'1.54b')+RB(2,'1.54c')+\r\n" +"RB(3,'2.13 ')+RB(4,'2.13b')+RB(5,'2.13c
')+RB(6,'2.13d
')+\r\n" +"RB(7,'2.7  ')+RB(8,'2.7b 
')+\r\n" +"RB(9,'2.9  ')+RB(10,'2.9b ')+RB(11,'2.9c 
')+RB(12,'2.9d
')+\r\n" +"RB(13,'4.2  ')+RB(14,'4.2b ')+RB(15,'4.2c 
')+\r\n" +"RB(16,'5.83 ')+RB(17,'5.83b')+RB(18,'5.83c
')+\r\n" +"RB(19,'7.5  ')+RB(20,'7.5b ')+RB(21,'7.5c 
')+\r\n" +"RB(22,'7.5 V2')+RB(23,'7.5b V2
')+\r\n" +"RB(24,'7.5b HD  ')+\r\n" +"RB(25,'5.65f
') + RB(26,'7.5 HD') + RB(27,'3.7
') + RB(28,'2.66') + RB(29,'5.83b V2
')+\r\n" +"RB(30,'2.9b V2') + RB(31,'1.54b V2
') + RB(32,'2.13b V3'));\r\n" +"}\r\n" +//------------------------------------------- +"function rbClick(index){\r\n" + "getElm('nud_w').value=""+epdArr[index][0];\r\n" + "getElm('nud_h').value=""+epdArr[index][1];\r\n" + "epdInd=index;\r\n" +"}\r\n"); +} + +void sendJS_B() +{ +server.send(200, "text/javascript", +"var source;\r\n" +"var dX, dY, dW, dH, sW, sH;\r\n" +//------------------------------------------- +"function getVal(p, i){\r\n" + "if((p.data[i]==0x00) && (p.data[i+1]==0x00))return 0;\r\n" + "if((p.data[i]==0xFF) && (p.data[i+1]==0xFF))return 1;\r\n" + "if((p.data[i]==0x7F) && (p.data[i+1]==0x7F))return 2;\r\n" + "return 3;\r\n" +"}\r\n" +//------------------------------------------- +"function setVal(p,i,c){\r\n" + "p.data[i]=curPal[c][0];\r\n" + "p.data[i+1]=curPal[c][1];\r\n" + "p.data[i+2]=curPal[c][2];\r\n" + "p.data[i+3]=255;\r\n" +"}\r\n" +//------------------------------------------- +"function getVal_7color(p, i) {\r\n"//for 5.65f E-Paper + "if((p.data[i]==0x00) && (p.data[i+1]==0x00) && (p.data[i+2]==0x00))return 0;\r\n" + "if((p.data[i]==0xFF) && (p.data[i+1]==0xFF) && (p.data[i+2]==0xFF))return 1;\r\n" + "if((p.data[i]==0x00) && (p.data[i+1]==0xFF) && (p.data[i+2]==0x00))return 2;\r\n" + "if((p.data[i]==0x00) && (p.data[i+1]==0x00) && (p.data[i+2]==0xFF))return 3;\r\n" + "if((p.data[i]==0xFF) && (p.data[i+1]==0x00) && (p.data[i+2]==0x00))return 4;\r\n" + "if((p.data[i]==0xFF) && (p.data[i+1]==0xFF) && (p.data[i+2]==0x00))return 5;\r\n" + "if((p.data[i]==0xFF) && (p.data[i+1]==0x80) && (p.data[i+2]==0x00))return 6;\r\n" + "return 7;\r\n" +"}\r\n" +//------------------------------------------- +"function addVal(c,r,g,b,k){\r\n" + "return[c[0]+(r*k)/32,c[1]+(g*k)/32,c[2]+(b*k)/32];\r\n" +"}\r\n" +//------------------------------------------- +"function getErr(r,g,b,stdCol){\r\n" + "r-=stdCol[0];\r\n" + "g-=stdCol[1];\r\n" + "b-=stdCol[2];\r\n" + "return r*r + g*g + b*b;\r\n" +"}\r\n" +//------------------------------------------- +"function getNear(r,g,b){\r\n" + "var ind=0;\r\n" + "var err=getErr(r,g,b,curPal[0]);\r\n" + "for (var i=1;iProcessed image
';\r\n" + "var canvas=getElm('canvas');\r\n" + "sW=srcImg.width;\r\n" + "sH=srcImg.height;\r\n" + "source=getElm('source');\r\n" + "source.width=sW;\r\n" + "source.height=sH;\r\n" + "source.getContext('2d').drawImage(srcImg,0,0,sW,sH);\r\n" + "dX=parseInt(getElm('nud_x').value);\r\n" + "dY=parseInt(getElm('nud_y').value);\r\n" + "dW=parseInt(getElm('nud_w').value);\r\n" + "dH=parseInt(getElm('nud_h').value);\r\n" + + "if((dW<3)||(dH<3)){\r\n" + "alert('Image is too small');\r\n" + "return;\r\n" + "}\r\n" + + "canvas.width=dW;\r\n" + "canvas.height=dH;\r\n" + "var index=0;\r\n" + "var pSrc=source.getContext('2d').getImageData(0,0,sW,sH);\r\n" + "var pDst=canvas.getContext('2d').getImageData(0,0,dW,dH);\r\n" + + "if(isLvl){\r\n" + "for (var j=0;j=sH)){\r\n" + "for (var i=0;i=sW)){\r\n" + "setVal(pDst,index,(i+j)%2==0?1:0);\r\n" + "index+=4;\r\n" + "continue;\r\n" + "}\r\n" + + "var pos=(y*sW+x)*4;\r\n" + "setVal(pDst,index,getNear(pSrc.data[pos],pSrc.data[pos+1],pSrc.data[pos+2]));\r\n" + "index+=4;\r\n" + "}\r\n" + "}\r\n" + "}else{\r\n" + "var aInd=0;\r\n" + "var bInd=1;\r\n" + "var errArr=new Array(2);\r\n" + "errArr[0]=new Array(dW);\r\n" + "errArr[1]=new Array(dW);\r\n" + + "for (var i=0;i=sH)){\r\n" + "for (var i=0;i=sW)){\r\n" + "setVal(pDst,index,(i+j)%2==0?1:0);\r\n" + "index+=4;\r\n" + "continue;\r\n" + "}\r\n" + + "var pos=(y*sW+x)*4;\r\n" + "var old=errArr[aInd][i];\r\n" + "var r=pSrc.data[pos ]+old[0];\r\n" + "var g=pSrc.data[pos+1]+old[1];\r\n" + "var b=pSrc.data[pos+2]+old[2];\r\n" + "var colVal = curPal[getNear(r,g,b)];\r\n" + "pDst.data[index++]=colVal[0];\r\n" + "pDst.data[index++]=colVal[1];\r\n" + "pDst.data[index++]=colVal[2];\r\n" + "pDst.data[index++]=255;\r\n" + "r=(r-colVal[0]);\r\n" + "g=(g-colVal[1]);\r\n" + "b=(b-colVal[2]);\r\n" + + "if (i==0){\r\n" + "errArr[bInd][i ]=addVal(errArr[bInd][i ],r,g,b,7.0);\r\n" + "errArr[bInd][i+1]=addVal(errArr[bInd][i+1],r,g,b,2.0);\r\n" + "errArr[aInd][i+1]=addVal(errArr[aInd][i+1],r,g,b,7.0);\r\n" + "}else if (i==dW-1){\r\n" + "errArr[bInd][i-1]=addVal(errArr[bInd][i-1],r,g,b,7.0);\r\n" + "errArr[bInd][i ]=addVal(errArr[bInd][i ],r,g,b,9.0);\r\n" + "}else{\r\n" + "errArr[bInd][i-1]=addVal(errArr[bInd][i-1],r,g,b,3.0);\r\n" + "errArr[bInd][i ]=addVal(errArr[bInd][i ],r,g,b,5.0);\r\n" + "errArr[bInd][i+1]=addVal(errArr[bInd][i+1],r,g,b,1.0);\r\n" + "errArr[aInd][i+1]=addVal(errArr[aInd][i+1],r,g,b,7.0);\r\n" + "}\r\n" + "}\r\n" + "}\r\n" + "}\r\n" + + "canvas.getContext('2d').putImageData(pDst,0,0);\r\n" +"}\r\n"); +} + +void sendJS_D() +{ +server.send(200, "text/javascript", +"var pxInd,stInd;\r\n" +"var dispW,dispH;\r\n" +"var xhReq,dispX;\r\n" +"var rqPrf,rqMsg;\r\n" + +"var prvPx,prvSt;\r\n" +"function ldPrv(){if(xhReq.status!=200){pxInd=prvPx;stInd=prvSt;}}\r\n" +"function svPrv(){prvPx=pxInd;prvSt=stInd;}\r\n" + +"function byteToStr(v){return String.fromCharCode((v & 0xF) + 97, ((v >> 4) & 0xF) + 97);}\r\n" +"function wordToStr(v){return byteToStr(v&0xFF) + byteToStr((v>>8)&0xFF);}\r\n" +//------------------------------------------- +"function u_send(cmd,next){\r\n" + "xhReq.open('POST',rqPrf+cmd, true);\r\n" + "xhReq.send();\r\n" + "if(next)stInd++;\r\n" + "return 0;\r\n" +"}\r\n" +//------------------------------------------- +"function u_next(){\r\n" + "lnInd=0;\r\n" + "pxInd=0;\r\n" + "u_send('NEXT',true);\r\n" +"}\r\n" +//------------------------------------------- +"function u_done(){\r\n" + "setInn('logTag','Complete!');\r\n" + "return u_send('SHOW',true);\r\n" +"}\r\n" +//------------------------------------------- +"function u_loadA(a,k1,k2){\r\n" + "var x=''+(k1+k2*pxInd/a.length);\r\n" + "if(x.length>5)x=x.substring(0,5);\r\n" + "setInn('logTag','Progress: '+x+'%');\r\n" + "xhReq.open('POST',rqPrf+'LOAD', true);\r\n" + "xhReq.send(rqMsg+wordToStr(rqMsg.length)+'LOAD');\r\n" + "if(pxInd>=a.length)stInd++;\r\n" + "return 0;\r\n" +"}\r\n" +//------------------------------------------- +"function u_loadB(a,k1,k2){\r\n" + "var x=''+(k1+k2*pxInd/a.length);\r\n" + "if(x.length>5)x=x.substring(0,5);\r\n" + "setInn('logTag','Progress: '+x+'%');\r\n" + "xhReq.open('POST',rqPrf+'LOAD', true);\r\n" + "xhReq.send(rqMsg+wordToStr(rqMsg.length)+'LOAD');\r\n" + "if(pxInd>=a.length)stInd++;\r\n" + "return 0;\r\n" +"}\r\n" +//------------------------------------------- +"function u_dataA(a,c,k1,k2)\r\n" +"{\r\n" + "rqMsg='';\r\n" + "svPrv();\r\n" + + "if(c==-1)\r\n" + "{\r\n" + "while((pxInd>i);\r\n" + "pxInd++;\r\n" + "}\r\n" + + "rqMsg += byteToStr(v);\r\n" + "}\r\n" + "}\r\n" + + "return u_loadA(a,k1,k2);\r\n" +"}\r\n" +//------------------------------------------- +"function u_dataB(a,k1,k2){\r\n" + "var x;\r\n" + "rqMsg='';\r\n" + "svPrv();\r\n" + + "while(rqMsg.length<1500)\r\n" + "{\r\n" + "x=0;\r\n" + + "while(x<122)\r\n" + "{\r\n" + "var v=0;\r\n" + "for (var i=0;(i<8)&&(x<122);i++,x++)if(a[pxInd++]!=0)v|=(128>>i);\r\n" + "rqMsg += byteToStr(v);\r\n" + "}\r\n" + "}\r\n" + + "return u_loadB(a,k1,k2);\r\n" +"}\r\n" +//------------------------------------------- +"function uploadImage(){\r\n" + "var c=getElm('canvas');\r\n" + "var w=dispW=c.width;\r\n" + "var h=dispH=c.height;\r\n" + "var p=c.getContext('2d').getImageData(0,0,w,h);\r\n" + "var a=new Array(w*h);\r\n" + "var i=0;\r\n" + "for(var y=0;y15 && epdInd < 22){\r\n" + "xhReq.onload=xhReq.onerror=function(){\r\n" + "ldPrv();\r\n" + "if(stInd==0)return u_dataA(a,-1,0,100);\r\n" + "if(stInd==1)return u_done();\r\n" + "};\r\n" + + "xhReq.open('POST',init, true);\r\n" + "xhReq.send(byteToStr(epdInd));\r\n" + "return 0;\r\n" + "}\r\n" + "if (epdInd == 25)\r\n" + "{\r\n" + "xhReq.onload=xhReq.onerror=function()\r\n" + "{\r\n" + "ldPrv();\r\n" + "if(stInd==0)return u_dataA(a,-2,0,100);\r\n" + "if(stInd==1)return u_done();\r\n" + "};\r\n" + "xhReq.open('POST',init, true);\r\n" + "xhReq.send(byteToStr(epdInd));\r\n" + "return 0;\r\n" + "}\r\n" + "else{\r\n" + "xhReq.onload=xhReq.onerror=function(){\r\n" + "ldPrv();\r\n" + "if(stInd==0&&epdInd==23)return u_dataA(a,0,0,100);\r\n" + "if(stInd==0)return u_dataA(a,(epdInd==1)||(epdInd==12)?-1:0,0,50);\r\n" + "if(stInd==1)return u_next();\r\n" + "if(stInd==2)return u_dataA(a,3,50,50);\r\n" + "if(stInd==3)return u_done();\r\n" + " };\r\n" + "xhReq.open('POST',init, true);\r\n" + "xhReq.send(byteToStr(epdInd));\r\n" + "return 0;\r\n" + "}\r\n" +"}\r\n"); +}