Beispiel #1
0
        public static void Main()
        {
            var application = new Application();

            application.RenderException += (_, args) => Console.WriteLine(args.Exception);
            using (var timerFactory = new TimerFactory())
                using (var gpioConnectionDriverFactory = new GpioConnectionDriverFactory(true))
                {
                    var(textDisplayDevice, lcd) = Create(gpioConnectionDriverFactory);
                    using (lcd)
                    {
                        // var textViewNavigator = application.StartRendering(new TextViewRendererFactory(textDisplayDevice, timerFactory));
                        var menuButton = new PullDownButtonDevice(ConnectorPin.P1Pin13);
                        var playButton = new PullDownButtonDevice(ConnectorPin.P1Pin15);
                        var nextButton = new PullDownButtonDevice(ConnectorPin.P1Pin16);
                        var prevButton = new PullDownButtonDevice(ConnectorPin.P1Pin18);
                        using (var gpioConnection = new GpioConnection(gpioConnectionDriverFactory, menuButton.PinConfiguration, playButton.PinConfiguration, nextButton.PinConfiguration, prevButton.PinConfiguration))
                        {
                            using (var rfidTransceiver = new Mfrc522Connection("/dev/spidev0.0", ConnectorPin.P1Pin22, gpioConnectionDriverFactory, null, new RfidConnectionLogger()))
                                using (var rotaryEncoder = new Ky040Device(ConnectorPin.P1Pin36, ConnectorPin.P1Pin38, ConnectorPin.P1Pin40, gpioConnectionDriverFactory, new Ky040ConsoleReporter()))
                                {
                                    menuButton.Pressed          += (sender, eventArgs) => Console.WriteLine("Menu");
                                    playButton.Pressed          += (sender, eventArgs) => Console.WriteLine("Play");
                                    nextButton.Pressed          += (sender, eventArgs) => Console.WriteLine("Next");
                                    prevButton.Pressed          += (sender, eventArgs) => Console.WriteLine("Prev");
                                    rotaryEncoder.Pressed       += (sender, args) => Console.WriteLine("Rotary");
                                    rotaryEncoder.Rotated       += RotaryEncoder_Rotated;
                                    rfidTransceiver.TagDetected += RfidTransceiver_TagDetected;
                                    // textViewNavigator.NavigateToAsync(new MainTextView(rfidTransceiver, rotaryEncoder, menuButton,
                                    //    playButton, nextButton, prevButton));
                                    // application.Run();
                                    var i     = 0;
                                    var token = new CancellationTokenSource();
                                    Console.CancelKeyPress += (sender, args) => token.Cancel();
                                    while (!token.IsCancellationRequested)
                                    {
                                        textDisplayDevice.WriteLine(AlignedString.Format("Hello: {0:9, <>}", i++));
                                        Thread.Sleep(100);
                                        textDisplayDevice.WriteLine("                ");
                                        Thread.Sleep(1000);
                                    }
                                }
                        }
                    }
                }

            Console.WriteLine("Ending...");
        }
Beispiel #2
0
        public void Format_Then_ResultShouldBeExpectedResult(object value, string format, string expectedResult)
        {
            var result = AlignedString.FormatInvariant($@"/{format}\", value);

            result.Should().Be(expectedResult);
        }