Border-less full-screen console app in Ultibo

I made my first project in Ultibo and compiled some example one. Everything was just fine (actually — perfect), if not for that green border with Ultibo name and release version.

Don’t get me wrong. I already love UItibo and will spread the word. But, for security reasons, I’d like to get rid of any info that clearly communicates what was used to build particular piece of software.

Fortunately, with a small research (here and here), it turned out that the solution is very easy.

Linux-like console

The entire program’s code is as simple as:

program ConsoleColors;

{$mode objfpc}{$H+}

uses
  RaspberryPi3,
  GlobalConfig,
  GlobalConst,
  GlobalTypes,
  Platform,
  Threads,
  SysUtils,
  Classes,
  Console,
  Ultibo;

var
 h: TWindowHandle;
 c: PConsoleDevice;

begin
  c := ConsoleDeviceGetDefault;
  h := ConsoleWindowCreate(c, CONSOLE_POSITION_FULLSCREEN, true);

  ConsoleDeviceClear(c, COLOR_BLACK);
  ConsoleWindowSetBackcolor(h, COLOR_BLACK);
  ConsoleWindowSetForecolor(h, COLOR_WHITE);

  ConsoleWindowWriteLn(h, 'Hello World!');
end.

Methods used here:

  • ConsoleDeviceClear — clears a console device using the specified color (black)
  • ConsoleWindowSetBackcolor — sets the current background color of an existing console window (black)
  • ConsoleWindowSetForecolor — similarly set the current foreground color of an existing console window (white)

These methods are defined in Console unit. And colors definitions comes from GlobalConst unit.

With the above code put somewhere into application I had finally a full-screen console window, with a entire black background and white text. Just as in typical Linux console.

Refer to this section for details on building Ultibo apps and deploying them to Raspberry Pi.

Other colors

I have extended this code to display all colors available in console (all color constants from GlobalConst unit).

You can grab its source code in newest version from GitHub.

If you wish an entire package (in version available when this article was first time published) then:

This file contains everything you need. Just unzip its content to a microSD card and boot RPi from that card.

Black and White Web Server

I did exactly the same as above to example project no 12 (12-WebServer) for Raspberry 3A/3B/3B+ (you can find it it C:\Ultibo\Core\examples\12-WebServer\RPi3). Otherwise than changing console window to full-screen black-and-white this is exactly the same project.

You can grab source code from GitHub.

Entire package is also available:

It is also ready to be put to microSD card and run.

Leave a Reply