com.qualcomm.robotcore.hardware

## Class I2cDeviceSynch.ReadWindow

- java.lang.Object
- - com.qualcomm.robotcore.hardware.I2cDeviceSynch.ReadWindow

- Enclosing interface:
    I2cDeviceSynch

      public static class I2cDeviceSynch.ReadWindow
      extends java.lang.Object

  RegWindow is a utility class for managing the window of I2C register bytes that are read from our I2C device on every hardware cycle

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `READ_REGISTER_COUNT_MAX` enableI2cReadMode and enableI2cWriteMode both impose a maximum length on the size of data that can be read or written at one time.
    `static int` | `WRITE_REGISTER_COUNT_MAX`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ReadWindow(int iregFirst, int creg, I2cDeviceSynch.ReadMode readMode)` Create a new register window with the indicated starting register and register count

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `canBeUsedToRead()` Answers as to whether we're allowed to read using this window.
    `boolean` | `contains(I2cDeviceSynch.ReadWindow him)` Answers as to whether the receiver wholly contains the indicated window.
    `boolean` | `contains(int ireg, int creg)` Answers as to whether the receiver wholly contains the indicated set of registers.
    `boolean` | `containsWithSameMode(I2cDeviceSynch.ReadWindow him)` Answers as to whether the receiver wholly contains the indicated window and also has the same modality.
    `I2cDeviceSynch.ReadMode` | `getReadMode()` Returns the mode of the window
    `int` | `getRegisterCount()` Returns the number of registers in the window
    `int` | `getRegisterFirst()` Returns the first register in the window
    `int` | `getRegisterMax()` Returns the first register NOT in the window
    `boolean` | `hasWindowBeenUsedForRead()` Returns whether a read has ever been issued for this window or not
    `boolean` | `mayInitiateSwitchToReadMode()` Answers as to whether this window in its present state ought to cause a transition to read-mode when there's nothing else for the device to be doing.
    `void` | `noteWindowUsedForRead()` Sets that a read has in fact been issued for this window
    `I2cDeviceSynch.ReadWindow` | `readableCopy()` Returns a copy of this window but with the `usedForRead` flag clear
    `boolean` | `sameAsIncludingMode(I2cDeviceSynch.ReadWindow him)` Do the receiver and the indicated register window cover exactly the same set of registers and have the same modality?

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### READ_REGISTER_COUNT_MAX

          public static final int READ_REGISTER_COUNT_MAX

      enableI2cReadMode and enableI2cWriteMode both impose a maximum length on the size of data that can be read or written at one time. `READ_REGISTER_COUNT_MAX` and `WRITE_REGISTER_COUNT_MAX` indicate those maximum sizes.
      See Also:
        `WRITE_REGISTER_COUNT_MAX`, Constant Field Values

    - #### WRITE_REGISTER_COUNT_MAX

          public static final int WRITE_REGISTER_COUNT_MAX

      See Also:
        `READ_REGISTER_COUNT_MAX`, Constant Field Values

  - ### Constructor Detail

    - #### ReadWindow

          public ReadWindow(int iregFirst,
                            int creg,
                            I2cDeviceSynch.ReadMode readMode)

      Create a new register window with the indicated starting register and register count
      Parameters:
        `iregFirst` - the index of the first register to read
        `creg` - the number of registers to read
        `readMode` - whether to repeat-read or read only once

  - ### Method Detail

    - #### getRegisterFirst

          public int getRegisterFirst()

      Returns the first register in the window
      Returns:
        the first register in the window

    - #### getRegisterMax

          public int getRegisterMax()

      Returns the first register NOT in the window
      Returns:
        the first register NOT in the window

    - #### getRegisterCount

          public int getRegisterCount()

      Returns the number of registers in the window
      Returns:
        the number of registers in the window

    - #### getReadMode

          public I2cDeviceSynch.ReadMode getReadMode()

      Returns the mode of the window
      Returns:
        the mode of the window

    - #### hasWindowBeenUsedForRead

          public boolean hasWindowBeenUsedForRead()

      Returns whether a read has ever been issued for this window or not
      Returns:
        whether a read has ever been issued for this window or not

    - #### noteWindowUsedForRead

          public void noteWindowUsedForRead()

      Sets that a read has in fact been issued for this window

    - #### canBeUsedToRead

          public boolean canBeUsedToRead()

      Answers as to whether we're allowed to read using this window. This will return false for ONLY_ONCE windows after `noteWindowUsedForRead()` has been called on them.
      Returns:
        whether it is permitted to perform a read for this window.

    - #### mayInitiateSwitchToReadMode

          public boolean mayInitiateSwitchToReadMode()

      Answers as to whether this window in its present state ought to cause a transition to read-mode when there's nothing else for the device to be doing.
      Returns:
        whether this device should cause a read mode transition

    - #### readableCopy

          public I2cDeviceSynch.ReadWindow readableCopy()

      Returns a copy of this window but with the `usedForRead` flag clear
      Returns:
        a fresh copy of the window into which data can actually be read.

    - #### sameAsIncludingMode

          public boolean sameAsIncludingMode(I2cDeviceSynch.ReadWindow him)

      Do the receiver and the indicated register window cover exactly the same set of registers and have the same modality?
      Parameters:
        `him` - the other window to compare to
      Returns:
        the result of the comparison

    - #### contains

          public boolean contains(I2cDeviceSynch.ReadWindow him)

      Answers as to whether the receiver wholly contains the indicated window.
      Parameters:
        `him` - the window we wish to see whether we contain
      Returns:
        whether or not we contain the window
      See Also:
        `contains(int, int)`

    - #### containsWithSameMode

          public boolean containsWithSameMode(I2cDeviceSynch.ReadWindow him)

      Answers as to whether the receiver wholly contains the indicated window and also has the same modality.
      Parameters:
        `him` - the window we wish to see whether we contain
      Returns:
        whether or not we contain the window

    - #### contains

          public boolean contains(int ireg,
                                  int creg)

      Answers as to whether the receiver wholly contains the indicated set of registers.
      Parameters:
        `ireg` - the first register of interest
        `creg` - the number of registers of interest
      Returns:
        whether or not the receiver contains this set of registers