예제 #1
0
    public void Setup(string port, int lines, int cols, int delay, int linesG, int colsG, int timeG, bool backLight,
                      int backlightLevel, bool contrast, int contrastLevel, bool blankOnExit)
    {
      Log.Info("(IDisplay) iMONLCDg.Setup(): called");
      MiniDisplayHelper.InitEQ(ref EQSettings);
      MiniDisplayHelper.InitDisplayControl(ref DisplaySettings);
      MiniDisplayHelper.InitDisplayOptions(ref DisplayOptions);
      _BlankDisplayOnExit = blankOnExit;
      _Backlight = false;
      _BacklightLevel = (ulong)backlightLevel;
      _Contrast = true;
      _ContrastLevel = ((ulong)contrastLevel) >> 2;
      InitializeDriver();
      if (_DelayStartup)
      {
        Log.Info("iMONLCDg.Setup(): Delaying device initialization by 10 seconds");
        Thread.Sleep(0x2710);
      }
      Check_iMON_Manager_Status();
      if (_IMON == null)
      {
        _IMON = new iMONDisplay();
      }
      int fWVersion = -1;
      int rEGVersion = -1;
      switch (_ForceDisplay)
      {
        case "LCD":
          _DisplayType = DisplayType.LCD;
          _VfdType = 0x18;
          _VfdReserved = 0x8888;
          Log.Info("(IDisplay) iMONLCDg.Setup(): Advanced options forces display type to LCD");
          break;
        case "LCD2":
          _DisplayType = DisplayType.LCD2;
          _VfdType = 0x1b;
          _VfdReserved = 0x8888;
          Log.Info("(IDisplay) iMONLCDg.Setup(): Advanced options forces display type to LCD2");
          break;
        case "VFD":
          _DisplayType = DisplayType.VFD;
          _VfdType = 0x10;
          _VfdType = 0x1a;
          _VfdReserved = 0;
          Log.Info("(IDisplay) iMONLCDg.Setup(): Advanced options forces display type to VFD");
          break;
        case "LCD3R":
          _DisplayType = DisplayType.ThreeRsystems;
          _VfdType = 9;
          _VfdReserved = 0;
          Log.Info("(IDisplay) iMONLCDg.Setup(): Advanced options forces display type to LCD3R");
          break;
        default:
          Log.Info("(IDisplay) iMONLCDg.Setup(): Autodetecting iMON Display device");
          try
          {
            Log.Info("(IDisplay) iMONLCDg.Setup(): attempting hardware information test");
            if (_IMON.RC_Available())
            {
              Log.Info("(IDisplay) iMONLCDg.Setup(): hardware information test - Opening SG_RC.dll");
              if (_IMON.iMONRC_Init(0x77, 0x83, 0x8888))
              {
                long num4 = _IMON.iMONRC_CheckDriverVersion();
                int num5 = _IMON.iMONRC_GetFirmwareVer();
                int num6 = _IMON.iMONRC_GetHWType();
                int num7 = _IMON.iMONRC_GetLastRFMode();
                Log.Info(
                  "(IDisplay) iMONLCDg.Setup(): RC TEST returned DRVR: 0x{0}, FW: 0x{1} (HW: 0x{2}), RC_HW: 0x{3}, RF: 0x{4}",
                  num4.ToString("x0000000000000000"), num5.ToString("x00000000"),
                  GetVFDTypeFromFirmware(num5).ToString("x00000000"), num6.ToString("x00000000"),
                  num7.ToString("x00000000"));
                if (num5 > 0)
                {
                  fWVersion = num5;
                }
                Log.Info("(IDisplay) iMONLCDg.Setup(): Closing SG_RC.dll");
                _IMON.iMONRC_Uninit();
              }
              else
              {
                long num8 = _IMON.iMONRC_CheckDriverVersion();
                int num9 = _IMON.iMONRC_GetFirmwareVer();
                int num10 = _IMON.iMONRC_GetHWType();
                int num11 = _IMON.iMONRC_GetLastRFMode();
                Log.Info("iMONLCDg.Setup(): RC TEST returned DRVR: 0x{0}, FW: 0x{1} (HW: {2}), RC_HW: 0x{3}, RF: 0x{4}",
                         num8.ToString("x0000000000000000"), num9.ToString("x00000000"),
                         GetVFDTypeFromFirmware(num9).ToString("x00000000"), num10.ToString("x00000000"),
                         num11.ToString("x00000000"));
                if (num9 > 0)
                {
                  Log.Info("iMONLCDg.Setup(): Found valid display information");
                  fWVersion = num9;
                }
                Log.Info("iMONLCDg.Setup(): Closing SG_RC.dll");
              }
            }
            else
            {
              Log.Info("iMONLCDg.Setup(): Hardware AutoDetect not available");
            }
          }
          catch (Exception exception)
          {
            Log.Info("iMONLCDg.Setup(): RC TEST FAILED... SG_RC.dll not found. Exception: {0}", exception);
          }
          try
          {
            int num3;
            for (int i = 0; i < _BrandTableLength; i++)
            {
              string curBrand = _BrandTable[i, 0];
              string curApp = _BrandTable[i, 1];
              Log.Info("iMONLCDg.Setup(): checking registry for " + curBrand + " entries");
              RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software" + curBrand + "\\" + curApp, false);
              if (key != null)
              {
                num3 = (int)key.GetValue("LastVFD", 0);
                if (num3 > 0)
                {
                  Log.Info("iMONLCDg.Setup(): " + curBrand + " registry entries found - HW: {0}", num3.ToString("x00"));
                  rEGVersion = num3;
                }
                else
                {
                  Log.Info("iMONLCDg.Setup(): " + curBrand + " \"LastVFD\" key not found");
                }
              }
              else
              {
                Log.Info("iMONLCDg.Setup(): " + curBrand + " registry entries NOT found");
              }
              Registry.CurrentUser.Close();
              if (rEGVersion >= 0)
              {
                break;
              }
            }
          }
          catch (Exception exception2)
          {
            Log.Info("iMONLCDg.Setup(): registry test caught exception {0}", exception2);
          }
          if (fWVersion > -1)
          {
            if (GetDisplayInfoFromFirmware(fWVersion))
            {
              Log.Info("iMONLCDg.Setup(): Hardware tests determined - iMON Type: {0}, Display Type: {1} Rsrvd: {2}",
                       _VfdType.ToString("x00"), DisplayType.TypeName(_DisplayType), _VfdReserved.ToString("x00"));
            }
            else
            {
              Log.Info("iMONLCDg.Setup(): Hardware tests determined UNSUPPORTED display type!");
              _DisplayType = DisplayType.Unsupported;
            }
          }
          else if (rEGVersion > -1)
          {
            if (GetDisplayInfoFromRegistry(rEGVersion))
            {
              Log.Info("iMONLCDg.Setup(): Registry tests determined - iMON Type: {0}, Display Type: {1} Rsrvd: {2}",
                       _VfdType.ToString("x00"), DisplayType.TypeName(_DisplayType), _VfdReserved.ToString("x00"));
            }
            else
            {
              Log.Info("iMONLCDg.Setup(): Registry tests determined UNSUPPORTED display type!");
              _DisplayType = DisplayType.Unsupported;
              _isDisabled = true;
            }
          }
          else
          {
            Log.Info("(IDisplay) iMONLCDg.Setup(): Display Type could not be determined");
            _DisplayType = DisplayType.Unsupported;
            _isDisabled = true;
          }
          if (_DisplayType == DisplayType.Unsupported)
          {
            _isDisabled = true;
            Log.Info("(IDisplay) iMONLCDg.Setup(): Display Type is NOT SUPPORTED - Plugin disabled");
          }
          break;
      }

      if (!_isDisabled)
      {
        try
        {
          Log.Info("(IDisplay) iMONLCDg.Setup(): Testing iMON Display device");
          if (_IMON.iMONVFD_IsInited())
          {
            Log.Info("(IDisplay) iMONLCDg.Setup(): iMON Display found");
            _IMON.iMONVFD_Uninit();
          }
          Log.Info("(IDisplay) iMONLCDg.Setup(): opening display type {0}", DisplayType.TypeName(_DisplayType));
          if (!_IMON.iMONVFD_Init(_VfdType, _VfdReserved))
          {
            Log.Info("(IDisplay) iMONLCDg.Setup(): Open failed - No iMON device found");
            _isDisabled = true;
            _errorMessage = "iMONLCDg could not find an iMON LCD display";
          }
          else
          {
            Log.Info("(IDisplay) iMONLCDg.Setup(): iMON Display device found");
            _IMON.iMONVFD_Uninit();
          }
        }
        catch (Exception exception3)
        {
          _isDisabled = true;
          _errorMessage = exception3.Message;
          Log.Info("(IDisplay) iMONLCDg.Setup(): caught an exception.");
        }
      }
      string property = GUIPropertyManager.GetProperty("#currentmodule");
      Log.Info("(IDisplay) iMONLCDg.Setup(): current module = {0}", property);
      if ((_DisplayType == DisplayType.LCD) || (_DisplayType == DisplayType.LCD2))
      {
        _grows = linesG;
        if (_grows > 0x10)
        {
          _grows = 0x10;
          Log.Info(
            "(IDisplay) iMONLCDg.Setup(): DISPLAY CONFIGURATION (GRAPHICS MODE) ERROR - Rows must be less then or equal to 16");
        }
        _gcols = colsG;
        if (_gcols > 0x60)
        {
          _gcols = 0x60;
          Log.Info(
            "(IDisplay) iMONLCDg.Setup(): DISPLAY CONFIGURATION (GRAPHICS MODE) ERROR - Columns must be less then or equal to 96");
        }
      }
      else if (_DisplayType == DisplayType.VFD)
      {
        _trows = lines;
        if (_trows > 2)
        {
          _trows = 2;
          Log.Info(
            "(IDisplay) iMONLCDg.Setup(): DISPLAY CONFIGURATION (TEXT MODE) ERROR - Rows must be less then or equal to 2");
        }
        else
        {
          Log.Info("(IDisplay) iMONLCDg.Setup(): _trows (Text Mode Rows) set to {0}", _trows);
        }
        Log.Info("(IDisplay) iMONLCDg.Setup(): _tcols (Text Mode Columns) set to {0}", _tcols);
        DisplayOptions.DiskMediaStatus = false;
        DisplayOptions.VolumeDisplay = false;
        DisplayOptions.ProgressDisplay = false;
        DisplayOptions.UseCustomFont = false;
        DisplayOptions.UseLargeIcons = false;
        DisplayOptions.UseCustomIcons = false;
        DisplayOptions.UseInvertedIcons = false;
      }
      else if (_DisplayType == DisplayType.ThreeRsystems)
      {
        _trows = lines;
        if (_trows > 1)
        {
          _trows = 1;
          Log.Info("(IDisplay) iMONLCDg.Setup(): DISPLAY CONFIGURATION (3Rsystems MODE) ERROR - Rows must be 1");
        }
        _gcols = 12;
        Log.Info(
          "(IDisplay) iMONLCDg.Setup(): DISPLAY CONFIGURATION (3Rsystems MODE) ERROR - Columns must be less then or equal to 12");

        DisplayOptions.DiskMediaStatus = false;
        DisplayOptions.VolumeDisplay = false;
        DisplayOptions.ProgressDisplay = false;
        DisplayOptions.UseCustomFont = false;
        DisplayOptions.UseLargeIcons = false;
        DisplayOptions.UseCustomIcons = false;
        DisplayOptions.UseInvertedIcons = false;
      }
      _delay = delay;
      _delayG = timeG;
      _delay = Math.Max(_delay, _delayG);
      if ((_DisplayType == DisplayType.LCD) || (_DisplayType == DisplayType.LCD2))
      {
        _delay = Math.Min(2, _delay);
      }
      Log.Info("(IDisplay) iMONLCDg.Setup(): Completed");
    }
