Onion Omega2 Dash

by Onion

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

View all updates Jan 27, 2020

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:

  • \033 acts as an escape character
  • [94m sets the color to bright blue
  • Wow is the text
  • \033 escape character and [0m to reset the text formatting to default

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))
    print(u"\033[0m")

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.

About the Author

Lazar D

greenbreakfast  ·   Toronto, Canada


$34,720 raised

of $10,000 goal

347% Funded! Order Below

Product Choices

$69

Omega2 Dash

An Omega2 Dash IoT computer. Perfect for making internet-connected control panels and user interfaces.


$94

Omega2 Dash Essentials Collection

An Omega2 Dash and the Ethernet and ADC Expansions. Build projects that use wireless or wired networking and can communicate with all sorts of devices, digital or analog.


$134

Omega2 Dash Ultimate Collection

An Omega2 Dash and a whole set of Expansions: NFC/RFID Expansion, ADC Expansion, Servo (PWM) Expansion, Ethernet Expansion, Proto Expansion.

Credits

Onion

Onion is a team of technology enthusiasts, creators, and strivers, looking to make amazing products and even better user experiences. Onion has been in business since 2014, graduating from the TechStars Startup Accelerator in Boston that year. In 2015, we introduced the world to the Onion Omega IoT computer.


Lazar Demin

Zheng Han

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