コード例 #1
0
        // This class maps GPIOs to Buttons processable by Microsoft.SPOT.Presentation
        public GPIOButtonInputProvider(PresentationSource source)
        {
            // Set the input source.
            this.source = source;
            // Register our object as an input source with the input manager and get back an
            // InputProviderSite object which forwards the input report to the input manager,
            // which then places the input in the staging area.
            site = InputManager.CurrentInputManager.RegisterInputProvider(this);
            // Create a delegate that refers to the InputProviderSite object's ReportInput method
            callback   = new ReportInputCallback(site.ReportInput);
            Dispatcher = Dispatcher.CurrentDispatcher;

            // Allocate button pads and assign the (emulated) hardware pins as input
            // from specific buttons.
            ButtonPad[] buttons = new ButtonPad[]
            {
                // Associate the buttons to the pins as setup in the emulator/hardware
                new ButtonPad(this, Button.VK_LEFT, (Cpu.Pin) 86),
                new ButtonPad(this, Button.VK_RIGHT, (Cpu.Pin) 87),
                new ButtonPad(this, Button.VK_UP, (Cpu.Pin) 88),
                new ButtonPad(this, Button.VK_SELECT, (Cpu.Pin) 89),
                new ButtonPad(this, Button.VK_DOWN, (Cpu.Pin) 90),

                // For a hardware board that has predefined buttons,  can use the
                // Microsoft.SPOT.Hardware.GetButtonPin to retrieve the GPIO pin number associate
                // with button name
                //      new ButtonPad(this, Button.Left  , hwProvider.GetButtonPins(Button.Left)),
                //      new ButtonPad(this, Button.Right , hwProvider.GetButtonPins(Button.Right)),
                //      new ButtonPad(this, Button.Up    , hwProvider.GetButtonPins(Button.Up)),
                //      new ButtonPad(this, Button.Select, hwProvider.GetButtonPins(Button.Select)),
                //      new ButtonPad(this, Button.Down  , hwProvider.GetButtonPins(Button.Down)),
            };

            this.buttons = buttons;
        }
コード例 #2
0
        // This class maps GPIOs to Buttons processable by nanoFramework.UI.Presentation
        public GpioButtonInputProvider(PresentationSource source)
        {
            // Set the input source.
            this.source = source;
            // Register our object as an input source with the input manager and get back an
            // InputProviderSite object which forwards the input report to the input manager,
            // which then places the input in the staging area.
            site = InputManager.CurrentInputManager.RegisterInputProvider(this);
            // Create a delegate that refers to the InputProviderSite object's ReportInput method
            callback   = new ReportInputCallback(site.ReportInput);
            Dispatcher = Dispatcher.CurrentDispatcher;


            GpioPin pinLeft   = Gpio.OpenPin(1);
            GpioPin pinRight  = Gpio.OpenPin(2);
            GpioPin pinUp     = Gpio.OpenPin(3);
            GpioPin pinSelect = Gpio.OpenPin(4);
            GpioPin pinDown   = Gpio.OpenPin(5);


            // Allocate button pads and assign the (emulated) hardware pins as input
            // from specific buttons.
            ButtonPad[] buttons = new ButtonPad[]
            {
                // Associate the buttons to the pins as discovered or set above
                new ButtonPad(this, Button.VK_LEFT, pinLeft),
                new ButtonPad(this, Button.VK_RIGHT, pinRight),
                new ButtonPad(this, Button.VK_UP, pinUp),
                new ButtonPad(this, Button.VK_SELECT, pinSelect),
                new ButtonPad(this, Button.VK_DOWN, pinDown),
            };

            this.buttons = buttons;
        }
