示例#1
0
        // TODO: remove try catch after https://github.com/dotnet/corefx/issues/32015 deployed
        public static UnixDriver Create()
        {
            UnixDriver driver = null;

            try
            {
                driver = new LibGpiodDriver();
            }
            catch (PlatformNotSupportedException)
            {
                driver = new SysFsDriver();
            }
            return(driver);
        }
示例#2
0
        public static async Task Main(string[] args)
        {
            try
            {
                _console = new ConsoleWrapper();
                _console.WriteLine("JukeCore started!");

                string jukeCoreMediaPath = args.First();
                _console.WriteLine($"Path to media folder is: '{jukeCoreMediaPath}'.");

                _console.WriteLine("Initialzing LibVLC ... ");
                Core.Initialize();

                _console.WriteLine("Creating app registry ... ");
                var fileSystem = new FileSystem();
                using var libVlc = new LibVLC();
                _playlist        = new Playlist(_console);
                _mediaPlayer     = new MediaPlayerWrapper(new MediaPlayer(libVlc), _console, _playlist);
                var commandFactory =
                    new MediaFactory(fileSystem.Directory,
                                     fileSystem.Path, _console, libVlc);
                var processor = new IdProcessor(commandFactory, _console, _playlist, _mediaPlayer);
                var mainLoop  = new MainLoop(_console, processor);

                var driver           = new SysFsDriver();
                var controller       = new GpioController(PinNumberingScheme.Logical, driver);
                var volDownButton    = new VolumeDownButton(controller, _mediaPlayer, _console);
                var volUpButton      = new VolumeUpButton(controller, _mediaPlayer, _console);
                var previousButton   = new PreviousButton(controller, _mediaPlayer, _playlist, _console);
                var nextButton       = new NextButton(controller, _mediaPlayer, _playlist, _console);
                var playPlauseButton = new PlayPauseButton(controller, _mediaPlayer, _console);

#pragma warning disable 4014
                volDownButton.Activate(4);
                volUpButton.Activate(17);
                previousButton.Activate(22);
                nextButton.Activate(24);
                playPlauseButton.Activate(23);
#pragma warning restore 4014

                await mainLoop.Run(jukeCoreMediaPath);
            }
            catch (Exception e)
            {
                _console.WriteLine(e.Message);
            }
        }
示例#3
0
    /// <summary>
    /// Static factory method
    /// </summary>
    /// <returns>An instance of GpioDriver, depending on which one fits</returns>
    // TODO: remove try catch after https://github.com/dotnet/corefx/issues/32015 deployed
    public static UnixDriver Create()
    {
        if (Environment.OSVersion.Platform != PlatformID.Unix)
        {
            throw new PlatformNotSupportedException(nameof(UnixDriver) + " is only supported on Linux/Unix");
        }

        UnixDriver?driver = null;

        try
        {
            driver = new LibGpiodDriver();
        }
        catch (PlatformNotSupportedException)
        {
            driver = new SysFsDriver();
        }

        return(driver);
    }