public MovementController(Relays relayBoard, Compass compassBoard, Program passedModel)
 {
     model = passedModel;
     relays = relayBoard;
     compass = compassBoard;
     compass.MeasurementComplete +=new Compass.MeasurementCompleteEventHandler(compassContinuousComplete);
 }
Exemple #2
0
        void compass_MeasurementComplete(GTM.Seeed.Compass sender, GTM.Seeed.Compass.SensorData compassSensorData)
        {
            /*
             * compassX = compassSensorData.X;
             * compassY = compassSensorData.Y;
             * compassZ = compassSensorData.Z;
             *
             * if (compassX > compassXmax)
             *  compassXmax = compassX;
             * if (compassX < compassXmin)
             *  compassXmin = compassX;
             * if (compassY > compassYmax)
             *  compassYmax = compassY;
             * if (compassY < compassYmin)
             *  compassYmin = compassY;
             */

            heading = compassSensorData.Angle;
        }
 void compassContinuousComplete(Compass sender, Compass.SensorData sensorData)
 {
     int value = (int)localise(sensorData.X);
     if (Math.Abs(value - objective) < 3){
         stop();
         compass.StopContinuousMeasurements();
         model.movementFinished();
     }
 }
 void compassDiscreteComplete(Compass sender, Compass.SensorData sensorData)
 {
     offset = 45 - sensorData.X;
 }
Exemple #5
0
 /// <summary>
 /// Raises the <see cref="MeasurementComplete"/> event.
 /// </summary>
 /// <param name="sender">The object that raised the event.</param>
 /// <param name="sensorData">The <see cref="SensorData"/> object that contains the results of the measurement.</param>
 protected virtual void OnMeasurementCompleteEvent(Compass sender, SensorData sensorData)
 {
     if (_OnMeasurementComplete == null)
         _OnMeasurementComplete = new MeasurementCompleteEventHandler(OnMeasurementCompleteEvent);
     if (Program.CheckAndInvoke(MeasurementComplete, _OnMeasurementComplete, sender, sensorData))
     {
         MeasurementComplete(sender, sensorData);
     }
 }
Exemple #6
0
 void compass_MeasurementComplete(Compass sender, Compass.SensorData sensorData)
 {
     compassAngleMeas = sensorData.Angle;
 }