openHAB - E-Paper 296x128 Bricklet

Bemerkung

Zur Zeit ist nur die englische openHAB-Dokumentation verfügbar.

This is the description of the openHAB API bindings for the E-Paper 296x128 Bricklet. General information and technical specifications for the E-Paper 296x128 Bricklet are summarized in its hardware description.

An installation guide for the openHAB API bindings is part of their general description.

Examples

The example code below is Public Domain (CC0 1.0).

Counter

Download (ExampleCounter.rules)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// For this example create an item linked to the Draw Status channel of your E-Paper 296x128 Bricklet.

var counter = 0

val DRAW_STATUS_IDLE = 0
val FONT_24X32 = 9
val COLOR_BLACK = 0
val COLOR_WHITE = 1
val ORIENTATION_HORIZONTAL = 0

rule "draw"
when
    System started or Item XYZ_DrawStatus changed // Change XYZ_DrawStatus to the created item name
then
    // Only draw if the current draw status is idle
    if ((XYZ_DrawStatus.state as Number).intValue != DRAW_STATUS_IDLE) {
        return
    }
    
    // Change XYZ to the UID of your E-Paper 296x128 Bricklet
    val epaperActions = getActions("tinkerforge", "tinkerforge:brickletepaper296x128:XYZ")
    
    // Remove last image from buffer
    epaperActions.brickletEPaper296x128FillDisplay(COLOR_WHITE)
    
    // Add current counter to buffer
    epaperActions.brickletEPaper296x128DrawText(140, 50, FONT_24X32, COLOR_BLACK, ORIENTATION_HORIZONTAL, String.valueOf(counter))
    
    // Draw buffer
    epaperActions.brickletEPaper296x128Draw()
    
    counter = counter + 1
end

Thing

UID:
  • tinkerforge:brickletepaper296x128:[UID]
Required firmware version:
  • 2.0.0
Firmware update supported:
  • yes
Channels:
Actions:
Parameters:
  • Status LED Config – Type: Choice, Default: Show Status
  • The status LED configuration. By default the LED shows communication traffic between Brick and Bricklet, it flickers once for every 10 received data packets. You can also turn the LED permanently on/off or show a heartbeat. If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
  • Options: Off, On, Show Heartbeat, Show Status

Channels

Draw Status

One of three draw statuses:

  • 0: Idle
  • 1: Copying: Data is being copied from the buffer of the Bricklet to the buffer of the display.
  • 2: Drawing: The display is updating its content (during this phase the flickering etc happens).

You can write to the buffer (through one of the write or draw functions) when the status is either idle or drawing. You should not write to the buffer while it is being copied to the display. There is no double-buffering.

Type:
  • Number:Dimensionless
UID:
  • tinkerforge:brickletepaper296x128:[UID]:BrickletEPaper296x128DrawStatus
Read only:
  • Yes

Actions

Actions can be used in rules by creating an action object. All actions return a Map<String, Object>. Returned values can be accessed by name, sometimes the type deduction needs some hints, as shown below:

val actions = getActions("tinkerforge", "tinkerforge:brickletepaper296x128:[UID]")
val hwVersion = actions.brickletEPaper296x128GetIdentity().get("hardwareVersion") as short[]
logInfo("Example", "Hardware version: " + hwVersion.get(0) + "." + hwVersion.get(1) + "." + hwVersion.get(2))

Basic Actions

brickletEPaper296x128Draw()

Draws the current black/white and red or gray buffer to the e-paper display.

The Bricklet does not have any double-buffering. You should not call this function while writing to the buffer. See Draw Status.

brickletEPaper296x128GetDrawStatus()
Return Map:
  • drawStatus – Type: int, Range: See constants

Returns one of three draw statuses:

  • Idle
  • Copying: Data is being copied from the buffer of the Bricklet to the buffer of the display.
  • Drawing: The display is updating its content (during this phase the flickering etc happens).

You can write to the buffer (through one of the write or draw functions) when the status is either idle or drawing. You should not write to the buffer while it is being copied to the display. There is no double-buffering.

