rem FunctionPins.bas rem rem last revision 14 Aug 2002 rem rem shows how LOCK, HOLD and CAPTURE pins can be used rem either as switches or as simple buttons. rem rem TEST pin cannnot be used as it will always reset the rem meter together with the macro. rem rem LOCK, HOLD and TEST pins always perform additional rem actions which can be selected in CODE9 // in this macro we will use: // - HOLD as a button to show a message // - LOCK as a button to switch between CH3 and CH2 display // - CAPTURE as a START/STOP switch, BIT |SHOW_MSG = |HOLD_PIN BIT |SWITCH_DISPLAY = |LOCK_PIN BIT |START = |CAPTURE_PIN Reset_Macro: // set both HOLD and LOCK to 'clear tare' // to omit interference with this particular macro &CODE9 = 0055 CONST BUTTONS_OFF = 0 CONST SHOW_MSG = 1 CONST SWITCH_DISPLAY = 2 #buttons = BUTTONS_OFF CONST COUNT_TIMEOUT = 10 &DATA_SOURCE_DISPLAY1 = addr(&CH3) &CH3 = 300 &CH2 = 200 end Main_Macro: if |SHOW_MSG = on then #buttons = SHOW_MSG elsif #buttons = SHOW_MSG then #buttons = BUTTONS_OFF gosub show_message endif if |SWITCH_DISPLAY = on then #buttons = SWITCH_DISPLAY elsif #buttons = SWITCH_DISPLAY then #buttons = BUTTONS_OFF gosub switch_display endif if |START = on then // run the application: increment &CH3 if &TIMER1 >= COUNT_TIMEOUT then &CH3 = &CH3 + 1 &TIMER1 = 0 endif else // stop the application: reset TIMER1, don't increment &CH3 &TIMER1 = 0 endif end show_message: write "" write " you pressed the show message button " return switch_display: if &DATA_SOURCE_DISPLAY1 = addr(&CH3) then &DATA_SOURCE_DISPLAY1 = addr(&CH2) else &DATA_SOURCE_DISPLAY1 = addr(&CH3) endif return