@Test public void readSample() throws IOException { Mma7660Fc driver = new Mma7660Fc(mI2c); driver.readSample(); Mockito.verify(mI2c).read(aryEq(new byte[3]), eq(3)); }
public float[] readSample() throws IOException, IllegalStateException { if (mDevice == null) { throw new IllegalStateException("device not connected"); } byte[] sample = new byte[3]; mDevice.read(sample, 3); int x = sample[0] & 0x3f; int y = sample[1] & 0x3f; int z = sample[2] & 0x3f; return new float[]{ DRIVER_ACC_LOOKUP_G[x], DRIVER_ACC_LOOKUP_G[y], DRIVER_ACC_LOOKUP_G[z] }; }
Mma7660Fc implements AutoCloseable { public float[] readSample() throws IOException, IllegalStateException { if (mDevice == null) { throw new IllegalStateException("device not connected"); } byte[] sample = new byte[3]; mDevice.read(sample, 3); int x = sample[0] & 0x3f; int y = sample[1] & 0x3f; int z = sample[2] & 0x3f; return new float[]{ DRIVER_ACC_LOOKUP_G[x], DRIVER_ACC_LOOKUP_G[y], DRIVER_ACC_LOOKUP_G[z] }; } }
Mma7660Fc implements AutoCloseable { public float[] readSample() throws IOException, IllegalStateException { if (mDevice == null) { throw new IllegalStateException("device not connected"); } byte[] sample = new byte[3]; mDevice.read(sample, 3); int x = sample[0] & 0x3f; int y = sample[1] & 0x3f; int z = sample[2] & 0x3f; return new float[]{ DRIVER_ACC_LOOKUP_G[x], DRIVER_ACC_LOOKUP_G[y], DRIVER_ACC_LOOKUP_G[z] }; } Mma7660Fc(String bus);   Mma7660Fc(I2cDevice device); }
Mma7660Fc implements AutoCloseable { public float[] readSample() throws IOException, IllegalStateException { if (mDevice == null) { throw new IllegalStateException("device not connected"); } byte[] sample = new byte[3]; mDevice.read(sample, 3); int x = sample[0] & 0x3f; int y = sample[1] & 0x3f; int z = sample[2] & 0x3f; return new float[]{ DRIVER_ACC_LOOKUP_G[x], DRIVER_ACC_LOOKUP_G[y], DRIVER_ACC_LOOKUP_G[z] }; } Mma7660Fc(String bus);   Mma7660Fc(I2cDevice device); @Override void close(); void setMode(@Mode int mode); @SuppressWarnings("ResourceType") @Mode int getMode(); void setSamplingRate(@SamplingRate int rate); @SuppressWarnings("ResourceType") @SamplingRate int getSamplingRate(); float[] readSample(); }
Mma7660Fc implements AutoCloseable { public float[] readSample() throws IOException, IllegalStateException { if (mDevice == null) { throw new IllegalStateException("device not connected"); } byte[] sample = new byte[3]; mDevice.read(sample, 3); int x = sample[0] & 0x3f; int y = sample[1] & 0x3f; int z = sample[2] & 0x3f; return new float[]{ DRIVER_ACC_LOOKUP_G[x], DRIVER_ACC_LOOKUP_G[y], DRIVER_ACC_LOOKUP_G[z] }; } Mma7660Fc(String bus);   Mma7660Fc(I2cDevice device); @Override void close(); void setMode(@Mode int mode); @SuppressWarnings("ResourceType") @Mode int getMode(); void setSamplingRate(@SamplingRate int rate); @SuppressWarnings("ResourceType") @SamplingRate int getSamplingRate(); float[] readSample(); static final int I2C_ADDRESS; static final int RATE_120HZ; static final int RATE_64HZ; static final int RATE_32HZ; static final int RATE_16HZ; static final int RATE_8HZ; static final int RATE_4HZ; static final int RATE_2HZ; static final int RATE_1HZ; static final int MODE_STANDBY; static final int MODE_ACTIVE; }