コード例 #3
0
        // This class maps GPIOs to Buttons processable by Microsoft.SPOT.Presentation
        public GPIOButtonInputProvider(PresentationSource source)
        {
            // Set the input source.
            this.source = source;
            // Register our object as an input source with the input manager and get back an
            // InputProviderSite object which forwards the input report to the input manager,
            // which then places the input in the staging area.
            site = InputManager.CurrentInputManager.RegisterInputProvider(this);
            // Create a delegate that refers to the InputProviderSite object's ReportInput method
            callback = new ReportInputCallback(site.ReportInput);
            Dispatcher = Dispatcher.CurrentDispatcher;

            // Allocate button pads and assign the (emulated) hardware pins as input
            // from specific buttons.
            ButtonPad[] buttons = new ButtonPad[]
            {
                // Associate the buttons to the pins as setup in the emulator/hardware
                new ButtonPad(this, Button.Left  , Meridian.Pins.GPIO6),
                new ButtonPad(this, Button.Right , Meridian.Pins.GPIO8),
                new ButtonPad(this, Button.Up    , Meridian.Pins.GPIO5),
                new ButtonPad(this, Button.Select, Meridian.Pins.GPIO7),
                new ButtonPad(this, Button.Down  , Meridian.Pins.GPIO9),
            };

            this.buttons = buttons;
        }
コード例 #4
0
        // This class maps GPIOs to Buttons processable by Microsoft.SPOT.Presentation
        public GPIOButtonInputProvider(PresentationSource source)
        {
            // Set the input source.
            this.source = source;
            // Register our object as an input source with the input manager and get back an
            // InputProviderSite object which forwards the input report to the input manager,
            // which then places the input in the staging area.
            site = InputManager.CurrentInputManager.RegisterInputProvider(this);
            // Create a delegate that refers to the InputProviderSite object's ReportInput method
            callback   = new ReportInputCallback(site.ReportInput);
            Dispatcher = Dispatcher.CurrentDispatcher;

            // Allocate button pads and assign the (emulated) hardware pins as input
            // from specific buttons.
            ButtonPad[] buttons = new ButtonPad[]
            {
                // Associate the buttons to the pins as setup in the emulator/hardware
                new ButtonPad(this, Button.Left, Meridian.Pins.GPIO6),
                new ButtonPad(this, Button.Right, Meridian.Pins.GPIO8),
                new ButtonPad(this, Button.Up, Meridian.Pins.GPIO5),
                new ButtonPad(this, Button.Select, Meridian.Pins.GPIO7),
                new ButtonPad(this, Button.Down, Meridian.Pins.GPIO9),
            };

            this.buttons = buttons;
        }
コード例 #5
0
        // This class maps GPIOs to Buttons processable by Microsoft.SPOT.Presentation
        public GPIOButtonInputProvider(PresentationSource source)
        {
            // Set the input source.
            this.source = source;
            // Register our object as an input source with the input manager and get back an
            // InputProviderSite object which forwards the input report to the input manager,
            // which then places the input in the staging area.
            site = InputManager.CurrentInputManager.RegisterInputProvider(this);
            // Create a delegate that refers to the InputProviderSite object's ReportInput method
            callback   = new ReportInputCallback(site.ReportInput);
            Dispatcher = Dispatcher.CurrentDispatcher;

            // Create a hardware provider
            HardwareProvider hwProvider = new HardwareProvider();

            // Create the pins we will need for the buttons
            // Default their values for the emulator
            Cpu.Pin pinLeft   = Cpu.Pin.GPIO_Pin0;
            Cpu.Pin pinRight  = Cpu.Pin.GPIO_Pin1;
            Cpu.Pin pinUp     = Cpu.Pin.GPIO_Pin2;
            Cpu.Pin pinSelect = Cpu.Pin.GPIO_Pin3;
            Cpu.Pin pinDown   = Cpu.Pin.GPIO_Pin4;

            // Use the hardware provider to get the pins
            // If the left pin is not set then assume none of them are
            // and set the left pin back to the default emulator value
            if ((pinLeft = hwProvider.GetButtonPins(Button.VK_LEFT)) == Cpu.Pin.GPIO_NONE)
            {
                pinLeft = Cpu.Pin.GPIO_Pin0;
            }
            else
            {
                pinRight  = hwProvider.GetButtonPins(Button.VK_RIGHT);
                pinUp     = hwProvider.GetButtonPins(Button.VK_UP);
                pinSelect = hwProvider.GetButtonPins(Button.VK_SELECT);
                pinDown   = hwProvider.GetButtonPins(Button.VK_DOWN);
            }

            // Allocate button pads and assign the (emulated) hardware pins as input
            // from specific buttons.
            ButtonPad[] buttons = new ButtonPad[]
            {
                // Associate the buttons to the pins as discovered or set above
                new ButtonPad(this, Button.VK_LEFT, pinLeft),
                new ButtonPad(this, Button.VK_RIGHT, pinRight),
                new ButtonPad(this, Button.VK_UP, pinUp),
                new ButtonPad(this, Button.VK_SELECT, pinSelect),
                new ButtonPad(this, Button.VK_DOWN, pinDown),
            };

            this.buttons = buttons;
        }
