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 imuSens.configureAccelerometer() imuSens.configureMagnetometer() while True: if (imuSens.readStatusReg() & 0x80): x, y, z = imuSens.pollAccelerometer() print "Accelerometer data x: %d, y: %d, z: %d \r\n" % (x, y, z) pitch, roll = pitchAndroll(x, y, z) print "pitch %f, roll %f \r\n" % (pitch, roll) mx, my, mz = imuSens.pollMagnetometer() print "Magnetometer data mx: %d, my: %d, mz: %d \r\n" % (mx, my, mz) angle = mag_to_tilt_compensated_heading(mx, my, mz, pitch, roll) print "Angle: %f" % angle print "Heading : %f" % imuSens.getHeading() print "Shutting down"
def main(): id = imuSens.getID() #Verify chip ID print "Chip ID: 0x%02X. \r\n" % id imuSens.standbyMode() # imuSens.writeByte(0x0B,0x01) #Set to wake up 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 #id = imuSens.readByte(PL_BF_ZCOMP) #print "PL_BF_ZCOMP: 0x%02X. \r\n" % id imuSens.configureAccelerometer() imuSens.configureMagnetometer() while True: if(imuSens.readStatusReg() & 0x80): x,y,z = imuSens.pollAccelerometer() print "Accelerometer data x: %d, y: %d, z: %d \r\n" % (x, y, z) # mx,my,mz = imuSens.pollMagnetometer() # print "Magnetometer data mx: %d, my: %d, mz: %d \r\n" % (mx, my, mz) 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 imuSens.configureAccelerometer() imuSens.configureMagnetometer() while True: if(imuSens.readStatusReg() & 0x80): x,y,z = imuSens.pollAccelerometer() print "Accelerometer data x: %d, y: %d, z: %d \r\n" % (x, y, z) pitch,roll = pitchAndroll(x,y,z) print "pitch %f, roll %f \r\n" % (pitch,roll) mx,my,mz = imuSens.pollMagnetometer() print "Magnetometer data mx: %d, my: %d, mz: %d \r\n" % (mx, my, mz) angle = mag_to_tilt_compensated_heading(mx, my, mz,pitch,roll) print "Angle: %f" % angle print "Heading : %f" % imuSens.getHeading() print "Shutting down"
def main(argv): print "========= MPL3115A2 Sensor demo ==========" print "******************************************" height = GLCD.TFT_HEIGHT width = GLCD.TFT_WIDTH disp = GLCD.TFT() # Create TFT LCD display class. disp.initialize() # Initialize display. disp.clear() # Alternatively can clear to a black screen by calling: draw = disp.draw() # Get a PIL Draw object to start drawing on the display buffer font = ImageFont.truetype('/usr/share/fonts/droid/DroidSans.ttf', 14) # use a truetype font time.sleep(1) channel1 = AmbientLight.readChannel(1) #Take a reading from channel one print "Channel 1 value: %d." % channel1 channel2 = AmbientLight.readChannel(0) #Take a reading from channel two print "Channel 2 value: %d" % channel2 Lux = AmbientLight.getLuxLevel(channel1,channel2) print "Lux output: %d." % Lux button = NoPress #reset button button = CapTouch.readPressedButton() #poll for new press if (button != NoPress): print "Button B%d pressed.\r\n" % int(button) ser = serial.Serial('/dev/ttyS0',115200,timeout=3) # Open the serial port ser.write("X-shield UART Demo\r\n") # Write a serial string to the serial port for num in range(1,10): ser.write("Number" + str(num) + "\r\n") # Write a serial string to the serial port print "Serial closed" ser.close() imuSens = imuSens.FXOS8700CQR1() #Configure chip in hybrid mode id = imuSens.getID() #Verify chip ID print "Chip ID: 0x%02X. \r\n" % id imuSens.standbyMode() # imuSens.writeByte(0x0B,0x01) #Set to wake up imuSens.activeMode() while True: if(imuSens.readStatusReg() & 0x80): x,y,z = imuSens.pollAccelerometer() print "Accelerometer data x: %d, y: %d, z: %d \r\n" % (x, y, z) press = AltiBar.ReadBarometricPressure() #Take a pressure reading time.sleep(1) draw.text((30, 10), "Pressure (Pa)", font=font) draw.text((30, 30), str(press), font=font) disp.display() time.sleep(5) disp.clear()
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"
#!/usr/bin/python import Image import TFT as display import sys import time import FXOS8700CQR1 as imuSens from ctypes import * imuSens = imuSens.FXOS8700CQR1() #Configure chip in hybrid mode imuSens.standbyMode() imuSens.activeMode() graphicDisplay = display.TFT() graphicDisplay.initialize() # Initialize display. image1 = Image.open('logoscreen.jpg') def L1(): print "Landscape right.\r\n" image = image1.rotate(270).resize((128, 160)) graphicDisplay.display(image) def L2(): print "Landscape left. \r\n" image = image1.rotate(90).resize((128, 160)) graphicDisplay.display(image) def P1(): print "Portrait down.\r\n"
#!/usr/bin/python import Image import TFT as display import sys import time import FXOS8700CQR1 as imuSens from ctypes import * imuSens = imuSens.FXOS8700CQR1() #Configure chip in hybrid mode imuSens.standbyMode() imuSens.activeMode() graphicDisplay = display.TFT() graphicDisplay.initialize() # Initialize display. image1 = Image.open('logoscreen.jpg') def L1(): print "Landscape right.\r\n" image = image1.rotate(270).resize((128, 160)) graphicDisplay.display(image) def L2(): print "Landscape left. \r\n" image = image1.rotate(90).resize((128, 160)) graphicDisplay.display(image)