Permalink
Browse files

update to PR #296; added secondary `setBacklight` method with optiona…

…l `immediate` argument to avoid breaking backwards compatibility with the addition of the thrown Exception on method signature
1 parent 89e276e commit e8a90c3fb69827640cee0a63f8f5bd2a1ede5fb3 @savageautomate savageautomate committed Dec 29, 2016
Showing with 13 additions and 3 deletions.
  1. +13 −3 pi4j-device/src/main/java/com/pi4j/component/lcd/impl/I2CLcdDisplay.java
@@ -42,6 +42,7 @@
//~--- JDK imports ------------------------------------------------------------
+import java.io.IOException;
import java.util.BitSet;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -333,10 +334,19 @@ public void setCursorPosition(int row, int column) {
*/
public void setBacklight(boolean backlight) {
this.backlight = backlight;
+ }
- dev.write((byte)(backlight
- ? 1 << (byte)backlightBit
- : 0 << (byte)backlightBit));
+ /**
+ * @param backlight the backlight to set
+ * @param immediate optionally update the device immediately
+ */
+ public void setBacklight(boolean backlight, boolean immediate) throws IOException {
+ setBacklight(backlight);
+ if(immediate) {
+ dev.write((byte) (backlight
+ ? 1 << (byte) backlightBit
+ : 0 << (byte) backlightBit));
+ }
}
private void setRS(boolean val) {

0 comments on commit e8a90c3

Please sign in to comment.