if LcdLogoName != 1541ii nor 1541classic, try to load file from SD card

This commit is contained in:
penfold42 2018-07-04 11:48:55 +10:00
parent 34c75658eb
commit b101e8f635
3 changed files with 53 additions and 14 deletions

View file

@ -81,6 +81,9 @@ const long int CBMFont_size = 4096;
unsigned char CBMFontData[4096]; unsigned char CBMFontData[4096];
unsigned char* CBMFont = 0; unsigned char* CBMFont = 0;
#define LCD_LOGO_MAX_SIZE 1024
u8 LcdLogoFile[LCD_LOGO_MAX_SIZE];
u8 s_u8Memory[0xc000]; u8 s_u8Memory[0xc000];
DiskCaddy diskCaddy; DiskCaddy diskCaddy;
@ -346,41 +349,67 @@ void InitialiseHardware()
void InitialiseLCD() void InitialiseLCD()
{ {
FILINFO filLcdIcon;
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 i2cLcdOnContrast = options.I2CLcdOnContrast(); int i2cLcdOnContrast = options.I2CLcdOnContrast();
int i2cLcdDimContrast = options.I2CLcdDimContrast(); int i2cLcdDimContrast = options.I2CLcdDimContrast();
int i2cLcdDimTime = options.I2CLcdDimTime(); int i2cLcdDimTime = options.I2CLcdDimTime();
int i2cLcdModel = 0;
if (strcasecmp(options.GetLCDName(), "ssd1306_128x64") == 0) if (strcasecmp(options.GetLCDName(), "ssd1306_128x64") == 0)
i2cLcdModel = 1306;
else if (strcasecmp(options.GetLCDName(), "sh1106_128x64") == 0)
i2cLcdModel = 1106;
if (i2cLcdModel)
{ {
screenLCD = new ScreenLCD(); screenLCD = new ScreenLCD();
screenLCD->Open(128, 64, 1, i2cBusMaster, i2cLcdAddress, i2cLcdFlip, 1306); screenLCD->Open(128, 64, 1, i2cBusMaster, i2cLcdAddress, i2cLcdFlip, i2cLcdModel);
bool logo_done = false;
if (strcasecmp(options.GetLcdLogoName(), "1541ii") == 0) if (strcasecmp(options.GetLcdLogoName(), "1541ii") == 0)
{ {
screenLCD->PlotRawImage(logo_ssd_1541ii, 0, 0, 128, 64); screenLCD->PlotRawImage(logo_ssd_1541ii, 0, 0, 128, 64);
snprintf(tempBuffer, tempBufferSize, "Pi1541 V%d.%02d", versionMajor, versionMinor); snprintf(tempBuffer, tempBufferSize, "Pi1541 V%d.%02d", versionMajor, versionMinor);
screenLCD->PrintText(0, 16, 0, tempBuffer, 0xffffffff); screenLCD->PrintText(0, 16, 0, tempBuffer, 0xffffffff);
screenLCD->RefreshScreen(); logo_done = true;
} }
if (strcasecmp(options.GetLcdLogoName(), "1541classic") == 0) else if (strcasecmp(options.GetLcdLogoName(), "1541classic") == 0)
{ {
screenLCD->PlotRawImage(logo_ssd_1541classic, 0, 0, 128, 64); screenLCD->PlotRawImage(logo_ssd_1541classic, 0, 0, 128, 64);
screenLCD->RefreshScreen(); logo_done = true;
}
else if (f_stat(options.GetLcdLogoName(), &filLcdIcon) == FR_OK && filLcdIcon.fsize <= LCD_LOGO_MAX_SIZE)
{
FIL fp;
FRESULT res;
res = f_open(&fp, filLcdIcon.fname, FA_READ);
if (res == FR_OK)
{
u32 bytesRead;
f_read(&fp, LcdLogoFile, LCD_LOGO_MAX_SIZE, &bytesRead);
f_close(&fp);
screenLCD->PlotRawImage(LcdLogoFile, 0, 0, 128, 64);
logo_done = true;
}
} }
if (!logo_done)
{
snprintf(tempBuffer, tempBufferSize, "Pixxxx V%d.%02d", versionMajor, versionMinor);
int x = (128 - 8*strlen(tempBuffer) ) /2;
int y = (64-16)/2;
screenLCD->PrintText(0, x, y, tempBuffer, 0x0);
}
screenLCD->RefreshScreen();
screenLCD->SetContrast(i2cLcdOnContrast); 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
{
}
} }
//void UpdateUartControls(bool refreshStatusDisplay, bool LED, bool Motor, bool ATN, bool DATA, bool CLOCK, u32 Track, u32 romIndex) //void UpdateUartControls(bool refreshStatusDisplay, bool LED, bool Motor, bool ATN, bool DATA, bool CLOCK, u32 Track, u32 romIndex)

View file

@ -143,10 +143,13 @@ Options::Options(void)
, i2cBusMaster(1) , i2cBusMaster(1)
, i2cLcdAddress(0x3C) , i2cLcdAddress(0x3C)
, i2cLcdFlip(0) , i2cLcdFlip(0)
, i2cLcdOnContrast(127)
, i2cLcdModel(0)
, keyboardBrowseLCDScreen(0) , keyboardBrowseLCDScreen(0)
{ {
autoMountImageName[0] = 0; autoMountImageName[0] = 0;
strcpy(ROMFontName, "chargen"); strcpy(ROMFontName, "chargen");
strcpy(LcdLogoName, "1541ii");
starFileName[0] = 0; starFileName[0] = 0;
ROMName[0] = 0; ROMName[0] = 0;
ROMNameSlot2[0] = 0; ROMNameSlot2[0] = 0;
@ -228,6 +231,11 @@ void Options::Process(char* buffer)
else if ((strcasecmp(pOption, "LCDName") == 0)) else if ((strcasecmp(pOption, "LCDName") == 0))
{ {
strncpy(LCDName, pValue, 255); strncpy(LCDName, pValue, 255);
if (strcasecmp(pValue, "ssd1306_128x64") == 0)
i2cLcdModel = 1306;
else if (strcasecmp(pValue, "sh1106_128x64") == 0)
i2cLcdModel = 1106;
} }
else if ((strcasecmp(pOption, "ROM") == 0) || (strcasecmp(pOption, "ROM1") == 0)) else if ((strcasecmp(pOption, "ROM") == 0) || (strcasecmp(pOption, "ROM1") == 0))
{ {

View file

@ -76,6 +76,7 @@ public:
inline unsigned int I2CLcdOnContrast() const { return i2cLcdOnContrast; } inline unsigned int I2CLcdOnContrast() const { return i2cLcdOnContrast; }
inline unsigned int I2CLcdDimContrast() const { return i2cLcdDimContrast; } inline unsigned int I2CLcdDimContrast() const { return i2cLcdDimContrast; }
inline unsigned int I2CLcdDimTime() const { return i2cLcdDimTime; } inline unsigned int I2CLcdDimTime() const { return i2cLcdDimTime; }
inline unsigned int I2CLcdModel() const { return i2cLcdModel; }
inline const char* GetLcdLogoName() const { return LcdLogoName; } inline const char* GetLcdLogoName() const { return LcdLogoName; }
// 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.
@ -112,9 +113,10 @@ private:
unsigned int i2cBusMaster; unsigned int i2cBusMaster;
unsigned int i2cLcdAddress; unsigned int i2cLcdAddress;
unsigned int i2cLcdFlip; unsigned int i2cLcdFlip;
unsigned int i2cLcdOnContrast = 127; unsigned int i2cLcdOnContrast;
unsigned int i2cLcdDimContrast; unsigned int i2cLcdDimContrast;
unsigned int i2cLcdDimTime; unsigned int i2cLcdDimTime;
unsigned int i2cLcdModel;
unsigned int keyboardBrowseLCDScreen; unsigned int keyboardBrowseLCDScreen;