Exemplo n.º 1
0
        /// <summary>
        /// preferred method for Head pan/tilt control
        /// </summary>
        /// <param name="panDegreesFromCenter"></param>
        /// <param name="tiltDegreesFromCenter"></param>
        public void setPanTilt(double panDegreesFromCenter, double tiltDegreesFromCenter)
        {
            currentPan = panDegreesFromCenter;

            double mksPan = PanTiltAlignment.getInstance().mksPan(panDegreesFromCenter);

            int panMks = (int)mksPan;


            currentTilt = tiltDegreesFromCenter;

            double mksTilt = PanTiltAlignment.getInstance().mksTilt(tiltDegreesFromCenter);

            int tiltMks = (int)mksTilt;


            if (panMks != panMksLast || tiltMks != tiltMksLast)
            {
                panMksLast  = panMks;
                tiltMksLast = tiltMks;

                Debug.WriteLine("setPanTilt: panMks=" + panMks + "  tiltMks=" + tiltMks);

                ToArduino toArduino1 = new ToArduino {
                    channel = (int)AnimationChannels.PAN, command = (int)AnimationCommands.SET_VALUE, commandValues = new int[] { panMks }
                };
                ToArduino toArduino2 = new ToArduino {
                    channel = (int)AnimationChannels.TILT, command = (int)AnimationCommands.SET_VALUE, commandValues = new int[] { tiltMks }
                };

                SendToArduino2(toArduino1, toArduino2);
            }
        }
Exemplo n.º 2
0
 public static PanTiltAlignment getInstance()
 {
     if (instance == null)
     {
         instance = new PanTiltAlignment();
     }
     return(instance);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Jaw open angle
        /// </summary>
        /// <param name="degreesFromCenter"></param>
        public void setJaw(double degreesFromCenter)
        {
            currentJaw = degreesFromCenter;

            double mks = PanTiltAlignment.getInstance().mksTilt(degreesFromCenter);

            setJawMks((int)mks);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Head pan
        /// </summary>
        /// <param name="degreesFromCenter"></param>
        public void setPan(double degreesFromCenter)
        {
            currentPan = degreesFromCenter;

            double mks = PanTiltAlignment.getInstance().mksPan(degreesFromCenter);

            setPanMks((int)mks);
        }
Exemplo n.º 5
0
 public static PanTiltAlignment getInstance()
 {
     if (instance == null)
     {
         instance = new PanTiltAlignment();
     }
     return instance;
 }
Exemplo n.º 6
0
 public static PanTiltAlignment RestoreOrDefault()
 {
     if (File.Exists(filename))
     {
         using (TextReader reader = new StreamReader(filename))
         {
             XmlSerializer x = new System.Xml.Serialization.XmlSerializer(typeof(PanTiltAlignment));
             instance = (PanTiltAlignment)x.Deserialize(reader);
         }
     }
     else
     {
         instance = new PanTiltAlignment();
     }
     return(instance);
 }
Exemplo n.º 7
0
 public static PanTiltAlignment RestoreOrDefault()
 {
     if (File.Exists(filename))
     {
         using (TextReader reader = new StreamReader(filename))
         {
             XmlSerializer x = new System.Xml.Serialization.XmlSerializer(typeof(PanTiltAlignment));
             instance = (PanTiltAlignment)x.Deserialize(reader);
         }
     }
     else
     {
         instance = new PanTiltAlignment();
     }
     return instance;
 }
Exemplo n.º 8
0
        private void Window_Loaded(object sender, EventArgs e)
        {
            _panTiltAlignment = PanTiltAlignment.RestoreOrDefault();

            OpenBrickConnector();

            SafePosture();

            this.ListAnimCombos.ItemsSource = animationCombo.Keys;
            this.ListAnim.ItemsSource = animations.Keys;

            speak("Ready for action!");
        }