Файл: Fast AVR. Basic compiller for AVR. User manual (2004).pdf

ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 13.06.2025

Просмотров: 1436

Скачиваний: 1

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

FastAVR Basic compiler Manual

Another possibility is to use SPI as serial interface - this is much faster transfer.

Display Coonection

Dont forget a 470nF capacitor beetween Vout and GND!

Look at Nokia3310.bas

6.3.2.$GLCD

Description:

Tells the compiler details about Graphic LCD connections.

Syntax:

$GLCD PCD8544, SDIN=PORTx.n, SCLK=PORTx.n, DC=PORTy.n, SCE=PORTy.n

Remarks:

PCD8544 or NOKIA3310 is the graphic controller chip used

SDIN, SCLK, DC, SCE Nokia display signals names.

SDIN and SCLK MUST be on the same PORT!

DC and SCE MUST be on the same PORT!

Control signals can be declared in any order!

You may also assign any valid AvrPort pin that is available for RESET Graphic module or use an appropriate RC setup for the LCD module reset like 10k PullUp resistor with 100nF capacitor to GND.

Example:

$GLCD NOKIA3310, SDIN=PORTA.0, SCLK=PORTA.1, DC=PORTA.2, SCE=PORTA.3

67

FastAVR Basic compiler Manual

6.3.3.Contrast

Description:

Sets Nokia LCD module contrast.

Syntax:

Contrast=numeric expression

Remarks:

numeric expression Value from 0 to 127 to set contrast (defailt is 72).

Example:

For n=50 To 120

Contrast=n ' finding best contrast

Wait 1

Next

6.3.4.FontSet

Description:

Selects soft Font.

Syntax:

FontSet NameOfFontTable

Remarks:

NameOfFontTable Table in Flash that contains individual letter definitions.

NameOfFontTable must be declared first and added into source ($Included)!

Fonts can be edited with the FastLCD utility and saved in bas format ready to include in source! Selected Font is active until another Font is selected with FontSet.

Example:

Dim F0HD As Flash Byte

Dim F1HD As Flash Byte

Dim n As Byte

Dim s As String*20

n=15

s="Graphic LCD"

FontSet F1HD

' Selects

F1

GLcd(15, 0),

n

' Writes n with F1

GLcd(15, 7),

s

' Writes w with F1

FontSet F0HD

' Selects

F0

GLcd(15, 1), "HD61202"

' Writes txt with F0

$Included "C:\FastAVR\F0HD.bas"

' Here is

6x8

font definition

$Included "C:\FastAVR\F1HD.bas"

' Here is

8x8

font definition

Related Topics:

GLcd

68


FastAVR Basic compiler Manual

6.3.5.Glcd

Description:

Writes text on graphic LCD using previously specified soft Font.

Syntax:

GLcd(varX, varP), var

Remarks:

varX Starting X coordinate, normally between 0 and 83 varP Line to write in, between 0 and 5

var num, string, string constant or hex to write

Y coordinates are in Lines not in Pixels!

Font MUST be set (FontSet)prior to using Glcd!

If You wish to show just a few words, maybe ImgSet is better (shorter) solution (word is made as an Immage)!

If $LeadChar is defined then result will be right justified with Leading Chars as defined. Also, if Format() is defined then optional decimal point will be inserted!

Example:

GLcd(15, 0), n

' Writes num variable on upper Line

GLcd(15, 1), s

' Writes string var on second Line

GLcd(15, 2), "This is HD61202" ' Writes string on third Line

GLcd(15, 3), Chr(61)

' Writes letter A on 4. Line

GLcd(15, 4), Hex(61)

' Writes Hex string on 5. Line

Related Topics:

FontSet

6.3.6.Gwrite

Description:

Writes a byte at selected X and Line.

Syntax:

GWrite(varX, varL), var

Remarks:

varX X coordinate, normally between 0 and 83 varL Line, between 0 and 5

var to be written to desired position.

This is the graphic controllers native Write function.

Y coordinates are in Lines not in Pixels!

Example:

