def main(argv):
	id = imuSens.getID()					#Verify chip ID
	print "Chip ID: 0x%02X. \r\n" % id	
	imuSens.standbyMode()	
	imuSens.activeMode()
		
	id = imuSens.getChipMode()			#Configure sensor as accelerometer
	print "Chip Mode: 0x%02X. \r\n" % id
		
	id = imuSens.getTemperature()
	print "Chip Temperature: 0x%02X. \r\n" % id

	def L1():
		print "Landscape right.\r\n"
		
	def L2():
		print "Landscape left. \r\n"
			
	def P1():
		print "Portrait down.\r\n"
			
	def P2():
		print "Portrait up.\r\n" 
		
	options = {0 : L1,
				1 : L2,
				2 : P1,
				3 : P2
			}

	imuSens.configureAccelerometer()
	imuSens.configureMagnetometer()
	imuSens.configureOrientation();
	modeprevious = 0

	while True:
		if(imuSens.readStatusReg() & 0x80):	
			orienta = imuSens.getOrientation()
			mode = (orienta >> 1) & 0x03	
			
			if (mode != modeprevious):
				options[mode]()
				
			modeprevious = mode
			
	print "Shutting down"	
def main(argv):
    id = imuSens.getID()  # Verify chip ID
    print "Chip ID: 0x%02X. \r\n" % id
    imuSens.standbyMode()
    imuSens.activeMode()

    id = imuSens.getChipMode()  # Configure sensor as accelerometer
    print "Chip Mode: 0x%02X. \r\n" % id

    id = imuSens.getTemperature()
    print "Chip Temperature: 0x%02X. \r\n" % id

    def L1():
        print "Landscape right.\r\n"

    def L2():
        print "Landscape left. \r\n"

    def P1():
        print "Portrait down.\r\n"

    def P2():
        print "Portrait up.\r\n"

    options = {0: L1, 1: L2, 2: P1, 3: P2}

    imuSens.configureAccelerometer()
    imuSens.configureMagnetometer()
    imuSens.configureOrientation()
    modeprevious = 0

    while True:
        if imuSens.readStatusReg() & 0x80:
            orienta = imuSens.getOrientation()
            mode = (orienta >> 1) & 0x03

            if mode != modeprevious:
                options[mode]()

            modeprevious = mode

    print "Shutting down"
	graphicDisplay.display(image)
	
options = {0 : L1,
			1 : L2,
			2 : P1,
			3 : P2
		}

imuSens.configureAccelerometer()
imuSens.configureMagnetometer()
imuSens.configureOrientation();
modeprevious = 0

while True:
	if(imuSens.readStatusReg() & 0x80):	
		orienta = imuSens.getOrientation()
		mode = (orienta >> 1) & 0x03	
		
		if (mode != modeprevious):
			options[mode]()
			
		modeprevious = mode
		
print "Shutting down"	

 # /****************************************************************************
 # * Copyright (C) 2015 Sensorian
 # *                                                                          *
 # * This file is part of Sensorian.                                          *
 # *                                                                          *
 # *   Sensorian is free software: you can redistribute it and/or modify it   *
Beispiel #4
0
def P2():
    print "Portrait up.\r\n"
    image = image1.rotate(180).resize((128, 160))
    graphicDisplay.display(image)


options = {0: L1, 1: L2, 2: P1, 3: P2}

imuSens.configureAccelerometer()
imuSens.configureMagnetometer()
imuSens.configureOrientation()
modeprevious = 0

while True:
    if (imuSens.readStatusReg() & 0x80):
        orienta = imuSens.getOrientation()
        mode = (orienta >> 1) & 0x03

        if (mode != modeprevious):
            options[mode]()

        modeprevious = mode

print "Shutting down"

# /****************************************************************************
# * Copyright (C) 2015 Sensorian
# *                                                                          *
# * This file is part of Sensorian.                                          *
# *                                                                          *
# *   Sensorian is free software: you can redistribute it and/or modify it   *