コード例 #6
0
        // This class maps GPIOs to Buttons processable by Microsoft.SPOT.Presentation
        public GPIOButtonInputProvider(PresentationSource source)
        {
            // Set the input source.
            this.source = source;
            // Register our object as an input source with the input manager and get back an
            // InputProviderSite object which forwards the input report to the input manager,
            // which then places the input in the staging area.
            site = InputManager.CurrentInputManager.RegisterInputProvider(this);
            // Create a delegate that refers to the InputProviderSite object's ReportInput method
            callback = new ReportInputCallback(site.ReportInput);
            Dispatcher = Dispatcher.CurrentDispatcher;

            // Create a hardware provider
            HardwareProvider hwProvider = new HardwareProvider();

            // Create the pins we will need for the buttons
            // Default their values for the emulator
            Cpu.Pin pinLeft = Cpu.Pin.GPIO_Pin0;
            Cpu.Pin pinRight = Cpu.Pin.GPIO_Pin1;
            Cpu.Pin pinUp = Cpu.Pin.GPIO_Pin2;
            Cpu.Pin pinSelect = Cpu.Pin.GPIO_Pin3;
            Cpu.Pin pinDown = Cpu.Pin.GPIO_Pin4;

            // Use the hardware provider to get the pins
            // If the left pin is not set then assume none of them are
            // and set the left pin back to the default emulator value
            if ((pinLeft = hwProvider.GetButtonPins(Button.VK_LEFT)) == Cpu.Pin.GPIO_NONE)
                pinLeft = Cpu.Pin.GPIO_Pin0;
            else
            {
                pinRight = hwProvider.GetButtonPins(Button.VK_RIGHT);
                pinUp = hwProvider.GetButtonPins(Button.VK_UP);
                pinSelect = hwProvider.GetButtonPins(Button.VK_SELECT);
                pinDown = hwProvider.GetButtonPins(Button.VK_DOWN);
            }

            // Allocate button pads and assign the (emulated) hardware pins as input
            // from specific buttons.
            ButtonPad[] buttons = new ButtonPad[]
            {
                // Associate the buttons to the pins as discovered or set above
                new ButtonPad(this, Button.VK_LEFT  , pinLeft),
                new ButtonPad(this, Button.VK_RIGHT , pinRight),
                new ButtonPad(this, Button.VK_UP    , pinUp),
                new ButtonPad(this, Button.VK_SELECT, pinSelect),
                new ButtonPad(this, Button.VK_DOWN  , pinDown),
            };

            this.buttons = buttons;
        }
