rem Buttons.bas rem rem last revision on 12 Mar 2003 rem rem Simple example on how to use the front panel rem buttons in a macro. rem Meter may be setup to react to 'button events', rem for example entering view mode on UP/DOWN. rem See ButtonsFullControl.bas for more details rem how to omit such interferences. Customer_ID_Macro: write " Buttons " END CONST BUTTON_TIMEOUT = 5 Reset_Macro: #prog_button = 0 #button_press_counter = 0 &TIMER1 = BUTTON_TIMEOUT &TIMER2 = BUTTON_TIMEOUT &DATA_SOURCE_DISPLAY1 = addr(&DISPLAY) // usually set by Texmate Meter Utility // &DATA_SOURCE_DISPLAY1 = addr(#button_press_counter) END prog_button_pressed: write " Prog pressed " return up_button_pressed: &DISPLAY = &DISPLAY + 1 // #button_press_counter = #button_press_counter + 1 return down_button_pressed: &DISPLAY = &DISPLAY - 1 // #button_press_counter = #button_press_counter - 1 return Main_Macro: // Don't do anything as long as we are in view or edit mode if &VIEW_POINTER <> 0 OR &EDIT_STATE <> 0 then end endif // execute prog_button_pressed after prog_button is released if |PROG_BUTTON = on then #prog_button = 1 elsif #prog_button = 1 then #prog_button = 0 gosub prog_button_pressed endif // repeat increment/decrement when buttons are still pressed if |UP_BUTTON = on then if &TIMER1 > BUTTON_TIMEOUT then &TIMER1 = 0 gosub up_button_pressed endif else &TIMER1 = BUTTON_TIMEOUT endif if |DOWN_BUTTON = on then if &TIMER2 > BUTTON_TIMEOUT then &TIMER2 = 0 gosub down_button_pressed endif else &TIMER2 = BUTTON_TIMEOUT endif END