Warning
The openHAB bindings are still in beta, but the development was stopped.
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.
The example code below is Public Domain (CC0 1.0).
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
|
UID:
- tinkerforge:brickletepaper296x128:[UID]
Required firmware version:
- 2.0.3
Firmware update supported:
- yes
Channels: Actions: Parameters:
- Status LED Configuration – 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
Draw Status
¶One of three draw statuses:
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 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))
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: |
|
---|
Returns one of three draw statuses:
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:
brickletEPaper296x128WriteBlackWhite
(int xStart, int yStart, int xEnd, int yEnd, boolean[] pixels)¶Parameters: |
|
---|
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: |
|
---|---|
Return Map: |
|
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: |
|
---|
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: |
|
---|---|
Return Map: |
|
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: |
|
---|
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:
brickletEPaper296x128DrawText
(int positionX, int positionY, int font, int color, int orientation, String text)¶Parameters: |
|
---|
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 font conforms to code page 437.
The following constants are available for this function:
For font:
For color:
For orientation:
brickletEPaper296x128DrawLine
(int positionXStart, int positionYStart, int positionXEnd, int positionYEnd, int color)¶Parameters: |
|
---|
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:
brickletEPaper296x128DrawBox
(int positionXStart, int positionYStart, int positionXEnd, int positionYEnd, boolean fill, int color)¶Parameters: |
|
---|
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:
brickletEPaper296x128SetUpdateMode
(int updateMode)¶Parameters: |
|
---|
Note
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:
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:
brickletEPaper296x128GetUpdateMode
()¶Return Map: |
|
---|
Returns the update mode as set by SetUpdateMode()
.
The following constants are available for this function:
For updateMode:
brickletEPaper296x128GetDisplayType
()¶Return Map: |
|
---|
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:
brickletEPaper296x128GetDisplayDriver
()¶Return Map: |
|
---|
Returns the e-paper display driver.
The following constants are available for this function:
For displayDriver:
New in version 2.0.3 (Plugin).
brickletEPaper296x128GetChipTemperature
()¶Return Map: |
|
---|
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: |
|
---|
Returns the configuration as set by the thing configuration
The following constants are available for this function:
For config:
brickletEPaper296x128GetSPITFPErrorCount
()¶Return Map: |
|
---|
Returns the error count for the communication between Brick and Bricklet.
The errors are divided into
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.
brickletEPaper296x128Reset
()¶Calling this function will reset the Bricklet. All configurations will be lost.
After a reset you have to create new device objects, calling functions on the existing ones will result in undefined behavior!
brickletEPaper296x128GetIdentity
()¶Return Map: |
|
---|
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). A Bricklet connected to an Isolator Bricklet is always at position 'z'.
The device identifier numbers can be found here.