Пример #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("\nGPIO Button and LED Test\n");

            IO.Objects.USB.HID.Messenger m = new IO.Objects.USB.HID.Messenger();
            IO.Remote.Device             d = new IO.Remote.Device(m);

            // Configure LED output

            IO.Interfaces.GPIO.Pin LD1 =
                new IO.Remote.GPIO(d, 0, IO.Interfaces.GPIO.Direction.Output);

            // Configure button input

            IO.Interfaces.GPIO.Pin SW1 =
                new IO.Remote.GPIO(d, 1, IO.Interfaces.GPIO.Direction.Input);

            bool OldState = !SW1.state;
            bool NewState = OldState;

            // Read the button and write the LED

            for (;;)
            {
                NewState = SW1.state;

                if (NewState != OldState)
                {
                    if (NewState)
                    {
                        Console.WriteLine("PRESSED");
                        LD1.state = true;
                    }
                    else
                    {
                        Console.WriteLine("RELEASED");
                        LD1.state = false;
                    }

                    OldState = NewState;
                }

                System.Threading.Thread.Sleep(100);
            }
        }
Пример #2
0
        /// <summary>
        /// Create a Remote I/O device object for a Munts Technologies
        /// USB raw HID (VID=0x16D0, PID=0x0AFA) device Remote I/O Server.
        /// </summary>
        public Device()
        {
            transport = new IO.Objects.USB.HID.Messenger();

            Message cmd  = new Message(0);
            Message resp = new Message();

            cmd.payload[0] = (byte)MessageTypes.VERSION_REQUEST;
            cmd.payload[1] = 1;

            transport.Transaction(cmd, resp);
            Version_string = System.Text.Encoding.UTF8.GetString(resp.payload, 3, Message.Size - 3).Trim('\0');

            cmd.payload[0] = (byte)MessageTypes.CAPABILITY_REQUEST;
            cmd.payload[1] = 2;

            transport.Transaction(cmd, resp);
            Capability_string = System.Text.Encoding.UTF8.GetString(resp.payload, 3, Message.Size - 3).Trim('\0');
        }
Пример #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("\nGPIO Pin Toggle Test\n");

            IO.Objects.USB.HID.Messenger m = new IO.Objects.USB.HID.Messenger();
            IO.Remote.Device             d = new IO.Remote.Device(m);

            // Create GPIO pin object

            Console.Write("GPIO channel number? ");

            IO.Interfaces.GPIO.Pin Output =
                new IO.Remote.GPIO(d, int.Parse(Console.ReadLine()),
                                   IO.Interfaces.GPIO.Direction.Output);

            // Toggle the GPIO output

            Console.WriteLine("\nPress CONTROL-C to exit");

            for (;;)
            {
                Output.state = !Output.state;
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("\nUSB HID Remote I/O Device Information Query Test\n");

            IO.Objects.USB.HID.Messenger m   = new IO.Objects.USB.HID.Messenger();
            IO.Remote.Device             dev = new IO.Remote.Device(m);

            // Display some device information

            Console.WriteLine(m.Info);
            Console.WriteLine(dev.Version);
            Console.WriteLine(dev.Capabilities);
            Console.WriteLine();

            // Display the available ADC inputs

            Console.Write("ADC inputs:  ");

            foreach (int input in dev.ADC_Available())
            {
                Console.Write(input.ToString() + " ");
            }

            Console.WriteLine();

            // Display the available DAC outputs

            Console.Write("DAC outputs: ");

            foreach (int input in dev.DAC_Available())
            {
                Console.Write(input.ToString() + " ");
            }

            Console.WriteLine();

            // Display the available GPIO pins

            Console.Write("GPIO Pins:   ");

            foreach (int pin in dev.GPIO_Available())
            {
                Console.Write(pin.ToString() + " ");
            }

            Console.WriteLine();

            // Display the available I2C buses

            Console.Write("I2C buses:   ");

            foreach (int bus in dev.I2C_Available())
            {
                Console.Write(bus.ToString() + " ");
            }

            Console.WriteLine();

            // Display the available PWM outputs

            Console.Write("PWM outputs: ");

            foreach (int bus in dev.PWM_Available())
            {
                Console.Write(bus.ToString() + " ");
            }

            Console.WriteLine();

            // Display the available SPI devices

            Console.Write("SPI devices: ");

            foreach (int bus in dev.SPI_Available())
            {
                Console.Write(bus.ToString() + " ");
            }

            Console.WriteLine();
        }