예제 #2
0
 private void InitializeDriver()
 {
   DoDebug = Assembly.GetEntryAssembly().FullName.Contains("Configuration") | Settings.Instance.ExtensiveLogging;
   _IsConfiguring = Assembly.GetEntryAssembly().FullName.Contains("Configuration");
   Log.Info("iMONLCDg.InitializeDriver(): started.");
   Log.Info("iMONLCDg.InitializeDriver(): iMONLCDg Driver - {0}", Description);
   Log.Info("iMONLCDg.InitializeDriver(): Called by \"{0}\".", Assembly.GetEntryAssembly().FullName);
   var info = new FileInfo(Assembly.GetExecutingAssembly().Location);
   if (DoDebug)
   {
     Log.Info("iMONLCDg.InitializeDriver(): Assembly creation time: {0} ( {1} UTC )", info.LastWriteTime,
              info.LastWriteTimeUtc.ToUniversalTime());
   }
   LoadAdvancedSettings();
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options - Idle Message: {0}", Settings.Instance.IdleMessage);
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options - Delay driver startup: {0}", _DelayStartup.ToString());
   Log.Info(
     "iMONLCDg.InitializeDriver(): Advanced options - Ensure Antec/iMON Manager is running before driver startup: {0}",
     _EnsureManagerStartup.ToString());
   Log.Info(
     "iMONLCDg.InitializeDriver(): Advanced options - Force Antec/iMON Manager Restart after driver startup: {0}",
     _ForceManagerRestart.ToString());
   Log.Info(
     "iMONLCDg.InitializeDriver(): Advanced options - Force Antec/iMON Manager Reload during driver startup: {0}",
     _ForceManagerReload.ToString());
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options - Restart Antec/iMON Manager FrontView on exit: {0}",
            _RestartFrontviewOnExit.ToString());
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options - Leave Antec/iMON Manager FrontView active: {0}",
            _LeaveFrontviewActive.ToString());
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options - Force Manager to use KeyBoard mode for iMON PAD: {0}",
            _ForceKeyBoardMode.ToString());
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options - Force Display Type: {0}", _ForceDisplay);
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options - Blank display on MediaPortal exit: {0}",
            _BlankDisplayOnExit);
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options - Control Brightness: {0}", _Backlight);
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options - Control Contrast: {0}", _Contrast);
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options - Force Graphic Text: {0}",
            Settings.Instance.ForceGraphicText);
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options - Use Disk Icon: {0}", DisplayOptions.DiskIcon.ToString());
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options - Volume Bar: {10",
            DisplayOptions.VolumeDisplay.ToString());
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options - Progress Bar: {0}",
            DisplayOptions.ProgressDisplay.ToString());
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options - Use Disk Icon For Media Status: {0}",
            DisplayOptions.DiskMediaStatus.ToString());
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options - Use Disk Icon For CD/DVD device status: {0}",
            DisplayOptions.DiskMonitor.ToString());
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options - Custom Font: {0}",
            DisplayOptions.UseCustomFont.ToString());
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options - Large Icons: {0}",
            DisplayOptions.UseLargeIcons.ToString());
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options - Custom Large Icons: {0}",
            DisplayOptions.UseCustomIcons.ToString());
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options - Equalizer Display: {0}", EQSettings.UseEqDisplay);
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options -   EQMode: {0}", EQSettings._useEqMode);
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options -   Normal Equalizer Display: {0}", EQSettings.UseNormalEq);
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options -   Stereo Equalizer Display: {0}", EQSettings.UseStereoEq);
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options -   VU Meter Display: {0}", EQSettings.UseVUmeter);
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options -   VU Meter Style 2 Display: {0}", EQSettings.UseVUmeter2);
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options -     Use VU Channel indicators: {0}",
            EQSettings._useVUindicators);
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options -   Restrict EQ Update Rate: {0}", EQSettings.RestrictEQ);
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options -     Restricted EQ Update Rate: {0} updates per second",
            EQSettings._EQ_Restrict_FPS);
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options -   Delay EQ Startup: {0}", EQSettings.DelayEQ);
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options -     Delay EQ Startup Time: {0} seconds",
            EQSettings._DelayEQTime);
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options -   Smooth EQ Amplitude Decay: {0}", EQSettings.SmoothEQ);
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options -   Show Track Info with EQ display: {0}",
            EQSettings.EQTitleDisplay);
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options -     Show Track Info Interval: {0} seconds",
            EQSettings._EQTitleDisplayTime);
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options -     Show Track Info duration: {0} seconds",
            EQSettings._EQTitleShowTime);
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options - Blank display with video: {0}",
            DisplaySettings.BlankDisplayWithVideo);
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options -   Enable Display on Action: {0}",
            DisplaySettings.EnableDisplayAction);
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options -     Enable display for: {0} seconds",
            DisplaySettings.DisplayActionTime);
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options - Monitor PowerState Events: {0}", _MonitorPower);
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options - Blank display when idle: {0}",
            DisplaySettings.BlankDisplayWhenIdle);
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options -     blank display after: {0} seconds",
            DisplaySettings._BlankIdleTimeout / 0xf4240L);
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options - Shutdown Message - Line 1: {0}",
            DisplaySettings._Shutdown1);
   Log.Info("iMONLCDg.InitializeDriver(): Advanced options - Shutdown Message - Line 2: {0}",
            DisplaySettings._Shutdown2);
   Log.Info("iMONLCDg.InitializeDriver(): Setting - Audio using ASIO: {0}", EQSettings._AudioUseASIO);
   Log.Info("iMONLCDg.InitializeDriver(): Setting - Audio using Mixer: {0}", EQSettings._AudioIsMixing);
   if (!DisplayOptions.DiskMonitor & !DisplayOptions.DiskMediaStatus)
   {
     DisplayOptions.DiskIcon = false;
   }
   if (_ForceDisplay == "LCD")
   {
     _DisplayType = DisplayType.LCD;
     Log.Info("iMONLCDg.InitializeDriver(): Advanced options forces display type to LCD");
   }
   else if (_ForceDisplay == "LCD2")
   {
     _DisplayType = DisplayType.LCD2;
     Log.Info("iMONLCDg.InitializeDriver(): Advanced options forces display type to LCD2");
   }
   else if (_ForceDisplay == "VFD")
   {
     _DisplayType = DisplayType.VFD;
     Log.Info("iMONLCDg.InitializeDriver(): Advanced options forces display type to VFD");
   }
   else if (_ForceDisplay == "LCD3R")
   {
     _DisplayType = DisplayType.VFD;
     Log.Info("iMONLCDg.InitializeDriver(): Advanced options forces display type to LCD3R");
   }
   Log.Info("iMONLCDg.InitializeDriver(): Extensive logging: {0}", DoDebug);
   Log.Info("iMONLCDg.InitializeDriver(): Use V3 DLL for VFD: {0}", _VFD_UseV3DLL);
   Log.Info("iMONLCDg.InitializeDriver(): Display Type: {0}", DisplayType.TypeName(_DisplayType));
   if (((imonVFD_DLLFile = FindImonVFDdll()) == string.Empty) & !_VFD_UseV3DLL)
   {
     Log.Info("iMONLCDg.InitializeDriver(): Failed - installed sg_vfd.dll not found - driver disabled");
     _isDisabled = true;
   }
   else
   {
     _IMON = new iMONDisplay();
     if (!_IMON.Initialize(imonVFD_DLLFile))
     {
       Log.Info("iMONLCDg.InitializeDriver(): DLL linking Failed - driver disabled");
       _isDisabled = true;
     }
     else
     {
       _isDisabled = false;
       Log.Info("iMONLCDg.InitializeDriver(): completed.");
     }
   }
 }