VAST vled.txt

Warning: if you clip this code into your program, look out for possible html code slipping in.

REM   VAST 8-Digit display and 8x8 LED utility routines for the SBC2000-074.
REM
REM   Author: Steven R. Wheeler
REM
REM   Copyright 1998-2000 Vesta Technology, Inc.
REM   All rights reserved.
REM
REM   Revision history:
REM     Aug 6, 1999     SRW
REM        Changed VAST_SPI_XFER() calls for revision 4 of VSTB.
REM     Apr 7, 2000     SRW
REM        Made VLED_Register() a VITAL function so that VAST transfers don't
REM        get interfered with by event-handling routines.


REM   This is the lowest-level access to the V8LED board. It is used by the other
REM   routines.

VITAL FUNCTION VLED_Register(board AS INTEGER, reg AS INTEGER, value AS INTEGER) AS INTEGER
LOCAL dummy AS INTEGER
	VAST_OPEN(board)
	dummy = VAST_SPI_XFER(16, (reg * 256) OR (value AND 0xFF))
	VAST_CLOSE(15)
END


REM   Set the segments in a display location as specified by the low-order eight
REM   bits of value.

SUBROUTINE VLED_Matrix(position AS INTEGER, value AS INTEGER)
LOCAL dummy AS INTEGER
	dummy = VLED_Register(position/8, 8-position\8, value)
END


REM   Send a command to the V8LED board. The command value is as follows:
REM
REM   D3-D0     brightness level, 0=off, 15 = max
REM   D6-D4     digits to display (from right). 0 = all, 1 = 1, 2 = 2, etc.
REM   D7        Test mode (1 = all segments on, 0 = normal operation)

SUBROUTINE VLED_Command(board AS INTEGER, value AS INTEGER)
LOCAL dummy AS INTEGER
	REM   First, program the shutdown register
	IF (value AND 0x0F) = 0
		REM   Turn the display OFF
		dummy = VLED_Register(board, 12, 0)
	ELSE
		REM   Turn the display ON
		dummy = VLED_Register(board, 12, 1)
	ENDIF

	REM   Set up the Decode register for no decoding
	dummy = VLED_Register(board, 9, 0)

	REM   Set up the Intensity register for the specified brightness level
	dummy = dummy OR VLED_Register(board, 10, (value AND 0x0F)-1)

	REM   Set up the number of digits to be displayed when on
	dummy = dummy OR VLED_Register(board, 11, ((value / 16)-1) AND 7)

	REM   Put into or out of test mode as specified
	dummy = dummy OR VLED_Register(board, 15, (value AND 0x80) = 0x80)
END



 

VestaTech Home

© 2002 Vesta Technology