3.9.2.6 class MagneticNorthData

Class Attribute

Azimuth: 0 to 359 clockwise degrees from magnetic north.

Example

from sensor import *
import e32


class DemoApp():

    def __init__(self):
        self.magnetic_north = MagneticNorthData()
        self.magnetic_north.set_callback(data_callback=self.my_callback)

    def my_callback(self):
        azimuth = str(self.magnetic_north.azimuth)
        print "Azimuth:", azimuth
        print "Timestamp:", timestamp

    def run(self):
        self.magnetic_north.start_listening()

if __name__ == '__main__':
    d = DemoApp()
    d.run()
    e32.ao_sleep(1)
    d.magnetic_north.stop_listening()
    print "Exiting MagneticNorth"

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