コード例 #7
0
        /// <summary>
        /// Creates new instance of input provider
        /// </summary>
        /// <param name="source">Presentation source</param>
        /// <param name="controller">TV Remote Receiver controller driver</param>
        /// <param name="address">Address of device. Use -1 for everything.</param>
        /// <param name="buttons">Command to WPF button maping</param>
        public TVRemoteInputProvider(PresentationSource source, TVRemoteReceiver controller, int address, TVRemoteButtonPad[] buttons)
        {
            // Set the input source.
            this.source = source;
            // Register our object as an input source with the input manager and get back an
            // InputProviderSite object which forwards the input report to the input manager,
            // which then places the input in the staging area.
            site = InputManager.CurrentInputManager.RegisterInputProvider(this);
            // Create a delegate that refers to the InputProviderSite object's ReportInput method
            callback   = new ReportInputCallback(site.ReportInput);
            Dispatcher = Dispatcher.CurrentDispatcher;

            deviceAddress = address;
            this.buttons  = buttons;

            ButtonAction = RawButtonActions.ButtonUp;

            controller.DataReceived += new TVRemoteReceiver.TVRemoteDataHandler(controller_DataReceived);
        }
コード例 #8
0
        /// <summary>
        /// Creates new instance of input provider
        /// </summary>
        /// <param name="source">Presentation source</param>
        /// <param name="controller">TV Remote Receiver controller driver</param>
        /// <param name="address">Address of device. Use -1 for everything.</param>
        /// <param name="buttons">Command to WPF button maping</param>
        public TVRemoteInputProvider(PresentationSource source, TVRemoteReceiver controller, int address, TVRemoteButtonPad[] buttons)
        {
            // Set the input source.
            this.source = source;
            // Register our object as an input source with the input manager and get back an
            // InputProviderSite object which forwards the input report to the input manager,
            // which then places the input in the staging area.
            site = InputManager.CurrentInputManager.RegisterInputProvider(this);
            // Create a delegate that refers to the InputProviderSite object's ReportInput method
            callback = new ReportInputCallback(site.ReportInput);
            Dispatcher = Dispatcher.CurrentDispatcher;

            deviceAddress = address;
            this.buttons = buttons;

            ButtonAction = RawButtonActions.ButtonUp;

            controller.DataReceived += new TVRemoteReceiver.TVRemoteDataHandler(controller_DataReceived);
        }
コード例 #9
0
        // This class maps GPIOs to Buttons processable by Microsoft.SPOT.Presentation
        public GPIOButtonInputProvider(PresentationSource source)
        {
            // Set the input source.
            this.source = source;
            // Register our object as an input source with the input manager and get back an
            // InputProviderSite object which forwards the input report to the input manager,
            // which then places the input in the staging area.
            site = InputManager.CurrentInputManager.RegisterInputProvider(this);
            // Create a delegate that refers to the InputProviderSite object's ReportInput method
            callback = new ReportInputCallback(site.ReportInput);
            Dispatcher = Dispatcher.CurrentDispatcher;

            // Allocate button pads and assign the (emulated) hardware pins as input 
            // from specific buttons.
            ButtonPad[] buttons = new ButtonPad[]
            {
                // Associate the buttons to the pins as setup in the emulator/hardware
                new ButtonPad(this, Button.VK_LEFT  , (Cpu.Pin)86),
                new ButtonPad(this, Button.VK_RIGHT , (Cpu.Pin)87),
                new ButtonPad(this, Button.VK_UP    , (Cpu.Pin)88),
                new ButtonPad(this, Button.VK_SELECT, (Cpu.Pin)89),
                new ButtonPad(this, Button.VK_DOWN  , (Cpu.Pin)90),

                // For a hardware board that has predefined buttons,  can use the 
                // Microsoft.SPOT.Hardware.GetButtonPin to retrieve the GPIO pin number associate 
                // with button name
                //      new ButtonPad(this, Button.Left  , hwProvider.GetButtonPins(Button.Left)),
                //      new ButtonPad(this, Button.Right , hwProvider.GetButtonPins(Button.Right)),
                //      new ButtonPad(this, Button.Up    , hwProvider.GetButtonPins(Button.Up)),
                //      new ButtonPad(this, Button.Select, hwProvider.GetButtonPins(Button.Select)),
                //      new ButtonPad(this, Button.Down  , hwProvider.GetButtonPins(Button.Down)),
                
                
            };

            this.buttons = buttons;
        }