Ejemplo n.º 1
0
        private static async void Test(string ipString)
        {
            var ipAddress = IPAddress.Parse(ipString);
            var remoteEp  = new IPEndPoint(ipAddress, Port);

            using (var client = new PiFaceClient(remoteEp))
            {
                client.Connect();

                var initResult = await client.WiringPiSetupPiFaceAsync();

                Log.HighLight(initResult.ToString());

                Array.ForEach(
                    Enumerable.Range(0, 8).ToArray(),
                    async pin =>
                {
                    var pudResult = await client.PullUpDnControlAsync(pin, PullUpDn.Up);
                    Log.HighLight(pudResult.ToString());
                }
                    );
                var dwResult = await client.DigitalWriteAsync(0, PinState.High);

                Log.HighLight(dwResult.ToString());

                Thread.Sleep(5000);

                dwResult = await client.DigitalWriteAsync(0, PinState.Low);

                Log.HighLight(dwResult.ToString());

                var rdResult = await client.DigitalReadAsync(0);

                Log.HighLight(rdResult.ToString());


                client.BeginMonitorInput(
                    0,
                    callback: client.ControlSaftblandare
                    );

                Console.Read();
            }
        }
Ejemplo n.º 2
0
 private static void ControlSaftblandare(this PiFaceClient client, Command command)
 {
     client.BeginDigitalWrite(0, command.Value == 1 ? PinState.Low : PinState.High);
 }