Facebook Pixel

AN-00046 Designer or ViSi Displaying Texts And Strings on Goldelox Displays

 

Description This Application Note will simply teach the user how to display text and strings on a GOLDELOX display module. This will demonstrate a simplified approach in to learning text and string related functions of the 4DGL programming language used in GOLDELOX platform.
Supported Processor GOLDELOX
Supported Environment Designer, ViSi
Difficulty Easy

 

File Downloads
Files

  Description

This application note is dedicated to providing the reader a simple and straight forward documentation about string functions. This application is intended for use in the Workshop 4 – Designer environment. The 4DGL code of the Designer project can be copied and pasted to an empty ViSi project and it will compile normally. The code can also be integrated to that of an existing ViSi project.

The tools needed include the following;

  • Any of the following 4D Goldelox display modules:

uOLED-96-G2

uOLED-128-G2

uOLED-160-G2

uLCD-144-G2

uTOLED-20-G2

or any superseded module that supports the Designer and/or ViSi environments

Application Overview

This application note will simply teach the user how to display text and strings on a Goldelox display module.  This will demonstrate a simplified approach in to learning text and string related functions of the 4DGL programming language used in Goldelox platform. 

This application note focuses on a step-by-step approach in learning the Goldelox text and string functions. It is composed of a set of application notes all dedicated to discuss a common group or pair of functions of the Goldelox internal instructions.

 

Setup Procedure

For instructions on how to launch Workshop 4, how to open a Designer project, and how to change the target display, kindly refer to the section “Setup Procedure” of the application note

Designer Getting Started - First Project

For instructions on how to launch Workshop 4, how to open a ViSi project, and how to change the target display, kindly refer to the section “Setup Procedure” of the application note

ViSi Getting Started - First Project for Goldelox

Create a New Project

For instructions on how to create a new Designer project, please refer to the section “Create a New Project” of the application note

Designer Getting Started - First Project

For instructions on how to create a new ViSi project, please refer to the section “Create a New Project” of the application note

ViSi Getting Started - First Project for Goldelox

 

Design the Project

Using the print(…) Function

The print function of the 4DGL is a versatile function. It is one of the most useful and most commonly used function when it comes to directing the Goldelox processor to display a string, number, or values in several numerical formats unto the device’s display.

A part of the program that is automatically displayed when starting a Designer environment based program includes an example on how to use the print(…) function. Let us begin understanding the print(…) function using the program below.

 

In this program, the print function is used to display into the Goldelox screen the words Hello World. Notice that is enclosed by a pair of quotation marks. The quotation marks are used to indicate the string to be displayed. If we are to run this program we shall notice that the text quotation marks are not displayed but only the string inside of it.

This is how simple it is to use the print(…) function. Numbers, spaces and other special characters can also be displayed directly to the screen using the same program. So changing the content of the text in the print(…) function, for instance we write these information:  “John Smith is 12?“.

From all of the samples above, you will notice that anything that is written inside the quotation marks are directly written or displayed into the screen. If using the print(…) function, the display always starts at the topmost left of the screen when displaying a set of characters or phrases.

Moving another step forward, Let us try replacing the sentence again the phrases inside the quotation marks with a longer set of string:  “John Smith is 12 years of age?”. After downloading this to the device, we will have an output similar to the image shown here.

We can see that from the last string set in to the print function that a couple of words are missing after being displayed. The reason behind is that the print function directly sends out the data into the screen without any automatic text wrapping. There is a command that is very useful for these kinds of simple errors – the newline command \n.

 

The newline command \n tells the print function- print the succeeding words of the string to a newline. This is now one simple way of formatting output by wrapping the extra words to the next line.

The print(…) function is relatively very simple to use and that the output can be readily seen after downloading the program to the Goldelox display module. At this point we can say that regardless of the character being a letter in the alphabet or a number the print(…) function can readily have this sent and displayed to the screen of  the Goldelox display module.

Using the putstr(…) function

Printing a set of character into the display screen is relatively easy.  Another useful command that can be used to achieve this purpose is the put string function which has a syntax putstr(…).

 

Referring to the program below we have the putstr(…) function to direct the processor to display the Hello World into the screen display. Let us look at the statement written in line 10.

The need for the quotation marks to enclose the string to be displayed is a requirement of this function.

The characters that can be included to the string could again be a letter, a number of special characters. Illustrating this, let us change the text to be displayed with – “12 red apples?”.

 

Using the putstr (…) function would look like this and the result will be similar to the image below.

 

It can be noticed that the manner of using the putstr(…) is the same as that of the print(…). The display processor translates this functions and directly outputs the string to the screen.  Now we take another example program that shall again display a sentence.  This program uses the putstr(…) function to direct the processor again to simply display the message to the display module.

With the use of the putstr(…) function, the text can be clearly displayed into the display module. On the otherhand, due to the length of the number of the characters contained in the function, several of the remaining character succeeding the numerical number 1 cannot be displayed.

Similar to the result using the print(…) function, the characters which exceed the limits of the horizontal character capacity of the screen are neither displayed nor move to the next line. The putstr(…) function directs the processor to continue displaying without any additional formatting.

Similar to print(…) function, the addition of a newline command is very useful in correcting this kinds of display problems. Adding this to the putstr(…) have an output the same as the one below.

 

At this point, we are now able to simply display strings in our display module using the print(…) and putstr(…)  functions. A useful exercise at this part is to try and put the \n at any point inside the string. Observe and take note of the effects of placing it at different parts of string.

Change the Point of Origin

The origin point of text and string printing can be changed. Using the 4DGL Goldelox internal function - txt_MoveCursor(), printing at any point of the screen is possible.

This function includes two parameters for it to function properly. A line and column data is written inside the parentheses. Note that this function must precede the print() or putstr() function statement. Below is a program that shows how to use this function.

 

The txt_MoveCursor(3,2) statement, means that the succeeding printing function will start to display text and strings on the 2nd column of the 3rd line. Downloading this program to the Goldelox display module will have a display output similar to the image below.

Run the Program

For instructions on how to save a Designer project, how to connect the target display to the PC, how to select the program destination, and how to compile and download a program, please refer to the section “Run the Program” of the application note

Designer Getting Started - First Project

For instructions on how to save a ViSi project, how to connect the target display to the PC, how to select the program destination (this option is not available for Goldelox displays), and how to compile and download a program, please refer to the section “Run the Program” of the application note

ViSi Getting Started - First Project for Goldelox

The uOLED-96-G2 and/or the uOLED-160-G2 display modules are commonly used as examples, but the procedure is the same for other displays.

 

Share: