Add new field property and method for uncalibrated field
@@ -17,11 +17,18 @@ To disable compass::
>>> compass.disable()
-To get the orientation::
+To get the field::
- >>> compass.orientation
+ >>> compass.field()
(-23.721826553344727, -5.7114701271057129, -36.749668121337891)
+To get the uncalibrated field along with iron bias estimation::
+
+ >>> compass.field_uncalib()
+ (a,b,c,x,y,z)
+ # a,b,c denote the Geomagnetic field strength
+ # (without hard iron calibration) along the three axes.
+ # x,y,z denote the Iron bias estimation along the three axes.
'''
@@ -34,12 +41,37 @@ class Compass(object):
@property
def orientation(self):
'''
+ WARNING:: This property is deprecated after API level 8.
+ Use `compass.field` instead.
+
+ Property that returns values of the current compass
+ (magnetic field) sensors, as a (x, y, z) tuple.
+ Returns (None, None, None) if no data is currently available.
+ '''
+ return self.get_orientation()
+
+ @property
+ def field(self):
+ '''
+ .. versionadded:: 1.3.1
+
Property that returns values of the current compass
(magnetic field) sensors, as a (x, y, z) tuple.
Returns (None, None, None) if no data is currently available.
'''
return self.get_orientation()
+ @property
+ def field_uncalib(self):
+ '''
+ .. versionadded:: 1.3.1
+
+ Property that returns the current value of Uncalibrated Magnetic Field
+ (without hard iron calibration) along with the iron bias estimation
+ along the three axes.
+ '''
+ return self.get_field_uncalib()
+
def enable(self):
'''
Activate the compass sensor.
@@ -55,6 +87,12 @@ class Compass(object):
def get_orientation(self):
return self._get_orientation()
+ def get_field_uncalib(self):
+ '''
+ .. versionadded:: 1.3.1
+ '''
+ return self._get_field_uncalib()
+
# private
def _enable(self):
@@ -65,3 +103,6 @@ class Compass(object):
def _get_orientation(self):
raise NotImplementedError()
+
+ def _get_field_uncalib(self):
+ raise NotImplementedError()