The following constants are available for this function:

For drawStatus:

  • val DRAW_STATUS_IDLE = 0
  • val DRAW_STATUS_COPYING = 1
  • val DRAW_STATUS_DRAWING = 2
brickletEPaper296x128WriteBlackWhite(int xStart, int yStart, int xEnd, int yEnd, boolean[] pixels)
Parameters:
  • xStart – Type: int, Range: [0 to 295]
  • yStart – Type: int, Range: [0 to 127]
  • xEnd – Type: int, Range: [0 to 295]
  • yEnd – Type: int, Range: [0 to 127]
  • pixels – Type: boolean[], Length: variable

Writes black/white pixels to the specified window into the buffer.

The pixels are written into the window line by line top to bottom and each line is written from left to right.

The value 0 (false) corresponds to a black pixel and the value 1 (true) to a white pixel.

This function writes the pixels into the black/white pixel buffer, to draw the buffer to the display use Draw().

Use WriteColor() to write red or gray pixels.

brickletEPaper296x128ReadBlackWhite(int xStart, int yStart, int xEnd, int yEnd)
Parameters:
  • xStart – Type: int, Range: [0 to 295]
  • yStart – Type: int, Range: [0 to 127]
  • xEnd – Type: int, Range: [0 to 295]
  • yEnd – Type: int, Range: [0 to 127]
Return Map:
  • pixels – Type: boolean[], Length: variable

Returns the current content of the black/white pixel buffer for the specified window.

The pixels are read into the window line by line top to bottom and each line is read from left to right.

The current content of the buffer does not have to be the current content of the display. It is possible that the data was not drawn to the display yet and after a restart of the Bricklet the buffer will be reset to black, while the display retains its content.

brickletEPaper296x128WriteColor(int xStart, int yStart, int xEnd, int yEnd, boolean[] pixels)
Parameters:
  • xStart – Type: int, Range: [0 to 295]
  • yStart – Type: int, Range: [0 to 127]
  • xEnd – Type: int, Range: [0 to 295]
  • yEnd – Type: int, Range: [0 to 127]
  • pixels – Type: boolean[], Length: variable

The E-Paper 296x128 Bricklet is available with the colors black/white/red and black/white/gray. Depending on the model this function writes either red or gray pixels to the specified window into the buffer.

The pixels are written into the window line by line top to bottom and each line is written from left to right.

The value 0 (false) means that this pixel does not have color. It will be either black or white (see WriteBlackWhite()). The value 1 (true) corresponds to a red or gray pixel, depending on the Bricklet model.

This function writes the pixels into the red or gray pixel buffer, to draw the buffer to the display use Draw().

Use WriteBlackWhite() to write black/white pixels.

brickletEPaper296x128ReadColor(int xStart, int yStart, int xEnd, int yEnd)
Parameters:
  • xStart – Type: int, Range: [0 to 295]
  • yStart – Type: int, Range: [0 to 127]
  • xEnd – Type: int, Range: [0 to 295]
  • yEnd – Type: int, Range: [0 to 127]
Return Map:
  • pixels – Type: boolean[], Length: variable

Returns the current content of the red or gray pixel buffer for the specified window.

The pixels are written into the window line by line top to bottom and each line is written from left to right.

The current content of the buffer does not have to be the current content of the display. It is possible that the data was not drawn to the display yet and after a restart of the Bricklet the buffer will be reset to black, while the display retains its content.

brickletEPaper296x128FillDisplay(int color)
Parameters:
  • color – Type: int, Range: See constants

Fills the complete content of the display with the given color.

This function writes the pixels into the black/white/red|gray pixel buffer, to draw the buffer to the display use Draw().

The following constants are available for this function:

For color:

  • val COLOR_BLACK = 0
  • val COLOR_WHITE = 1
  • val COLOR_RED = 2
  • val COLOR_GRAY = 2
brickletEPaper296x128DrawText(int positionX, int positionY, int font, int color, int orientation, String text)
Parameters:
  • positionX – Type: int, Range: [0 to 295]
  • positionY – Type: int, Range: [0 to 127]
  • font – Type: int, Range: See constants
  • color – Type: int, Range: See constants
  • orientation – Type: int, Range: See constants
  • text – Type: String, Length: up to 50

