internal static RaspberryPi3LinuxDriver?CreateInternalRaspberryPi3LinuxDriver(out RaspberryBoardInfo boardInfo)
        {
            RaspberryBoardInfo      identification = RaspberryBoardInfo.LoadBoardInfo();
            RaspberryPi3LinuxDriver?linuxDriver;

            boardInfo = identification;
            switch (identification.BoardModel)
            {
            case RaspberryBoardInfo.Model.RaspberryPi3B:
            case RaspberryBoardInfo.Model.RaspberryPi3BPlus:
            case RaspberryBoardInfo.Model.RaspberryPi4:
                linuxDriver = new RaspberryPi3LinuxDriver();
                break;

            case RaspberryBoardInfo.Model.RaspberryPiComputeModule3:
                linuxDriver = new RaspberryPiCm3Driver();
                break;

            default:
                linuxDriver = null;
                break;
            }

            return(linuxDriver);
        }
Beispiel #2
0
        /// <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)
            {
                RaspberryPi3LinuxDriver 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();
            }
        }
Beispiel #3
0
 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");
     }
 }
Beispiel #4
0
 /// <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();
     }
 }