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/

Revision:
36:668396f861d2
Parent:
33:f87f06292637
--- a/Protocols/I2C_bus.cpp	Sun May 21 20:50:09 2017 +0000
+++ b/Protocols/I2C_bus.cpp	Sun Apr 22 21:41:24 2018 +0000
@@ -13,12 +13,13 @@
  
 #include "I2C_bus.h"
 
-I2C_bus::I2C_bus(int Hz, int address, PinName sda, PinName scl)
-    : _i2c(sda,scl)
+I2C_bus::I2C_bus(int Hz, int address, PinName sda, PinName scl, PinName reset)
+    : _i2c(sda,scl), _reset(reset)
 {
     _i2c.frequency(Hz);
     _address = address;
-    //hw_reset();    
+    _reset = 1;
+    hw_reset();    
 }
 
 void I2C_bus::wr_cmd8(unsigned char cmd)
@@ -30,7 +31,10 @@
 }
 void I2C_bus::wr_data8(unsigned char data)
 {
-    _i2c.write(data);    // write 8bit
+    char tmp[2];
+    tmp[0] = 0x40;  //data mode
+    tmp[1] = data;
+    _i2c.write(_address,tmp,2);    // write 
 }
 void I2C_bus::wr_cmd16(unsigned short cmd)
 {     
@@ -83,8 +87,9 @@
     _i2c.write(0x40);          // data continue
     while(lenght)
     {
-        _i2c.write((*data)>>8);    // write 8bit
-        _i2c.write((*data)&0xFF);    // write 8bit
+        //_i2c.write((*data)>>8);      // write high 8bit
+        _i2c.write((*data)&0xFF);    // write low 8bit
+        _i2c.write((*data)>>8);      // write high 8bit
         data++;
         lenght--;
     }
@@ -93,7 +98,11 @@
 
 void I2C_bus::hw_reset()
 {
-    
+    wait_ms(15);
+    _reset = 0;                        // display reset
+    wait_ms(2);
+    _reset = 1;                       // end reset
+    wait_ms(100);
 }
 void I2C_bus::BusEnable(bool enable)
 {