com.qualcomm.robotcore.hardware

## Interface LegacyModule

- All Superinterfaces:
    HardwareDevice, I2cController

      public interface LegacyModule
      extends HardwareDevice, I2cController

  Legacy Module for working with NXT devices. The Modern Robotics Core Legacy Module provides backward compatibility to enable LEGO NXT devices to connect to an Android device or a PC via a USB connection. Each Legacy Module has six (6) ports and virtually any combination of devices can be connected to the module. The Legacy Module firmware supports all NXT LEGO sensors (except the Lego Color Sensor), HiTechnic sensors, Matrix controllers as well as the HiTechnic Tetrix motor and servo controllers. Each Legacy Module port can operate in digital as well as analog modes. In digital mode, legacy connector pins 5 and 6 can be set to logic 0 or logic 1. In analog mode, the voltage on legacy connector pin 1 is measured using a 10 bit analog to digital converter. Additionally, pins 5 and 6 can be set to logic 0 or logic 1 for control of the attached device, such as a LEGO light sensor which uses pin 5 to turn the sensor LED on and off. In I2C mode, legacy connector pins 5 and 6 are used to communicate with I2C devices in accordance with the LEGO interpretation of I2C. Ports 4 and 5 can additionally be switched into pin 1 9v supply mode to permit LEGO ultrasonic range sensors to be used
  See Also:
    Modern Robotics Legacy Module

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface com.qualcomm.robotcore.hardware.I2cController

      `I2cController.I2cPortReadyBeginEndNotifications, I2cController.I2cPortReadyCallback`

    - ### Nested classes/interfaces inherited from interface com.qualcomm.robotcore.hardware.HardwareDevice

      `HardwareDevice.Manufacturer`

  - ### Field Summary

    - ### Fields inherited from interface com.qualcomm.robotcore.hardware.I2cController

      `I2C_BUFFER_START_ADDRESS`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `enable9v(int physicalPort, boolean enable)` Enable or disable 9V power on a port
    `void` | `enableAnalogReadMode(int physicalPort)` Enable a physical port in analog read mode
    `double` | `getMaxAnalogInputVoltage()` Returns the maximum voltage that can be read by our analog inputs
    `byte[]` | `readAnalogRaw(int physicalPort)` Read an analog value from a device; only works in analog read mode
    `double` | `readAnalogVoltage(int physicalPort)` Reads the analog voltage from a device.
    `void` | `setDigitalLine(int physicalPort, int line, boolean set)` Set the value of digital line 0 or 1 while in analog mode.

    - ### Methods inherited from interface com.qualcomm.robotcore.hardware.I2cController

      `clearI2cPortActionFlag, copyBufferIntoWriteBuffer, deregisterForPortReadyBeginEndCallback, deregisterForPortReadyCallback, enableI2cReadMode, enableI2cWriteMode, getCopyOfReadBuffer, getCopyOfWriteBuffer, getI2cPortReadyCallback, getI2cReadCache, getI2cReadCacheLock, getI2cReadCacheTimeWindow, getI2cWriteCache, getI2cWriteCacheLock, getMaxI2cWriteLatency, getPortReadyBeginEndCallback, getSerialNumber, isArmed, isI2cPortActionFlagSet, isI2cPortInReadMode, isI2cPortInWriteMode, isI2cPortReady, readI2cCacheFromController, readI2cCacheFromModule, registerForI2cPortReadyCallback, registerForPortReadyBeginEndCallback, setI2cPortActionFlag, writeI2cCacheToController, writeI2cCacheToModule, writeI2cPortFlagOnlyToController, writeI2cPortFlagOnlyToModule`

    - ### Methods inherited from interface com.qualcomm.robotcore.hardware.HardwareDevice

      `close, getConnectionInfo, getDeviceName, getManufacturer, getVersion, resetDeviceConfigurationForOpMode`

- - ### Method Detail

    - #### enableAnalogReadMode

          void enableAnalogReadMode(int physicalPort)

      Enable a physical port in analog read mode
      Parameters:
        `physicalPort` - physical port number on the device

    - #### readAnalogRaw

          byte[] readAnalogRaw(int physicalPort)

      Read an analog value from a device; only works in analog read mode
      Parameters:
        `physicalPort` - physical port number on the device
      Returns:
        byte[] containing the two analog values; low byte first, high byte second

    - #### readAnalogVoltage

          double readAnalogVoltage(int physicalPort)

      Reads the analog voltage from a device. The port indicated must currently be in analog read mode.
      Parameters:
        `physicalPort` - the port whose voltage is to be read
      Returns:
        the voltage level read, in volts

    - #### getMaxAnalogInputVoltage

          double getMaxAnalogInputVoltage()

      Returns the maximum voltage that can be read by our analog inputs
      Returns:
        the maximum voltage that can be read by our analog inputs

    - #### enable9v

          void enable9v(int physicalPort,
                        boolean enable)

      Enable or disable 9V power on a port
      Parameters:
        `physicalPort` - physical port number on the device
        `enable` - true to enable; false to disable

    - #### setDigitalLine

          void setDigitalLine(int physicalPort,
                              int line,
                              boolean set)

      Set the value of digital line 0 or 1 while in analog mode.

      These are port pins 5 and 6.

      Parameters:
        `physicalPort` - physical port number on the device
        `line` - line 0 or 1
        `set` - true to set; otherwise false