Draws a text with up to 50 characters at the pixel position (x, y).

You can use one of 9 different font sizes and draw the text in black/white/red|gray. The text can be drawn horizontal or vertical.

This function writes the pixels into the black/white/red|gray pixel buffer, to draw the buffer to the display use Draw().

The following constants are available for this function:

For font:

  • val FONT_6X8 = 0
  • val FONT_6X16 = 1
  • val FONT_6X24 = 2
  • val FONT_6X32 = 3
  • val FONT_12X16 = 4
  • val FONT_12X24 = 5
  • val FONT_12X32 = 6
  • val FONT_18X24 = 7
  • val FONT_18X32 = 8
  • val FONT_24X32 = 9

For color:

  • val COLOR_BLACK = 0
  • val COLOR_WHITE = 1
  • val COLOR_RED = 2
  • val COLOR_GRAY = 2

For orientation:

  • val ORIENTATION_HORIZONTAL = 0
  • val ORIENTATION_VERTICAL = 1
brickletEPaper296x128DrawLine(int positionXStart, int positionYStart, int positionXEnd, int positionYEnd, int color)
Parameters:
  • positionXStart – Type: int, Range: [0 to 295]
  • positionYStart – Type: int, Range: [0 to 127]
  • positionXEnd – Type: int, Range: [0 to 295]
  • positionYEnd – Type: int, Range: [0 to 127]
  • color – Type: int, Range: See constants

Draws a line from (x, y)-start to (x, y)-end in the given color.

This function writes the pixels into the black/white/red|gray pixel buffer, to draw the buffer to the display use Draw().

The following constants are available for this function:

For color:

  • val COLOR_BLACK = 0
  • val COLOR_WHITE = 1
  • val COLOR_RED = 2
  • val COLOR_GRAY = 2
brickletEPaper296x128DrawBox(int positionXStart, int positionYStart, int positionXEnd, int positionYEnd, boolean fill, int color)
Parameters:
  • positionXStart – Type: int, Range: [0 to 295]
  • positionYStart – Type: int, Range: [0 to 127]
  • positionXEnd – Type: int, Range: [0 to 295]
  • positionYEnd – Type: int, Range: [0 to 127]
  • fill – Type: boolean
  • color – Type: int, Range: See constants

Draws a box from (x, y)-start to (x, y)-end in the given color.

If you set fill to true, the box will be filled with the color. Otherwise only the outline will be drawn.

This function writes the pixels into the black/white/red|gray pixel buffer, to draw the buffer to the display use Draw().

The following constants are available for this function:

For color:

  • val COLOR_BLACK = 0
  • val COLOR_WHITE = 1
  • val COLOR_RED = 2
  • val COLOR_GRAY = 2

Advanced Actions

brickletEPaper296x128SetUpdateMode(int updateMode)
Parameters:
  • updateMode – Type: int, Range: See constants, Default: 0

Bemerkung

The default update mode corresponds to the default e-paper display manufacturer settings. All of the other modes are experimental and will result in increased ghosting and possibly other long-term side effects.

If you want to know more about the inner workings of an e-paper display take a look at this excellent video from Ben Krasnow: https://www.youtube.com/watch?v=MsbiO8EAsGw.

If you are not sure about this option, leave the update mode at default.

Currently there are three update modes available:

  • Default: Settings as given by the manufacturer. An update will take about 7.5 seconds and during the update the screen will flicker several times.
  • Black/White: This will only update the black/white pixel. It uses the manufacturer settings for black/white and ignores the red or gray pixel buffer. With this mode the display will flicker once and it takes about 2.5 seconds. Compared to the default settings there is more ghosting.
  • Delta: This will only update the black/white pixel. It uses an aggressive method where the changes are not applied for a whole buffer but only for the delta between the last and the next buffer. With this mode the display will not flicker during an update and it takes about 900-950ms. Compared to the other two settings there is more ghosting. This mode can be used for something like a flicker-free live update of a text.

