예제 #1
0
        public void Run()
        {
            _logger.Information("Application started");

            Pi.Init <BootstrapWiringPi>();
            _logger.Information("Raspberry Pi bootstrapped");
            _logger.Information($"Raspberry Model: {Pi.Info.RaspberryPiVersion}");
            _logger.Information($"Debug mode: {EnvVar.DebugMode.Value}");
            _logger.Debug($"TERM={EnvVar.Get<string>("TERM", null).Value}");

            _speaker.Initialize();
            _laser.Initialize();

            _speaker.BeepAsync(SpeakerSound.Greet);
            _logger.Information("Application ready");

            ConsoleKeyInfo key;

            do
            {
                key = Console.ReadKey(true);

                _laser.Turned = key.Key switch
                {
                    ConsoleKey.D1 => true,
                    ConsoleKey.D2 => false,
                    _ => _laser.Turned
                };

                _speaker.BeepAsync(SpeakerSound.Beep);
            } while (key.Key != ConsoleKey.Enter);

            _logger.Information("Exiting");
            _laser.Turned = false;
            _speaker.Beep(SpeakerSound.Bye);
        }
    }