diff --git a/src/main.cpp b/src/main.cpp index c2a4e22..acfc0de 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -343,6 +343,31 @@ void InitialiseHardware() RPI_PropertyProcess(); } +void InitialiseLCD() +{ + int i2cBusMaster = options.I2CBusMaster(); + int i2cLcdAddress = options.I2CLcdAddress(); + int i2cLcdFlip = options.I2CLcdFlip(); + 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 + { + } +} + //void UpdateUartControls(bool refreshStatusDisplay, bool LED, bool Motor, bool ATN, bool DATA, bool CLOCK, u32 Track, u32 romIndex) //{ // //InputMappings* inputMappings = InputMappings::Instance(); @@ -994,6 +1019,27 @@ static void LoadOptions() } } +void DisplayOptions(int y_pos) +{ + // print confirmation of parsed options + snprintf(tempBuffer, tempBufferSize, "ignoreReset = %d\r\n", options.IgnoreReset()); + screen.PrintText(false, 0, y_pos += 16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); + snprintf(tempBuffer, tempBufferSize, "RAMBOard = %d\r\n", options.GetRAMBOard()); + screen.PrintText(false, 0, y_pos += 16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); + snprintf(tempBuffer, tempBufferSize, "splitIECLines = %d\r\n", options.SplitIECLines()); + screen.PrintText(false, 0, y_pos += 16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); + snprintf(tempBuffer, tempBufferSize, "invertIECInputs = %d\r\n", options.InvertIECInputs()); + screen.PrintText(false, 0, y_pos += 16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); + snprintf(tempBuffer, tempBufferSize, "invertIECOutputs = %d\r\n", options.InvertIECOutputs()); + screen.PrintText(false, 0, y_pos += 16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); + snprintf(tempBuffer, tempBufferSize, "i2cLcdAddress = %d\r\n", options.I2CLcdAddress()); + screen.PrintText(false, 0, y_pos += 16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); + snprintf(tempBuffer, tempBufferSize, "i2cLcdFlip = %d\r\n", options.I2CLcdFlip()); + screen.PrintText(false, 0, y_pos += 16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); + snprintf(tempBuffer, tempBufferSize, "LCDName = %s\r\n", options.GetLCDName()); + screen.PrintText(false, 0, y_pos += 16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); +} + static void CheckOptions() { FIL fp; @@ -1008,30 +1054,6 @@ static void CheckOptions() deviceID = (u8)options.GetDeviceID(); DEBUG_LOG("DeviceID = %d\r\n", deviceID); - - // print confirmation of parsed options - if (0) { - screen.Clear(COLOUR_BLACK); - int y_pos = 200; - snprintf(tempBuffer, tempBufferSize, "ignoreReset = %d\r\n", options.IgnoreReset()); - screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); - snprintf(tempBuffer, tempBufferSize, "RAMBOard = %d\r\n", options.GetRAMBOard()); - screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); - snprintf(tempBuffer, tempBufferSize, "splitIECLines = %d\r\n", options.SplitIECLines()); - screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); - snprintf(tempBuffer, tempBufferSize, "invertIECInputs = %d\r\n", options.InvertIECInputs()); - screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); - snprintf(tempBuffer, tempBufferSize, "invertIECOutputs = %d\r\n", options.InvertIECOutputs()); - screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); - snprintf(tempBuffer, tempBufferSize, "i2cLcdAddress = %d\r\n", options.I2CLcdAddress()); - screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); - snprintf(tempBuffer, tempBufferSize, "i2cLcdFlip = %d\r\n", options.I2CLcdFlip()); - screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); - snprintf(tempBuffer, tempBufferSize, "LCDName = %s\r\n", options.GetLCDName()); - screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); - IEC_Bus::WaitMicroSeconds(5 * 1000000); - } - ROMName = options.GetRomFontName(); if (ROMName) { @@ -1131,6 +1153,9 @@ extern "C" write32(ARM_GPIO_GPCLR0, 0xFFFFFFFF); DisplayLogo(); + + InitialiseLCD(); + int y_pos = 184; snprintf(tempBuffer, tempBufferSize, "Copyright(C) 2018 Stephen White"); screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); @@ -1139,6 +1164,8 @@ extern "C" snprintf(tempBuffer, tempBufferSize, "This is free software, and you are welcome to redistribute it."); screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); + if (options.ShowOptions()) + DisplayOptions(y_pos+32); if (!options.QuickBoot()) IEC_Bus::WaitMicroSeconds(3 * 1000000); @@ -1165,29 +1192,6 @@ extern "C" CheckOptions(); - - int i2cBusMaster = options.I2CBusMaster(); - int i2cLcdAddress = options.I2CLcdAddress(); - int i2cLcdFlip = options.I2CLcdFlip(); - 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 - { - } - IEC_Bus::SetSplitIECLines(options.SplitIECLines()); IEC_Bus::SetInvertIECInputs(options.InvertIECInputs()); IEC_Bus::SetInvertIECOutputs(options.InvertIECOutputs()); diff --git a/src/options.cpp b/src/options.cpp index b8c0f25..3d8e538 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -129,6 +129,7 @@ Options::Options(void) , supportUARTInput(0) , graphIEC(0) , quickBoot(0) + , showOptions(0) , displayPNGIcons(0) , soundOnGPIO(0) , soundOnGPIODuration(1000) @@ -193,6 +194,7 @@ void Options::Process(char* buffer) ELSE_CHECK_DECIMAL_OPTION(supportUARTInput) ELSE_CHECK_DECIMAL_OPTION(graphIEC) ELSE_CHECK_DECIMAL_OPTION(quickBoot) + ELSE_CHECK_DECIMAL_OPTION(showOptions) ELSE_CHECK_DECIMAL_OPTION(displayPNGIcons) ELSE_CHECK_DECIMAL_OPTION(soundOnGPIO) ELSE_CHECK_DECIMAL_OPTION(soundOnGPIODuration) diff --git a/src/options.h b/src/options.h index 36e9400..9c9844a 100644 --- a/src/options.h +++ b/src/options.h @@ -56,6 +56,7 @@ public: inline unsigned int GraphIEC() const { return graphIEC; } inline unsigned int QuickBoot() const { return quickBoot; } + inline unsigned int ShowOptions() const { return showOptions; } inline unsigned int DisplayPNGIcons() const { return displayPNGIcons; } inline unsigned int SoundOnGPIO() const { return soundOnGPIO; } inline unsigned int SoundOnGPIODuration() const { return soundOnGPIODuration; } @@ -93,6 +94,7 @@ private: unsigned int supportUARTInput; unsigned int graphIEC; unsigned int quickBoot; + unsigned int showOptions; unsigned int displayPNGIcons; unsigned int soundOnGPIO; unsigned int soundOnGPIODuration;