/// <summary> /// Creates an instance of the RaspberryPi3Driver. /// This driver works on Raspberry 3 or 4, both on Linux and on Windows /// </summary> public RaspberryPi3Driver() { if (Environment.OSVersion.Platform == PlatformID.Unix) { _linuxDriver = CreateInternalRaspberryPi3LinuxDriver(out RaspberryBoardInfo boardInfo); if (_linuxDriver == null) { throw new PlatformNotSupportedException($"Not a supported Raspberry Pi type: " + boardInfo.BoardModel); } _setSetRegister = (value) => _linuxDriver.SetRegister = value; _setClearRegister = (value) => _linuxDriver.ClearRegister = value; _getSetRegister = () => _linuxDriver.SetRegister; _getClearRegister = () => _linuxDriver.ClearRegister; _internalDriver = _linuxDriver; } else { _internalDriver = CreateWindows10GpioDriver(); _setSetRegister = (value) => throw new PlatformNotSupportedException(); _setClearRegister = (value) => throw new PlatformNotSupportedException(); _getSetRegister = () => throw new PlatformNotSupportedException(); _getClearRegister = () => throw new PlatformNotSupportedException(); } }
/// <summary> /// Creates an instance of the RaspberryPi3Driver. /// This driver works on Raspberry 3 or 4, both on Linux and on Windows /// </summary> public RaspberryPi3Driver() { _internalDriver = new RaspberryPi3LinuxDriver(); RaspberryPi3LinuxDriver linuxDriver = _internalDriver as RaspberryPi3LinuxDriver; _setSetRegister = (value) => linuxDriver.SetRegister = value; _setClearRegister = (value) => linuxDriver.ClearRegister = value; _getSetRegister = () => linuxDriver.SetRegister; _getClearRegister = () => linuxDriver.ClearRegister; }
internal RaspberryPi3Driver(RaspberryPi3LinuxDriver linuxDriver) { if (Environment.OSVersion.Platform == PlatformID.Unix) { _setSetRegister = (value) => linuxDriver.SetRegister = value; _setClearRegister = (value) => linuxDriver.ClearRegister = value; _getSetRegister = () => linuxDriver.SetRegister; _getClearRegister = () => linuxDriver.ClearRegister; _internalDriver = linuxDriver; } else { throw new NotSupportedException("This ctor is for internal use only"); } }
/// <summary> /// Creates an instance of the RaspberryPi3Driver. /// This driver works on Raspberry 3 or 4, both on Linux and on Windows /// </summary> public RaspberryPi3Driver() { if (Environment.OSVersion.Platform == PlatformID.Unix) { _internalDriver = new RaspberryPi3LinuxDriver(); RaspberryPi3LinuxDriver linuxDriver = _internalDriver as RaspberryPi3LinuxDriver; _setSetRegister = (value) => linuxDriver.SetRegister = value; _setClearRegister = (value) => linuxDriver.ClearRegister = value; _getSetRegister = () => linuxDriver.SetRegister; _getClearRegister = () => linuxDriver.ClearRegister; } else { _internalDriver = new Windows10Driver(); _setSetRegister = (value) => throw new PlatformNotSupportedException(); _setClearRegister = (value) => throw new PlatformNotSupportedException(); _getSetRegister = () => throw new PlatformNotSupportedException(); _getClearRegister = () => throw new PlatformNotSupportedException(); } }