This is the description of the Shell API bindings for the OLED 128x64 Bricklet. General information and technical specifications for the OLED 128x64 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 128x64 Bricklet
5
6# Clear display
7tinkerforge call oled-128x64-bricklet $uid clear-display
8
9# Write "Hello World" starting from upper left corner of the screen
10tinkerforge call oled-128x64-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 128x64 Bricklet
7
8SCREEN_WIDTH=128
9SCREEN_HEIGHT=64
10
11function draw_matrix {
12 declare -A column
13 declare -A column_write
14
15 for ((i=0; i<${SCREEN_HEIGHT}/8; i++))
16 do
17 for ((j=0; j<${SCREEN_WIDTH}; j++))
18 do
19 page=0
20
21 for ((k=0; k<8; k++))
22 do
23 if ((${pixel_matrix[$((((${i}*8))+${k})),${j}]}))
24 then
25 page=$((${page}|$((1<<${k}))))
26 fi
27 done
28 column[${i},${j}]=${page}
29 done
30 done
31 tinkerforge call oled-128x64-bricklet ${uid} new-window 0 $((${SCREEN_WIDTH}-1)) 0 7
32
33 for ((i=0; i<${SCREEN_HEIGHT}/8; i++))
34 do
35 l=0
36 for ((j=0; j < ${SCREEN_WIDTH}/2; j++))
37 do
38 column_write[${l}]=${column[${i},${j}]}
39 l=$((l+1))
40 done
41 write_bytes=""
42 for ((j=0; j<${SCREEN_WIDTH}/2; j++))
43 do
44 write_bytes+=${column_write[${j}]}
45 if ((${j}==${SCREEN_HEIGHT}-1))
46 then
47 continue
48 fi
49 write_bytes+=","
50 done
51 tinkerforge call oled-128x64-bricklet ${uid} write ${write_bytes}
52
53 l=0
54 for ((j=${SCREEN_WIDTH}/2; j < ${SCREEN_WIDTH}; j++))
55 do
56 column_write[${l}]=${column[${i},${j}]}
57 l=$((l+1))
58 done
59
60 write_bytes=""
61 for ((j=0; j<${SCREEN_WIDTH}/2; j++))
62 do
63 write_bytes+=${column_write[${j}]}
64 if ((${j}==${SCREEN_HEIGHT}-1))
65 then
66 continue
67 fi
68 write_bytes+=","
69 done
70 tinkerforge call oled-128x64-bricklet ${uid} write ${write_bytes}
71 done
72}
73
74# Clear display
75tinkerforge call oled-128x64-bricklet $uid clear-display
76
77# Draw checkerboard pattern
78declare -A pixel_matrix
79
80for ((h=0;h<${SCREEN_HEIGHT};h++))
81do
82 for ((w=0;w<${SCREEN_WIDTH};w++))
83 do
84 pixel_matrix[${h},${w}]=$((((${h}/8))%2==((${w}/8))%2))
85 done
86done
87
88draw_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 128x64 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 128x64 Bricklet and exits
| Parameters: |
|
|---|
The dispatch command is used to dispatch a callback of the OLED 128x64 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 128x64 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 127 and row
from 0 to 7 (the whole display) each call of write (red arrow) will
write half of a 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 half of the row
and the next two the second row and so on. To fill the whole display
you need to call write 16 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 26 characters.
For example: (1, 10, "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.