Positron Compiler Documentation

Cursor

Source: Positron8 Compiler User Manual, PDF page 264

Syntax

Cursor Line, Position

Overview

Move the cursor position on an Alphanumeric or Graphic LCD to a specified line (Ypos) and position (Xpos).

Parameters

Line is a constant, variable, or expression that corresponds to the line (Ypos) number from 1 to maximum lines (0 to maximum lines if using a graphic LCD). Position is a constant, variable, or expression that moves the position within the position (Xpos) chosen, from 1 to maximum position (0 to maximum position if using a graphic LCD).

Example 1

Dim Line as Byte
Dim Xpos as Byte
Line = 2
Xpos = 1
Cls
                      ' Clear the LCD
Print "Hello"
                      ' Display the word "Hello" on the LCD
Cursor Line, Xpos
                      ' Move the cursor to line 2, position 1
Print "World"
                      ' Display the word "World" on the LCD

In the above example, the LCD is cleared using the Cls command, which also places the cursor at the home position i.e. line 1, position 1. Next, the word "Hello" is displayed in the top left corner. The cursor is then moved to line 2 position 1, and the word "World" is displayed.

Example 2

  Dim Xpos as Byte
  Dim Ypos as Byte
Again:
  Ypos = 1
                             ' Start on line 1
  For Xpos = 1 to 16
                             ' Create a loop of 16
     Cls
                             ' Clear the LCD
     Cursor Ypos, Xpos
                             ' Move the cursor to position Ypos,Xpos
     Print "*"
                             ' Display the character
     DelayMs 100
  Next
  Ypos = 2
                             ' Move to line 2
  For Xpos = 16 to 1 Step -1 ' Create another loop, this time reverse
     Cls
                             ' Clear the LCD
     Cursor Ypos, Xpos
                             ' Move the cursor to position Ypos,Xpos
     Print "*"
                             ' Display the character
     DelayMs 100
  Next
  GoTo Again
                             ' Repeat forever

Example 2 displays an asterisk character moving around the perimeter of a 2-line by 16 character LCD.

See also : Cls, Print