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

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

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

Добавлен: 12.06.2025

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

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

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

© MCS Electronics, 1995-2007

GLCDCMD byte

Remarks

byte A variable or numeric constant to send to the display.

With GLCDCMD you can write command bytes to the display. This is convenient to control the display when there is no specific statement available.

You need to include the glibSED library with : $LIB "glibsed.lbx"

See also

CONFIG GRAPHLCD , LCDAT, GLCDDATA

Example

NONE

GLCDDATA

Action

Sends a data byte to the SED graphical LCD display.

Syntax

GLCDDATA byte

Remarks

byte

A variable or numeric constant to send to the display.

With GLCDDATA you can write data bytes to the display. This is convenient to control the display when there is no specific statement available.

You need to include the glibSED library with :

$LIB "glibsed.lbx"

See also

CONFIG GRAPHLCD , LCDAT, GLCDCMD

Example

NONE

page -516-

© MCS Electronics, 1995-2007

GOSUB

Action

Branch to and execute subroutine.

Syntax

GOSUB label

Remarks

Label

The name of the label where to branch to.

With GOSUB, your program jumps to the specified label, and continues execution at that label.

When it encounters a RETURN statement, program execution will continue after the GOSUB statement.

See also

GOTO , CALL , RETURN

Example

'-----------------------------------------------------------------------------

------------

: gosub.bas

'name

'copyright

: (c) 1995-2005, MCS Electronics

'purpose

: demo: GOTO, GOSUB and RETURN

'micro

: Mega48

'suited for demo

: yes

'commercial addon needed

: no

'-----------------------------------------------------------------------------

------------

$regfile = "m48def.dat"

' specify the used

micro

' used crystal

$crystal = 4000000

frequency

' use baud rate

$baud = 19200

$hwstack = 32

' default use 32

for the hardware stack

' default use 10

$swstack = 10

for the SW stack

' default use 40

$framesize = 40

for the frame space

Goto Continue

Print "This code will not be executed"

Continue:

'end a label with

a colon

Print "We will start execution here"

Gosub Routine

Print "Back from Routine"

End

Routine:

'start a

page -517-


© MCS Electronics, 1995-2007

subroutine

Print "This will be executed"

'return from

Return

subroutine

GOTO

Action

Jump to the specified label.

Syntax

GOTO label

Remarks

Labels can be up to 32 characters long.

When you use duplicate labels, the compiler will give you a warning.

See also

GOSUB

Example

Dim A As Byte

Start:

'a label must end with a colon

A = A + 1

'increment a

If A < 10 Then

'is it less than 10?

Goto Start

'do it again

End If

'close IF

Print

"Ready"

'that is it

GRAY2BIN

Action

Returns the numeric value of a Gray code.

Syntax

var1 = GRAY2BIN(var2)

Remarks

var1

Variable that will be assigned with the binary value of the Grey code.

var2

A variable in Grey format that will be converted.

Gray code is used for rotary encoders. Gray2bin() works for byte, integer, word and long variables.

page -518-


© MCS Electronics, 1995-2007

See also

BIN2GRAY

ASM

Depending on the data type of the target variable the following routine will be called from mcs.lbx:

_Bin2grey for bytes , _Bin2Grey2 for integer/word and _Bin2grey4 for ongsl.

Example

'-----------------------------------------------------------------------------

------------

: graycode.bas

'name

'copyright

: (c) 1995-2005, MCS Electronics

'purpose

: show the Bin2Gray and Gray2Bin functions

'micro

: Mega48

'suited for demo

: yes

'commercial addon needed

: no

'-----------------------------------------------------------------------------

------------

$regfile = "m48def.dat"

' specify the used

micro

' used crystal

$crystal = 4000000

frequency

' use baud rate

$baud = 19200

$hwstack = 32

' default use 32

for the hardware stack

' default use 10

$swstack = 10

for the SW stack

' default use 40

$framesize = 40

for the frame space

'Bin2Gray() converts a byte,integer,word or long into grey code.

'Gray2Bin() converts a gray code into a binary value

Dim B As Byte

' could be

word,integer or long too

Print "BIN" ; Spc(8) ; "GREY"

For B = 0 To 15

Print B ; Spc(10) ; Bin2gray(b)

Next

Print "GREY" ; Spc(8) ; "BIN"

For B = 0 To 15

Print B ; Spc(10) ; Gray2bin(b)

Next

End

HEX

Action

Returns a string representation of a hexadecimal number.

page -519-


© MCS Electronics, 1995-2007

Syntax

var = HEX( x )

Remarks

var

A string variable.

X

A numeric variable of data type Byte, Integer, Word, Long,

Single or Double.

See also

HEXVAL , VAL , STR , BIN , BINVAL

Example

$regfile = "m48def.dat"

' specify the used

micro

' used crystal

$crystal = 8000000

frequency

' use baud rate

$baud = 19200

$hwstack = 32

' default use 32

for the hardware stack

' default use 10

$swstack = 10

for the SW stack

' default use 40

$framesize = 40

for the frame space

Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0

Dim B As Byte , J As Integer , W As Word , L As Long

B = 1 : J = &HF001

W = &HF001

L = W

Print B ; Spc(3) ; Hex(b)

Print J ; Spc(3) ; Hex(j)

Print W ; Spc(3) ; Hex(w)

Print L ; Spc(3) ; Hex(l)

End

HEXVAL

Action

Convert string representing a hexadecimal number into a numeric variable.

Syntax

var = HEXVAL( x )

Remarks

Var

The numeric variable that must be assigned.

page -520-