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

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

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

Добавлен: 12.06.2025

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

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

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

© MCS Electronics, 1995-2007

Syntax

BOX (x1,y1) - (x2,y2) , color

Remarks

x1

The left corner position of the box

y1

The top position of the box

x2

The right corner position of the box

y2

The bottom position of the box

color

The color to use to fill the box

The BOX command will only work on Color displays. In a future version it will be implemented for other graphical displays as well.

The BOX command will create a filled box with the specified color.

See also

LINE, CIRCLE

ASM

NONE

Example

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

'The support for this display has been made possible by Peter Küsters from (c) Display3000

'You can buy the displays from Display3000 or MCS Electronics

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

'

'

'special color display support

$lib"lcd-pcf8833.lbx"

$regfile= "m88def.dat"

'ATMega 8, change if using different processors

$crystal= 8000000

'8 MHz

'First we define that we use a graphic LCD

Config Graphlcd = Color,Controlport= Portc,Cs = 1,Rs = 0,Scl= 3,Sda = 2 'here we define the colors

Const Blue= &B00000011

''predefined contants are making programming easier

Const Yellow= &B11111100

Const Red = &B11100000

Const Green = &B00011100

Const Black= &B00000000

Const White = &B11111111

Const Brightgreen = &B00111110

Const Darkgreen = &B00010100

Const Darkred = &B10100000

Const Darkblue = &B00000010

Const Brightblue= &B00011111

Const Orange = &B11111000

'clear the display

Cls

'create a cross

Line(0 ,0)-(130 , 130),Blue

Line(130 ,0)-(0 , 130), Red

Waitms 1000

'show an RLE encoded picture

Showpic 0,0,Plaatje

Showpic 40 ,40 ,Plaatje

page -291-


© MCS Electronics, 1995-2007

Waitms 1000

'select a font Setfont Color16x16 'and show some text

Lcdat 100 ,0,"12345678",Blue,Yellow

Waitms 1000

Circle(30 ,30),10 ,Blue

Waitms 1000 'make a box

Box(10 ,30)-(60 , 100), Red

'set some pixels Pset 32 ,110 ,Black Pset 38 ,110 ,Black Pset 35 ,112 ,Black

End

Plaatje: $bgf"a.bgc"

$include"color.font" $include"color16x16.font"

BSAVE

Action

Save a range in SRAM to a File

Syntax

BSave sFileName, wSRAMPointer, wLength

Remarks

sFileName

(String) Name of the File to be written

wSRAMPointer

(Word) Variable, which holds the SRAM Address, fromwhere SRAM

should be written to a File

wLength

(Word) Count of Bytes from SRAM, which should be written to the file

This function writes a range from the SRAM to a file. A free file handle is needed for this function.

See also

INITFILESYSTEM , OPEN , CLOSE, FLUSH , PRINT, LINE INPUT, LOC, LOF , EOF , FREEFILE , FILEATTR , SEEK , BLOAD , KILL , DISKFREE , DISKSIZE , GET , PUT , FILEDATE , FILETIME , FILEDATETIME , DIR , FILELEN , WRITE , INPUT

ASM

Calls _BSave

page -292-


© MCS Electronics, 1995-2007

Input

X: Pointer to string with

Z: Pointer to Long-variable, which holds the start

filename

position of SRAM

r20/r21: Count of bytes to be

written

Output

r25: Errorcode

C-Flag: Set on Error

Example

' THIS IS A CODE FRAGMENT, it needs AVR-DOS in order to work

'now the good old bsave and bload

Dim Ar(100)as Byte , I Asbyte

For I = 1 To 100

' fill the array

Ar(i) = I

Next

Wait 2

W = Varptr(ar(1))

Bsave"josef.img", W , 100

For I = 1 To 100

' reset the array

Ar(i) = 0

Next

Bload "josef.img" , W

' Josef you are

amazing !

For I = 1 To 10

Print Ar(i) ; " ";

Next

Print

BUFSPACE

Action

Returns the amount of free space of a serial buffer.

Syntax

Var = BufSpace(n)

Remarks

Var

A word or integer variable that is assigned with the free buffer space.

N

A constant in the range from 0-3.

A value of 0 : output buffer first UART

A value of 1 : input buffer first UART

A value of 2

: output buffer second UART

A value of 3

: input buffer second UART

While serial buffers are great because you do not have to wait/blockthe processor, the buffer can become full when the micro has no time to empty the buffer. With the bufspace() function you can determine if there is still room in the buffer.

page -293-


© MCS Electronics, 1995-2007

See Also

CONFIG SERIAL , CLEAAR

Example

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

NONE

BYVAL

Action

Specifies that a variable will be passed by value.

Syntax

Sub Test(BYVAL var)

Remarks

Var Variable name

The default for passing variables to SUBS and FUNCTIONS, is by reference(BYREF). When you pass a variable by reference, the address is passed to the SUB or FUNCTION. When you pass a variable by Value, a temp variable is created on the frame and the address of the copy is passed.

When you pass by reference, changes to the variable will be made to the calling variable. When you pass by value, changes to the variable will be made to the copy so the original value will not be changed.

By default passing by reference is used.

Note that calling by reference will generate less code.

See also

CALL , DECLARE , SUB , FUNCTION

ASM

NONE

Example

Declare Sub Test(Byval X As Byte, Byref Y As Byte, Z As Byte)

CALL

Action

Call and execute a subroutine.

page -294-

© MCS Electronics, 1995-2007

Syntax

CALL Test [ (var1, var-n) ]

Remarks

Var1

Any BASCOM variable or constant.

Var-n

Any BASCOM variable or constant.

Test

Name of the subroutine. In this case Test.

You can call sub routines with or without passing parameters.

It is important that the SUB routine is DECLARED before you make the CALL to the subroutine. Of course the number of declared parameters must match the number of passed parameters.

It is also important that when you pass constants to a SUB routine, you must DECLARE these parameters with the BYVAL argument.

With the CALL statement, you can call a procedure or subroutine.

For example: Call Test2

The call statement enables you to implement your own statements.

You don't have to use the CALL statement:

Test2 will also call subroutine test2

When you don't supply the CALL statement, you must leave out the parenthesis. So Call Routine(x,y,z) must be written as Routine x,y,x

Unlike normal SUB programs called with the GOSUB statement, the CALL statement enables you to pass variables to a SUB routine that may be local to the SUB.

See also

DECLARE , SUB , EXIT , FUNCTION , LOCAL

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 A As Byte , B As Byte

'dimension some

page -295-