Class UARTSensor

    • Field Detail

      • currentMode

        protected int currentMode
    • Constructor Detail

      • UARTSensor

        public UARTSensor​(UARTPort port)
        Standard constructor for a UARTSensor initialises things and places the device into mode 0.
        Parameters:
        port - The port the sensor is attached to.
      • UARTSensor

        public UARTSensor​(Port port)
        Standard constructor for a UARTSensor initialises things and places the device into mode 0.
        Parameters:
        port - The port the sensor is attached to.
      • UARTSensor

        public UARTSensor​(UARTPort port,
                          int mode)
        Create the sensor object and switch to the selected mode
        Parameters:
        port - The port the sensor is attached to.
        mode - Operating mode for the sensor.
      • UARTSensor

        public UARTSensor​(Port port,
                          int mode)
        Create the sensor object and switch to the selected mode
        Parameters:
        port - The port the sensor is attached to.
        mode - Operating mode for the sensor.
    • Method Detail

      • switchMode

        protected void switchMode​(int newMode,
                                  long switchDelay)
        Switch to the selected mode (if not already in that mode) and delay for the specified period to allow the sensor to settle in the new mode.
        A mode of -1 resets the sensor. TODO: There really should be a better way to work out when the switch is complete, if you don't wait though you end up reading data from the previous mode.
        Parameters:
        newMode - The mode to switch to.
        switchDelay - Time in mS to delay after the switch.