#!/usr/bin/env python # coding: latin-1 # Load the XLoBorg library import sys import time import decimal from XLoBorg import * # Tell the library to disable diagnostic printouts printFunction = NoPrint # Start the XLoBorg module (sets up devices) Init() if len(sys.argv) >= 3 and sys.argv[1].find("-n") == 0: n = decimal.Decimal(sys.argv[2]) dlay = 0 if len(sys.argv) >= 4: dlay = decimal.Decimal(sys.argv[3]) print("Taking %d samples delay %d mS" % (n, dlay)) fdlay = 0.0 fdlay = dlay / 1000 i = 0 vals = [] while n > 0: (mX, mY, mZ) = ReadCompassRaw() print("%+06d, %+06d, %+06d" % (mX, mY, mZ)) #print("mX = %+06d, mY = %+06d, mZ = %+06d" % (mX, mY, mZ)) vals = vals + [mX, mY, mZ] i = i + 1 n = n - 1 time.sleep(fdlay) else: # Read and display the raw magnetometer readings print 'mX = %+06d, mY = %+06d, mZ = %+06d' % ReadCompassRaw()