/// <summary> /// Called when a pin otherwise used for the LCD controller is reserved for another module /// We have to ensure the LCD controller pins are disabled so they can be reused /// </summary> internal static void LCDControllerPinReuse() { if (_lcdControllerConfig != null && _lcdControllerConfig.LCDControllerEnabled) { DisplayError("ERROR: Cannot use LCD controller pins as IOs simultaneously with using them to drive a display"); } if (_lcdConfigInUnknownState || LCDControllerEnabled) { Mainboard.SetLCD(lcdPinsUsedAsIOs); LCDControllerEnabled = false; // need to explicitly reboot in case _lcdConfigInUnknownState DisplayReboot(); } if (_lcdControllerConfig == null) { _lcdControllerConfig = lcdPinsUsedAsIOs; } }
/// <summary> /// Sets the display configuration. This must be called by all display module constructors (even ones not using LCD displays) /// </summary> /// <param name="displayConfig">The display configuration.</param> protected static void SetLCDConfig(Mainboard.LCDConfiguration displayConfig) { if (_numDisplaysConstructed != _numDisplaysConfigured + 1) { DisplayError("ERROR IN DISPLAY MODULE DRIVER: All display module constructors must call DisplayModule.SetLCDConfig()"); } if (displayConfig != Mainboard.LCDConfiguration.HeadlessConfig && (displayConfig.Height == 0 || displayConfig.Width == 0)) { DisplayError("ERROR IN DISPLAY MODULE DRIVER: LCDConfiguration must specify Height and Width of display"); } _numDisplaysConfigured++; _displayModuleToBeConfigured._config = displayConfig; if (displayConfig.LCDControllerEnabled) { if (_lcdControllerConfig != null) { if (_lcdControllerConfig == lcdPinsUsedAsIOs) { DisplayError("ERROR: Cannot use LCD controller pins as IOs and also use an LCD controller based display"); } else { DisplayError("ERROR: Cannot use more than one LCD controller based display at a time"); } } _lcdControllerConfig = displayConfig; Mainboard.SetLCD(displayConfig); // this reboots if necessary LCDControllerEnabled = true; // known issue: this does not check all settings match (will be fixed in the NETMF 4.2 version) if (SystemMetrics.ScreenWidth != displayConfig.Width || SystemMetrics.ScreenHeight != displayConfig.Height) { DisplayReboot(); } } }