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
78
79
80
81
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

Download FunctionPins.bas
(1.8 KB , Aug. 26, 2008)