3.9.2.9 class OrientationData

Class Attribute

device_orientation: Values range from -1 to 6. To determine the logical names of these values get_logicalname API can be used with class name as TSensrvDeviceOrientation.

Example

from sensor import *
import e32

class DemoApp():

    def __init__(self):

        self.orientation = OrientationData()

        self.orientation.set_callback(data_callback=self.my_callback)

    def my_callback(self):

        print 'orientation : ', get_logicalname(TSensrvDeviceOrientation, self.orientation.device_orientation)

    def run(self):

        self.orientation.start_listening()

if __name__ == '__main__':

    d = DemoApp()

    d.run()

    e32.ao_sleep(10)

    d.orientation.stop_listening()

    print "Exiting Orientation"

See About this document... for information on suggesting changes.