Up

Deplhi Programming

Examples interfacing Matrix Orbital displays using Delphi.

Sending more advanced commands such as Custom Startup Screen.

Example 4: clear screen, set backlight off and write text on startup

 

As a fourth example I've created a little application called "Small Foot", which can be used to set the backlight off, clear the screen and/or send some text to the display on startup, without showing any forms. When started with "settings" as a parameter in the commandline, the settings-form is shown in which some settings can be altered. The settings are saved in a inifile called "SmallFootSettings.ini" in the default ini-directory.

ZIP-file with source code and binary, a total size of 205KB

Here's a screenshot: 

smallfoot screeny

 

Sending a commands to a display.


Example 2: Clear screen

This example sends the command to clear the screen of the display to the display, when the user clicks Button1. So this code assumes that you have a TButton named "Button1" on the form, and the code should be in the OnClick event-handler. The caption for the button could be "Clear screen".

procedure TForm1.Button1Click(Sender: TObject);
begin
 //This function will clear the screen by sending 'X'
 //to the display after a command-byte (255)

 //Initialize settings
 ComPort1.Port := 'COM1';
 ComPort1.BaudRate := br19200;

 //Open the comport
 try
  ComPort1.Open;
 except
  //If there was an error while opening the comport, inform the user and exit
  ShowMessage('Com-port 1 could not be opened.');
  exit;
 end;


 //Send the command (commands sent to the display are always preceeded
 //by byte 255, the command-byte):
 ComPort1.WriteStr(#255'X');

 //Close the port
 ComPort1.Close;

end;


Example 3: set backlight on

This example will set the backlight for the display on, infinite. This means that the backlight will not go out after some minutes, but only if they display gets disconnected, powered off or the command is sent to set the backlight off


procedure TForm1.Button2Click(Sender: TObject);
begin
 //This function lights the backlight

 //Initialize settings
 ComPort1.Port := 'COM1';
 ComPort1.BaudRate := br19200;

 //Open the comport
 try
  ComPort1.Open;
 except
  //If there was an error while opening the comport, inform the user
  //and exit
  ShowMessage('Com-port 1 could not be opened.');
  exit;
 end;


 //Send the command ('B' for backlight on), followed by 0 (zero) for infinite on
 ComPort1.WriteStr(#255'B'#0);

 //To set the backlight off, send 'F' instead of 'B', like this:
 //ComPort1.WriteStr(#255'F');

 //Close the port
 ComPort1.Close;

end;

A special thanks to David (Relix) Ovichen for this example.

 

Sending simple text to the screen.

Introduction: 
This source is developped in Delphi 5, but should work for Delphi 3 and above.

The component used for communicating with the com-port is TComPort from Dejan Crnila. You can download it here.

The code assumes that you have a form "TForm1" with a TComPort on it named "ComPort1".

Example 1: Sending simple text to the screen
This example will send the traditional "Hello World!" to the display at com-port 1, at baudrate 19200, you may have to modify these setting to match your display.


procedure TForm1.HelloWorld;
begin
 //Initialize settings
 ComPort1.Port := 'COM1';
 ComPort1.BaudRate := br19200;

 //Open the comport
 try
  ComPort1.Open;
 except
  //If there was an error while opening the comport, inform the user
  //and exit
  ShowMessage('Com-port 1 could not be opened.');
  exit;
 end;

 //Send the string
 ComPort1.WriteStr('Hello World!');

 //Close the comport again
 ComPort1.Close;

end;


A special thanks to David (Relix) Ovichen for this example.

For technical discussions and questions, please visit our forums