Added SetContrast functions

This commit is contained in:
penfold42 2018-06-22 22:32:54 +10:00
parent 3242a517b3
commit bd8a31604c
7 changed files with 27 additions and 7 deletions

View file

@ -222,6 +222,12 @@ void SSD1306::DisplayOff()
SendCommand(SSD1306_CMD_DISPLAY_OFF);
}
void SSD1306::SetContrast(u8 value)
{
SendCommand(SSD1306_CMD_SET_CONTRAST_CONTROL);
SendCommand(value);
}
void SSD1306::Plottext(int x, int y, char* str, bool inverse)
{
int i;

View file

@ -79,6 +79,7 @@ public:
void DisplayOn();
void DisplayOff();
void SetContrast(u8 value);
void ClearScreen();
void RefreshScreen();

View file

@ -60,6 +60,11 @@ void ScreenLCD::Clear(RGBA colour)
ssd1306->ClearScreen();
}
void ScreenLCD::SetContrast(u8 value)
{
ssd1306->SetContrast(value);
}
void ScreenLCD::WriteChar(bool petscii, u32 x, u32 y, unsigned char c, RGBA colour)
{
if (opened)

View file

@ -37,6 +37,8 @@ public:
void ClearArea(u32 x1, u32 y1, u32 x2, u32 y2, RGBA colour);
void Clear(RGBA colour);
void SetContrast(u8 value);
void ScrollArea(u32 x1, u32 y1, u32 x2, u32 y2);
void WriteChar(bool petscii, u32 x, u32 y, unsigned char c, RGBA colour);

View file

@ -496,7 +496,8 @@ void UpdateScreen()
if (screenLCD)
{
screenLCD->PrintText(false, 0, 0, tempBuffer, RGBA(0xff, 0xff, 0xff, 0xff), RGBA(0xff, 0xff, 0xff, 0xff));
screenLCD->RefreshRows(0, 2); //SwapBuffers();
// screenLCD->SetContrast(3*track);
screenLCD->RefreshRows(0, 2);
}
}
@ -1167,18 +1168,20 @@ extern "C"
int i2cBusMaster = options.I2CBusMaster();
int i2cLcdAddress = options.I2CLcdAddress();
int i2cLcdFlip = options.I2CLcdFlip();
int i2cLcdOnBright = options.I2CLcdOnBright();
int i2cLcdDimBright = options.I2CLcdDimBright();
int i2cLcdOnContrast = options.I2CLcdOnContrast();
int i2cLcdDimContrast = options.I2CLcdDimContrast();
int i2cLcdDimTime = options.I2CLcdDimTime();
if (strcasecmp(options.GetLCDName(), "ssd1306_128x64") == 0)
{
screenLCD = new ScreenLCD();
screenLCD->Open(128, 64, 1, i2cBusMaster, i2cLcdAddress, i2cLcdFlip, 1306);
screenLCD->SetContrast(i2cLcdOnContrast);
}
else if (strcasecmp(options.GetLCDName(), "sh1106_128x64") == 0)
{
screenLCD = new ScreenLCD();
screenLCD->Open(128, 64, 1, i2cBusMaster, i2cLcdAddress, i2cLcdFlip, 1106);
screenLCD->SetContrast(i2cLcdOnContrast);
}
else
{

View file

@ -206,6 +206,9 @@ void Options::Process(char* buffer)
ELSE_CHECK_DECIMAL_OPTION(i2cBusMaster)
ELSE_CHECK_DECIMAL_OPTION(i2cLcdAddress)
ELSE_CHECK_DECIMAL_OPTION(i2cLcdFlip)
ELSE_CHECK_DECIMAL_OPTION(i2cLcdOnContrast)
ELSE_CHECK_DECIMAL_OPTION(i2cLcdDimContrast)
ELSE_CHECK_DECIMAL_OPTION(i2cLcdDimTime)
ELSE_CHECK_DECIMAL_OPTION(keyboardBrowseLCDScreen)
else if ((strcasecmp(pOption, "StarFileName") == 0))
{

View file

@ -71,8 +71,8 @@ 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 I2CLcdOnContrast() const { return i2cLcdOnContrast; }
inline unsigned int I2CLcdDimContrast() const { return i2cLcdDimContrast; }
inline unsigned int I2CLcdDimTime() const { return i2cLcdDimTime; }
// Page up and down will jump a different amount based on the maximum number rows displayed.
@ -108,8 +108,8 @@ private:
unsigned int i2cBusMaster;
unsigned int i2cLcdAddress;
unsigned int i2cLcdFlip;
unsigned int i2cLcdOnBright;
unsigned int i2cLcdDimBright;
unsigned int i2cLcdOnContrast = 127;
unsigned int i2cLcdDimContrast;
unsigned int i2cLcdDimTime;
unsigned int keyboardBrowseLCDScreen;