@Test public void setContrastValidValues() throws IOException { mockStatic(BitmapHelper.class); mockStatic(Bitmap.class); Ssd1306 ssd1306 = new Ssd1306(mI2c); int[] validValues = {0, 66, 255}; for (int validValue : validValues) { ssd1306.setContrast(validValue); Mockito.verify(mI2c).writeRegByte(0x00, (byte) 0x81); Mockito.verify(mI2c).writeRegByte(0x00, (byte) validValue); Mockito.reset(mI2c); } }
public void setContrast(int level) throws IOException, IllegalArgumentException { if (mI2cDevice == null) { throw new IllegalStateException("I2C Device not open"); } if (level < 0 || level > 255) { throw new IllegalArgumentException("Invalid contrast " + String.valueOf(level) + ", level must be between 0 and 255"); } mI2cDevice.writeRegByte(0, (byte) COMMAND_CONTRAST_LEVEL); mI2cDevice.writeRegByte(0, (byte) level); }
Ssd1306 implements Closeable { public void setContrast(int level) throws IOException, IllegalArgumentException { if (mI2cDevice == null) { throw new IllegalStateException("I2C Device not open"); } if (level < 0 || level > 255) { throw new IllegalArgumentException("Invalid contrast " + String.valueOf(level) + ", level must be between 0 and 255"); } mI2cDevice.writeRegByte(0, (byte) COMMAND_CONTRAST_LEVEL); mI2cDevice.writeRegByte(0, (byte) level); } }
Ssd1306 implements Closeable { public void setContrast(int level) throws IOException, IllegalArgumentException { if (mI2cDevice == null) { throw new IllegalStateException("I2C Device not open"); } if (level < 0 || level > 255) { throw new IllegalArgumentException("Invalid contrast " + String.valueOf(level) + ", level must be between 0 and 255"); } mI2cDevice.writeRegByte(0, (byte) COMMAND_CONTRAST_LEVEL); mI2cDevice.writeRegByte(0, (byte) level); } Ssd1306(String i2cName);  Ssd1306(String i2cName, int width, int height);  Ssd1306(String i2cName, int i2cAddress);  Ssd1306(String i2cName, int i2cAddress, int width, int height);   Ssd1306(I2cDevice device); }
Ssd1306 implements Closeable { public void setContrast(int level) throws IOException, IllegalArgumentException { if (mI2cDevice == null) { throw new IllegalStateException("I2C Device not open"); } if (level < 0 || level > 255) { throw new IllegalArgumentException("Invalid contrast " + String.valueOf(level) + ", level must be between 0 and 255"); } mI2cDevice.writeRegByte(0, (byte) COMMAND_CONTRAST_LEVEL); mI2cDevice.writeRegByte(0, (byte) level); } Ssd1306(String i2cName);  Ssd1306(String i2cName, int width, int height);  Ssd1306(String i2cName, int i2cAddress);  Ssd1306(String i2cName, int i2cAddress, int width, int height);   Ssd1306(I2cDevice device); @Override void close(); int getLcdWidth(); int getLcdHeight(); void clearPixels(); void setPixel(int x, int y, boolean on); void setContrast(int level); void setDisplayOn(boolean on); void show(); void startScroll(int startY, int finishY, ScrollMode scrollMode); void stopScroll(); }
Ssd1306 implements Closeable { public void setContrast(int level) throws IOException, IllegalArgumentException { if (mI2cDevice == null) { throw new IllegalStateException("I2C Device not open"); } if (level < 0 || level > 255) { throw new IllegalArgumentException("Invalid contrast " + String.valueOf(level) + ", level must be between 0 and 255"); } mI2cDevice.writeRegByte(0, (byte) COMMAND_CONTRAST_LEVEL); mI2cDevice.writeRegByte(0, (byte) level); } Ssd1306(String i2cName);  Ssd1306(String i2cName, int width, int height);  Ssd1306(String i2cName, int i2cAddress);  Ssd1306(String i2cName, int i2cAddress, int width, int height);   Ssd1306(I2cDevice device); @Override void close(); int getLcdWidth(); int getLcdHeight(); void clearPixels(); void setPixel(int x, int y, boolean on); void setContrast(int level); void setDisplayOn(boolean on); void show(); void startScroll(int startY, int finishY, ScrollMode scrollMode); void stopScroll(); @Deprecated
    static final int I2C_ADDRESS; @Deprecated
    static final int I2C_ADDRESS_ALT; static final int I2C_ADDRESS_SA0_LOW; static final int I2C_ADDRESS_SA0_HIGH; }