@Test public void setBrightnessFloat() throws IOException { Ht16k33 driver = new Ht16k33(mI2c); driver.setBrightness(0.5f); int brightness = Math.round(0.5f * Ht16k33.HT16K33_BRIGHTNESS_MAX); Mockito.verify(mI2c).write(new byte[]{(byte) (0xE0 | brightness)}, 1); }
public void setBrightness(int value) throws IOException { if (mDevice == null) { throw new IllegalStateException("I2C device not opened"); } if (value < 0 || value > HT16K33_BRIGHTNESS_MAX) { throw new IllegalArgumentException("brightness must be between 0 and " + HT16K33_BRIGHTNESS_MAX); } mDevice.write(new byte[]{(byte) (HT16K33_CMD_BRIGHTNESS | value)}, 1); }
Ht16k33 implements AutoCloseable { public void setBrightness(int value) throws IOException { if (mDevice == null) { throw new IllegalStateException("I2C device not opened"); } if (value < 0 || value > HT16K33_BRIGHTNESS_MAX) { throw new IllegalArgumentException("brightness must be between 0 and " + HT16K33_BRIGHTNESS_MAX); } mDevice.write(new byte[]{(byte) (HT16K33_CMD_BRIGHTNESS | value)}, 1); } }
Ht16k33 implements AutoCloseable { public void setBrightness(int value) throws IOException { if (mDevice == null) { throw new IllegalStateException("I2C device not opened"); } if (value < 0 || value > HT16K33_BRIGHTNESS_MAX) { throw new IllegalArgumentException("brightness must be between 0 and " + HT16K33_BRIGHTNESS_MAX); } mDevice.write(new byte[]{(byte) (HT16K33_CMD_BRIGHTNESS | value)}, 1); } Ht16k33(String bus);  Ht16k33(String bus, int i2cAddress); @VisibleForTesting  Ht16k33(I2cDevice device); }
Ht16k33 implements AutoCloseable { public void setBrightness(int value) throws IOException { if (mDevice == null) { throw new IllegalStateException("I2C device not opened"); } if (value < 0 || value > HT16K33_BRIGHTNESS_MAX) { throw new IllegalArgumentException("brightness must be between 0 and " + HT16K33_BRIGHTNESS_MAX); } mDevice.write(new byte[]{(byte) (HT16K33_CMD_BRIGHTNESS | value)}, 1); } Ht16k33(String bus);  Ht16k33(String bus, int i2cAddress); @VisibleForTesting  Ht16k33(I2cDevice device); @Override void close(); void setEnabled(boolean enabled); void setBrightness(int value); void setBrightness(float value); void writeColumn(int column, short data); }
Ht16k33 implements AutoCloseable { public void setBrightness(int value) throws IOException { if (mDevice == null) { throw new IllegalStateException("I2C device not opened"); } if (value < 0 || value > HT16K33_BRIGHTNESS_MAX) { throw new IllegalArgumentException("brightness must be between 0 and " + HT16K33_BRIGHTNESS_MAX); } mDevice.write(new byte[]{(byte) (HT16K33_CMD_BRIGHTNESS | value)}, 1); } Ht16k33(String bus);  Ht16k33(String bus, int i2cAddress); @VisibleForTesting  Ht16k33(I2cDevice device); @Override void close(); void setEnabled(boolean enabled); void setBrightness(int value); void setBrightness(float value); void writeColumn(int column, short data); static final int I2C_ADDRESS; static final int HT16K33_BRIGHTNESS_MAX; static final short SEGMENT_TOP; static final short SEGMENT_RIGHT_TOP; static final short SEGMENT_RIGHT_BOTTOM; static final short SEGMENT_BOTTOM; static final short SEGMENT_LEFT_BOTTOM; static final short SEGMENT_LEFT_TOP; static final short SEGMENT_CENTER_LEFT; static final short SEGMENT_CENTER_RIGHT; static final short SEGMENT_DIAGONAL_LEFT_TOP; static final short SEGMENT_CENTER_TOP; static final short SEGMENT_DIAGONAL_RIGHT_TOP; static final short SEGMENT_DIAGONAL_LEFT_BOTTOM; static final short SEGMENT_CENTER_BOTTOM; static final short SEGMENT_DIAGONAL_RIGHT_BOTTOM; static final short SEGMENT_DOT; }