This is the description of the Shell API bindings for the OLED 64x48 Bricklet. General information and technical specifications for the OLED 64x48 Bricklet are summarized in its hardware description.
An installation guide for the Shell API bindings is part of their general description.
The example code below is Public Domain (CC0 1.0).
Download (example-hello-world.sh)
1#!/bin/sh
2# Connects to localhost:4223 by default, use --host and --port to change this
3
4uid=XYZ # Change XYZ to the UID of your OLED 64x48 Bricklet
5
6# Clear display
7tinkerforge call oled-64x48-bricklet $uid clear-display
8
9# Write "Hello World" starting from upper left corner of the screen
10tinkerforge call oled-64x48-bricklet $uid write-line 0 0 "Hello World"
Download (example-pixel-matrix.sh)
1#!/bin/bash
2# Connects to localhost:4223 by default, use --host and --port to change this
3
4# This example requires Bash 4
5
6uid=XYZ # Change XYZ to the UID of your OLED 64x48 Bricklet
7
8screen_width=64
9screen_height=48
10
11function draw_matrix {
12 declare -A column
13
14 for ((i=0; i<${screen_height}/8; i++))
15 do
16 for ((j=0; j<${screen_width}; j++))
17 do
18 page=0
19
20 for ((k=0; k<8; k++))
21 do
22 if ((${pixel_matrix[$((((${i}*8))+${k})),${j}]}))
23 then
24 page=$((${page}|$((1<<${k}))))
25 fi
26 done
27 column[${i},${j}]=${page}
28 done
29 done
30 tinkerforge call oled-64x48-bricklet ${uid} new-window 0 $((${screen_width}-1)) 0 5
31
32 for ((i=0; i<${screen_height}/8; i++))
33 do
34 write_bytes=""
35 for ((j=0; j<${screen_width}; j++))
36 do
37 write_bytes+=${column[${i},${j}]}
38 if ((${j}==${screen_width}-1))
39 then
40 continue
41 fi
42 write_bytes+=","
43 done
44 tinkerforge call oled-64x48-bricklet ${uid} write ${write_bytes}
45 done
46}
47
48# Clear display
49tinkerforge call oled-64x48-bricklet $uid clear-display
50
51# Draw checkerboard pattern
52declare -A pixel_matrix
53
54for ((h=0;h<${screen_height};h++))
55do
56 for ((w=0;w<${screen_width};w++))
57 do
58 pixel_matrix[${h},${w}]=$((((${h}/8))%2==((${w}/8))%2))
59 done
60done
61
62draw_matrix
Possible exit codes for all tinkerforge commands are:
1: interrupted (ctrl+c)
2: syntax error
21: Python 2.5 or newer is required
22: Python argparse module is missing
23: socket error
24: other exception
25: invalid placeholder in format string
26: authentication error
201: timeout occurred
209: invalid argument value
210: function is not supported
211: unknown error
The common options of the call and dispatch commands are documented
here. The specific command structure is shown below.
| Parameters: |
|
|---|
The call command is used to call a function of the OLED 64x48 Bricklet. It can take several
options:
--help shows help for the specific call command and exits
--list-functions shows a list of known functions of the OLED 64x48 Bricklet and exits
| Parameters: |
|
|---|
The dispatch command is used to dispatch a callback of the OLED 64x48 Bricklet. It can
take several options:
--help shows help for the specific dispatch command and exits
--list-callbacks shows a list of known callbacks of the OLED 64x48 Bricklet and exits
| Parameters: |
|
|---|
The <function> to be called can take different options depending of its
kind. All functions can take the following options:
--help shows help for the specific function and exits
Getter functions can take the following options:
--execute <command> shell command line to execute for each incoming
response (see section about output formatting
for details)
Setter functions can take the following options:
--expect-response requests response and waits for it
The --expect-response option for setter functions allows to detect
timeouts and other error conditions calls of setters as well. The device will
then send a response for this purpose. If this option is not given for a
setter function then no response is sent and errors are silently ignored,
because they cannot be detected.
| Parameters: |
|
|---|
The <callback> to be dispatched can take several options:
--help shows help for the specific callback and exits
--execute <command> shell command line to execute for each incoming
response (see section about output formatting
for details)
| Parameters: |
|
|---|---|
| Output: |
|
Appends 64 byte of data to the window as set by new-window.
Each row has a height of 8 pixels which corresponds to one byte of data.
Example: if you call new-window with column from 0 to 63 and row
from 0 to 5 (the whole display) each call of write (red arrow) will
write one row.
The LSB (D0) of each data byte is at the top and the MSB (D7) is at the bottom of the row.
The next call of write will write the second row and so on. To
fill the whole display you need to call write 6 times.
| Parameters: |
|
|---|---|
| Output: |
|
Sets the window in which you can write with write. One row
has a height of 8 pixels.
| Output: |
|
|---|
Clears the current content of the window as set by new-window.
| Parameters: |
|
|---|---|
| Output: |
|
Writes text to a specific line with a specific position. The text can have a maximum of 13 characters.
For example: (1, 4, "Hello") will write Hello in the middle of the second line of the display.
You can draw to the display with write and then add text to it
afterwards.
The display uses a special 5x7 pixel charset. You can view the characters of the charset in Brick Viewer.
The font conforms to code page 437.
| Parameters: |
|
|---|---|
| Output: |
|
Sets the configuration of the display.
You can set a contrast value from 0 to 255 and you can invert the color (black/white) of the display.
| Output: |
|
|---|
Returns the configuration as set by set-display-configuration.
| Output: |
|
|---|
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.