private async void drawMaestroControls()
        {
            // get the number of servos on the board
            UInt16 count = maestroDevice.Maestro.ServoCount;

            // get all the settings stored on the board
            settings = await maestroDevice.Maestro.getUscSettings();

            Task.WaitAll();
            // maestroDevice.Maestro.getMaestroVariables();
            tbDeviceName.Text = maestroDevice.Name + " Connected";
            // Create an array of  controls
            channelSettings = new ChannelSettingsControl[count];
            for (byte i = 0; i < count; i++)
            {
                // add a speed , acceleration and target controls to the app
                channelSettings[i] = new ChannelSettingsControl();
                channelSettings[i].ChannelNumber = i;

                channelSettings[i].Acceleration = settings.channelSettings[i].acceleration;
                channelSettings[i].Speed        = settings.channelSettings[i].speed;
                channelSettings[i].MinPosition  = settings.channelSettings[i].minimum;
                channelSettings[i].MaxPosition  = settings.channelSettings[i].maximum;
                channelSettings[i].ServoName    = settings.channelSettings[i].name;
                channelSettings[i].Mode         = settings.channelSettings[i].mode;
                channelSettings[i].homeMode     = settings.channelSettings[i].homeMode;
                channelSettings[i].Range        = (Int16)settings.channelSettings[i].range;
                channelSettings[i].Target       = settings.channelSettings[i].home;
                channelSettings[i].Nuetral8Bit  = settings.channelSettings[i].neutral;
                ControlPanel.Children.Add(channelSettings[i]);
            }
        }
Exemple #2
0
        protected async override void OnNavigatedTo(NavigationEventArgs eventArgs)
        {
            if (eventArgs.Parameter as MaestroBoard != null)
            {
                maestroDevice     = (eventArgs.Parameter as MaestroBoard).maestro;
                tbDeviceName.Text = maestroDevice.Name + " Connected";
                UInt16 count = maestroDevice.Maestro.ServoCount;
                // get all the settings stored on the board

                settings = await maestroDevice.Maestro.getUscSettings();

                await maestroDevice.Maestro.updateMaestroVariables();

                Task.WaitAll();  // wait until we have all the data
                servoStatus = maestroDevice.Maestro.servoStatus;
                maestroDevice.Maestro.setTarget(0, (ushort)(maestroDevice.Maestro.angleToMicroseconds(0, RHP) + (Offsets[0] * 4)));
                maestroDevice.Maestro.setTarget(1, (ushort)(maestroDevice.Maestro.angleToMicroseconds(1, RKP) + (Offsets[1] * 4)));
                maestroDevice.Maestro.setTarget(2, (ushort)(maestroDevice.Maestro.angleToMicroseconds(2, RAP) + (Offsets[2] * 4)));
                maestroDevice.Maestro.setTarget(3, (ushort)(maestroDevice.Maestro.angleToMicroseconds(3, LHP) + (Offsets[3] * 4)));
                maestroDevice.Maestro.setTarget(4, (ushort)(maestroDevice.Maestro.angleToMicroseconds(4, LKP) + (Offsets[4] * 4)));
                maestroDevice.Maestro.setTarget(5, (ushort)(maestroDevice.Maestro.angleToMicroseconds(5, LAP) + (Offsets[5] * 4)));
                fname = ApplicationData.Current.LocalFolder.Path + "\\Brat.cfg";
                if (File.Exists(fname))
                {
                    // load offsets
                    loadOffsets();
                }
            }
        }
        private async void updateSerialSettings()
        {
            settings = await maestroDevice.Maestro.getUscSettings();

            Task.WaitAll();
            if (settings.serialMode == uscSerialMode.SERIAL_MODE_USB_DUAL_PORT)
            {
                usbDualPort.IsChecked = true;
            }
            if (settings.serialMode == uscSerialMode.SERIAL_MODE_USB_CHAINED)
            {
                usbChained.IsChecked = true;
            }
            if (settings.serialMode == uscSerialMode.SERIAL_MODE_UART_FIXED_BAUD_RATE)
            {
                uartFixedBaud.IsChecked = true;
            }
            if (settings.serialMode == uscSerialMode.SERIAL_MODE_UART_DETECT_BAUD_RATE)
            {
                uartbaudDetect.IsChecked = true;
            }
            BaudRate.Value       = (int)settings.fixedBaudRate;
            crcenabled.IsChecked = settings.enableCrc;
            deviceNumber.Value   = settings.serialDeviceNumber;
            sscoffset.Value      = settings.miniSscOffset;
            timeout.Value        = settings.serialTimeout;
        }
        //  private unsafe int getservostructsize()
        //{
        //  return sizeof(ServoStatus);
        //}

        private async void drawMaestroControls()
        {
            // get the number of servos on the board
            UInt16 count = maestroDevice.Maestro.ServoCount;

            // get all the settings stored on the board

            settings = await maestroDevice.Maestro.getUscSettings();

            await maestroDevice.Maestro.updateMaestroVariables();

            Task.WaitAll();  // wait until we have all the data
            Connected         = true;
            tbDeviceName.Text = maestroDevice.Name + " Connected";
            // Create an array of  controls
            maestroChannels = new MaestroControl[count];
            for (UInt16 i = 0; i < count; i++)
            {
                // add a speed , acceleration and target controls to the app
                maestroChannels[i] = new MaestroControl();
                maestroChannels[i].ChannelNumber = i;
                // update the controls to show current values from the board
                maestroChannels[i].Acceleration = Convert.ToUInt16(settings.channelSettings[i].acceleration);
                maestroChannels[i].Speed        = Convert.ToUInt16(settings.channelSettings[i].speed);
                // position / 4 as it returns it in 1/4 microseconds
                maestroChannels[i].Position = Convert.ToUInt16(MaestroDevice.positionToMicroseconds(maestroDevice.Maestro.servoStatus[i].position));
                maestroPanel.Children.Add(maestroChannels[i]);
                // add the callbacks for changes
                maestroChannels[i].positionChanged     += MainPage_positionChanged;
                maestroChannels[i].speedChanged        += MainPage_speedChanged;
                maestroChannels[i].accelerationChanged += MainPage_accelerationChanged;
            }
        }
Exemple #5
0
        static void configure(Usc usc, string filename)
        {
            Stream        file     = File.Open(filename, FileMode.Open);
            StreamReader  sr       = new StreamReader(file);
            List <String> warnings = new List <string>();
            UscSettings   settings = ConfigurationFile.load(sr, warnings);

            usc.fixSettings(settings, warnings);
            usc.setUscSettings(settings, true);
            sr.Close();
            file.Close();
            usc.reinitialize();
        }