With the black/white/red display if you use either the black/white or the delta mode, after a while of going back and forth between black and white the white color will start to appear red-ish or pink-ish.

If you use the aggressive delta mode and rapidly change the content, we recommend that you change back to the default mode every few hours and in the default mode cycle between the three available colors a few times. This will get rid of the ghosting and after that you can go back to the delta mode with flicker-free updates.

The following constants are available for this function:

For updateMode:

  • val UPDATE_MODE_DEFAULT = 0
  • val UPDATE_MODE_BLACK_WHITE = 1
  • val UPDATE_MODE_DELTA = 2
brickletEPaper296x128GetUpdateMode()
Return Map:
  • updateMode – Type: int, Range: See constants, Default: 0

Returns the update mode as set by SetUpdateMode().

The following constants are available for this function:

For updateMode:

  • val UPDATE_MODE_DEFAULT = 0
  • val UPDATE_MODE_BLACK_WHITE = 1
  • val UPDATE_MODE_DELTA = 2
brickletEPaper296x128GetDisplayType()
Return Map:
  • displayType – Type: int, Range: See constants

Returns the type of the e-paper display. It can either be black/white/red or black/white/gray.

The following constants are available for this function:

For displayType:

  • val DISPLAY_TYPE_BLACK_WHITE_RED = 0
  • val DISPLAY_TYPE_BLACK_WHITE_GRAY = 1
brickletEPaper296x128GetChipTemperature()
Return Map:
  • temperature – Type: int, Unit: 1 °C, Range: [-215 to 215 - 1]

Returns the temperature as measured inside the microcontroller. The value returned is not the ambient temperature!

The temperature is only proportional to the real temperature and it has bad accuracy. Practically it is only useful as an indicator for temperature changes.

brickletEPaper296x128GetStatusLEDConfig()
Return Map:
  • config – Type: int, Range: See constants, Default: 3

Returns the configuration as set by the thing configuration

The following constants are available for this function:

For config:

  • val STATUS_LED_CONFIG_OFF = 0
  • val STATUS_LED_CONFIG_ON = 1
  • val STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2
  • val STATUS_LED_CONFIG_SHOW_STATUS = 3
brickletEPaper296x128GetSPITFPErrorCount()
Return Map:
  • errorCountAckChecksum – Type: long, Range: [0 to 232 - 1]
  • errorCountMessageChecksum – Type: long, Range: [0 to 232 - 1]
  • errorCountFrame – Type: long, Range: [0 to 232 - 1]
  • errorCountOverflow – Type: long, Range: [0 to 232 - 1]

Returns the error count for the communication between Brick and Bricklet.

The errors are divided into

  • ACK checksum errors,
  • message checksum errors,
  • framing errors and
  • overflow errors.

The errors counts are for errors that occur on the Bricklet side. All Bricks have a similar function that returns the errors on the Brick side.

brickletEPaper296x128GetIdentity()
Return Map:
  • uid – Type: String, Length: up to 8
  • connectedUid – Type: String, Length: up to 8
  • position – Type: char, Range: ['a' to 'h', 'i', 'z']
  • hardwareVersion – Type: short[], Length: 3
    • 0: major – Type: short, Range: [0 to 255]
    • 1: minor – Type: short, Range: [0 to 255]
    • 2: revision – Type: short, Range: [0 to 255]
  • firmwareVersion – Type: short[], Length: 3
    • 0: major – Type: short, Range: [0 to 255]
    • 1: minor – Type: short, Range: [0 to 255]
    • 2: revision – Type: short, Range: [0 to 255]
  • deviceIdentifier – Type: int, Range: [0 to 216 - 1]

Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.

The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port). The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet connected to an Isolator Bricklet is always as position 'z'.

The device identifier numbers can be found here

Internal Actions

brickletEPaper296x128ReadUID()
Return Map:
  • uid – Type: long, Range: [0 to 232 - 1]

Returns the current UID as an integer. Encode as Base58 to get the usual string version.