UniGraphic-Fork for ST7920-LCD-controller and SH1106. Tested with 128x64 LCD with SPI and 128x64-OLED with IIC

Dependents:   UniGraphic-St7920-Test AfficheurUTILECO

Fork of UniGraphic by GraphicsDisplay

Fork of the UniGraphic-Library for monochrome LCDs with ST7920 controller and 128x64-IIC-OLED-Display with SH1106-Controller

/media/uploads/charly/20170522_210344.jpg

/media/uploads/charly/20180425_230623.jpg

Had to adapt LCD for following reasons:

  • Give access to screenbuffer buffer[] to parent class
  • pixel() and pixel_read() as they are hardware-dependent
  • added reset-pin to IIC-Interface

GraphicDisplay:: sends buffer to LCD when auto_update is set to true.

Testprogram for ST7920 can be found here:

https://developer.mbed.org/users/charly/code/UniGraphic-St7920-Test/

Files at this revision

API Documentation at this revision

Comitter:
Geremia
Date:
Sun Nov 29 19:58:47 2015 +0000
Parent:
29:866213bb9bf0
Child:
31:ef4225cef157
Commit message:
Add ILI9320 init to ILI932x

Changed in this revision

Display/TFT932x.cpp Show annotated file Show diff for this revision Revisions of this file
Display/TFT932x.h Show annotated file Show diff for this revision Revisions of this file
Inits/ILI932x.cpp Show annotated file Show diff for this revision Revisions of this file
Inits/ILI932x.h Show annotated file Show diff for this revision Revisions of this file
Protocols/Protocols.h Show annotated file Show diff for this revision Revisions of this file
--- a/Display/TFT932x.cpp	Sat Nov 28 18:37:19 2015 +0000
+++ b/Display/TFT932x.cpp	Sun Nov 29 19:58:47 2015 +0000
@@ -37,6 +37,7 @@
     fastwindowready=false;
     is18bit=false;
     isBGR=false;
+    flipped=0;
   //  cls();
   //  locate(0,0);
 }
@@ -66,6 +67,7 @@
     fastwindowready=false;
     is18bit=false;
     isBGR=false;
+    flipped=0;
   //  cls();
   //  locate(0,0);
 }
@@ -90,6 +92,7 @@
     fastwindowready=false;
     is18bit=false;
     isBGR=false;
+    flipped=0;
   //  locate(0,0);
 }
 // dummy read needed before read gram
