""" Created August 9, 2011 @author: Janne Parkkila @contact: japskua@gmail.com @summary: This file contains class implementation on connecting to maemo dbus and receiving accelerometer data """ import dbus class Accelerometer(object): """ @summary: This class is used to get accelerometer data from the dbus """ bus = None accelerometer = None def __init__(self): """ @summary: The Constructor for the class """ self.bus = dbus.SystemBus() self.accelerometer = self.bus.get_object("com.nokia.mce", "/com/nokia/mce/request", "com.nokia.mce.request") def getData(self): """ @summary: This function returns the data of the accelerometer @return: orientation, stand, face, x, y, z @rtype: list """ return self.accelerometer.get_device_orientation() def displayData(self): """ @summary: This function is just used to display data """ orientation, stand, face, x, y, z = self.getData() print "Orientation: ", orientation print "Stand: ", stand print "Face: ", face print "X: ", x print "Y: ", y print "Z: ", z # This is only if we want to run the accelerometer test straight from the command line if __name__ == "__main__": print "Starting the Accelerometer test" accel = Accelerometer() accel.displayData()