@Test public void setBrightnessFloat_throwsIfTooSmall() throws IOException { Tm1637 tm1637 = new Tm1637(mDevice); mExpectedException.expect(IllegalArgumentException.class); tm1637.setBrightness(-1f); }
public void setBrightness(int value) throws IOException { if (mDevice == null) { throw new IllegalStateException("Device not opened"); } if (value < 0 || value > MAX_BRIGHTNESS) { throw new IllegalArgumentException("brightness must be between 0 and " + MAX_BRIGHTNESS); } mDevice.write(new byte[]{(byte) (TM1637_CMD | (byte) value)}, 1); }
Tm1637 implements Closeable { public void setBrightness(int value) throws IOException { if (mDevice == null) { throw new IllegalStateException("Device not opened"); } if (value < 0 || value > MAX_BRIGHTNESS) { throw new IllegalArgumentException("brightness must be between 0 and " + MAX_BRIGHTNESS); } mDevice.write(new byte[]{(byte) (TM1637_CMD | (byte) value)}, 1); } }
Tm1637 implements Closeable { public void setBrightness(int value) throws IOException { if (mDevice == null) { throw new IllegalStateException("Device not opened"); } if (value < 0 || value > MAX_BRIGHTNESS) { throw new IllegalArgumentException("brightness must be between 0 and " + MAX_BRIGHTNESS); } mDevice.write(new byte[]{(byte) (TM1637_CMD | (byte) value)}, 1); } Tm1637(String dataPin, String clockPin); @VisibleForTesting  Tm1637(I2cBitBangDevice device); }
Tm1637 implements Closeable { public void setBrightness(int value) throws IOException { if (mDevice == null) { throw new IllegalStateException("Device not opened"); } if (value < 0 || value > MAX_BRIGHTNESS) { throw new IllegalArgumentException("brightness must be between 0 and " + MAX_BRIGHTNESS); } mDevice.write(new byte[]{(byte) (TM1637_CMD | (byte) value)}, 1); } Tm1637(String dataPin, String clockPin); @VisibleForTesting  Tm1637(I2cBitBangDevice device); @Override void close(); void setBrightness(int value); void setBrightness(float value); void writeData(byte[] data); }
Tm1637 implements Closeable { public void setBrightness(int value) throws IOException { if (mDevice == null) { throw new IllegalStateException("Device not opened"); } if (value < 0 || value > MAX_BRIGHTNESS) { throw new IllegalArgumentException("brightness must be between 0 and " + MAX_BRIGHTNESS); } mDevice.write(new byte[]{(byte) (TM1637_CMD | (byte) value)}, 1); } Tm1637(String dataPin, String clockPin); @VisibleForTesting  Tm1637(I2cBitBangDevice device); @Override void close(); void setBrightness(int value); void setBrightness(float value); void writeData(byte[] data); static final int MAX_BRIGHTNESS; static final int MAX_DATA_LENGTH; }