Class AnalogSensor

    • Field Detail

      • currentType

        protected int currentType
    • Constructor Detail

      • AnalogSensor

        public AnalogSensor​(AnalogPort p)
      • AnalogSensor

        public AnalogSensor​(Port p,
                            int type,
                            int mode)
      • AnalogSensor

        public AnalogSensor​(Port p)
    • Method Detail

      • normalize

        protected float normalize​(float val)
        Helper method. Take a voltage and return it as a normalized value in the range 0.0-1.0
        Parameters:
        val - input value
        Returns:
        normalized value
      • NXTRawValue

        protected float NXTRawValue​(float val)
        Return the equivalent NXT RAW sensor reading to the given voltage
        Parameters:
        val - ADC voltage
        Returns:
        The reading that would be returned on the NXT
      • NXTRawIntValue

        protected int NXTRawIntValue​(float val)
        Return the equivalent NXT RAW sensor reading to the given voltage
        Parameters:
        val - ADC voltage
        Returns:
        The reading that would be returned on the NXT
      • switchType

        protected void switchType​(int newType,
                                  long switchDelay)
        Switch to the selected type (if not already in that type) and delay for the specified period to allow the sensor to settle in the new state.
        NOTE: This method is intended for use with NXT sensor drivers that use a sensor type to specify the operating mode.
        Parameters:
        newType - The type to switch to.
        switchDelay - Time in mS to delay after the switch.