Skip to content

Commit

Permalink
Merge pull request #208 from EAGrahamJr/screen-on
Browse files Browse the repository at this point in the history
Uses a local variable to track display state (on/off).
  • Loading branch information
mattjlewis authored Jul 29, 2024
2 parents 70e95c7 + a0317ec commit 0b0e1fd
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions diozero-core/src/main/java/com/diozero/devices/oled/SsdOled.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Organisation: diozero
* Project: diozero - Core
* Filename: SsdOled.java
*
*
* This file is part of the diozero project. More information about this project
* can be found at https://www.diozero.com/.
* %%
Expand All @@ -17,10 +17,10 @@
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand Down Expand Up @@ -50,6 +50,7 @@ public abstract class SsdOled implements DeviceInterface {
protected final int height;

protected int imageType;
protected boolean screenOn;

protected SsdOled(SsdOledCommunicationChannel channel, int width, int height, int imageType) {
this.channel = channel;
Expand All @@ -60,7 +61,7 @@ protected SsdOled(SsdOledCommunicationChannel channel, int width, int height, in

/**
* Each device must maintain a <b>static</b> byte buffer of the screen contents.
*
*
* @return the screen contents to write out
*/
protected abstract byte[] getBuffer();
Expand Down Expand Up @@ -99,7 +100,7 @@ public void show() {

/**
* Fills the buffer with the image and immediately displays it
*
*
* @param image the image to display
*/
public abstract void display(BufferedImage image);
Expand All @@ -117,8 +118,30 @@ public int getHeight() {
return height;
}

/**
* Set the display on or off.
* @param on if {@code true}, turn on the display, otherwise off
* @deprecated since 1.4.1: did not (formerly) store state
*/
@Deprecated(since = "1.4.1", forRemoval = true)
public void setDisplayOn(boolean on) {
setDisplay(on);
}

/**
* Set the display on or off.
* @param on if {@code true}, turn on the display, otherwise off
*/
public void setDisplay(boolean on) {
command(on ? DISPLAY_ON : DISPLAY_OFF);
screenOn = on;
}

/**
* Get the display state: on {@code true} or off {@code false}
*/
public boolean getDisplay() {
return screenOn;
}

@Override
Expand Down

0 comments on commit 0b0e1fd

Please sign in to comment.