コード例 #1
0
        private void SetTiltServo(bool save = false)
        {
            SetServoParamMsgData data = new SetServoParamMsgData();

            data.idx = 1;
            data.cen = (short)(numTiltCen.Value);
            data.max = (short)(numTiltMax.Value);
            data.min = (short)(numTiltMin.Value);
            data.nty = (short)(numTiltNinty.Value);
            data.acc = (short)(numTiltAcc.Value);
            //data.rev = (sbyte)(cbTiltRev.Checked ? -1 : 1);
            data.save = (byte)(save ? 1 : 0);

            var msg = link.Call(CommandType.SERVO_SET_SETTING, link.GetBytes(data), CommandType.CMD_ACK);

            if (msg.cmd == (byte)CommandType.CMD_ACK)
            {
                if (testTiltCen.Checked)
                {
                    SetServoAngleMsgData angle = new SetServoAngleMsgData();
                    angle.idx = 1;
                    msg       = link.Call(CommandType.SERVO_SET_ANGLE, link.GetBytes(angle));
                }
                else if (testTiltMax.Checked)
                {
                    SetServoPwmMsgData pwm = new SetServoPwmMsgData();
                    pwm.idx = 1;
                    pwm.pwm = (short)(data.max);
                    msg     = link.Call(CommandType.SERVO_SET_PWM, link.GetBytes(pwm));
                }
                else if (testTiltMin.Checked)
                {
                    SetServoPwmMsgData pwm = new SetServoPwmMsgData();
                    pwm.idx = 1;
                    pwm.pwm = (short)(data.min);
                    msg     = link.Call(CommandType.SERVO_SET_PWM, link.GetBytes(pwm));
                }
                else if (testTiltNinty.Checked)
                {
                    SetServoAngleMsgData angle = new SetServoAngleMsgData();
                    angle.idx   = 1;
                    angle.angle = 90;
                    msg         = link.Call(CommandType.SERVO_SET_ANGLE, link.GetBytes(angle));
                }
                else if (testTiltAcc.Checked)
                {
                }
            }
        }
コード例 #2
0
        private bool SetPanServo(bool save = false)
        {
            SetServoParamMsgData data = new SetServoParamMsgData();

            data.idx = 0;
            data.cen = (short)(numPanCen.Value);
            data.max = (short)(numPanMax.Value);
            data.min = (short)(2 * data.cen - data.max);

            data.nty = cbPanRev.Checked ? data.max : data.min;
            //data.nty = data.max;
            data.acc = (short)(numPanAcc.Value);
            //data.rev = (sbyte)(cbPanRev.Checked ? -1 : 1);
            data.save = (byte)(save ? 1 : 0);

            var msg = link.Call(CommandType.SERVO_SET_SETTING, link.GetBytes(data), CommandType.CMD_ACK);

            if (msg.cmd == (byte)CommandType.CMD_ACK)
            {
                if (testPanCen.Checked)
                {
                    SetServoAngleMsgData angle = new SetServoAngleMsgData();
                    msg = link.Call(CommandType.SERVO_SET_ANGLE, link.GetBytes(angle));
                }
                else if (testPanMax.Checked)
                {
                    SetServoPwmMsgData pwm = new SetServoPwmMsgData();
                    pwm.pwm = (short)(data.max / 2);
                    msg     = link.Call(CommandType.SERVO_SET_PWM, link.GetBytes(pwm));
                }
                else if (testPanAcc.Checked)
                {
                }
            }

            return(msg.cmd == (byte)CommandType.CMD_ACK);
        }
コード例 #3
0
ファイル: ServoPanel.cs プロジェクト: cuav/MAAT
        private void SetTiltServo(bool save = false)
        {
            SetServoParamMsgData data = new SetServoParamMsgData();
            data.idx = 1;
            data.cen = (short)(numTiltCen.Value);
            data.max = (short)(numTiltMax.Value);
            data.min = (short)(numTiltMin.Value);
            data.nty = (short)(numTiltNinty.Value);
            data.acc = (short)(numTiltAcc.Value);
            //data.rev = (sbyte)(cbTiltRev.Checked ? -1 : 1);
            data.save = (byte)(save ? 1 : 0);

            var msg = link.Call(CommandType.SERVO_SET_SETTING, link.GetBytes(data), CommandType.CMD_ACK);
            if (msg.cmd == (byte)CommandType.CMD_ACK)
            {

                if (testTiltCen.Checked)
                {
                    SetServoAngleMsgData angle = new SetServoAngleMsgData();
                    angle.idx = 1;
                    msg = link.Call(CommandType.SERVO_SET_ANGLE, link.GetBytes(angle));
                }
                else if (testTiltMax.Checked)
                {
                    SetServoPwmMsgData pwm = new SetServoPwmMsgData();
                    pwm.idx = 1;
                    pwm.pwm = (short)(data.max);
                    msg = link.Call(CommandType.SERVO_SET_PWM, link.GetBytes(pwm));
                }
                else if (testTiltMin.Checked)
                {
                    SetServoPwmMsgData pwm = new SetServoPwmMsgData();
                    pwm.idx = 1;
                    pwm.pwm = (short)(data.min);
                    msg = link.Call(CommandType.SERVO_SET_PWM, link.GetBytes(pwm));
                }
                else if (testTiltNinty.Checked)
                {
                    SetServoAngleMsgData angle = new SetServoAngleMsgData();
                    angle.idx = 1;
                    angle.angle = 90;
                    msg = link.Call(CommandType.SERVO_SET_ANGLE, link.GetBytes(angle));
                }
                else if (testTiltAcc.Checked)
                {

                }
            }
        }
コード例 #4
0
ファイル: ServoPanel.cs プロジェクト: cuav/MAAT
        private bool SetPanServo(bool save = false)
        {
            SetServoParamMsgData data = new SetServoParamMsgData();
            data.idx = 0;
            data.cen = (short)(numPanCen.Value);
            data.max = (short)(numPanMax.Value);
            data.min = (short)(2 * data.cen - data.max);

            data.nty = cbPanRev.Checked ? data.max : data.min;
            //data.nty = data.max;
            data.acc = (short)(numPanAcc.Value);
            //data.rev = (sbyte)(cbPanRev.Checked ? -1 : 1);
            data.save = (byte)(save ? 1 : 0);

            var msg = link.Call(CommandType.SERVO_SET_SETTING, link.GetBytes(data), CommandType.CMD_ACK);
            if (msg.cmd == (byte)CommandType.CMD_ACK)
            {

                if (testPanCen.Checked)
                {
                    SetServoAngleMsgData angle = new SetServoAngleMsgData();
                    msg = link.Call(CommandType.SERVO_SET_ANGLE, link.GetBytes(angle));
                }
                else if (testPanMax.Checked)
                {
                    SetServoPwmMsgData pwm = new SetServoPwmMsgData();
                    pwm.pwm = (short)(data.max / 2);
                    msg = link.Call(CommandType.SERVO_SET_PWM, link.GetBytes(pwm));
                }
                else if (testPanAcc.Checked)
                {

                }
            }

            return msg.cmd == (byte)CommandType.CMD_ACK;
        }