1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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

Download Buttons.bas
(1.7 KB , Aug. 26, 2008)