Ground work for sh1106 and brightness controls

- just options parsing
This commit is contained in:
penfold42 2018-06-22 09:31:13 +10:00
parent cf64cf1c2e
commit 3242a517b3
6 changed files with 22 additions and 6 deletions

View file

@ -57,9 +57,10 @@ extern "C"
unsigned char frame[SSD1306_128x64_BYTES]; 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) : BSCMaster(BSCMaster)
, address(address) , address(address)
, type(type)
{ {
RPI_I2CInit(BSCMaster, 1); RPI_I2CInit(BSCMaster, 1);

View file

@ -72,7 +72,7 @@ class SSD1306
public: public:
// 128x32 0x3C // 128x32 0x3C
// 128x64 0x3D or 0x3C (if SA0 is grounded) // 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 PlotCharacter(int x, int y, char ascii, bool inverse);
void Plottext(int x, int y, char* str, bool inverse); void Plottext(int x, int y, char* str, bool inverse);
@ -96,5 +96,6 @@ protected:
int BSCMaster; int BSCMaster;
u8 address; u8 address;
int type;
}; };
#endif #endif

View file

@ -22,7 +22,7 @@
#include <stdio.h> #include <stdio.h>
#include "debug.h" #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; bpp = 1;
@ -38,7 +38,7 @@ void ScreenLCD::Open(u32 widthDesired, u32 heightDesired, u32 colourDepth, int B
width = widthDesired; width = widthDesired;
height = heightDesired; height = heightDesired;
ssd1306 = new SSD1306(BSCMaster, LCDAddress, LCDFlip); ssd1306 = new SSD1306(BSCMaster, LCDAddress, LCDFlip, LCDType);
ssd1306->DisplayOn(); ssd1306->DisplayOn();
ssd1306->Plottext(5, 1, "Pi1541", false); ssd1306->Plottext(5, 1, "Pi1541", false);
ssd1306->RefreshScreen(); ssd1306->RefreshScreen();

View file

@ -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 ClearArea(u32 x1, u32 y1, u32 x2, u32 y2, RGBA colour);
void Clear(RGBA colour); void Clear(RGBA colour);

View file

@ -1167,10 +1167,18 @@ extern "C"
int i2cBusMaster = options.I2CBusMaster(); int i2cBusMaster = options.I2CBusMaster();
int i2cLcdAddress = options.I2CLcdAddress(); int i2cLcdAddress = options.I2CLcdAddress();
int i2cLcdFlip = options.I2CLcdFlip(); int i2cLcdFlip = options.I2CLcdFlip();
int i2cLcdOnBright = options.I2CLcdOnBright();
int i2cLcdDimBright = options.I2CLcdDimBright();
int i2cLcdDimTime = options.I2CLcdDimTime();
if (strcasecmp(options.GetLCDName(), "ssd1306_128x64") == 0) if (strcasecmp(options.GetLCDName(), "ssd1306_128x64") == 0)
{ {
screenLCD = new ScreenLCD(); 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 else
{ {

View file

@ -71,6 +71,9 @@ public:
inline unsigned int I2CBusMaster() const { return i2cBusMaster; } inline unsigned int I2CBusMaster() const { return i2cBusMaster; }
inline unsigned int I2CLcdAddress() const { return i2cLcdAddress; } inline unsigned int I2CLcdAddress() const { return i2cLcdAddress; }
inline unsigned int I2CLcdFlip() const { return i2cLcdFlip; } 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. // 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? // Perhaps we should use some keyboard modifier to the the other screen?
@ -105,6 +108,9 @@ private:
unsigned int i2cBusMaster; unsigned int i2cBusMaster;
unsigned int i2cLcdAddress; unsigned int i2cLcdAddress;
unsigned int i2cLcdFlip; unsigned int i2cLcdFlip;
unsigned int i2cLcdOnBright;
unsigned int i2cLcdDimBright;
unsigned int i2cLcdDimTime;
unsigned int keyboardBrowseLCDScreen; unsigned int keyboardBrowseLCDScreen;