rem ButtonsFullControl.bas rem rem last revision on 05 Feb 2003 rem rem Extended example on how to use the front panel rem buttons in a macro. Customer_ID_Macro: write " Buttons Full Control " END CONST PROG_BUTTON_TIMEOUT = 20 CONST BUTTON_TIMEOUT = 5 // bit masks for &SWITCHES (see also Register Supplement, register 151) CONST PROG = 0x01 CONST DOWN = 0x02 CONST UP = 0x04 CONST BUTTON_REMOTE = 0x8000 // Meter may be setup to react to 'button events', // for example entering view mode on UP/DOWN. // // distinguish between different operation modes CONST OFF_MODE = 0 // buttons work as setup with configuration utility CONST MACRO_MODE = 1 // macro controls buttons completely Reset_Macro: #mode = OFF_MODE #buttons = 0 &TIMER1 = 0 &SWITCHES = 0 &DATA_SOURCE_DISPLAY1 = addr(&DISPLAY) // usually set with Texmate Meter Utility END prog_button_pressed: write "" if #mode = OFF_MODE then write " OFF_MODE " else write " MACRO_MODE " endif return up_button_pressed: &DISPLAY = &DISPLAY + 1 return down_button_pressed: &DISPLAY = &DISPLAY - 1 return Main_Macro: // do nothing if we are already in view or edit mode if &VIEW_POINTER <> 0 OR &EDIT_STATE <> 0 then &TIMER1 = 0 END endif select #mode case OFF_MODE: if |PROG_BUTTON = on then if &TIMER1 > PROG_BUTTON_TIMEOUT then &SWITCHES = BUTTON_REMOTE #mode = MACRO_MODE &TIMER1 = 0 gosub prog_button_pressed endif else &TIMER1 = 0 endif case MACRO_MODE: if &SWITCHES = BUTTON_REMOTE then // we want to trigger button pressed event as soon as possible &TIMER1 = BUTTON_TIMEOUT elsif &TIMER1 >= BUTTON_TIMEOUT then if &TIMER1 >= PROG_BUTTON_TIMEOUT AND \ &SWITCHES = BUTTON_REMOTE + PROG then &TIMER1 = 0 &SWITCHES = 0 #mode = OFF_MODE gosub prog_button_pressed else if &SWITCHES = BUTTON_REMOTE + UP then gosub up_button_pressed &TIMER1 = 0 elsif &SWITCHES = BUTTON_REMOTE + DOWN then gosub down_button_pressed &TIMER1 = 0 endif endif endif endsel END