Positron Compiler Documentation

Plot

Positron16 · Revision 1.1.3.5 · PDF pages 271–273

Plot Ypos, Xpos

Set an individual pixel on a graphic LCD.

Xpos can be a constant, variable, or expression, pointing to the X-axis location of the pixel to set. This must be a value of 0 to the X resolution of the LCD. Where 0 is the far left row of pixels. Ypos can be a constant, variable, or expression, pointing to the Y-axis location of the pixel to set. This must be a value of 0 to the Y resolution of the LCD. Where 0 is the top column of pixels.

KS0108 LCD example

  Device = 24HJ128GP502             ' Select the device to compile for
  Declare Xtal = 16
'
' KS0108 graphic LCD declares
'
  Declare LCD_Type = KS0108         ' Setup for a KS0108 graphic LCD
  Declare LCD_DTPort = PORTB.Byte0
  Declare LCD_CS1Pin = PORTB.8
  Declare LCD_CS2Pin = PORTB.9
  Declare LCD_ENPin = PORTB.10
  Declare LCD_RSPin = PORTB.11
  Declare LCD_RWPin = PORTB.12

  Dim Xpos as Byte
'
' Draw a line across the LCD
'
  Do                              ' Create an infinite loop
     For Xpos = 0 to 127
       Plot 20, Xpos
       DelayMs 10
     Next
     '
     ' Now erase the line
     '
     For Xpos = 0 to 127
       UnPlot 20, Xpos
       DelayMs 10
     Next
  Loop
View original PDF page 271Open page in PDFOriginal PDF page 271

ILI9320 colour graphic LCD example

' Fill the LCD with colour using plot
'
  Device = 24EP128MC202               ' Select the device to compile for
  Declare Xtal = 140.03
'
' Setup the Pins used by the ILI9320 320x240 pixel graphic LCD
'
  Declare LCD_DTPort = PORTB.Byte0   ' Use the first 8-bits of PORTB
  Declare LCD_CSPin = PORTB.8         ' Connect to the LCD's CS pin
  Declare LCD_RDPin = PORTB.9        ' Connect to the LCD's RD pin
  Declare LCD_RSPin = PORTB.10        ' Connect to the LCD's RS pin
  Declare LCD_WRPin = PORTA.3         ' Connect to the LCD's WR pin

  Include "ILI9320.inc"               ' Load the ILI9320 routines into the program

  Dim wXpos As Word                   ' Create a variable for the X position
  Dim wYpos As Word                  ' Create a variable for the Y position
'--------------------------------------------------------------------------
Main:
' Configure the internal oscillator to operate the device at 140.03MHz
  PLL_Setup(76, 2, 2, $0300)

  Cls clYellow                       ' Clear the LCD with the colour yellow
  GLCD_InkColour(clBrightBlue)       ' Choose the pixel colour
'
' Fill the LCD with colour
'
  For wYpos = 0 To 319
     For wXpos = 0 To 239
       Plot wYpos, wXpos
     Next
  Next
'--------------------------------------------------------------------------
' Configure for internal 7.37MHz oscillator with PLL
' OSC pins are general purpose I/O
'
  Config FGS = GWRP_OFF, GCP_OFF
  Config FOSCSEL = FNOSC_FRCPLL, IESO_ON, PWMLOCK_OFF
  Config FOSC = POSCMD_NONE, OSCIOFNC_ON, IOL1WAY_OFF, FCKSM_CSDCMD
  Config FWDT = WDTPOST_PS256, WINDIS_OFF, PLLKEN_ON, FWDTEN_OFF
  Config FPOR = ALTI2C1_ON, ALTI2C2_OFF
  Config FICD = ICS_PGD1, JTAGEN_OFF

If using a colour graphic LCD, the Plot command will use the current colour of the pixel's Ink. As previously set by the GLCD_Ink command.

With an ILI9320 320x240 pixel colour graphic LCD, the colour is a 16-bit value formatted in RGB565, where the upper 5-bits represent the red content, the middle 6-bits represent the

Original diagram or table from Positron16, PDF page 272
Original figure / layout · PDF page 272
Text in this figure or table
High ByteLow Byte
1511 10540
Red valueGreen valueRed value

green content, and the lower 5-bits represent the blue content. As illustrated below:

See also : LCDread, LCDwrite, Pixel, UnPlot.

View original PDF page 272Open page in PDFOriginal PDF page 272
Original diagram or table from Positron16, PDF page 273
Original figure / layout · PDF page 273
Text in this figure or table

Graphic LCD pixel configuration for a 128x64 resolution display.

Line 0Line 1Line 2Line 3Line 4Line 5Line 6Line 7
063
127127

Xpos 0 - 127

00
0Ypos 0 - 6363
View original PDF page 273Open page in PDFOriginal PDF page 273