Пример #1
0
        public MainWindow()
        {
            InitializeComponent();
            string comPort = FindDeviceHack.TryAndFindIOIODevice();

            ComPort_Field.Text = comPort;
            if (comPort != null)
            {
                IOIOConnection connection = new SerialConnectionFactory().CreateConnection(comPort);

                ObserverConnectionState handlerCaptureState = new ObserverConnectionState();
                RotationObserver        rotationObserver    = new RotationObserver(
                    L3G4200DConstants.Gyro_DPS_LSB_2000,        // must match the sensitivity in register initialization
                    PollingIntervalMsec,
                    this.X_Angle, this.Y_Angle, this.Z_Angle,
                    this.X_RawField, this.Y_RawField, this.Z_RawField,
                    this.X_CallibField, this.Y_CallibField, this.Z_CallibField,
                    this.Teapot
                    );

                OurImpl_ = new IOIOImpl(connection, new List <IObserverIOIO>()
                {
                    handlerCaptureState, rotationObserver
                }
                                        );
                OurImpl_.WaitForConnect();

                IConnectedDeviceResponse device = handlerCaptureState.ConnectedDeviceDescription();
                if (device != null)
                {
                    // could display board details
                }
                CommandFactory_ = new IOIOMessageCommandFactory();
                ConfigureCompass();
                ConfigureTimedEvents();
            }
            else
            {
                ComPort_Field.Text = "Unable to find an IOIO device";
            }
        }
Пример #2
0
        public MainWindow()
        {
            InitializeComponent();
            string comPort = FindDeviceHack.TryAndFindIOIODevice();

            ComPort_Field.Text = comPort;
            if (comPort != null)
            {
                IOIOConnection connection = new SerialConnectionFactory().CreateConnection(comPort);

                ObserverConnectionState handlerCaptureState = new ObserverConnectionState();
                MessageObserver         textBoxObserver     = new MessageObserver(this.MessageLog);

                OurImpl_ = new IOIOImpl(connection, new List <IObserverIOIO>()
                {
                    handlerCaptureState, textBoxObserver
                }
                                        );
                OurImpl_.WaitForConnect();

                IConnectedDeviceResponse device = handlerCaptureState.ConnectedDeviceDescription();
                if (device != null)
                {
                    BoardDetails.Text = "Bootloader:" + device.BootloaderId
                                        + "\n" + "Firmware:" + device.FirmwareId
                                        + "\n" + "Hardware: " + device.HardwareId;
                }
                IOIOMessageCommandFactory commandFactory = new IOIOMessageCommandFactory();
                ConfigurePwm(commandFactory);
                ConfigureLed(commandFactory);
                ConfigureDigitalInput(commandFactory);
            }
            else
            {
                //this.Close();
                BoardDetails.Text = "Unable to find an IOIO device";
            }
        }