@Test public void setEnabled() throws IOException { Ht16k33 driver = new Ht16k33(mI2c); driver.setEnabled(true); Mockito.verify(mI2c).write(new byte[]{(byte) (0x20 | 1)}, 1); Mockito.verify(mI2c).write(new byte[]{(byte) (0x80 | 1)}, 1); driver.setEnabled(false); Mockito.verify(mI2c).write(new byte[]{(byte) (0x20 | 0)}, 1); Mockito.verify(mI2c).write(new byte[]{(byte) (0x80 | 0)}, 1); }
public void setEnabled(boolean enabled) throws IOException { if (mDevice == null) { throw new IllegalStateException("I2C device not opened"); } int oscillator_flag = enabled ? HT16K33_OSCILLATOR_ON : HT16K33_OSCILLATOR_OFF; mDevice.write(new byte[]{(byte) (HT16K33_CMD_SYSTEM_SETUP | oscillator_flag)}, 1); int display_flag = enabled ? HT16K33_DISPLAY_ON : HT16K33_DISPLAY_OFF; mDevice.write(new byte[]{(byte) (HT16K33_CMD_DISPLAYSETUP | display_flag)}, 1); }
Ht16k33 implements AutoCloseable { public void setEnabled(boolean enabled) throws IOException { if (mDevice == null) { throw new IllegalStateException("I2C device not opened"); } int oscillator_flag = enabled ? HT16K33_OSCILLATOR_ON : HT16K33_OSCILLATOR_OFF; mDevice.write(new byte[]{(byte) (HT16K33_CMD_SYSTEM_SETUP | oscillator_flag)}, 1); int display_flag = enabled ? HT16K33_DISPLAY_ON : HT16K33_DISPLAY_OFF; mDevice.write(new byte[]{(byte) (HT16K33_CMD_DISPLAYSETUP | display_flag)}, 1); } }
Ht16k33 implements AutoCloseable { public void setEnabled(boolean enabled) throws IOException { if (mDevice == null) { throw new IllegalStateException("I2C device not opened"); } int oscillator_flag = enabled ? HT16K33_OSCILLATOR_ON : HT16K33_OSCILLATOR_OFF; mDevice.write(new byte[]{(byte) (HT16K33_CMD_SYSTEM_SETUP | oscillator_flag)}, 1); int display_flag = enabled ? HT16K33_DISPLAY_ON : HT16K33_DISPLAY_OFF; mDevice.write(new byte[]{(byte) (HT16K33_CMD_DISPLAYSETUP | display_flag)}, 1); } Ht16k33(String bus);  Ht16k33(String bus, int i2cAddress); @VisibleForTesting  Ht16k33(I2cDevice device); }
Ht16k33 implements AutoCloseable { public void setEnabled(boolean enabled) throws IOException { if (mDevice == null) { throw new IllegalStateException("I2C device not opened"); } int oscillator_flag = enabled ? HT16K33_OSCILLATOR_ON : HT16K33_OSCILLATOR_OFF; mDevice.write(new byte[]{(byte) (HT16K33_CMD_SYSTEM_SETUP | oscillator_flag)}, 1); int display_flag = enabled ? HT16K33_DISPLAY_ON : HT16K33_DISPLAY_OFF; mDevice.write(new byte[]{(byte) (HT16K33_CMD_DISPLAYSETUP | display_flag)}, 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 setEnabled(boolean enabled) throws IOException { if (mDevice == null) { throw new IllegalStateException("I2C device not opened"); } int oscillator_flag = enabled ? HT16K33_OSCILLATOR_ON : HT16K33_OSCILLATOR_OFF; mDevice.write(new byte[]{(byte) (HT16K33_CMD_SYSTEM_SETUP | oscillator_flag)}, 1); int display_flag = enabled ? HT16K33_DISPLAY_ON : HT16K33_DISPLAY_OFF; mDevice.write(new byte[]{(byte) (HT16K33_CMD_DISPLAYSETUP | display_flag)}, 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; }