Skip to content

Commit

Permalink
E-Paper Driver HAT: Implemented setInvertDisplay()
Browse files Browse the repository at this point in the history
  • Loading branch information
leinardi committed Jan 19, 2018
1 parent c25e476 commit d5dea49
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,14 @@ public void reset() throws IOException {
*/
public abstract void setPixel(int x, int y, boolean on) throws IllegalArgumentException;

// /**
// * Invert the display color without rewriting the contents of the display data RAM..
// *
// * @param invert Set to true to invert the display color; set to false to set the display back to normal.
// * @throws IOException
// * @throws IllegalStateException
// */
// public abstract void setInvertDisplay(boolean invert) throws IOException, IllegalStateException;
/**
* Invert the display color without rewriting the contents of the display data RAM..
*
* @param invert Set to true to invert the display color; set to false to set the display back to normal.
* @throws IOException
* @throws IllegalStateException
*/
public abstract void setInvertDisplay(boolean invert) throws IOException, IllegalStateException;

/**
* Renders the current pixel data to the screen.
Expand All @@ -188,9 +188,9 @@ public void reset() throws IOException {
*/
public abstract void show() throws IOException;

public abstract void wakeUp() throws IOException;
protected abstract void wakeUp() throws IOException;

public abstract void sleep() throws IOException;
protected abstract void sleep() throws IOException;

protected abstract boolean isBusy() throws IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public class Gdew075t8Epd extends Epd {
private static final int PIXEL_ON = 0b011;

private byte[] mBuffer;
private boolean mInvertColor;

public Gdew075t8Epd() throws IOException {
}
Expand Down Expand Up @@ -163,6 +164,11 @@ public void setPixel(int x, int y, boolean on) throws IllegalArgumentException {
}
}

@Override
public void setInvertDisplay(boolean invert) throws IOException, IllegalStateException {
mInvertColor = invert;
}

@Override
public int getDisplayWidth() {
return EPD_WIDTH;
Expand All @@ -184,7 +190,7 @@ public void show() throws IOException {
}

@Override
public void wakeUp() throws IOException {
protected void wakeUp() throws IOException {
reset();

sendCommand(SPI_FLASH_CONTROL);
Expand Down Expand Up @@ -226,7 +232,11 @@ public void wakeUp() throws IOException {
sendData((byte) TEMPERATURE_CALIBRATION_INTERNAL);

sendCommand(VCOM_AND_DATA_INTERVAL_SETTING);
sendData((byte) VCOM_AND_DATA_INTERVAL_SETTING_DEFAULT_WHITE_BALCK);
int vcomAndDataIntervalSetting = VCOM_AND_DATA_INTERVAL_SETTING_DEFAULT_WHITE_BALCK;
if (mInvertColor) {
vcomAndDataIntervalSetting |= VCOM_AND_DATA_INTERVAL_SETTING_INVERT_COLORS;
}
sendData((byte) vcomAndDataIntervalSetting);

sendCommand(TCON_SETTING);
sendData((byte) TCON_SETTING_DEFAULT_S2G_G2S);
Expand All @@ -248,7 +258,7 @@ public void wakeUp() throws IOException {
}

@Override
public void sleep() throws IOException {
protected void sleep() throws IOException {
sendCommand(SPI_FLASH_CONTROL);
sendData((byte) SPI_FLASH_CONTROL_ENABLED);

Expand Down

0 comments on commit d5dea49

Please sign in to comment.