EPD display library.

Dependents:   acd52832_ePaper acd52832_SAADC_Differential_input_2 acd52832_SAADC_Differential_input_EPD acd52832_Car_battery_ch ... more

Fork of GDEP015OC1 by aconno dev team

Revision:
12:55f053e7f087
Parent:
11:9cf09f5a693a
Child:
16:637e8c66dee6
--- a/GDEP015OC1.cpp	Mon Mar 13 11:36:44 2017 +0000
+++ b/GDEP015OC1.cpp	Thu Jun 29 09:36:04 2017 +0000
@@ -28,6 +28,7 @@
     _cs = _dc = 0;
     wait_us(1);
     _spi.write(command);
+    _cs = 1;
 }
  
 void GDEP015OC1::_spiData(unsigned char data){
@@ -35,12 +36,82 @@
     _dc = 1;
     wait_us(1);
     _spi.write(data);
+    _cs = 1;
 }
  
 void GDEP015OC1::_init(void){
-    _rst = _cs = 1;
-    empty();    
+    _rst = _cs = 1;    
+    _rst = 0;
+    wait_ms(EPD_WAIT_CONSTANT);
+    _rst = 1;
+    wait_ms(EPD_WAIT_CONSTANT);    
 }
+
+void GDEP015OC1::initPartial(void){
+    
+    //Driver Output control
+    _spiCommand(0x01);
+    _spiData(0xC7);     // (yDot-1)%256
+    _spiData(0x00);     // (yDot-1)/256
+    _spiData(0x00);     // 0x00
+    
+    //Softstart
+    _spiCommand(0x0C);
+    _spiData(0xD7);
+    _spiData(0xD6);
+    _spiData(0x9D);
+ 
+    //VCOM setting
+    _spiCommand(0x2C);
+    _spiData(0xA8);
+    
+    //Dummy line period
+    _spiCommand(0x3A);
+    _spiData(0x1A);
+    
+    //Gate line width // 2us per line
+    _spiCommand(0x3B);
+    _spiData(0x08);
+    
+    //Set data entry mode
+    _spiCommand(0x11);
+    _spiData(0x01); //DO NOT TOUCH THIS! (MUST BE 0x01)
+ 
+    //Define X display size
+    _spiCommand(0x44);
+    _spiData(0x00);
+    _spiData(0x18);     //(xDot-1)/8
+    //Define Y display size
+    _spiCommand(0x45);
+    _spiData(0xC7);     //(yDot-1)%256
+    _spiData(0x00);     //(yDot-1)/256
+    _spiData(0x00);     // Was 0x2B
+    _spiData(0x00);     // Was 0x01
+ 
+    //Define X RAM address
+    _spiCommand(0x4E);
+    _spiData(0x00);
+    //Define Y RAM address
+    _spiCommand(0x4F);
+    _spiData(0xC7);
+    _spiData(0x00);
+ 
+ 
+    //Write LUT
+    //_spiCommand(0x32);
+    for(uint8_t i = 0; i<30;i++){
+        _spiData(_lutPart[i]);
+    }
+    
+    // Power ON
+    _spiCommand(0x22);
+    _spiData(0xC0);
+    _spiCommand(0x20);
+    
+    //wait_ms(1500);
+    
+    
+ }
  
 void GDEP015OC1::_wakeUp(bool partial){
     _rst = 0;
@@ -151,27 +222,74 @@
 }
  
 void GDEP015OC1::write(void){
-    _wakeUp(true);
+    //_wakeUp(true);
  
+    //Define X display size
+    _spiCommand(0x44);
+    _spiData(0x00);
+    _spiData(0x18);     //(xDot-1)/8
+    //Define Y display size
+    _spiCommand(0x45);
+    _spiData(0xC7);     //(yDot-1)%256
+    _spiData(0x00);     //(yDot-1)/256
+    _spiData(0x00);     // Was 0x2B
+    _spiData(0x00);     // Was 0x01
+ 
+    //Define X RAM address
+    _spiCommand(0x4E);
+    _spiData(0x00);
+    //Define Y RAM address
+    _spiCommand(0x4F);
+    _spiData(0xC7);
+    _spiData(0x00);
+    
+    
     _spiCommand(0x24);
     for(int16_t x=0; x>=0 && x<200; x++){
         for(int16_t y=24; y>=0 && y<25; y--){
             _spiData(_mirrorData(_pixelConv(_buffer, x*25+y)));
-            wait_us(EPD_WAIT_CONSTANT);
+            //wait_us(EPD_WAIT_CONSTANT);
         }
     }
  
+    
+    // Update Partial
     _spiCommand(0x22);
     _spiData(0x04);
-    _spiCommand(0x22);
-    _spiData(0x08);
+    _spiCommand(0x20);
+    _spiCommand(0xFF);
+ 
+    wait_ms(500);
+    
+        //Define X display size
+    _spiCommand(0x44);
+    _spiData(0x00);
+    _spiData(0x18);     //(xDot-1)/8
+    //Define Y display size
+    _spiCommand(0x45);
+    _spiData(0xC7);     //(yDot-1)%256
+    _spiData(0x00);     //(yDot-1)/256
+    _spiData(0x00);     // Was 0x2B
+    _spiData(0x00);     // Was 0x01
  
-    //Update
-    _spiCommand(0x22);
+    //Define X RAM address
+    _spiCommand(0x4E);
+    _spiData(0x00);
+    //Define Y RAM address
+    _spiCommand(0x4F);
     _spiData(0xC7);
-    _spiCommand(0x20);
+    _spiData(0x00);
+    
+    
+    _spiCommand(0x24);
+    for(int16_t x=0; x>=0 && x<200; x++){
+        for(int16_t y=24; y>=0 && y<25; y--){
+            _spiData(_mirrorData(_pixelConv(_buffer, x*25+y)));
+            //wait_us(EPD_WAIT_CONSTANT);
+        }
+    }
  
-    _sleep();
+    //_sleep();
 }
  
 void GDEP015OC1::writeFull(void){
@@ -195,7 +313,7 @@
     _spiData(0xC7);
     _spiCommand(0x20);
  
-    _sleep();
+    //_sleep();
 }
  
 void GDEP015OC1::drawPixel(uint16_t startX, uint16_t startY, bool color=0){