private void OpenLcd() { if (!_isDisabled) { Log.Info("iMONLCDg.OpenLcd(): called"); if (!_IMON.iMONVFD_IsInited()) { Log.Info("iMONLCDg.OpenLcd(): opening display"); Log.Info("iMONLCDg.OpenLcd(): opening display with iMONVFD_Init({0},{1})", _VfdType.ToString("x00"), _VfdReserved.ToString("x0000")); if (!_IMON.iMONVFD_Init(_VfdType, _VfdReserved)) { Log.Info("iMONLCDg.OpenLcd(): Could not open display with Open({0},{1})", _VfdType.ToString("x00"), _VfdReserved.ToString("x0000")); _isDisabled = true; _errorMessage = "Could not open iMON display device"; } else { Log.Info("iMONLCDg.OpenLcd(): display opened"); if (!_displayTest & ((_DisplayType == DisplayType.LCD) || (_DisplayType == DisplayType.LCD2))) { if (DisplayOptions.UseCustomFont) { CFont = new CustomFont(); CFont.InitializeCustomFont(); } if (DisplayOptions.UseLargeIcons) { CustomLargeIcon = new LargeIcon(); CustomLargeIcon.InitializeLargeIcons(); } _iconThread = new Thread(UpdateIcons) { IsBackground = true, Priority = ThreadPriority.BelowNormal, Name = "UpdateIconThread" }; _iconThread.Start(); if (_iconThread.IsAlive) { Log.Info("iMONLCDg.OpenLcd(): iMONLCDg.UpdateIcons() Thread Started"); } else { Log.Info("iMONLCDg.OpenLcd(): iMONLCDg.UpdateIcons() FAILED TO START"); } } else if (!_displayTest & (_DisplayType == DisplayType.VFD)) { if (EQSettings.UseEqDisplay || DisplaySettings.BlankDisplayWithVideo) { _iconThread = new Thread(VFD_EQ_Update) { IsBackground = true, Priority = ThreadPriority.BelowNormal, Name = "VFD_EQ_Update" }; _iconThread.Start(); if (_iconThread.IsAlive) { Log.Info("iMONLCDg.OpenLcd(): iMONLCDg.VFD_EQ_Update() Thread Started"); } else { Log.Info("iMONLCDg.OpenLcd(): iMONLCDg.VFD_EQ_Update() FAILED TO START"); } } } else if ((!_displayTest & (_DisplayType == DisplayType.ThreeRsystems)) && (EQSettings.UseEqDisplay || DisplaySettings.BlankDisplayWithVideo)) { _iconThread = new Thread(VFD_EQ_Update) { IsBackground = true, Priority = ThreadPriority.BelowNormal, Name = "VFD_EQ_Update" }; _iconThread.TrySetApartmentState(ApartmentState.MTA); _iconThread.Start(); if (_iconThread.IsAlive) { Log.Info("iMONLCDg.OpenLcd(): iMONLCDg.VFD_EQ_Update() Thread Started"); } else { Log.Info("iMONLCDg.OpenLcd(): iMONLCDg.VFD_EQ_Update() FAILED TO START"); } } } } else { Log.Info("iMONLCDg.OpenLcd: Display already open"); } if (_MonitorPower && !_IsHandlingPowerEvent) { Log.Info("iMONLCDg.OpenLcd(): Adding Power State Monitor callback to system event thread"); SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged; } lock (DWriteMutex) { if ((_DisplayType == DisplayType.LCD) || (_DisplayType == DisplayType.LCD2)) { if (_DisplayType == DisplayType.LCD2) { SendData(iMonCommand.LCD2.ClearDisplay); if (_Contrast) { Log.Info("iMONLCDg.OpenLcd(): Setting LCD2 contrast level to {0}", _ContrastLevel); SendData(iMonCommand.General.SetContrast, _ContrastLevel); } SendData(iMonCommand.General.SetIcons); SendData(iMonCommand.General.SetLines0); SendData(iMonCommand.General.SetLines1); SendData(iMonCommand.General.SetLines2); ClearDisplay(); } else { SendData(iMonCommand.LCD.ClearDisplay); SendData(iMonCommand.LCD.ClearAlarm); if (_Contrast) { Log.Info("iMONLCDg.OpenLcd(): Setting LCD contrast level to {0}", _ContrastLevel); SendData(iMonCommand.General.SetContrast, _ContrastLevel); } SendData(iMonCommand.General.KeypadLightOn); } } else if (_DisplayType == DisplayType.ThreeRsystems) { SendData(0x2020202020202000L); SendData(0x2020202020202002L); SendData(0x2020202020202004L); SendData(0x2020202020202006L); SendData(0x20202020ffffff08L); SendData(0x021c020000000000L); SendData(0x0000000000000002L); SendData(0x0200020000000000L); SendData(0x0000000000000002L); SendData(0x021b010000000000L); SendData(0x0000000000000002L); } } AdvancedSettings.OnSettingsChanged += AdvancedSettings_OnSettingsChanged; ForceManagerRestart(); Log.Info("iMONLCDg.OpenLcd(): completed"); } }