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

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

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

Добавлен: 12.06.2025

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

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

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

© MCS Electronics, 1995-2007

Wait 1

'locate works like the normal LCD locate statement ' LOCATE LINE,COLUMN LINE can be 1-8 and column 0-30

Locate 1 , 1

'Show some text

Lcd "MCS Electronics"

'And some othe text on line 2 Locate 2 , 1 : Lcd "T6963c support"

Locate 3 , 1 : Lcd "1234567890123456789012345678901234567890" Locate 16 , 1 : Lcd "write this to the lower line"

Wait 2

Cls Text

'use the new LINE statement to create a box

'LINE(X0,Y0) - (X1,Y1), on/off

' diagonal line

Line(0 , 0) -(239 , 127) , 255

Line(0 , 127) -(239 , 0) , 255

' diagonal line

Line(0 , 0) -(240 , 0) , 255

' horizontal upper

line

'horizontal lower

Line(0 , 127) -(239 , 127) , 255

line

' vertical left

Line(0 , 0) -(0 , 127) , 255

line

' vertical right

Line(239 , 0) -(239 , 127) , 255

line

Wait 2

'draw a line using PSET X,Y, ON/OFF

'PSET on.off param is 0 to clear a pixel and any other value to turn it on For X = 0 To 140

Pset X , 20 , 255

' set the pixel

Next

For X = 0 To 140

' set the pixel

Pset X , 127 , 255

Next

Wait 2

'circle time

'circle(X,Y), radius, color

'X,y is the middle of the circle,color must be 255 to show a pixel and 0 to

clear a pixel

For X = 1 To 10

' show circle

Circle(20 , 20) , X , 255

Wait 1

'remove circle

Circle(20 , 20) , X , 0

Wait 1

Next

Wait 2

For X = 1 To 10

' show circle

Circle(20 , 20) , X , 255

Waitms 200

Next

Wait 2

page -593-


© MCS Electronics, 1995-2007

'Now it is time to show a picture

'SHOWPIC X,Y,label

'The label points to a label that holds the image data

Test:

Showpic 0 , 0 , Plaatje

' show 2 since we

Showpic 0 , 64 , Plaatje

have a big display

Wait 2

' clear the text

Cls Text

End

'This label holds the mage data Plaatje:

'$BGF will put the bitmap into the program at this location $bgf "mcs.bgf"

'You could insert other picture data here

PS2MOUSEXY

Action

Sends mouse movement and button information to the PC.

Syntax

PS2MOUSEXY X , Y, button

Remarks

X

Y

Button

The X-movement relative to the current position.

The range is –255 to 255.

The Y-movement relative to the current position.

The range is –255 to 255.

A variable or constant that represents the button state.

0 – no buttons pressed

1- left button pressed

2- right button pressed

4- middle button pressed

You can combine these values by adding them. For example, 6 would emulate that the right and middle buttons are pressed.

To send a mouse click, you need to send two ps2mouseXY statements. The first must indicate that the button is pressed, and the second must release the button.

Ps2mouseXY 0,0,1 ' left mouse pressed

PsmouseXY 0,0,0 ' left mouse released

The SENDSCAN statement could also be used.

page -594-


© MCS Electronics, 1995-2007

See also

SENDSCAN, CONFIG PS2EMU

PULSEIN

Action

Returns the number of units between two occurrences of an edge of a pulse.

Syntax

PULSEIN var , PINX , PIN , STATE

Remarks

var

A word variable that is assigned with the result.

PINX

A PIN register like PIND

PIN

The pin number(0-7) to get the pulse time of.

STATE

May be 0 or 1.

0 means sample 0 to 1 transition.

1 means sample 1 to 0 transition.

ERR variable will be set to 1 in case of a time out. A time out will occur after 65535 unit counts. With 10 uS units this will be after 655.35 mS.

You can add a bitwait statement to be sure that the PULSEIN statement will wait for the start condition. But when using the BITWAIT statement and the start condition will never occur, your program will stay in a loop.

The PULSIN statement will wait for the specified edge.

When state 0 is used, the routine will wait until the level on the specified input pin is 0. Then a counter is started and stopped until the input level gets 1.

No hardware timer is used. A 16 bit counter is used. It will increase in 10 uS units. But this depends on the XTAL. You can change the library routine to adjust the units.

See also

PULSEOUT

ASM

The following ASM routine is called from mcs.lib _pulse_in (calls _adjust_pin)

On entry ZL points to the PINx register , R16 holds the state, R24 holds the pin number to sample.

On return XL + XH hold the 16 bit value.

page -595-


© MCS Electronics, 1995-2007

Example

Dim w As Word

pulsein w , PIND , 1 , 0 'detect time from 0 to 1 print w

end

PULSEOUT

Action

Generates a pulse on a pin of a PORT of specified period in 1uS units for 4 MHz.

Syntax

PULSEOUT PORT , PIN , PERIOD

Remarks

PORT

Name of the PORT. PORTB for example

PIN

Variable or constant with the pin number (0-7).

PERIOD

Number of periods the pulse will last. The periods are in uS

when an XTAL of 4 MHz is used.

The pulse is generated by toggling the pin twice, thus the initial state of the pin determines the polarity.

The PIN must be configured as an output pin before this statement can be used.

See also

PULSEIN

Example

Dim A As Byte

'PORTB all output

Config Portb = Output

pins

'all pins 0

Portb = 0

Do

For A = 0 To 7

'generate pulse

Pulseout Portb , A , 60000

Waitms 250

'wait a bit

Next

'loop for ever

Loop

PUSHALL

Action

Saves all registers that might be used by BASCOM.

page -596-