From 3242a517b33d91b2eb3a11f7c4af59a4b6e83e1a Mon Sep 17 00:00:00 2001 From: penfold42 Date: Fri, 22 Jun 2018 09:31:13 +1000 Subject: [PATCH] Ground work for sh1106 and brightness controls - just options parsing --- src/SSD1306.cpp | 3 ++- src/SSD1306.h | 3 ++- src/ScreenLCD.cpp | 4 ++-- src/ScreenLCD.h | 2 +- src/main.cpp | 10 +++++++++- src/options.h | 6 ++++++ 6 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/SSD1306.cpp b/src/SSD1306.cpp index 40377a0..688b6b5 100644 --- a/src/SSD1306.cpp +++ b/src/SSD1306.cpp @@ -57,9 +57,10 @@ extern "C" unsigned char frame[SSD1306_128x64_BYTES]; -SSD1306::SSD1306(int BSCMaster, u8 address, int flip) +SSD1306::SSD1306(int BSCMaster, u8 address, int flip, int type) : BSCMaster(BSCMaster) , address(address) + , type(type) { RPI_I2CInit(BSCMaster, 1); diff --git a/src/SSD1306.h b/src/SSD1306.h index 165d72f..c69fce5 100644 --- a/src/SSD1306.h +++ b/src/SSD1306.h @@ -72,7 +72,7 @@ class SSD1306 public: // 128x32 0x3C // 128x64 0x3D or 0x3C (if SA0 is grounded) - SSD1306(int BSCMaster = 1, u8 address = 0x3C, int flip = 0); + SSD1306(int BSCMaster = 1, u8 address = 0x3C, int flip = 0, int type=1306); void PlotCharacter(int x, int y, char ascii, bool inverse); void Plottext(int x, int y, char* str, bool inverse); @@ -96,5 +96,6 @@ protected: int BSCMaster; u8 address; + int type; }; #endif diff --git a/src/ScreenLCD.cpp b/src/ScreenLCD.cpp index 89b215b..998c1ed 100644 --- a/src/ScreenLCD.cpp +++ b/src/ScreenLCD.cpp @@ -22,7 +22,7 @@ #include #include "debug.h" -void ScreenLCD::Open(u32 widthDesired, u32 heightDesired, u32 colourDepth, int BSCMaster, int LCDAddress, int LCDFlip) +void ScreenLCD::Open(u32 widthDesired, u32 heightDesired, u32 colourDepth, int BSCMaster, int LCDAddress, int LCDFlip, int LCDType) { bpp = 1; @@ -38,7 +38,7 @@ void ScreenLCD::Open(u32 widthDesired, u32 heightDesired, u32 colourDepth, int B width = widthDesired; height = heightDesired; - ssd1306 = new SSD1306(BSCMaster, LCDAddress, LCDFlip); + ssd1306 = new SSD1306(BSCMaster, LCDAddress, LCDFlip, LCDType); ssd1306->DisplayOn(); ssd1306->Plottext(5, 1, "Pi1541", false); ssd1306->RefreshScreen(); diff --git a/src/ScreenLCD.h b/src/ScreenLCD.h index 4a17572..ee77614 100644 --- a/src/ScreenLCD.h +++ b/src/ScreenLCD.h @@ -32,7 +32,7 @@ public: { } - void Open(u32 width, u32 height, u32 colourDepth, int BSCMaster, int LCDAddress, int LCDFlip); + void Open(u32 width, u32 height, u32 colourDepth, int BSCMaster, int LCDAddress, int LCDFlip, int LCDType); void ClearArea(u32 x1, u32 y1, u32 x2, u32 y2, RGBA colour); void Clear(RGBA colour); diff --git a/src/main.cpp b/src/main.cpp index b187627..c797c41 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1167,10 +1167,18 @@ extern "C" int i2cBusMaster = options.I2CBusMaster(); int i2cLcdAddress = options.I2CLcdAddress(); int i2cLcdFlip = options.I2CLcdFlip(); + int i2cLcdOnBright = options.I2CLcdOnBright(); + int i2cLcdDimBright = options.I2CLcdDimBright(); + int i2cLcdDimTime = options.I2CLcdDimTime(); if (strcasecmp(options.GetLCDName(), "ssd1306_128x64") == 0) { screenLCD = new ScreenLCD(); - screenLCD->Open(128, 64, 1, i2cBusMaster, i2cLcdAddress, i2cLcdFlip); + screenLCD->Open(128, 64, 1, i2cBusMaster, i2cLcdAddress, i2cLcdFlip, 1306); + } + else if (strcasecmp(options.GetLCDName(), "sh1106_128x64") == 0) + { + screenLCD = new ScreenLCD(); + screenLCD->Open(128, 64, 1, i2cBusMaster, i2cLcdAddress, i2cLcdFlip, 1106); } else { diff --git a/src/options.h b/src/options.h index 283d773..bf8fd36 100644 --- a/src/options.h +++ b/src/options.h @@ -71,6 +71,9 @@ public: inline unsigned int I2CBusMaster() const { return i2cBusMaster; } inline unsigned int I2CLcdAddress() const { return i2cLcdAddress; } inline unsigned int I2CLcdFlip() const { return i2cLcdFlip; } + inline unsigned int I2CLcdOnBright() const { return i2cLcdOnBright; } + inline unsigned int I2CLcdDimBright() const { return i2cLcdDimBright; } + inline unsigned int I2CLcdDimTime() const { return i2cLcdDimTime; } // Page up and down will jump a different amount based on the maximum number rows displayed. // Perhaps we should use some keyboard modifier to the the other screen? @@ -105,6 +108,9 @@ private: unsigned int i2cBusMaster; unsigned int i2cLcdAddress; unsigned int i2cLcdFlip; + unsigned int i2cLcdOnBright; + unsigned int i2cLcdDimBright; + unsigned int i2cLcdDimTime; unsigned int keyboardBrowseLCDScreen;