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
rem RememberCalibration.bas
rem
rem last revision 19 Feb 2003
rem

REG &OFFSET_LO = &USER_MEMORY_1021
REG &OFFSET_HI = &USER_MEMORY_1022
REG &SCALE_LO = &USER_MEMORY_1023
REG &SCALE_HI = &USER_MEMORY_1024

MEM &OFFSET_LO = 0
MEM &OFFSET_HI = 0
MEM &SCALE_LO = 0
MEM &SCALE_HI = 0x3f80 // exponent = 0

Customer_ID_Macro:
write "      Remember Calibration      "
END

Reset_Macro:
#stored_offset = 0
%stored_scale = 1.0
gosub load_calibration
&TIMER1 = 0
END

F1_Button_Macro:
#stored_offset = &OFFSET_CH1
%stored_scale = &SCALE_FACTOR_CH1
gosub store_calibration
write ""
write "      calibration of CH1 stored      "
END

F2_Button_Macro:
gosub load_calibration
|NON_VOLATILE_WRITE = on
&OFFSET_CH1 = #stored_offset
|NON_VOLATILE_WRITE = on
&SCALE_FACTOR_CH1 = %stored_scale
write ""
write "      calibration of CH1 restored from memory      "
END


load_calibration:
// use bit mask on LO values, too, as they will be expanded to 32 bit during
// calculation, e.g. -1 = 0xffff (16bit) = 0xffffffff (32bit)
#stored_offset = (&OFFSET_LO and 0x0000ffff) or (&OFFSET_HI * 0x00010000)
&VARIABLE_A_INT = (&SCALE_LO and 0x0000ffff) or (&SCALE_HI * 0x00010000)
%stored_scale = &VARIABLE_A_FP
return

store_calibration:
&OFFSET_LO = #stored_offset and 0x0000ffff
&OFFSET_HI = (#stored_offset and 0xffff0000) / 0x00010000
&SCALE_LO = %stored_scale and 0x0000ffff
&SCALE_HI = (%stored_scale and 0xffff0000) / 0x00010000
return

Download RememberCalibration.bas
(1.4 KB , Aug. 26, 2008)