@@ -161,29 +164,29 @@
     // ORG bit set for all modes
     {
         case 0:// default, portrait view 0°
-            reg_write(0x0001,0x0100); // S720 to S1
-            reg_write(0x0060,0xA700); // G320 to G1
+            reg_write(0x0001,((flipped&FLIP_X)==0) ? 0x0100:0x0000); // S720toS1 or S1toS720
+            reg_write(0x0060,((flipped&FLIP_Y)==0) ? 0xA700:0x2700); // G320toG1 or G1toG320
             reg_write(0x03, 0x10B0);
             set_width(screensize_X);
             set_height(screensize_Y);
             break;
         case 1:// landscape view +90°
-            reg_write(0x0001,0x0000); // S1 to S720
-            reg_write(0x0060,0xA700); // G320 to G1
+            reg_write(0x0001,((flipped&FLIP_X)==0) ? 0x0000:0x0100); // S1toS720 or S720toS1
+            reg_write(0x0060,((flipped&FLIP_Y)==0) ? 0xA700:0x2700); // G320toG1 or G1toG320
             reg_write(0x03, 0x10B8); // AM=1 increase addr ctr first vertically then horizontally
             set_width(screensize_Y);
             set_height(screensize_X);
             break;
         case 2:// portrait view +180°
-            reg_write(0x0001,0x0000); // S1 to S720
-            reg_write(0x0060,0x2700); // G1 to G320
+            reg_write(0x0001,((flipped&FLIP_X)==0) ? 0x0000:0x0100); // S1toS720 or S720toS1
+            reg_write(0x0060,((flipped&FLIP_Y)==0) ? 0x2700:0xA700); // G1toG320 or G320toG1
             reg_write(0x03, 0x10B0);
             set_width(screensize_X);
             set_height(screensize_Y);
             break;
         case 3:// landscape view -90°
-            reg_write(0x0001,0x0100); // S720 to S1
-            reg_write(0x0060,0x2700); // G1 to G320
+            reg_write(0x0001,((flipped&FLIP_X)==0) ? 0x0100:0x0000); // S720toS1 or S1toS720
+            reg_write(0x0060,((flipped&FLIP_Y)==0) ? 0x2700:0xA700); // G1toG320 or G320toG1
             reg_write(0x03, 0x10B8); // AM=1 increase addr ctr first vertically then horizontally
             set_width(screensize_Y);
             set_height(screensize_X);
--- a/Display/TFT932x.h	Sat Nov 28 18:37:19 2015 +0000
+++ b/Display/TFT932x.h	Sun Nov 29 19:58:47 2015 +0000
@@ -249,6 +249,7 @@
     virtual void identify();
     
     unsigned int scrollbugfix;
+    unsigned char flipped;
     
     
     
--- a/Inits/ILI932x.cpp	Sat Nov 28 18:37:19 2015 +0000
+++ b/Inits/ILI932x.cpp	Sun Nov 29 19:58:47 2015 +0000
@@ -18,6 +18,7 @@
     BusEnable(true);  //set CS low, will stay low untill manually set high with BusEnable(false);
     identify(); // will collect tftID
     if(tftID==0x9325) init9325();
+    else if(tftID==0x9320) init9320();
     auto_gram_read_format();// try to get read gram pixel format, could be 16bit or 18bit, RGB or BGR. Will set flags accordingly
     set_orientation(0);
     FastWindow(true); // most but not all controllers support this, even if datasheet tells they should. 
@@ -31,6 +32,7 @@
     BusEnable(true);  //set CS low, will stay low untill manually set high with BusEnable(false);
     identify(); // will collect tftID
     if(tftID==0x9325) init9325();
+    else if(tftID==0x9320) init9320();
     auto_gram_read_format();// try to get read gram pixel format, could be 16bit or 18bit, RGB or BGR. Will set flags accordingly
     set_orientation(0);
     FastWindow(true); // most but not all controllers support this, even if datasheet tells they should. 
@@ -44,6 +46,7 @@
     BusEnable(true); //set CS low, TFT932x class will toggle CS every transfer
     identify(); // will collect tftID
     if(tftID==0x9325) init9325();
+    else if(tftID==0x9320) init9320();
     auto_gram_read_format();// try to get read gram pixel format, could be 16bit or 18bit, RGB or BGR. Will set flags accordingly
     set_orientation(0); 
     FastWindow(true); // most but not all controllers support this, even if datasheet tells they should. 
@@ -56,6 +59,8 @@
 {
     /* Example for ILI9325 ----------------------------------------------------*/
 
+ flipped=FLIP_NONE; // FLIP_NONE, FLIP_X, FLIP_Y, FLIP_X|FLIP_Y
+ 
  reg_write(0x0001,0x0100); 
  reg_write(0x0002,0x0700); 
  reg_write(0x0003,0x1030); 
@@ -123,4 +128,80 @@
  
  reg_write(0x0007,0x0133); // display on
 
+}
+void ILI932x::init9320()
+{
+    /* Example for ILI9320 ----------------------------------------------------*/
+
+ flipped=FLIP_X; // FLIP_NONE, FLIP_X, FLIP_Y, FLIP_X|FLIP_Y
+ 
+ reg_write(0x0001,0x0100); 
+ reg_write(0x0002,0x0700); 
+ reg_write(0x0003,0x1030); 
+ reg_write(0x0004,0x0000); 
+ reg_write(0x0008,0x0202);  
+ reg_write(0x0009,0x0000);
+ reg_write(0x000A,0x0000); 
+ reg_write(0x000C,0x0000); 
+ reg_write(0x000D,0x0000);
+ reg_write(0x000F,0x0000);
+//power on sequence
+ reg_write(0x0010,0x0000);   
+ reg_write(0x0011,0x0007);  
+ reg_write(0x0012,0x0000);  
+ reg_write(0x0013,0x0000); 
+ reg_write(0x0007,0x0001);
+wait_ms(200);
+
+ reg_write(0x0010,0x10C0);   
+ reg_write(0x0011,0x0007);
+wait_ms(50);
+
+ reg_write(0x0012,0x0110);
+ wait_ms(50);
+
+ reg_write(0x0013,0x0b00);
+ wait_ms(50); 
+
+ reg_write(0x0029,0x0000); 
+ reg_write(0x002B,0x4010); // bit 14???
+wait_ms(50);
+//gamma
+/*
+ reg_write(0x0030,0x0004);
+ reg_write(0x0031,0x0307);
+ reg_write(0x0032,0x0002);// 0006
+ reg_write(0x0035,0x0206);
+ reg_write(0x0036,0x0408);
+ reg_write(0x0037,0x0507); 
+ reg_write(0x0038,0x0204);//0200
+ reg_write(0x0039,0x0707); 
+ reg_write(0x003C,0x0405);// 0504
+ reg_write(0x003D,0x0F02);
+ */
+ //ram
+ reg_write(0x0050,0x0000); 
+ reg_write(0x0051,0x00EF);
+ reg_write(0x0052,0x0000); 
+ reg_write(0x0053,0x013F);  
+ reg_write(0x0060,0x2700); 
+ reg_write(0x0061,0x0001); 
+ reg_write(0x006A,0x0000); 
+ //
+ reg_write(0x0080,0x0000); 
+ reg_write(0x0081,0x0000); 
+ reg_write(0x0082,0x0000); 
+ reg_write(0x0083,0x0000); 
+ reg_write(0x0084,0x0000); 
+ reg_write(0x0085,0x0000); 
+ //
+ reg_write(0x0090,0x0000); 
+ reg_write(0x0092,0x0000); 
+ reg_write(0x0093,0x0001); 
+ reg_write(0x0095,0x0110); 
+ reg_write(0x0097,0x0000); 
+ reg_write(0x0098,0x0000);
+ 
+ reg_write(0x0007,0x0133); // display on
+
 }
\ No newline at end of file
--- a/Inits/ILI932x.h	Sat Nov 28 18:37:19 2015 +0000
+++ b/Inits/ILI932x.h	Sun Nov 29 19:58:47 2015 +0000
@@ -65,8 +65,7 @@
     /** Init command sequence  
     */
     void init9325();
-
-
+    void init9320();
 
 };
 #endif
\ No newline at end of file
--- a/Protocols/Protocols.h	Sat Nov 28 18:37:19 2015 +0000
+++ b/Protocols/Protocols.h	Sun Nov 29 19:58:47 2015 +0000
@@ -13,6 +13,10 @@
 #define RGB24to16(r,g,b)  (((r&0xF8)<<8)|((g&0xFC)<<3)|((b&0xF8)>>3)) //5 red | 6 green | 5 blue
 #define BGR2RGB(color) (((color&0x1F)<<11) | (color&0x7E0) | ((color&0xF800)>>11))
 
+#define FLIP_NONE   0
+#define FLIP_X      1
+#define FLIP_Y      2
+
 //#define USE_CS
 
 /** Protocol types