Positron Compiler Documentation

Cursor

Positron8 · Revision 4.0.6.5 · PDF page 264

Cursor Line, Position

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

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).

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.

  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

View original PDF page 264Open page in PDFOriginal PDF page 264