com.qualcomm.robotcore.hardware

## Interface I2cDeviceSynchSimple

- All Superinterfaces:
    HardwareDevice, HardwareDeviceHealth, I2cAddrConfig, I2cAddressableDevice, RobotConfigNameable
  All Known Subinterfaces:
    I2cDeviceSynch
  All Known Implementing Classes:
    I2cDeviceSynchImpl, I2cDeviceSynchImplOnSimple

      public interface I2cDeviceSynchSimple
      extends HardwareDevice, HardwareDeviceHealth, I2cAddrConfig, RobotConfigNameable

  I2cDeviceSyncSimple is an interface that provides simple synchronous read and write functionality to an I2c device.
  See Also:
    `I2cDeviceSynch`, `I2cDeviceSynchImplOnSimple`

- - ### Nested Class Summary

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

      `HardwareDeviceHealth.HealthStatus`

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

      `HardwareDevice.Manufacturer`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `enableWriteCoalescing(boolean enable)` Enables or disables an optimization wherein writes to two sets of adjacent register ranges may be coalesced into a single I2c transaction if the second write comes along while the first is still queued for writing.
    `I2cAddr` | `getI2cAddr()` Deprecated. Use `I2cAddressableDevice.getI2cAddress()` instead.
    `boolean` | `getLogging()`
    `java.lang.String` | `getLoggingTag()`
    `boolean` | `isArmed()` Returns whether, as of this instant, this device client is alive and operational in its normally expected mode; that is, whether it is currently in communication with its underlying hardware or whether it is in some other state.
    `boolean` | `isWriteCoalescingEnabled()` Answers as to whether write coalescing is currently enabled on this device.
    `byte[]` | `read(int ireg, int creg)` Read a contiguous set of device I2C registers.
    `byte` | `read8(int ireg)` Read the byte at the indicated register.
    `TimestampedData` | `readTimeStamped(int ireg, int creg)` Reads and returns a contiguous set of device I2C registers, together with a best-available timestamp of when the actual I2C read occurred.
    `void` | `setI2cAddr(I2cAddr i2cAddr)` Deprecated. Use `I2cAddrConfig.setI2cAddress(I2cAddr)` instead.
    `void` | `setLogging(boolean enabled)` Turn logging on or off.
    `void` | `setLoggingTag(java.lang.String loggingTag)` Set the tag to use when logging is on.
    `void` | `waitForWriteCompletions(I2cWaitControl waitControl)` Waits for the most recent write to complete according to the behavior specified in writeControl.
    `void` | `write(int ireg, byte[] data)` Writes data to a set of registers, beginning with the one indicated, using `I2cWaitControl.ATOMIC` semantics.
    `void` | `write(int ireg, byte[] data, I2cWaitControl waitControl)` Writes data to a set of registers, beginning with the one indicated.
    `void` | `write8(int ireg, int bVal)` Writes a byte to the indicated register using `I2cWaitControl.ATOMIC` semantics.
    `void` | `write8(int ireg, int bVal, I2cWaitControl waitControl)` Writes a byte to the indicated register.

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

      `getHealthStatus, setHealthStatus`

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

      `setI2cAddress`

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

      `getI2cAddress`

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

      `getUserConfiguredName, setUserConfiguredName`

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

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

