Code cleanups

This commit is contained in:
penfold42 2018-07-17 09:37:53 +10:00
parent 4a1c56df41
commit ca2aa5e09f
3 changed files with 16 additions and 14 deletions

View file

@ -82,7 +82,6 @@ void SSD1306::InitHardware()
SendCommand(0x14); // external = 0x10 internal = 0x14
SendCommand(SSD1306_CMD_SET_MEMORY_ADDRESSING_MODE); // 0x20 Set Memory Addressing Mode
// SendCommand(0x00); // 00 - Horizontal Addressing Mode
SendCommand(0x10); // 10 - Page Addressing Mode for SH1106 compatibility
Home();
@ -122,11 +121,11 @@ void SSD1306::MoveCursorByte(u8 row, u8 col)
if (row > 7) { row = 7; }
if (type == 1106)
col += 2;
col += 2; // sh1106 uses columns 2..129
SendCommand(0xB0 + row); // page address
SendCommand(0x00 | (col & 0xf)); // column address lower bits
SendCommand(0x10 | (col >> 4)); // column address upper bits
SendCommand(SSD1306_CMD_SET_PAGE | row); // 0xB0 page address
SendCommand(SSD1306_CMD_SET_COLUMN_LOW | (col & 0xf)); // 0x00 column address lower bits
SendCommand(SSD1306_CMD_SET_COLUMN_HIGH | (col >> 4)); // 0x10 column address upper bits
}
void SSD1306::RefreshScreen()
@ -138,12 +137,13 @@ void SSD1306::RefreshScreen()
}
}
void SSD1306::RefreshRows(u32 start, u32 numRows)
void SSD1306::RefreshRows(u32 start, u32 amountOfRows)
{
int i;
start <<= 1;
numRows <<=1;
u32 i;
for (i = start; i < start+numRows; i++)
amountOfRows <<= 1;
for (i = start; i < start+amountOfRows; i++)
{
RefreshPage(i);
}
@ -151,12 +151,11 @@ void SSD1306::RefreshRows(u32 start, u32 numRows)
void SSD1306::RefreshPage(u32 page)
{
MoveCursorByte(page, 0);
int i;
int start = page*128;
int end = page*128 + 128;
MoveCursorByte(page, 0);
for (i = start; i < end; i++)
{
SendData(frame[i]);

View file

@ -114,6 +114,9 @@ protected:
#endif
#define SSD1306_CMD_SET_COLUMN_LOW 0x00
#define SSD1306_CMD_SET_COLUMN_HIGH 0x10
#define SSD1306_CMD_SET_PAGE 0xB0
#define SSD1306_CMD_SET_MEMORY_ADDRESSING_MODE 0x20
#define SSD1306_CMD_SET_COLUMN_ADDRESS 0x21
#define SSD1306_CMD_SET_PAGE_ADDRESS 0x22

View file

@ -372,7 +372,7 @@ void InitialiseLCD()
screenLCD = new ScreenLCD();
screenLCD->Open(128, 64, 1, i2cBusMaster, i2cLcdAddress, i2cLcdFlip, i2cLcdModel);
screenLCD->SetContrast(i2cLcdOnContrast);
screenLCD->ClearInit(0);
screenLCD->ClearInit(0); // sh1106 needs this
bool logo_done = false;
if (strcasecmp(options.GetLcdLogoName(), "1541ii") == 0)
@ -405,7 +405,7 @@ void InitialiseLCD()
if (!logo_done)
{
snprintf(tempBuffer, tempBufferSize, "Pixxxx V%d.%02d", versionMajor, versionMinor);
snprintf(tempBuffer, tempBufferSize, "Pi1541 V%d.%02d", versionMajor, versionMinor);
int x = (128 - 8*strlen(tempBuffer) ) /2;
int y = (64-16)/2;
screenLCD->PrintText(0, x, y, tempBuffer, 0x0);