displayDefineChar (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

DX4 pro, NX-400, LX4

Firmware version:

1.30 / 1.00.00


This function is used to define a character in the display.

 

The display uses characters 8 pixels wide by 16 pixels high.

To help visualise and calculate the character map, use a table with 8 * 16 cells, where each cell represents a pixel.

 

display_map1

(Figure 1. Empty character pixel map)

 

The last 4 rows (with green background in Figure 1) are below the writing line and should only be used if a character similar to "p", "g" or "q" is defined.

 

Draw the character in the table by using 1's (1's show a pixel) and 0's (0's hide a pixel) as shown in Figure 2.

 

display_map2

(Figure 2. Sample character: Smile)

 

Once the table has been filled, calculate the 2 Hex digits for each line.

The map string in the function contains the Hex digits from the top left and down.

For the sample character in Figure 2., the map string would look like this:

"0000180C6666060666660C1800000000"

 

Note: only upper case characters can be used and no spacing characters can be included.

 

 

Input:

index : INT (0..31)

The index of the character to define.

 

map : STRING

The calculated map of the character.

 

Returns: INT

0

- Success.

-1

- The character map is illegal.

-2

- Display not ready.

 

Declaration:

FUNCTION displayDefineChar : INT;
VAR_INPUT
  index : INT;
  map   : STRING;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM example;
VAR
  sym1 : ARRAY[1..22] OF SINT
  := 16#1F, 16#00, 16#20, 16#80, 16#40, 16#40, 16#80, 16#20, 16#80, 16#20, 16#80, 16#20, 16#80, 16#20, 16#80, 16#20, 16#40, 16#40, 16#20, 16#80, 16#1F, 16#00;
  sym2 : ARRAY[1..22] OF SINT
  := 16#1F, 16#00, 16#24, 16#80, 16#44, 16#40, 16#84, 16#20, 16#84, 16#20, 16#FF, 16#E0, 16#84, 16#20, 16#84, 16#20, 16#44, 16#40, 16#24, 16#80, 16#1F, 16#00;
  sym3 : ARRAY[1..22] OF SINT
  := 16#1F, 16#00, 16#20, 16#80, 16#60, 16#C0, 16#91, 16#20, 16#8A, 16#20, 16#84, 16#20, 16#8A, 16#20, 16#91, 16#20, 16#60, 16#C0, 16#20, 16#80, 16#1F, 16#00;
END_VAR;
 
  // Turn on the display
  displayPower(power := ON);
 
  // Define smile
  displayDefineChar(index := 0, map := "0000180C6666060666660C1800000000");
 
  // Draw line 1 symbol
  displayCircle(x := 8, y := 8, rad := 5);
  displayLine(x1 := 8, y1 := 3, x2 := 8,  y2 := 13);
  displayLine(x1 := 3, y1 := 8, x2 := 13, y2 := 8);
 
  // Draw line 2 symbol
  displayImage(x := 3,  y := 19, width := 11, height := 11, data := ADDR(sym3));
 
  // Show text
  displayXY(x := 3, y := 1);
  displayString(message := "Hello World $80");
  displayXY(x := 3, y := 2);
  displayString(message := "Cookie: ");
  displayXY(x := 11, y := 2);
  displayNumber(number := 4711);
 
  // Draw bounding
  displayBox(x1 := 1, y1 := 1, x2 := 125, y2 := 31);
 
BEGIN
  ...
END;
END_PROGRAM;