Class Attribute
Example
from sensor import * import e32 class DemoApp(): def __init__(self): self.rotation = RotationData() self.rotation.set_callback(data_callback=self.my_callback) self.counter = 0 def my_callback(self): # For stream sensor data the callback is hit 35 times per sec(On 5800). # The device cannot handle resource hungry operations like print in the # callback function for such high frequencies. A workaround is to # sample the data as demonstrated below. if self.counter % 5 == 0: print "X:%s, Y:%s, Z:%s" % (self.rotation.x, self.rotation.y, self.rotation.z) print "Timestamp:", self.rotation.timestamp self.counter = self.counter + 1 def run(self): self.rotation.start_listening() if __name__ == '__main__': d = DemoApp() d.run() e32.ao_sleep(5) d.rotation.stop_listening() print "Exiting Rotation"
See About this document... for information on suggesting changes.