ON keypad.txt

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

REM   KEYPADTEST.TXT
REM
REM   This file is a demonstration application showing how to use the ON INT
REM   feature to respond to activity on the keypad.
REM
REM   Author: Steven R. Wheeler
REM
REM   Copyright 1998 Vesta Technology, Inc.
REM   All rights reserved.


INCLUDE "HexPrint.txt"


REM   This subroutine gains control when the status of the input on port B of
REM   the SBC2000-074/062 changes. This will happen when any key on the keypad
REM   is either pressed or released. The action taken in this handler is to
REM   show the state of the keypad on the LCD.

VITAL SUBROUTINE VTI_KHandler(irq_pattern AS INTEGER)
LOCAL keycode AS INTEGER
	keycode = KEYPAD(1)		: REM   Get the raw keycode
	LCD_Command(0x02)		: REM   "Home" the LCD display
	IF keycode
		PRINT "Key pressed "
		PrintHex(keycode)
	ELSE
		PRINT "Key released    "
	ENDIF
	SET INT0 TO 1			: REM   Re-enable handler
END


REM   Here is the start of the demonstration application's main code. First,
REM   set up the handler for the interrupt inputs and enable it.

ON INT0 VTI_KHandler
SET INT0 TO 1

REM   Next, direct print output to the LCD.

PIPE PRINT LCD


REM   No further code is required in this application. All we have to do is to
REM   keep the handlers active.

END