GWrite(17, 2), 15 ' Four pixels will be written to x=17 on the Line 2.

69


FastAVR Basic compiler Manual

6.3.7.ImgSet

Description:

Displays an Image or a part of ImageArray on the graphic LCD at selected X and Line.

Syntax:

ImgSet(varX, varP), NameOfImgTable

Or, if You wat to display just a part of an ImageArray:

(Image must be saved as ImageArray, when edited using FastLCD utility!)

ImgSet(varX, varP, var), NameOfImgTable

Remarks:

varX X coordinate, normally between 0 and 83 varL Line, between 0 and 5

var which part of Image, (index in ImageArray) NameOfImgTable Table in Flash that contains the bit image.

Y coordinates are in Lines not in Pixels!

NameOfImgTable must be declared first and added into source ($Included)! Images can be edited with FastLCD image editor which can save Images in bas format. The saved image is then ready to be included in the source program!

Example:

Dim Img0 As Flash Byte

Dim Img1 As Flash Byte

ImgSet(15, 2), Img1

' Image Img1 will be copied to location

$Included "C:\FastAVR\Img0.bas" ' Img0 bit image definition $Included "C:\FastAVR\Img1.bas" ' Img1 bit image definition

Second syntax:

Using ImageArray, a large letters, Icons or Sprites can be displayed, all saved in a single Image! Any part of this Image is accessable by its index, yeaa - this means animations!

Example:

Dim Sclk1616HD As Flash Byte

ImgSet(15, 2, 1), Sclk1616HD ' SandClock with index 1, second sub-Image will be displayed

$Included "C:\FastAVR\Sclk1616HD.bas" ' SandClock definition

Related Topics:

GLcd

70

FastAVR Basic compiler Manual

6.3.8.Inverse

Description:

Sets NORMAL or INVERSE screen.

Syntax:

Inverse(var)

Remarks:

var 0 - normal, 1 - inverse

Only whole display can be Inversed!

Example:

Inverse(1)

' Screen is Inversed

6.3.9.Gcls

Description:

Clears the Graphic LCD

Syntax:

GCls

Example:

GCls

' Graphic LCD is now cleared

6.4.T6963C Graphic LCD support

6.4.1.$GLCD, $GCtl

Description:

Tells the compiler details about Graphic LCD connections.

Syntax:

$GLCD T6963C, Data=AVRPort, Ctrl=AVRPort, NumOfXpix, NumOfYpix, i

$GCtrl WR=4, RD=3, CE=2, CD=1, FS=1

Remarks:

T6963C is the graphic controller chip used

Data AVRPort where data bus is connected.

Ctrl AVRPort where control lines are connected.

AVRPort any valid AVRPort. Any bidirectional port can be used!

NumOfXpix how many Pixels LCD has on X

71


FastAVR Basic compiler Manual

NumOfYpix how many Pixels LCD has on Y

i 1 for single, 2 for double scan graphic LCD display module (low pix modules has single scan, larges double scan. Look datasheets for details)

WR, RD, CE, CD valid Control line names for T6963C

FS 1 for 6x8 and 0 for 8x8 fonts - tells how Bytes will be using (6 or 8 bits)

Note: Because of differences in Graphic Lcds, no provision is made for a hardware reset.

You may, however, assign any valid AvrPort pin that is available or use an appropriate RC setup for the LCD module reset. Please refer to the datasheet or manual for the specific graphic LCD module being used.

FontSelect (FS) MUST be fixed to 1 for 6x8 internal Font and 6 pix wide column or fixed to 1 for 8x8 internal Font and 8 pix wide column.

Control lines can be declared in any order!

Example:

$GLCD T6963C, Data=PORTB, Ctrl=PORTD, 128, 64, 1

$Gctrl WR=4, RD=3, CE=2, CD=1, FS=1

'WR is connected to PORTD.4, RD to PORTD.3...

6.4.2.Box

Description:

Draws or Clears a box.

Syntax:

Box(varX0, varY0, varX1, varY1), 0|1

Remarks:

