@@ -98,10 +98,6 @@ def acceleration(self):
98
98
"""Read the x, y, z acceleration values. These values are returned in
99
99
a 3-tuple and are in m / s ^ 2.
100
100
"""
101
- data = self ._read_register (REG_OUT_X_L | 0x80 , 6 )
102
- x = struct .unpack ('<h' , data [0 :2 ])[0 ]
103
- y = struct .unpack ('<h' , data [2 :4 ])[0 ]
104
- z = struct .unpack ('<h' , data [4 :6 ])[0 ]
105
101
divider = 1
106
102
accel_range = self .range
107
103
if accel_range == RANGE_16_G :
@@ -112,6 +108,9 @@ def acceleration(self):
112
108
divider = 8190
113
109
elif accel_range == RANGE_2_G :
114
110
divider = 16380
111
+
112
+ x , y , z = struct .unpack ('<hhh' , self ._read_register (REG_OUT_X_L | 0x80 , 6 ))
113
+
115
114
return (x / divider * 9.806 , y / divider * 9.806 , z / divider * 9.806 )
116
115
117
116
def read_adc_raw (self , adc ):
@@ -120,8 +119,8 @@ def read_adc_raw(self, adc):
120
119
"""
121
120
if adc < 1 or adc > 3 :
122
121
raise ValueError ('ADC must be a value 1 to 3!' )
123
- data = self . _read_register (( REG_OUTADC1_L + (( adc - 1 ) * 2 )) | 0x80 , 2 )
124
- return struct .unpack ('<h' , data [ 0 : 2 ] )[0 ]
122
+
123
+ return struct .unpack ('<h' , self . _read_register (( REG_OUTADC1_L + (( adc - 1 ) * 2 )) | 0x80 , 2 ) )[0 ]
125
124
126
125
def read_adc_mV (self , adc ):
127
126
"""Read the specified analog to digital converter value in millivolts.
0 commit comments