Onion Omega2 Dash

An open-source touchscreen & Wi-Fi-connected Linux dev board

Limited items in stock

View Purchasing Options
Jan 27, 2020

Project update 7 of 18

Writing Text

by Lazar D

Hey everyone,

With the campaign coming to a close at the end of the week, we’ve realized we have yet to cover a fundamental use-case: writing text to the display on the Omega2 Dash!

But before we dive in, there’s still time for more backers to join us over the next couple of days before the campaign closes! If you know anybody who would get a kick out of the Omega2 Dash, send them a link to our campaign page.

Writing Text

In the Omega2 Dash Linux operating system, the Linux framebuffer is connected to the /dev/tty1 virtual terminal device. So anything written to this virtual terminal, will actually show up on the screen!

It’s as easy as piping your program output to /dev/tty1, and seeing it displayed on the screen.

Try it out:

echo "Hello world, it's the Omega2 Dash" > /dev/tty1

To clear the screen:

clear > /dev/tty1

Adding Color

But that’s not all, using ANSI escape characters we can add color!

For example:

echo -e "\033[94mWow\033[0m! So \033[92mmuch\033[0m \033[91mroom\033[0m for \033[4mactivities\033[0m" > /dev/tty1

Looking at the command it might seem confusing but it’s straightforward when it’s broken down.

Take \033[94mWow\033[0m:

Learn more about ANSI escape characters here and here, and see this list of color codes.

A Dash of Higher Level Programming Languages

Taking this one step further, we can incorporate ANSI escape characters in our scripts and programs.

For example, check out this Python program that loops through the available colors:

import sys
for i in range(0, 14):
    for j in range(0, 16):
        code = str(i * 16 + j)
        sys.stdout.write(u"\033[38;5;" + code + "m " + code.ljust(4))

Run it on your Omega2 Dash and pipe the output to /dev/tty1:

python3 color.py > /dev/tty1

More Python

We’ve also put together a little Python script that makes it easy to color your text with functions like term.red(), term.blue(), and so on.

python3 colorMessage.py > /dev/tty1

Grab the source code from Github.

Sign up to receive future updates for Onion Omega2 Dash.

Subscribe to the Crowd Supply newsletter, highlighting the latest creators and projects