varX0 X coordinate of Upper Left corner varY0 Y coordinate of Upper Left corner varX1 X coordinate of Lower Right corner varY1 Y coordinate of Lower Right

0|1 0 will Clear Line, 1 will Draw Line

Example:

Circle(0, 0, 239, 127), 1 ' Rectangle around 240x128 pix LCD

Related Topics:

Pset

Line

Circle

LineH

LineV

72

FastAVR Basic compiler Manual

6.4.3.Circle

Description:

Draws or Clears a Circle.

Syntax:

Circle(varX, varY, radius), 0|1

Remarks:

varX X coordinate of center varY Y coordinate of center radius of the circle

0|1 0 will Clear Line, 1 will Draw Line

Example:

Circle(120, 64, 60), 1 ' Circle on center 240x128 pix LCD, r=60

Related Topics:

Line

Box

LineH

LineV

Pset

6.4.4.Fill

Description:

Fills specified area on the screen.

Syntax:

Fill(varX, varY, varX1, varL1), Pat

Remarks:

varX LeftMost X coordinate of area, between 0 and NofColumns varL TopMost coordinate, between 0 and Ymax

varX1 number of columns to Inverse varL1 number of lines (pixels) to Inverse Pat Byte the area will be filled with

X coordinates are in Columns not in Pixels! Also suitable for clearing a specific area.

Example:

Fill(15, 1, 6, 40), &haa ' Specified area will be filled with &haa

Related Topics:

GCls

Inverse

73


FastAVR Basic compiler Manual

6.4.5.FontSet

Description:

Selects soft Font.

Syntax:

FontSet NameOfFontTable

Remarks:

NameOfFontTable Table in Flash that contains individual letter definitions.

NameOfFontTable must be declared first and added into source ($Included)!

Fonts can be edited with the FastLCD utility and saved in bas format ready to include in source! Selected Font is active until another Font is selected with FontSet.

Example:

Dim F0T As Flash Byte

Dim F1T As Flash Byte

Dim n As Byte

Dim s As String*20

n=15

s="Graphic LCD"

FontSet F1T

' Selects F1T

GLcd(15, 0), n

' Writes n with F1

GLcd(15, 7), s

' Writes w with F1

FontSet F0T

' Selects F0T

GLcd(15, 1), "T6963c"

' Writes txt with F0

$Included "C:\FastAVR\F0T.bas" ' Here is 6x8 font definition $Included "C:\FastAVR\F1T.bas" ' Here is 8x8 font definition

Related Topics:

GLcd

Tlcd

6.4.6.Gcls

Description:

Clears the graphic area on Graphic LCD.

Syntax:

GCls

Example:

GCls

' Graphic area is now cleared

74

FastAVR Basic compiler Manual

6.4.7.GCommand

Description:

Directly controls T6963C graphic LCD controler. Used for several setings.

Syntax:

GCommand var

Remarks:

var appropriate value to set needed command according to tabel:

Graphic Mode Set:

&h80 Logycally OR of Text with Graphics &h81 Logycally XOR of Text with Graphics &h83 Logycally AND of Text with Graphics

&h84 Text only, with Attribute data in Graphic Area &h90 Display OFF

&h92 Text Cursor ON, Blink OFF

&h93 Text Cursor ON, Blink ON &h94 Text ON, Graphic OFF &h98 Text OFF, Graphic ON &h9a Text ON, Graphic ON

Text Cursor on Text Page Shape: &ha0 1 line Cursor

&ha1 2 line Cursor &ha2 3 line Cursor &ha3 4 line Cursor &ha4 5 line Cursor &ha5 6 line Cursor &ha6 7 line Cursor &ha7 8 line Cursor

Text Page and Cursor must be turned ON and Cursor shape defined with GCommand!

Example:

GCommand &h80 ' OR with Txt and Grph

GCommand &h98 ' turn Txt OFF, Grp ON

6.4.8.GCursor

Description:

Sets the shape of Text curcor on Text Page.

Syntax:

GCursor varX, varY

Remarks:

varX X coordinate in Characters (Columns) varY Y coordinate in Lines

75