Example #1
0
 /// <summary>
 /// Frees the resources allocated for reading values from the analog joystick
 /// </summary>
 public void Dispose()
 {
     Xinput.Dispose();
     Xinput = null;
     Yinput.Dispose();
     Yinput = null;
 }
Example #2
0
        //void IDisposable.Dispose() {
        //    if (analogPin != null) { analogPin.Dispose(); }
        //}

        protected override void SensorCleanup()
        {
            if (analogPin != null)
            {
                analogPin.Dispose();
            }
        }
Example #3
0
        /// <summary>
        /// Calculate Temperature value
        /// </summary>
        /// <returns>Float value of current Temperature reading</returns>
        /// <remarks>Assuming AREF of 3.3v, the default for Rev. B Netduino Plus boards.
        /// It's an internal value, no feed to AREF required.
        /// Using code tutorial from adafruit http://www.ladyada.net/learn/sensors/thermistor.html </remarks>
        private float CalculateTemperature()
        {
            AnalogInput ain = new AnalogInput(AnalogChannels.ANALOG_PIN_A0);

            // take 10 readings to even out the noise
            float average = 0.0F;

            for (int i = 0; i < 10; i++)
            {
                average += (int)ain.Read();
            }
            average /= 10;

            if (average == 0)
            {
                return(10.0F);
            }

            // convert to a resistance
            average = 1023 / average - 1;
            average = SeriesResistor / average;

            // apply steinhart
            float tempValue = average / ThermistorNominal;

            tempValue  = Extensions.Math.Log(tempValue);
            tempValue /= BetaCoefficient;
            tempValue += 1.0F / (TemperatureNominal + 273.15F);
            tempValue  = 1.0F / tempValue;
            tempValue -= 273.15F;

            ain.Dispose();
            return(tempValue);
        }
Example #4
0
        /// <summary>
        ///     Releases managed and native resources
        /// </summary>
        /// <param name="disposing"></param>
        private void dispose(bool disposing)
        {
            if (!disposing)
            {
                return;
            }
#if USE_LOCKING
            lock (ain)
#endif
            {
                ain?.Dispose();
            }
        }
Example #5
0
        public static void TearDownAfterClass()
        {
            compressor.Dispose();

            fakePressureSwitch.Dispose();
            fakeCompressor.Dispose();

            fakeSolenoid1.Dispose();
            fakeSolenoid2.Dispose();

            if (RobotBase.IsSimulation)
            {
                SimData.DIO[11].CancelValueCallback(callbackId);
            }
        }
Example #6
0
 public void Dispose()
 {
     if (_linearActuatorSensor != null)
     {
         _linearActuatorSensor.Dispose();
     }
     if (_megaMotoSensor != null)
     {
         _megaMotoSensor.Dispose();
     }
     if (_megaMotoPWMA != null)
     {
         _megaMotoPWMA.Dispose();
     }
     if (_megaMotoPWMB != null)
     {
         _megaMotoPWMB.Dispose();
     }
     if (_megaMotoEnable != null)
     {
         _megaMotoEnable.Dispose();
     }
     GC.SuppressFinalize(this);
 }
Example #7
0
 public void Dispose()
 {
     GC.SuppressFinalize(this);
     _input.Dispose();
 }
 public bool Teardown()
 {
     m_input.Dispose();
     m_output.Dispose();
     return(true);
 }
Example #9
0
 public void Dispose()
 {
     _analogInput.Dispose();
 }
Example #10
0
 protected override void DisposeManagedResources()
 {
     _port.Dispose();
 }
Example #11
0
        //public static void Main()
        //{

        //    using (var a1 = new AnalogInput(Cpu.AnalogChannel.ANALOG_1))
        //    {
        //        var last = 0.0d;
        //        while (Debugger.IsAttached)
        //        {
        //            var reading = a1.Read();

        //            if (reading != last)
        //            {
        //                Debug.Print(reading.ToString());
        //                last = reading;
        //            }

        //        }

        //    }

        //}

        public static void Main()
        {
            var wiiChuck  = new WiiChuck(true);
            var debugMode = Debugger.IsAttached;

            _redLed   = new OutputPort(Pins.GPIO_PIN_D13, false);
            _greenLed = new OutputPort(Pins.GPIO_PIN_A0, false);

            _pot = new AnalogInput(Cpu.AnalogChannel.ANALOG_1);

            //_speaker = new PWM(Pins.GPIO_PIN_D9);

            //_speakerThread = new Thread(PlaySound);
            //_speakerThread.Start();
            //_servo1 = new ServoController(Mshield.Servo1, 600, 2400, startDegree: 90);
            _robot = new TankRobot();


            while (!debugMode || Debugger.IsAttached)
            {
                // try to read the data from nunchucku
                if (wiiChuck.GetData())
                {
                    CheckButtons(wiiChuck.CButtonDown, wiiChuck.ZButtonDown);

                    if (Recording)
                    {
                        _iteration++;
                        SetMotorSpeed(_robot, wiiChuck);
                    }
                    else if (PlayingBack)
                    {
                        if (_currentPlaybackIndex >= _record.Count)
                        {
                            PlayingBack           = false;
                            _currentPlaybackIndex = 0;
                        }
                        else
                        {
                            _iteration++;

                            var record = (DataPoint)_record[_currentPlaybackIndex];

                            if (record.Iterations == _iteration)
                            {
                                _currentPlaybackIndex++;
                                _robot.Move(record.LeftSpeed, record.RightSpeed);
                            }
                        }
                    }
                    else
                    {
                        SetMotorSpeed(_robot, wiiChuck);
                    }
                    //var degrees = ((int) (90+(-90*wiiChuck.AccelerationXGs))/2)*2;

                    //if (degrees < 0)
                    //    degrees = 0;
                    //else if (degrees > 180)
                    //    degrees = 180;

                    //_servo1.Rotate(degrees);
                    //Debug.Print("AccelX = " + wiiChuck.AccelerationXGs + "   AccelY=" + wiiChuck.AccelerationYGs);
                }
            }

            wiiChuck.Dispose();

            _robot.Dispose();

            //_speaker.Dispose();
            //_speaker = null;

            //_servo1.Dispose();

            _redLed.Dispose();
            _greenLed.Dispose();

            _pot.Dispose();
        }
        /// <summary>
        /// Calculate Temperature value
        /// </summary>
        /// <returns>Float value of current Temperature reading</returns>
        /// <remarks>Assuming AREF of 3.3v, the default for Rev. B Netduino Plus boards.
        /// It's an internal value, no feed to AREF required.
        /// Using code tutorial from adafruit http://www.ladyada.net/learn/sensors/thermistor.html </remarks>
        private float CalculateTemperature()
        {
            AnalogInput ain = new AnalogInput(Pins.GPIO_PIN_A0);

            // take 10 readings to even out the noise
            float average = 0.0F;
            for (int i = 0; i < 10; i++) { average += ain.Read(); }
            average /= 10;

            // convert to a resistance
            average = 1023 / average - 1;
            average = SeriesResistor / average;

            // apply steinhart
            float tempValue = average / ThermistorNominal;
            tempValue = Controller.Math.Log(tempValue);
            tempValue /= BetaCoefficient;
            tempValue += 1.0F / (TemperatureNominal + 273.15F);
            tempValue = 1.0F / tempValue;
            tempValue -= 273.15F;

            ain.Dispose();
            return tempValue;
        }
Example #13
0
 public void Dispose()
 {
     _lightin.Dispose();
 }