- - ### Method Detail

    - #### read8

          byte read8(int ireg)

      Read the byte at the indicated register. See `readTimeStamped(int, int)` for a complete description.
      Parameters:
        `ireg` - the register number to read
      Returns:
        the byte that was read
      See Also:
        `read(int, int)`, `readTimeStamped(int, int)`, `I2cDeviceSynch.ensureReadWindow(I2cDeviceSynch.ReadWindow, I2cDeviceSynch.ReadWindow)`

    - #### read

          byte[] read(int ireg,
                      int creg)

      Read a contiguous set of device I2C registers. See `readTimeStamped(int, int)` for a complete description.
      Parameters:
        `ireg` - the register number of the first byte register to read
        `creg` - the number of bytes / registers to read
      Returns:
        the data which was read
      See Also:
        `read8(int)`, `readTimeStamped(int, int)`, `I2cDeviceSynch.ensureReadWindow(I2cDeviceSynch.ReadWindow, I2cDeviceSynch.ReadWindow)`

    - #### readTimeStamped

          TimestampedData readTimeStamped(int ireg,
                                          int creg)

      Reads and returns a contiguous set of device I2C registers, together with a best-available timestamp of when the actual I2C read occurred. Note that this can take many tens of milliseconds to execute, and thus should not be called from the loop() thread.

      You can always just call this method without worrying at all about `read windows`, that will work, but usually it is more efficient to take some thought and care as to what set of registers the I2C device controller is being set up to read, as adjusting that window of registers incurs significant extra time.

      If the current read window can't be used to read the requested registers, then a new read window will automatically be created as follows. If the current read window is non null and wholly contains the registers to read but can't be read because it is a used-up `ReadMode#ONLY_ONCE` window, a new read fresh window will be created with the same set of registers. Otherwise, a window that exactly covers the requested set of registers will be created.

      Parameters:
        `ireg` - the register number of the first byte register to read
        `creg` - the number of bytes / registers to read
      Returns:
        the data which was read, together with the timestamp
      See Also:
        `read(int, int)`, `read8(int)`, `I2cDeviceSynch.ensureReadWindow(I2cDeviceSynch.ReadWindow, I2cDeviceSynch.ReadWindow)`

    - #### write8

          void write8(int ireg,
                      int bVal)

      Writes a byte to the indicated register using `I2cWaitControl.ATOMIC` semantics.
      Parameters:
        `ireg` - the register number that is to be written
        `bVal` - the byte which is to be written to that register
      See Also:
        `write(int, byte[], I2cWaitControl)`

    - #### write

          void write(int ireg,
                     byte[] data)

      Writes data to a set of registers, beginning with the one indicated, using `I2cWaitControl.ATOMIC` semantics.
      Parameters:
        `ireg` - the first of the registers which is to be written
        `data` - the data which is to be written to the registers
      See Also:
        `write(int, byte[], I2cWaitControl)`

    - #### write8

          void write8(int ireg,
                      int bVal,
                      I2cWaitControl waitControl)

      Writes a byte to the indicated register. See also `write(int, byte[], I2cWaitControl)`.
      Parameters:
        `ireg` - the register number that is to be written
        `bVal` - the byte which is to be written to that register
        `waitControl` - controls the behavior of waiting for the completion of the write
      See Also:
        `write(int, byte[], I2cWaitControl)`

    - #### write

          void write(int ireg,
                     byte[] data,
                     I2cWaitControl waitControl)

      Writes data to a set of registers, beginning with the one indicated. The data will be written to the I2C device in an expeditious manner. Once data is accepted by this API, it is guaranteed that (barring catastrophic failure) the data will be transmitted to the USB controller module before the I2cDeviceSync is closed. The call itself may or may block until the data has been transmitted to the USB controller module according to a caller-provided parameter.
      Parameters:
        `ireg` - the first of the registers which is to be written
        `data` - the data which is to be written to the registers
        `waitControl` - controls the behavior of waiting for the completion of the write

    - #### waitForWriteCompletions

          void waitForWriteCompletions(I2cWaitControl waitControl)

      Waits for the most recent write to complete according to the behavior specified in writeControl.
      Parameters:
        `waitControl` - controls the behavior of waiting for the completion of the write Note that a value of `I2cWaitControl.NONE` is essentially a no-op.

    - #### enableWriteCoalescing

          void enableWriteCoalescing(boolean enable)

      Enables or disables an optimization wherein writes to two sets of adjacent register ranges may be coalesced into a single I2c transaction if the second write comes along while the first is still queued for writing. By default, write coalescing is disabled.
      Parameters:
        `enable` - whether to enable write coalescing or not
      See Also:
        `isWriteCoalescingEnabled()`

    - #### isWriteCoalescingEnabled

          boolean isWriteCoalescingEnabled()

      Answers as to whether write coalescing is currently enabled on this device.
      Returns:
        whether write coalescing is currently enabled or not.
      See Also:
        `enableWriteCoalescing(boolean)`

    - #### isArmed

          boolean isArmed()

      Returns whether, as of this instant, this device client is alive and operational in its normally expected mode; that is, whether it is currently in communication with its underlying hardware or whether it is in some other state. Note that a device client which is not engaged will never report as armed.
      Returns:
        the arming state of this device client
      See Also:
        `Engagable.engage()`

    - #### setI2cAddr

          @Deprecated
          void setI2cAddr(I2cAddr i2cAddr)

      Deprecated. Use `I2cAddrConfig.setI2cAddress(I2cAddr)` instead.
      Sets the I2C address of the underlying client. If necessary, the client may be briefly disengaged (and then automatically reengaged) in the process.
      Parameters:
        `i2cAddr` - the new I2C address

    - #### getI2cAddr

          @Deprecated
          I2cAddr getI2cAddr()

      Deprecated. Use `I2cAddressableDevice.getI2cAddress()` instead.
      Returns the I2C address currently being used by this device client
      Returns:
        the current I2C address

    - #### setLogging

          void setLogging(boolean enabled)

      Turn logging on or off. Logging output can be viewed using the Android Logcat tools.
      Parameters:
        `enabled` - whether to enable logging or not

    - #### getLogging

          boolean getLogging()

      See Also:
        `setLogging(boolean)`

    - #### setLoggingTag

          void setLoggingTag(java.lang.String loggingTag)

      Set the tag to use when logging is on.
      Parameters:
        `loggingTag` - the logging tag to sue

    - #### getLoggingTag

          java.lang.String getLoggingTag()

      See Also:
        `setLoggingTag(String)`