rem DigitalIO.bas rem rem last revision 2004 October 19 rem rem In this example, HOLD and LOCK are used as macro controlled rem outputs while CAPTURE remains an input. rem The 3 rear pins HOLD, LOCK, and CAPTURE can be used either rem as inputs (default) or as outputs and are controlled by the rem DIGITAL_IO register (&152 on Tiger 320) in bits 0-2. rem rem Writing a 1 into the according flag turns it into an output. rem Writing a 0 into the according flag turns it into an input. rem rem To avoid errors, the bit flags (e.g. |HOLD_PIN) are read-only. rem If a pin is used as an output the whole register &DIGITAL_IO rem has to be set appropriately. rem rem Note: set only the output bits and leave the other bits at 0 !!! CONST HOLD_ON = 0x0001 CONST LOCK_ON = 0x0002 CONST HOLD_LOCK_ON = 0x0003 // clear tare instead of display hold/key lock function for HOLD/LOCK MEM &CODE9 = 0055 /////////////////////////////////////////////////////////////////////////// CUSTOMER_ID_MACRO: /////////////////////////////////////////////////////////////////////////// write " Digital IO " END /////////////////////////////////////////////////////////////////////////// RESET_MACRO: /////////////////////////////////////////////////////////////////////////// // set HOLD/LOCK/CAPTURE flag to 0 => all inputs &DIGITAL_IO = 0 // remember last status of capture pin |capture_last = |CAPTURE_PIN #outputs = 0 END /////////////////////////////////////////////////////////////////////////// MAIN_MACRO: /////////////////////////////////////////////////////////////////////////// // switch outputs each time CAPTURE pin is connected if |CAPTURE_PIN = on and |capture_last = off then |capture_last = on // look only at the output flags #outputs = &DIGITAL_IO and HOLD_LOCK_ON // set only the output bits and leave the input bits at 0 !!! select #outputs case HOLD_ON: &DIGITAL_IO = HOLD_LOCK_ON case HOLD_LOCK_ON: &DIGITAL_IO = LOCK_ON // => HOLD flag is 0 case LOCK_ON: &DIGITAL_IO = 0 default: &DIGITAL_IO = HOLD_ON // => LOCK flag is 0 endsel elsif |CAPTURE_PIN = off then |capture_last = off endif // use the LEDs to show the current status of the rear pins if |HOLD_PIN = on then |LED1 = on |LED2 = on else |LED1 = off |LED2 = off endif if |LOCK_PIN = on then |LED3 = on |LED4 = on else |LED3 = off |LED4 = off endif if |CAPTURE_PIN = on then |LED5 = on |LED6 = on else |LED5 = off |LED6 = off endif END