diff options
Diffstat (limited to 'peripheral/libupm/examples/python')
130 files changed, 0 insertions, 8280 deletions
diff --git a/peripheral/libupm/examples/python/a110x.py b/peripheral/libupm/examples/python/a110x.py deleted file mode 100644 index 15ba01e..0000000 --- a/peripheral/libupm/examples/python/a110x.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_a110x as upmA110x - -# Instantiate a Hall Effect magnet sensor on digital pin D2 -myHallEffectSensor = upmA110x.A110X(2) - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, including functions from myHallEffectSensor -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -while(1): - if (myHallEffectSensor.magnetDetected()): - print "Magnet (south polarity) detected." - else: - print "No magnet detected." - time.sleep(1) diff --git a/peripheral/libupm/examples/python/ad8232.py b/peripheral/libupm/examples/python/ad8232.py deleted file mode 100644 index 97284ad..0000000 --- a/peripheral/libupm/examples/python/ad8232.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_ad8232 as upmAD8232 - -# Instantiate a AD8232 sensor on digital pins 10 (LO+), 11 (LO-) -# and an analog pin, 0 (OUTPUT) -myAD8232 = upmAD8232.AD8232(10, 11, 0) - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, including functions from myAD8232 -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -# Output the raw numbers from the ADC, for plotting elsewhere. -# A return of 0 indicates a Lead Off (LO) condition. -# In theory, this data could be fed to software like Processing -# (https://www.processing.org/) to plot the data just like an -# EKG you would see in a hospital. -while(1): - print myAD8232.value() - time.sleep(.001) diff --git a/peripheral/libupm/examples/python/adafruitms1438-stepper.py b/peripheral/libupm/examples/python/adafruitms1438-stepper.py deleted file mode 100644 index 5385951..0000000 --- a/peripheral/libupm/examples/python/adafruitms1438-stepper.py +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_adafruitms1438 as upmAdafruitms1438 - - -# Import header values -I2CBus = upmAdafruitms1438.ADAFRUITMS1438_I2C_BUS -I2CAddr = upmAdafruitms1438.ADAFRUITMS1438_DEFAULT_I2C_ADDR - -M12Motor = upmAdafruitms1438.AdafruitMS1438.STEPMOTOR_M12 -MotorDirCW = upmAdafruitms1438.AdafruitMS1438.DIR_CW -MotorDirCCW = upmAdafruitms1438.AdafruitMS1438.DIR_CCW - - -# Instantiate an Adafruit MS 1438 on I2C bus 0 -myMotorShield = upmAdafruitms1438.AdafruitMS1438(I2CBus, I2CAddr) - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, -# including functions from myMotorShield -def exitHandler(): - myMotorShield.disableStepper(M12Motor) - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -# Setup for use with a stepper motor connected to the M1 & M2 ports - -# set a PWM period of 50Hz - -# disable first, to be safe -myMotorShield.disableStepper(M12Motor) - -# configure for a NEMA-17, 200 steps per revolution -myMotorShield.stepConfig(M12Motor, 200) - -# set speed at 10 RPM's -myMotorShield.setStepperSpeed(M12Motor, 10); -myMotorShield.setStepperDirection(M12Motor, MotorDirCW) - -# enable -print "Enabling..." -myMotorShield.enableStepper(M12Motor) - -print "Rotating 1 full revolution at 10 RPM speed." -myMotorShield.stepperSteps(M12Motor, 200) - -print "Sleeping for 2 seconds..." -time.sleep(2) -print "Rotating 1/2 revolution in opposite direction at 10 RPM speed." - -myMotorShield.setStepperDirection(M12Motor, MotorDirCCW) -myMotorShield.stepperSteps(M12Motor, 100) - -print "Disabling..." - -# exitHandler runs automatically diff --git a/peripheral/libupm/examples/python/adafruitms1438.py b/peripheral/libupm/examples/python/adafruitms1438.py deleted file mode 100644 index 816bbe5..0000000 --- a/peripheral/libupm/examples/python/adafruitms1438.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_adafruitms1438 as upmAdafruitms1438 - - -# Import header values -I2CBus = upmAdafruitms1438.ADAFRUITMS1438_I2C_BUS -I2CAddr = upmAdafruitms1438.ADAFRUITMS1438_DEFAULT_I2C_ADDR - -M3Motor = upmAdafruitms1438.AdafruitMS1438.MOTOR_M3 -MotorDirCW = upmAdafruitms1438.AdafruitMS1438.DIR_CW -MotorDirCCW = upmAdafruitms1438.AdafruitMS1438.DIR_CCW - - -# Instantiate an Adafruit MS 1438 on I2C bus 0 -myMotorShield = upmAdafruitms1438.AdafruitMS1438(I2CBus, I2CAddr) - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, -# including functions from myMotorShield -def exitHandler(): - myMotorShield.disableMotor(M3Motor) - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -# Setup for use with a DC motor connected to the M3 port - -# set a PWM period of 50Hz -myMotorShield.setPWMPeriod(50) - -# disable first, to be safe -myMotorShield.disableMotor(M3Motor) - -# set speed at 50% -myMotorShield.setMotorSpeed(M3Motor, 50) -myMotorShield.setMotorDirection(M3Motor, MotorDirCW) - -print ("Spin M3 at half speed for 3 seconds, " -"then reverse for 3 seconds.") -myMotorShield.enableMotor(M3Motor) - -time.sleep(3) - -print "Reversing M3" -myMotorShield.setMotorDirection(M3Motor, MotorDirCCW) - -time.sleep(3) - -print "Stopping M3" - -# exitHandler runs automatically diff --git a/peripheral/libupm/examples/python/adc121c021.py b/peripheral/libupm/examples/python/adc121c021.py deleted file mode 100644 index 61500c4..0000000 --- a/peripheral/libupm/examples/python/adc121c021.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_adc121c021 as upmAdc121c021 - -# Instantiate an ADC121C021 on I2C bus 0 -busID = upmAdc121c021.ADC121C021_I2C_BUS -I2CAddr = upmAdc121c021.ADC121C021_DEFAULT_I2C_ADDR - -myAnalogDigitalConv = upmAdc121c021.ADC121C021(busID, I2CAddr) - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This lets you run code on exit, -# including functions from myAnalogDigitalConv -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -# get the data every 50 milliseconds -while(1): - val = myAnalogDigitalConv.value() - voltsVal = myAnalogDigitalConv.valueToVolts(val) - print "ADC value: %s Volts = %s" % (val, voltsVal) - time.sleep(.05) diff --git a/peripheral/libupm/examples/python/adxl335.py b/peripheral/libupm/examples/python/adxl335.py deleted file mode 100644 index bc62181..0000000 --- a/peripheral/libupm/examples/python/adxl335.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_adxl335 as upmAdxl335 - -myAnalogAccel = upmAdxl335.ADXL335(0, 1, 2) - -print "Please make sure the sensor is completely still." -print "Sleeping for 2 seconds" -time.sleep(2) - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, -# including functions from myAnalogAccel -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -print "Calibrating..." -myAnalogAccel.calibrate() - -x = upmAdxl335.new_intPointer() -y = upmAdxl335.new_intPointer() -z = upmAdxl335.new_intPointer() - -aX = upmAdxl335.new_floatPointer() -aY = upmAdxl335.new_floatPointer() -aZ = upmAdxl335.new_floatPointer() - -while (1): - myAnalogAccel.values(x, y, z) - outputStr = "Raw Values: X: {0} Y: {1} Z: {2}".format( - upmAdxl335.intPointer_value(x), upmAdxl335.intPointer_value(y), - upmAdxl335.intPointer_value(z)) - print outputStr - - myAnalogAccel.acceleration(aX, aY, aZ) - outputStr = ("Acceleration: X: {0}g\n" - "Acceleration: Y: {1}g\n" - "Acceleration: Z: {2}g").format(upmAdxl335.floatPointer_value(aX), - upmAdxl335.floatPointer_value(aY), - upmAdxl335.floatPointer_value(aZ)) - print outputStr - - print " " - - time.sleep(.2) diff --git a/peripheral/libupm/examples/python/adxl345.py b/peripheral/libupm/examples/python/adxl345.py deleted file mode 100644 index d19110a..0000000 --- a/peripheral/libupm/examples/python/adxl345.py +++ /dev/null @@ -1,41 +0,0 @@ -# Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com> -# Copyright (c) 2014 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -from time import sleep -import pyupm_adxl345 as adxl345 - -# Create an I2C accelerometer object -adxl = adxl345.Adxl345(0) - -# Loop indefinitely -while True: - - adxl.update() # Update the data - raw = adxl.getRawValues() # Read raw sensor data - force = adxl.getAcceleration() # Read acceleration force (g) - print "Raw: %6d %6d %6d" % (raw[0], raw[1], raw[2]) - print "ForceX: %5.2f g" % (force[0]) - print "ForceY: %5.2f g" % (force[1]) - print "ForceZ: %5.2f g\n" % (force[2]) - - # Sleep for 1 s - sleep(1) diff --git a/peripheral/libupm/examples/python/adxrs610.py b/peripheral/libupm/examples/python/adxrs610.py deleted file mode 100644 index 5183e7b..0000000 --- a/peripheral/libupm/examples/python/adxrs610.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_adxrs610 as sensorObj - -# Instantiate a ADXRS610 sensor on analog pin A0 (dataout), and -# analog A1 (temp out) with an analog reference voltage of -# 5.0 -sensor = sensorObj.ADXRS610(0, 1, 5.0) - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - -# set a deadband region around the zero point to report 0.0 (optional) -sensor.setDeadband(0.015); - -# Every tenth of a second, sample the ADXRS610 and output it's -# corresponding temperature and angular velocity - -while (1): - print "Vel (deg/s):", sensor.getAngularVelocity() - print "Temp (C):", sensor.getTemperature() - time.sleep(.1) diff --git a/peripheral/libupm/examples/python/ak8975.py b/peripheral/libupm/examples/python/ak8975.py deleted file mode 100644 index ad19df9..0000000 --- a/peripheral/libupm/examples/python/ak8975.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_mpu9150 as sensorObj - -# Instantiate an AK8975 on I2C bus 0 -sensor = sensorObj.AK8975() - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - -sensor.init() - -x = sensorObj.new_floatp() -y = sensorObj.new_floatp() -z = sensorObj.new_floatp() - -while (1): - sensor.update() - sensor.getMagnetometer(x, y, z) - print "Magnetometer: MX: ", sensorObj.floatp_value(x), - print " MY: ", sensorObj.floatp_value(y), - print " MZ: ", sensorObj.floatp_value(z) - - print - - time.sleep(.5) diff --git a/peripheral/libupm/examples/python/apds9002.py b/peripheral/libupm/examples/python/apds9002.py deleted file mode 100644 index f9ea3cb..0000000 --- a/peripheral/libupm/examples/python/apds9002.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_apds9002 as upmApds9002 - -# Instantiate a Grove Luminance sensor on analog pin A0 -myLuminance = upmApds9002.APDS9002(0) - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This lets you run code on exit, including functions from myLuminance -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -while(1): - print "Luminance value is {0}".format( - myLuminance.value()) - - time.sleep(1) diff --git a/peripheral/libupm/examples/python/at42qt1070.py b/peripheral/libupm/examples/python/at42qt1070.py deleted file mode 100644 index 06addfe..0000000 --- a/peripheral/libupm/examples/python/at42qt1070.py +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_at42qt1070 as upmAt42qt1070 - -# functions -def printButtons(touchObj): - buttonPressed = False - buttons = touchObj.getButtons() - - sys.stdout.write("Buttons Pressed: ") - for i in range(7): - if (buttons & (1 << i)): - sys.stdout.write(str(i) + " ") - buttonPressed = True - - if (not buttonPressed): - sys.stdout.write("None") - - print " " - - if (touchObj.isCalibrating()): - print "Calibration is occurring." - - if (touchObj.isOverflowed()): - print "Overflow was detected." - - -# Global code that runs on startup - -I2C_BUS = upmAt42qt1070.AT42QT1070_I2C_BUS -DEFAULT_I2C_ADDR = upmAt42qt1070.AT42QT1070_DEFAULT_I2C_ADDR - -# Instantiate an AT42QT1070 on I2C bus 0 -myTouchSensor = upmAt42qt1070.AT42QT1070(I2C_BUS, - DEFAULT_I2C_ADDR) - - -# Exit handlers -def SIGINTHandler(signum, frame): - raise SystemExit - -def exitHandler(): - print "Exiting" - sys.exit(0) - - -# This function lets you run code on exit, including functions from myTouchSensor -atexit.register(exitHandler) -# This function stops python from printing a stacktrace when you hit control-C -signal.signal(signal.SIGINT, SIGINTHandler) - - -# Print the button being touched every 0.1 seconds -while(1): - myTouchSensor.updateState() - printButtons(myTouchSensor) - time.sleep(.1) diff --git a/peripheral/libupm/examples/python/biss0001.py b/peripheral/libupm/examples/python/biss0001.py deleted file mode 100644 index ba8901d..0000000 --- a/peripheral/libupm/examples/python/biss0001.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_biss0001 as upmMotion - -# Instantiate a Grove Motion sensor on GPIO pin D2 -myMotion = upmMotion.BISS0001(2) - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, including functions from myMotion -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -# Read the value every second and detect motion -while(1): - if (myMotion.value()): - print "Detecting moving object" - else: - print "No moving objects detected" - time.sleep(1) diff --git a/peripheral/libupm/examples/python/bma220.py b/peripheral/libupm/examples/python/bma220.py deleted file mode 100644 index 9db6cdf..0000000 --- a/peripheral/libupm/examples/python/bma220.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_bma220 as sensorObj - -# Instantiate an BMA220 using default parameters (bus 0, addr 0x0a) -sensor = sensorObj.BMA220() - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - -x = sensorObj.new_floatp() -y = sensorObj.new_floatp() -z = sensorObj.new_floatp() - -while (1): - sensor.update() - sensor.getAccelerometer(x, y, z) - print "Accelerometer: AX:", sensorObj.floatp_value(x), - print " AY:", sensorObj.floatp_value(y), - print " AZ:", sensorObj.floatp_value(z) - - time.sleep(.5) diff --git a/peripheral/libupm/examples/python/bmpx8x.py b/peripheral/libupm/examples/python/bmpx8x.py deleted file mode 100644 index 017fba5..0000000 --- a/peripheral/libupm/examples/python/bmpx8x.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_bmpx8x as upmBmpx8x - -# Load Barometer module on i2c -myBarometer = upmBmpx8x.BMPX8X(0, upmBmpx8x.ADDR); - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, including functions from myBarometer -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -# Print the pressure, altitude, sea level, and -# temperature values every 0.1 seconds -while(1): - outputStr = ("pressure value = {0}" - ", altitude value = {1}" - ", sealevel value = {2}" - ", temperature = {3}".format( - myBarometer.getPressure(), - myBarometer.getTemperature(), - myBarometer.getAltitude(), - myBarometer.getSealevelPressure())) - - print outputStr - time.sleep(.1) diff --git a/peripheral/libupm/examples/python/buzzer.py b/peripheral/libupm/examples/python/buzzer.py deleted file mode 100644 index b1a3d18..0000000 --- a/peripheral/libupm/examples/python/buzzer.py +++ /dev/null @@ -1,45 +0,0 @@ -# Author: Sarah Knepper <sarah.knepper@intel.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time -import pyupm_buzzer as upmBuzzer - -# Create the buzzer object using GPIO pin 5 -buzzer = upmBuzzer.Buzzer(5) - -chords = [upmBuzzer.DO, upmBuzzer.RE, upmBuzzer.MI, upmBuzzer.FA, - upmBuzzer.SOL, upmBuzzer.LA, upmBuzzer.SI, upmBuzzer.DO, - upmBuzzer.SI]; - -# Print sensor name -print buzzer.name() - -# Play sound (DO, RE, MI, etc.), pausing for 0.1 seconds between notes -for chord_ind in range (0,7): - # play each note for one second - print buzzer.playSound(chords[chord_ind], 1000000) - time.sleep(0.1) - -print "exiting application" - -# Delete the buzzer object -del buzzer diff --git a/peripheral/libupm/examples/python/cjq4435.py b/peripheral/libupm/examples/python/cjq4435.py deleted file mode 100644 index a4ed268..0000000 --- a/peripheral/libupm/examples/python/cjq4435.py +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -from __future__ import division -import time -import pyupm_cjq4435 as upmCjq4435 - -# Instantiate a CJQ4435 MOSFET on a PWM capable digital pin D3 -myMOSFETsensor = upmCjq4435.CJQ4435(3) - - -myMOSFETsensor.setPeriodMS(10) -myMOSFETsensor.enable(True) - -# start with a duty cycle of 0.0 (off) and increment to 1.0 (on) -for i in range(11): - myMOSFETsensor.setDutyCycle(i / 10) - time.sleep(.1) -time.sleep(1) - -# Now take it back down -# start with a duty cycle of 1.0 (on) and decrement to 0.0 (off) -for i in range(10, -1, -1): - myMOSFETsensor.setDutyCycle(i / 10) - time.sleep(.1) -time.sleep(1) diff --git a/peripheral/libupm/examples/python/dfrph.py b/peripheral/libupm/examples/python/dfrph.py deleted file mode 100644 index 1fadf03..0000000 --- a/peripheral/libupm/examples/python/dfrph.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_dfrph as sensorObj - -# Instantiate a DFRPH sensor on analog pin A0, with an analog -# reference voltage of 5.0 -sensor = sensorObj.DFRPH(0, 5.0) - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - -# After calibration, set the offset (based on calibration with a pH -# 7.0 buffer solution). See the UPM sensor documentation for -# calibrations instructions. -sensor.setOffset(0.065); - -# Every second, sample the pH and output it's corresponding -# analog voltage. - -while (1): - print "Detected volts: ", sensor.volts() - print "pH value: ", sensor.pH() - time.sleep(1) diff --git a/peripheral/libupm/examples/python/ds1307.py b/peripheral/libupm/examples/python/ds1307.py deleted file mode 100644 index 7d35d8e..0000000 --- a/peripheral/libupm/examples/python/ds1307.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_ds1307 as upmDs1307 - -# load RTC clock on i2c bus 0 -myRTCClock = upmDs1307.DS1307(0) - -def printTime(RTCObj): - timeStr = "The time is: {0}/{1}/{2} {3}:{4}:{5}".format( - RTCObj.month, RTCObj.dayOfMonth, RTCObj.year, - RTCObj.hours, RTCObj.minutes, RTCObj.seconds) - - if (RTCObj.amPmMode): - timeStr += (" PM " if RTCObj.pm else " AM ") - - print timeStr - - print "Clock is in", ("AM/PM mode" - if RTCObj.amPmMode else "24hr mode") - - -# always do this first -print "Loading the current time... " -result = myRTCClock.loadTime() -if (not result): - print "myRTCClock.loadTime() failed." - sys.exit(0) - -printTime(myRTCClock); - -# set the year as an example -print "setting the year to 50" -myRTCClock.year = 50 -myRTCClock.setTime() - -# reload the time and print it -myRTCClock.loadTime() -printTime(myRTCClock) diff --git a/peripheral/libupm/examples/python/eboled.py b/peripheral/libupm/examples/python/eboled.py deleted file mode 100644 index b33aaba..0000000 --- a/peripheral/libupm/examples/python/eboled.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys - -import pyupm_i2clcd as lcdObj - -# setup with default values -lcd = lcdObj.EBOLED(); - -lcd.clear(); -lcd.setCursor(10, 15); -lcd.write("Hello"); -lcd.setCursor(30, 15); -lcd.write("World!"); -lcd.refresh(); -print "Sleeping for 5 seconds..." -time.sleep(5) - - - diff --git a/peripheral/libupm/examples/python/enc03r.py b/peripheral/libupm/examples/python/enc03r.py deleted file mode 100644 index 45db89f..0000000 --- a/peripheral/libupm/examples/python/enc03r.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_enc03r as upmEnc03r - -# Instantiate an ENC03R on analog pin A0 -myAnalogGyro = upmEnc03r.ENC03R(0) - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, -# including functions from myAnalogGyro -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -CALIBRATION_SAMPLES = 1000 - -print ("Please place the sensor in a stable location,\n" -"and do not move it while calibration takes place.\n" -"This may take a couple of minutes.") - -myAnalogGyro.calibrate(CALIBRATION_SAMPLES) -print "Calibration complete. " -print "Reference value: ", myAnalogGyro.calibrationValue() - -while(1): - gyroVal = myAnalogGyro.value(); - outputStr = ("Raw value: {0}, " - "angular velocity: {1}" - " deg/s".format(gyroVal, myAnalogGyro.angularVelocity(gyroVal))) - print outputStr - - time.sleep(.1) diff --git a/peripheral/libupm/examples/python/es08a.py b/peripheral/libupm/examples/python/es08a.py deleted file mode 100644 index 09a1284..0000000 --- a/peripheral/libupm/examples/python/es08a.py +++ /dev/null @@ -1,46 +0,0 @@ -# Author: John Van Drasek <john.r.van.drasek@intel.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time -import pyupm_servo as servo - -# Create the servo object using D5 -gServo = servo.ES08A(5) - -for i in range(0,10): - # Set the servo arm to 0 degrees - gServo.setAngle(0) - print 'Set angle to 0' - time.sleep(1) - - # Set the servo arm to 90 degrees - gServo.setAngle(90) - print 'Set angle to 90' - time.sleep(1) - - # Set the servo arm to 180 degrees - gServo.setAngle(180) - print 'Set angle to 180' - time.sleep(1) - -# Delete the servo object -del gServo diff --git a/peripheral/libupm/examples/python/gp2y0a.py b/peripheral/libupm/examples/python/gp2y0a.py deleted file mode 100644 index f736d2c..0000000 --- a/peripheral/libupm/examples/python/gp2y0a.py +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_gp2y0a as upmGp2y0a - -# Note, for the Grove 80cm version of this sensor, due to the way it is wired, -# you need to plug this into the A0 port, where it will use the available -# A1 pin for data. -# Instantiate a GP2Y0A on analog pin A1 -myIRProximity = upmGp2y0a.GP2Y0A(1) - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This lets you run code on exit, -# including functions from myIRProximity -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -# analog voltage, usually 3.3 or 5.0 -GP2Y0A_AREF = 5.0; -SAMPLES_PER_QUERY = 20; - -# The higher the voltage (closer to AREF) the closer the object is. -# NOTE: The measured voltage will probably not exceed 3.3 volts. -# Every second, print the averaged voltage value -# (averaged over 20 samples). -while (1): - print "AREF: {0}, Voltage value (higher means closer): {1}".format( - GP2Y0A_AREF, - myIRProximity.value(GP2Y0A_AREF, SAMPLES_PER_QUERY)) - time.sleep(1) diff --git a/peripheral/libupm/examples/python/grovebutton.py b/peripheral/libupm/examples/python/grovebutton.py deleted file mode 100644 index c62c399..0000000 --- a/peripheral/libupm/examples/python/grovebutton.py +++ /dev/null @@ -1,35 +0,0 @@ -# Author: Sarah Knepper <sarah.knepper@intel.com> -# Copyright (c) 2014 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time -import pyupm_grove as grove - -# Create the button object using GPIO pin 0 -button = grove.GroveButton(0) - -# Read the input and print, waiting one second between readings -while 1: - print button.name(), ' value is ', button.value() - time.sleep(1) - -# Delete the button object -del button diff --git a/peripheral/libupm/examples/python/grovecircularled.py b/peripheral/libupm/examples/python/grovecircularled.py deleted file mode 100644 index 1c5a485..0000000 --- a/peripheral/libupm/examples/python/grovecircularled.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/python -# -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_my9221 as upmGroveCircularLED - -# Exit handlers -def SIGINTHandler(signum, frame): - raise SystemExit - -def exitHandler(): - circle.setLevel(0, True) - print "Exiting" - sys.exit(0) - -# This function lets you run code on exit -atexit.register(exitHandler) -# This function stops python from printing a stacktrace when you hit control-C -signal.signal(signal.SIGINT, SIGINTHandler) - -# Instantiate a Grove Circular LED on gpio pins 9 and 8 -circle = upmGroveCircularLED.GroveCircularLED(9, 8) - -level = 0 - -while(1): - circle.setSpinner(level) - level = (level + 1) % 24 - time.sleep(.1) diff --git a/peripheral/libupm/examples/python/grovecollision.py b/peripheral/libupm/examples/python/grovecollision.py deleted file mode 100644 index 6cdd05c..0000000 --- a/peripheral/libupm/examples/python/grovecollision.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_grovecollision as upmGrovecollision - -# The was tested with the Grove Collision Sensor -# Instantiate a Grove Collision on digital pin D2 -myGrovecollision = upmGrovecollision.GroveCollision(2) - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This lets you run code on exit, -# including functions from myGrovecollision -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -collisionState = False -print "No collision" - -while(1): - if (myGrovecollision.isColliding() and not collisionState): - print "Collision!" - collisionState = True - elif (not myGrovecollision.isColliding() and collisionState): - print "No collision" - collisionState = False diff --git a/peripheral/libupm/examples/python/groveehr.py b/peripheral/libupm/examples/python/groveehr.py deleted file mode 100644 index 3dd0ee2..0000000 --- a/peripheral/libupm/examples/python/groveehr.py +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - -import time, sys, signal, atexit -import pyupm_groveehr as upmGroveehr - -# Instantiate a Grove Ear-clip Heart Rate sensor on digital pin D2 -myHeartRateSensor = upmGroveehr.GroveEHR(2) - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This lets you run code on exit, -# including functions from myHeartRateSensor -def exitHandler(): - myHeartRateSensor.stopBeatCounter() - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -# set the beat counter to 0, init the clock and start counting beats -myHeartRateSensor.clearBeatCounter() -myHeartRateSensor.initClock() -myHeartRateSensor.startBeatCounter() - -while(1): - # we grab these (millis and flowCount) just for display - # purposes in this example - millis = myHeartRateSensor.getMillis() - beats = myHeartRateSensor.beatCounter() - - # heartRate() requires that at least 5 seconds pass before - # returning anything other than 0 - fr = myHeartRateSensor.heartRate() - - # output milliseconds passed, beat count, and computed heart rate - outputStr = "Millis: {0} Beats: {1} Heart Rate: {2}".format( - millis, beats, fr) - print outputStr - time.sleep(1) diff --git a/peripheral/libupm/examples/python/groveeldriver.py b/peripheral/libupm/examples/python/groveeldriver.py deleted file mode 100644 index c9fd936..0000000 --- a/peripheral/libupm/examples/python/groveeldriver.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_groveeldriver as upmGroveeldriver - -# The was tested with the Grove El Driver Module -# Instantiate a Grove El Driver on digital pin D2 -myEldriver = upmGroveeldriver.GroveElDriver(2) - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, including functions from myEldriver -def exitHandler(): - print "Exiting" - myEldriver.off() - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -lightState = True - -while(1): - if (lightState): - myEldriver.on() - else: - myEldriver.off() - lightState = not lightState - - time.sleep(1) diff --git a/peripheral/libupm/examples/python/groveelectromagnet.py b/peripheral/libupm/examples/python/groveelectromagnet.py deleted file mode 100644 index c84af68..0000000 --- a/peripheral/libupm/examples/python/groveelectromagnet.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_groveelectromagnet as upmGroveelectromagnet - -# This was tested with the Grove Electromagnetic Module -# Instantiate a Grove Electromagnet on digital pin D2 -myElectromagnet = upmGroveelectromagnet.GroveElectromagnet(2) - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This lets you run code on exit, -# including functions from myElectromagnet -def exitHandler(): - print "Exiting" - myElectromagnet.off() - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -magnetState = False - -# Turn magnet on and off every 5 seconds -while(1): - magnetState = not magnetState - if (magnetState): - myElectromagnet.on() - else: - myElectromagnet.off() - print "Turning magnet", ("on" if magnetState else "off") - - time.sleep(5) diff --git a/peripheral/libupm/examples/python/groveemg.py b/peripheral/libupm/examples/python/groveemg.py deleted file mode 100644 index 898db26..0000000 --- a/peripheral/libupm/examples/python/groveemg.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_groveemg as upmGroveemg - -# Tested with the GroveEMG Muscle Signal Reader Sensor Module -# Instantiate a GroveEMG on analog pin A0 -myEMG = upmGroveemg.GroveEMG(0) - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This lets you run code on exit, including functions from myEMG -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -print "Calibrating...." -myEMG.calibrate() - -while (1): - print myEMG.value() - time.sleep(.1) diff --git a/peripheral/libupm/examples/python/grovegprs.py b/peripheral/libupm/examples/python/grovegprs.py deleted file mode 100644 index d441e38..0000000 --- a/peripheral/libupm/examples/python/grovegprs.py +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_grovegprs as sensorObj - -# Instantiate a GroveGPRS Module on UART 0 -sensor = sensorObj.GroveGPRS(0) - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - -# Set the baud rate, 19200 baud is the default. -if (sensor.setBaudRate(19200)): - print "Failed to set baud rate" - sys.exit(0) - - -usageStr = ("Usage:\n" -"If an argument is supplied on the command line, that argument is\n" -"sent to the module and the response is printed out.\n\n" -"If no argument is used, then the manufacturer and the current\n" -"saved profiles are queried and the results printed out.\n\n") -print usageStr - -# simple helper function to send a command and wait for a response -def sendCommand(sensor, cmd): - # commands need to be terminated with a carriage return - cmd += "\r"; - sensor.writeDataStr(cmd) - - # wait up to 1 second - if (sensor.dataAvailable(1000)): - print "Returned: ", - print sensor.readDataStr(1024) - else: - print "Timed out waiting for response" - - -if (len(sys.argv) > 1): - print "Sending command line argument (" + sys.argv[1] + ")..." - sendCommand(sensor, sys.argv[1]) -else: - # query the module manufacturer - print "Querying module manufacturer (AT+CGMI)..." - sendCommand(sensor, "AT+CGMI"); - - time.sleep(1); - - # query the saved profiles - print "Querying the saved profiles (AT&V)..." - sendCommand(sensor, "AT&V"); - - # A comprehensive list is available from the datasheet at: - # http://www.seeedstudio.com/wiki/images/7/72/AT_Commands_v1.11.pdf diff --git a/peripheral/libupm/examples/python/grovegsr.py b/peripheral/libupm/examples/python/grovegsr.py deleted file mode 100644 index 993a6b0..0000000 --- a/peripheral/libupm/examples/python/grovegsr.py +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_grovegsr as upmGrovegsr - -# Tested with the GroveGSR Galvanic Skin Response Sensor module. - -# Instantiate a GroveGSR on analog pin A0 -myGSR = upmGrovegsr.GroveGSR(0) - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This lets you run code on exit, including functions from myGSR -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -print "Calibrating...." -myGSR.calibrate() - -while (1): - print myGSR.value() - time.sleep(.5) diff --git a/peripheral/libupm/examples/python/groveled.py b/peripheral/libupm/examples/python/groveled.py deleted file mode 100644 index eb104bf..0000000 --- a/peripheral/libupm/examples/python/groveled.py +++ /dev/null @@ -1,41 +0,0 @@ -# Author: Sarah Knepper <sarah.knepper@intel.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time -import pyupm_grove as grove - -# Create the Grove LED object using GPIO pin 2 -led = grove.GroveLed(2) - -# Print the name -print led.name() - -# Turn the LED on and off 10 times, pausing one second -# between transitions -for i in range (0,10): - led.on() - time.sleep(1) - led.off() - time.sleep(1) - -# Delete the Grove LED object -del led diff --git a/peripheral/libupm/examples/python/groveledbar.py b/peripheral/libupm/examples/python/groveledbar.py deleted file mode 100644 index 39d8462..0000000 --- a/peripheral/libupm/examples/python/groveledbar.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_my9221 as upmMy9221 - -# Instantiate a MY9221, we use D8 for the data, and D9 for the -# data clock. This was tested with a Grove LED bar. -myLEDBar = upmMy9221.GroveLEDBar(8, 9) - - -# Exit handlers -def SIGINTHandler(signum, frame): - raise SystemExit - -def exitHandler(): - myLEDBar.setBarLevel(0, True) - print "Exiting" - sys.exit(0) - -# This function lets you run code on exit -atexit.register(exitHandler) -# This function stops python from printing a stacktrace when you hit control-C -signal.signal(signal.SIGINT, SIGINTHandler) - - -directionBool = True -level = 1 - -x = 0 -while(1): - # If it's less than 10 - # light up the LED now - # call show_LED again in 50 ms - if (level <= 10): - myLEDBar.setBarLevel(level, directionBool) - level += 1 - # Switch LED lighting directions between lighting cycles - else: - directionBool = not directionBool - level = 1 - time.sleep(1) - time.sleep(.05) - x += 1 diff --git a/peripheral/libupm/examples/python/grovelight.py b/peripheral/libupm/examples/python/grovelight.py deleted file mode 100644 index a1939d7..0000000 --- a/peripheral/libupm/examples/python/grovelight.py +++ /dev/null @@ -1,37 +0,0 @@ -# Author: Sarah Knepper <sarah.knepper@intel.com> -# Copyright (c) 2014 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time -import pyupm_grove as grove - -# Create the light sensor object using AIO pin 0 -light = grove.GroveLight(0) - -# Read the input and print both the raw value and a rough lux value, -# waiting one second between readings -while 1: - print light.name() + " raw value is %d" % light.raw_value() + \ - ", which is roughly %d" % light.value() + " lux"; - time.sleep(1) - -# Delete the light sensor object -del light diff --git a/peripheral/libupm/examples/python/grovelinefinder.py b/peripheral/libupm/examples/python/grovelinefinder.py deleted file mode 100644 index bdcd68a..0000000 --- a/peripheral/libupm/examples/python/grovelinefinder.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_grovelinefinder as upmGrovelinefinder - -# Instantiate a Grove line finder sensor on digital pin D2 -myLineFinder = upmGrovelinefinder.GroveLineFinder(2) - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, including functions from myLineFinder -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -while(1): - if (myLineFinder.whiteDetected()): - print "White detected." - else: - print "Black detected." - time.sleep(1) diff --git a/peripheral/libupm/examples/python/grovemd-stepper.py b/peripheral/libupm/examples/python/grovemd-stepper.py deleted file mode 100644 index 7bafae5..0000000 --- a/peripheral/libupm/examples/python/grovemd-stepper.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time -import pyupm_grovemd as upmGrovemd - -I2C_BUS = upmGrovemd.GROVEMD_I2C_BUS -I2C_ADDR = upmGrovemd.GROVEMD_DEFAULT_I2C_ADDR - -# Instantiate an I2C Grove Motor Driver on I2C bus 0 -myMotorDriver = upmGrovemd.GroveMD(I2C_BUS, I2C_ADDR) - -# This example demonstrates using the GroveMD to drive a stepper motor - -# configure it, for this example, we'll assume 200 steps per rev -myMotorDriver.configStepper(200) - -# set for half a rotation -myMotorDriver.setStepperSteps(100) - -# let it go - clockwise rotation, 10 RPM speed -myMotorDriver.enableStepper(upmGrovemd.GroveMD.STEP_DIR_CW, 10) - -time.sleep(3) - -# Now do it backwards... -myMotorDriver.setStepperSteps(100) -myMotorDriver.enableStepper(upmGrovemd.GroveMD.STEP_DIR_CCW, 10) - -# now disable -myMotorDriver.disableStepper() - diff --git a/peripheral/libupm/examples/python/grovemd.py b/peripheral/libupm/examples/python/grovemd.py deleted file mode 100644 index ac4243d..0000000 --- a/peripheral/libupm/examples/python/grovemd.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time -import pyupm_grovemd as upmGrovemd - -I2C_BUS = upmGrovemd.GROVEMD_I2C_BUS -I2C_ADDR = upmGrovemd.GROVEMD_DEFAULT_I2C_ADDR - -# Instantiate an I2C Grove Motor Driver on I2C bus 0 -myMotorDriver = upmGrovemd.GroveMD(I2C_BUS, I2C_ADDR) - - -# set direction to CW and set speed to 50% -print "Spin M1 and M2 at half speed for 3 seconds" -myMotorDriver.setMotorDirections(upmGrovemd.GroveMD.DIR_CW, upmGrovemd.GroveMD.DIR_CW) -myMotorDriver.setMotorSpeeds(127, 127) - -time.sleep(3) -# counter clockwise -print "Reversing M1 and M2 for 3 seconds" -myMotorDriver.setMotorDirections(upmGrovemd.GroveMD.DIR_CCW, -upmGrovemd.GroveMD.DIR_CCW) -time.sleep(3) - -print "Stopping motors" -myMotorDriver.setMotorSpeeds(0, 0) diff --git a/peripheral/libupm/examples/python/grovemoisture.py b/peripheral/libupm/examples/python/grovemoisture.py deleted file mode 100644 index 78d3fe4..0000000 --- a/peripheral/libupm/examples/python/grovemoisture.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_grovemoisture as upmMoisture - -# Instantiate a Grove Moisture sensor on analog pin A0 -myMoisture = upmMoisture.GroveMoisture(0) - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, including functions from myMoisture -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -# Values (approximate): -# 0-300, sensor in air or dry soil -# 300-600, sensor in humid soil -# 600+, sensor in wet soil or submerged in water - -# Read the value every second and print the corresponding moisture level -while(1): - moisture_val = myMoisture.value() - if (moisture_val >= 0 and moisture_val < 300): - result = "Dry" - elif (moisture_val >= 300 and moisture_val < 600): - result = "Moist" - else: - result = "Wet" - print "Moisture value: {0}, {1}".format(moisture_val, result) - time.sleep(1) diff --git a/peripheral/libupm/examples/python/groveo2.py b/peripheral/libupm/examples/python/groveo2.py deleted file mode 100644 index 03f612b..0000000 --- a/peripheral/libupm/examples/python/groveo2.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_groveo2 as upmGroveo2 - -# This was tested with the O2 Oxygen Concentration Sensor Module -# Instantiate a GroveO2 on analog pin A0 -myGroveO2 = upmGroveo2.GroveO2(0) - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This lets you run code on exit, including functions from myGroveO2 -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -while(1): - print "The output voltage is: {0}mV".format( - myGroveO2.voltageValue()) - - time.sleep(.1) diff --git a/peripheral/libupm/examples/python/groverelay.py b/peripheral/libupm/examples/python/groverelay.py deleted file mode 100644 index 44f033f..0000000 --- a/peripheral/libupm/examples/python/groverelay.py +++ /dev/null @@ -1,44 +0,0 @@ -# Author: Sarah Knepper <sarah.knepper@intel.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time -import pyupm_grove as grove - -# Create the relay switch object using GPIO pin 0 -relay = grove.GroveRelay(0) - -# Close and then open the relay switch 3 times, -# waiting one second each time. The LED on the relay switch -# will light up when the switch is on (closed). -# The switch will also make a noise between transitions. -for i in range (0,3): - relay.on() - if relay.isOn(): - print relay.name(), 'is on' - time.sleep(1) - relay.off() - if relay.isOff(): - print relay.name(), 'is off' - time.sleep(1) - -# Delete the relay switch object -del relay diff --git a/peripheral/libupm/examples/python/groverotary.py b/peripheral/libupm/examples/python/groverotary.py deleted file mode 100644 index 6d62c3c..0000000 --- a/peripheral/libupm/examples/python/groverotary.py +++ /dev/null @@ -1,45 +0,0 @@ -# Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com> -# Copyright (c) 2014 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -from time import sleep -import pyupm_grove as grove - -# New knob on AIO pin 0 -knob = grove.GroveRotary(0) - -# Loop indefinitely -while True: - - # Read values - abs = knob.abs_value() - absdeg = knob.abs_deg() - absrad = knob.abs_rad() - - rel = knob.rel_value() - reldeg = knob.rel_deg() - relrad = knob.rel_rad() - - print "Abs values: %4d" % int(abs) , " raw %4d" % int(absdeg), "deg = %5.2f" % absrad , " rad ", - print "Rel values: %4d" % int(rel) , " raw %4d" % int(reldeg), "deg = %5.2f" % relrad , " rad" - - # Sleep for 2.5 s - sleep(2.5) diff --git a/peripheral/libupm/examples/python/grovescam.py b/peripheral/libupm/examples/python/grovescam.py deleted file mode 100644 index 53ede09..0000000 --- a/peripheral/libupm/examples/python/grovescam.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/python -# -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import sys -import pyupm_grovescam as upmGrovescam - -# Instantiate a Grove Serial Camera on UART 0 -camera = upmGrovescam.GROVESCAM(0) - -# make sure port is initialized properly. 115200 baud is the default. -if (not camera.setupTty()): - print "Failed to setup tty port parameters" - sys.exit(1) - -if (camera.init()): - print "Initialized..." -else: - print "init() failed" - -if (camera.preCapture()): - print "preCapture succeeded..." -else: - print "preCapture failed." - -if (camera.doCapture()): - print "doCapture succeeded..." -else: - print "doCapture failed." - -print "Image size is", camera.getImageSize(), "bytes" - -if (camera.getImageSize() > 0): - print "Storing image.jpg..." - if (camera.storeImage("image.jpg")): - print "storeImage succeeded..." - else: - print "storeImage failed." - -print "Exiting." -sys.exit(0) diff --git a/peripheral/libupm/examples/python/groveslide.py b/peripheral/libupm/examples/python/groveslide.py deleted file mode 100644 index 894fdc8..0000000 --- a/peripheral/libupm/examples/python/groveslide.py +++ /dev/null @@ -1,39 +0,0 @@ -# Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com> -# Copyright (c) 2014 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -from time import sleep -import pyupm_grove as grove - -# New Grove Slider on AIO pin 0 -slider = grove.GroveSlide(0) - -# Loop indefinitely -while True: - - # Read values - raw = slider.raw_value() - volts = slider.voltage_value() - - print "Slider value: ", raw , " = %.2f" % volts , " V" - - # Sleep for 2.5 s - sleep(2.5) diff --git a/peripheral/libupm/examples/python/grovespeaker.py b/peripheral/libupm/examples/python/grovespeaker.py deleted file mode 100644 index 6e53b3c..0000000 --- a/peripheral/libupm/examples/python/grovespeaker.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_grovespeaker as upmGrovespeaker - -# Instantiate a Grove Speaker on digital pin D2 -mySpeaker = upmGrovespeaker.GroveSpeaker(2) - -# Play all 7 of the lowest notes -mySpeaker.playAll() - -# Play a medium C-sharp -mySpeaker.playSound('c', True, "med") diff --git a/peripheral/libupm/examples/python/grovetemp.py b/peripheral/libupm/examples/python/grovetemp.py deleted file mode 100644 index bd9cc24..0000000 --- a/peripheral/libupm/examples/python/grovetemp.py +++ /dev/null @@ -1,41 +0,0 @@ -# Author: Brendan Le Foll <brendan.le.foll@intel.com> -# Contributions: Sarah Knepper <sarah.knepper@intel.com> -# Copyright (c) 2014 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time -import pyupm_grove as grove - -# Create the temperature sensor object using AIO pin 0 -temp = grove.GroveTemp(0) -print temp.name() - -# Read the temperature ten times, printing both the Celsius and -# equivalent Fahrenheit temperature, waiting one second between readings -for i in range(0, 10): - celsius = temp.value() - fahrenheit = celsius * 9.0/5.0 + 32.0; - print "%d degrees Celsius, or %d degrees Fahrenheit" \ - % (celsius, fahrenheit) - time.sleep(1) - -# Delete the temperature sensor object -del temp diff --git a/peripheral/libupm/examples/python/grovevdiv.py b/peripheral/libupm/examples/python/grovevdiv.py deleted file mode 100644 index 7719277..0000000 --- a/peripheral/libupm/examples/python/grovevdiv.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_grovevdiv as upmGrovevdiv - -# Instantiate a Grove Voltage Divider sensor on analog pin A0 -myVoltageDivider = upmGrovevdiv.GroveVDiv(0) - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, -# including functions from myVoltageDivider -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -while(1): - val = myVoltageDivider.value(100) - gain3val = myVoltageDivider.computedValue(3, val) - gain10val = myVoltageDivider.computedValue(10, val) - print "ADC value: {0} Gain 3: {1}v Gain 10: {2}v".format( - val, gain3val, gain10val) - - time.sleep(1) diff --git a/peripheral/libupm/examples/python/grovewater.py b/peripheral/libupm/examples/python/grovewater.py deleted file mode 100644 index 54a3d14..0000000 --- a/peripheral/libupm/examples/python/grovewater.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_grovewater as upmGrovewater - -# Instantiate a Grove Water sensor on digital pin D2 -myWaterSensor = upmGrovewater.GroveWater(2) - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, including functions from myWaterSensor -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -while(1): - if (myWaterSensor.isWet()): - print "Sensor is wet" - else: - print "Sensor is dry" - time.sleep(1) diff --git a/peripheral/libupm/examples/python/grovewfs.py b/peripheral/libupm/examples/python/grovewfs.py deleted file mode 100644 index 84c5a97..0000000 --- a/peripheral/libupm/examples/python/grovewfs.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_grovewfs as upmGrovewfs - -# Instantiate a Grove Water Flow Sensor on digital pin D2 -myWaterFlow = upmGrovewfs.GroveWFS(2) - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, -# including functions from myWaterFlow -def exitHandler(): - myWaterFlow.stopFlowCounter() - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -# set the flow counter to 0 and start counting -myWaterFlow.clearFlowCounter() -myWaterFlow.startFlowCounter() - -while (1): - # we grab these (millis and flowCount) just for display - # purposes in this example - millis = myWaterFlow.getMillis() - flowCount = myWaterFlow.flowCounter() - - fr = myWaterFlow.flowRate() - - # output milliseconds passed, flow count, and computed flow rate - outputStr = "Millis: {0} Flow Count: {1} Flow Rate: {2} LPM".format( - millis, flowCount, fr) - print outputStr - time.sleep(2) diff --git a/peripheral/libupm/examples/python/guvas12d.py b/peripheral/libupm/examples/python/guvas12d.py deleted file mode 100644 index dca8de8..0000000 --- a/peripheral/libupm/examples/python/guvas12d.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_guvas12d as upmUV - -# Instantiate a UV sensor on analog pin A0 -myUVSensor = upmUV.GUVAS12D(0); - -# analog voltage, usually 3.3 or 5.0 -GUVAS12D_AREF = 5.0; -SAMPLES_PER_QUERY = 1024; - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, including functions from myUVSensor -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -while(1): - s = ("AREF: {0}, " - "Voltage value (higher means more UV): " - "{1}".format(GUVAS12D_AREF, - myUVSensor.value(GUVAS12D_AREF, SAMPLES_PER_QUERY))) - print s - time.sleep(1) diff --git a/peripheral/libupm/examples/python/h3lis331dl.py b/peripheral/libupm/examples/python/h3lis331dl.py deleted file mode 100644 index 60142f5..0000000 --- a/peripheral/libupm/examples/python/h3lis331dl.py +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_h3lis331dl as upmH3LIS331DL - -# Instantiate an H3LIS331DL on I2C bus 0 -myDigitalAccelerometer = upmH3LIS331DL.H3LIS331DL( - upmH3LIS331DL.H3LIS331DL_I2C_BUS, - upmH3LIS331DL.H3LIS331DL_DEFAULT_I2C_ADDR); - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, including functions from myDigitalAccelerometer -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -# Initialize the device with default values -myDigitalAccelerometer.init() - -x = upmH3LIS331DL.new_intp() -y = upmH3LIS331DL.new_intp() -z = upmH3LIS331DL.new_intp() - -ax = upmH3LIS331DL.new_floatp() -ay = upmH3LIS331DL.new_floatp() -az = upmH3LIS331DL.new_floatp() - -while (1): - myDigitalAccelerometer.update() - myDigitalAccelerometer.getRawXYZ(x, y, z) - outputStr = ("Raw: X = {0}" - " Y = {1}" - " Z = {2}").format(upmH3LIS331DL.intp_value(x), - upmH3LIS331DL.intp_value(y), - upmH3LIS331DL.intp_value(z)) - print outputStr - - myDigitalAccelerometer.getAcceleration(ax, ay, az) - outputStr = ("Acceleration: AX = {0}" - " AY = {1}" - " AZ = {2}").format(upmH3LIS331DL.floatp_value(ax), - upmH3LIS331DL.floatp_value(ay), - upmH3LIS331DL.floatp_value(az)) - print outputStr - time.sleep(.5) diff --git a/peripheral/libupm/examples/python/hdxxvxta.py b/peripheral/libupm/examples/python/hdxxvxta.py deleted file mode 100644 index c539d90..0000000 --- a/peripheral/libupm/examples/python/hdxxvxta.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2016 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_hdxxvxta as sensorObj - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - -print "Initializing..." - -# Instantiate an HDXXVXTA instance, using A1 for humidity and A0 -# for temperature -sensor = sensorObj.HDXXVXTA(1, 0) - -# update and print available values every second -while (1): - # update our values from the sensor - sensor.update() - - # we show both C and F for temperature - print "Temperature:", sensor.getTemperature(), "C /", - print sensor.getTemperature(True), "F" - - print "Humidity:", sensor.getHumidity(), "%" - - print - time.sleep(1) diff --git a/peripheral/libupm/examples/python/hm11.py b/peripheral/libupm/examples/python/hm11.py deleted file mode 100644 index c20a8ea..0000000 --- a/peripheral/libupm/examples/python/hm11.py +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_hm11 as upmHm11 - -# Instantiate a HM11 BLE Module on UART 0 -my_ble_obj = upmHm11.HM11(0) - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, -# including functions from my_ble_obj -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -bufferLength = 256 - -# make sure port is initialized properly. 9600 baud is the default. -if (not my_ble_obj.setupTty(upmHm11.cvar.int_B9600)): - print "Failed to setup tty port parameters" - sys.exit(0) - - -usageStr = ("Usage:\n" -"Pass a commandline argument (any argument) to this program\n" -"to query the radio configuration and output it. NOTE: the\n" -"radio must be in CONFIG mode for this to work.\n\n" -"Running this program without arguments will simply transmit\n" -"'Hello World!' every second, and output any data received from\n" -"another radio.\n\n") -print usageStr - -# simple helper function to send a command and wait for a response -def sendCommand(bleObj, cmd): - bleBuffer = upmHm11.charArray(bufferLength) - bleObj.writeData(cmd, len(cmd)) - - # wait up to 1 second - if (bleObj.dataAvailable(1000)): - bleObj.readData(bleBuffer, bufferLength) - bleData = "" - # read only the number of characters - # specified by myGPSSensor.readData - for x in range(0, bufferLength): - if (bleBuffer.__getitem__(x) == '\0'): - break - else: - bleData += bleBuffer.__getitem__(x) - print bleData - else: - print "Timed out waiting for response" - - -if (len(sys.argv) > 1): - print "Sending command line argument (" + sys.argv[1] + ")..." - sendCommand(my_ble_obj, sys.argv[1]) -else: - # query the module address - addr = "AT+ADDR?"; - print "Querying module address (" + addr + ")..." - - sendCommand(my_ble_obj, addr) - time.sleep(1) - # query the module address - pin = "AT+PASS?"; - print "Querying module PIN (" + pin + ")..." - sendCommand(my_ble_obj, pin) - - # Other potentially useful commands are: - # - # AT+VERS? - query module version - # AT+ROLE0 - set as slave - # AT+ROLE1 - set as master - # AT+CLEAR - clear all previous settings - # AT+RESET - restart the device - # - # A comprehensive list is available from the datasheet at: - # http://www.seeedstudio.com/wiki/images/c/cd/Bluetooth4_en.pdf - diff --git a/peripheral/libupm/examples/python/hmc5883l.py b/peripheral/libupm/examples/python/hmc5883l.py deleted file mode 100644 index 5043073..0000000 --- a/peripheral/libupm/examples/python/hmc5883l.py +++ /dev/null @@ -1,44 +0,0 @@ -# Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -from time import sleep -import pyupm_hmc5883l as hmc5883l - -# Create an I2C compass object and set declination -hmc = hmc5883l.Hmc5883l(0) -hmc.set_declination(0.2749) - -# Loop indefinitely -while True: - - hmc.update() # Update the data - pos = hmc.coordinates() # Read raw coordinates - hdg = hmc.heading() # Read heading - dir = hmc.direction() # Read direction - - # Print values - print "Coor: %5d %5d %5d" % (pos[0], pos[1], pos[2]) - print "Heading: %5.2f" % (hdg) - print "Direction: %3.2f\n" % (dir) - - # Sleep for 1 s - sleep(1) diff --git a/peripheral/libupm/examples/python/hmtrp.py b/peripheral/libupm/examples/python/hmtrp.py deleted file mode 100644 index dd2298f..0000000 --- a/peripheral/libupm/examples/python/hmtrp.py +++ /dev/null @@ -1,143 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_hmtrp as upmHmtrp - -# Instantiate a HMTRP radio device on uart 0 -my_HMTRP_Radio = upmHmtrp.HMTRP(0) - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, -# including functions from my_HMTRP_Radio -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -myCounter = 0 - -# normal read/write mode -bufferLength = 256 -radioBuffer = upmHmtrp.charArray(bufferLength) - -# make sure port is initialized properly. 9600 baud is the default. -if (not my_HMTRP_Radio.setupTty(upmHmtrp.cvar.int_B9600)): - print "Failed to setup tty port parameters" - sys.exit(0) - - -usageStr = ("Usage:\n" -"Pass a commandline argument (any argument) to this program\n" -"to query the radio configuration and output it. NOTE: the\n" -"radio must be in CONFIG mode for this to work.\n\n" -"Running this program without arguments will simply transmit\n" -"'Hello World!' every second, and output any data received from\n" -"another radio.\n\n") -print usageStr - -''' -By default, this radio simply transmits data sent via writeData() -and reads any available data via readData(). - -It can be placed into a configuration mode by grounding the -CONFIG pin on the module. When this is done, the various -configuration query and config methods can be used. In this -example, by default, we just read any data available fom the -device, and periodically transmit "Hello World". - -If any argument was specified on the command line, do a simple -configuration query and output the results. The radio must be in -CONFIG mode for this to work. - - -Note that the first command-line argument should be "hmtry.py" -The data we want would be the second... if it exists -''' -if (len(sys.argv) > 1): - # config mode - freq = upmHmtrp.uint32Array(0) - dataRate = upmHmtrp.uint32Array(0) - rxBandwidth = upmHmtrp.uint16Array(0) - modulation = upmHmtrp.uint8Array(0) - txPower = upmHmtrp.uint8Array(0) - uartBaud = upmHmtrp.uint32Array(0) - - if (my_HMTRP_Radio.getConfig(freq, dataRate, rxBandwidth, - modulation, txPower, uartBaud)): - print "Radio configuration:" - outputStr = ("freq: {0} dataRate: {1} " - "rxBandwidth: {2}Khz").format(freq.__getitem__(0), - dataRate.__getitem__(0), - rxBandwidth.__getitem__(0)) - print outputStr - - outputStr = "modulation: %d Khz txPower: %d uartBaud: %d" % ( - modulation.__getitem__(0), txPower.__getitem__(0), - uartBaud.__getitem__(0)) - print outputStr - else: - errString = ("getConfig() failed. Make sure the radio " - "is in CONFIG mode.") - print errString -else: - print "Running in normal read/write mode." - while (1): - # we don't want the read to block in this example, so always - # check to see if data is available first. - if (my_HMTRP_Radio.dataAvailable()): - rv = my_HMTRP_Radio.readData(radioBuffer, bufferLength) - - if (rv > 0): - resultStr = ""; - for x in range(rv): - resultStr += radioBuffer.__getitem__(x) - print "Received:", resultStr - - if (rv < 0): # some sort of read error occured - print "Port read error." - sys.exit(0) - myCounter += 1 - # every second, transmit "Hello World" - if (myCounter > 10): - msg = "Hello World!" - - print "Transmitting %s..." % msg - - # Adding 1 for NULL terminator. - # Note that SWIG automatically adds a NULL terminator, - # so no need to NULL-terminate ourselves. - # Just increment the message length to include - # the NULL that's already there - my_HMTRP_Radio.writeData(msg, (len(msg) + 1)) - myCounter = 0 - time.sleep(.1) diff --git a/peripheral/libupm/examples/python/hp20x.py b/peripheral/libupm/examples/python/hp20x.py deleted file mode 100644 index f0ae5e6..0000000 --- a/peripheral/libupm/examples/python/hp20x.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_hp20x as barometerObj - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, -# including functions from ringCoder -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - -# Instantiate an HP20X on default I2C bus and address -bar = barometerObj.HP20X() - -# Initialize the device with default values -bar.init() - -while(1): - print "Temperature:", bar.getTemperature(), "Celcius" - print "Pressure: ", bar.getPressure(), "Millibars" - print "Altitude: ", bar.getAltitude(), "Meters" - print - time.sleep(1) - diff --git a/peripheral/libupm/examples/python/ht9170.py b/peripheral/libupm/examples/python/ht9170.py deleted file mode 100644 index 838b0cc..0000000 --- a/peripheral/libupm/examples/python/ht9170.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_ht9170 as upmHt9170 - -# Instantiate a DTMF decoder -myDTMF = upmHt9170.HT9170(12, 11, 10, 9, 8) - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This lets you run code on exit, including functions from myDTMF -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -# Now we just spin in a loop, sleeping every 100ms, checking to see -# if a digit is available. If so, we decode and print the digit, -# and continue looping. -while (1): - if (dtmf_obj.digitReady()): - print "Got DTMF code:", dtmf_obj.decodeDigit() - # now spin until digitReady() goes false again - while (dtmf.digitReady()): - pass - time.sleep(.1) diff --git a/peripheral/libupm/examples/python/hwxpxx.py b/peripheral/libupm/examples/python/hwxpxx.py deleted file mode 100644 index 0def995..0000000 --- a/peripheral/libupm/examples/python/hwxpxx.py +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2016 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_hwxpxx as sensorObj - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit -def exitHandler(): - print "Exiting..." - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - -defaultDev = "/dev/ttyUSB0" - -# if an argument was specified, use it as the device instead -if (len(sys.argv) > 1): - defaultDev = sys.argv[1] - -print "Using device", defaultDev -print "Initializing..." - -# Instantiate an HWXPXX instance, using MODBUS slave address 3, and -# default comm parameters (19200, 8, N, 2) -sensor = sensorObj.HWXPXX(defaultDev, 3) - -# output the serial number and firmware revision -print "Slave ID:", sensor.getSlaveID() - -# stored temperature and humidity offsets -print "Temperature Offset:", sensor.getTemperatureOffset() -print "Humidity Offset:", sensor.getHumidityOffset() - -print - -# update and print available values every second -while (1): - # update our values from the sensor - sensor.update() - - # we show both C and F for temperature - print "Temperature:", sensor.getTemperature(), "C /", - print sensor.getTemperature(True), "F" - - print "Humidity:", sensor.getHumidity(), "%" - - print "Slider:", sensor.getSlider(), "%" - - print "Override Switch Status:", sensor.getOverrideSwitchStatus() - - print - time.sleep(1) diff --git a/peripheral/libupm/examples/python/ili9341.py b/peripheral/libupm/examples/python/ili9341.py deleted file mode 100644 index 5194cc3..0000000 --- a/peripheral/libupm/examples/python/ili9341.py +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/python -# Author: Shawn Hymel -# Copyright (c) 2016 SparkFun Electronics -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time -import pyupm_ili9341 as ili9341 - -# Pins (Edison) -# CS_LCD GP44 (MRAA 31) -# CS_SD GP43 (MRAA 38) unused -# DC GP12 (MRAA 20) -# RESEST GP13 (MRAA 14) -lcd = ili9341.ILI9341(31, 38, 20, 14) - -# Fill the screen with a solid color -lcd.fillScreen(lcd.color565(0, 40, 16)) - -# Draw some shapes -lcd.drawFastVLine(10, 10, 100, ili9341.ILI9341_RED) -lcd.drawFastHLine(20, 10, 50, ili9341.ILI9341_CYAN) -lcd.drawLine(160, 30, 200, 60, ili9341.ILI9341_GREEN) -lcd.fillRect(20, 30, 75, 60, ili9341.ILI9341_ORANGE) -lcd.drawCircle(70, 50, 20, ili9341.ILI9341_PURPLE) -lcd.fillCircle(120, 50, 20, ili9341.ILI9341_PURPLE) -lcd.drawTriangle(50, 100, 10, 140, 90, 140, ili9341.ILI9341_YELLOW) -lcd.fillTriangle(150, 100, 110, 140, 190, 140, ili9341.ILI9341_YELLOW) -lcd.drawRoundRect(20, 150, 50, 30, 10, ili9341.ILI9341_RED) -lcd.drawRoundRect(130, 150, 50, 30, 10, ili9341.ILI9341_RED) -lcd.fillRoundRect(75, 150, 50, 30, 10, ili9341.ILI9341_RED) - -# Write some text -lcd.setCursor(0, 200) -lcd.setTextColor(ili9341.ILI9341_LIGHTGREY) -lcd.setTextWrap(True) -lcd.setTextSize(1) -lcd._print("Text 1\n") -lcd.setTextSize(2) -lcd._print("Text 2\n") -lcd.setTextSize(3) -lcd._print("Text 3\n") -lcd.setTextSize(4) -lcd._print("Text 4\n") - -# Test screen rotation -for r in range(0, 4): - lcd.setRotation(r) - lcd.fillRect(0, 0, 5, 5, ili9341.ILI9341_WHITE) - time.sleep(1) - -# Invert colors, wait, then revert back -lcd.invertDisplay(True) -time.sleep(2) -lcd.invertDisplay(False) - -# Don't forget to free up that memory! -del lcd
\ No newline at end of file diff --git a/peripheral/libupm/examples/python/ina132.py b/peripheral/libupm/examples/python/ina132.py deleted file mode 100644 index 8db4862..0000000 --- a/peripheral/libupm/examples/python/ina132.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - -import time, sys, signal, atexit -import pyupm_ina132 as upmIna132 - -# Tested with the INA132 Differential Amplifier Sensor module. -# Instantiate an INA132 on analog pin A0 -myDifferentialAmplifier = upmIna132.INA132(0) - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This lets you run code on exit, -# including functions from myDifferentialAmplifier -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -while(1): - print myDifferentialAmplifier.value() - time.sleep(1) diff --git a/peripheral/libupm/examples/python/isd1820.py b/peripheral/libupm/examples/python/isd1820.py deleted file mode 100644 index f39f477..0000000 --- a/peripheral/libupm/examples/python/isd1820.py +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, atexit -import pyupm_isd1820 as upmIsd1820 - -# Instantiate a ISD1820 on digital pins 2 (play) and 3 (record) -# This example was tested on the Grove Recorder. -myRecorder = upmIsd1820.ISD1820(2, 3) - - -doRecord = False - -if len(sys.argv) > 1: - doRecord = True - - -# This lets you run code on exit, -# including functions from myRecorder -def exitHandler(): - # turn off whatever we were doing. - if (doRecord): - myRecorder.record(False) - else: - myRecorder.play(False) - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) - - -# if an argument was specified (any argument), go into record mode, -# else playback a previously recorded sample - -print "Supply any argument to the command line to record." -print "Running this example without arguments will play back any " -print "previously recorded sound." -print "There is approximately 10 seconds of recording time.\n" - - -# depending on what was selected, do it, and sleep for 15 seconds -if (doRecord): - myRecorder.record(True) -else: - myRecorder.play(True) - -# There are about 10 seconds of recording/playback time, so we will -# sleep for a little extra time. -print "Sleeping for 15 seconds..." -time.sleep(15) - - -# exitHandler runs automatically diff --git a/peripheral/libupm/examples/python/itg3200.py b/peripheral/libupm/examples/python/itg3200.py deleted file mode 100644 index cd4a7c4..0000000 --- a/peripheral/libupm/examples/python/itg3200.py +++ /dev/null @@ -1,42 +0,0 @@ -# Author: John Van Drasek <john.r.van.drasek@intel.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time -import pyupm_itg3200 as itg3200 - -# Create an I2C gyro object -gyro = itg3200.Itg3200(0) - -while(1): - gyro.update() # Update the data - rot = gyro.getRawValues() # Read raw sensor data - ang = gyro.getRotation() # Read rotational speed (deg/sec) - print "Raw: %6d %6d %6d" % (rot[0], rot[1], rot[2]) - print "AngX: %5.2f" % (ang[0]) - print "AngY: %5.2f" % (ang[1]) - print "AngZ: %5.2f" % (ang[2]) - print "Temp: %5.2f Raw: %6d" % (gyro.getTemperature(), gyro.getRawTemp()) - print ' ' - time.sleep(1) - -# Delete the gyro object -del gyro diff --git a/peripheral/libupm/examples/python/jhd1313m1-lcd.py b/peripheral/libupm/examples/python/jhd1313m1-lcd.py deleted file mode 100644 index fc0bc65..0000000 --- a/peripheral/libupm/examples/python/jhd1313m1-lcd.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/python -# Author: Brendan Le Foll <brendan.le.foll@intel.com> -# Copyright (c) 2014 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import pyupm_i2clcd as lcd - -# Initialize Jhd1313m1 at 0x3E (LCD_ADDRESS) and 0x62 (RGB_ADDRESS) -myLcd = lcd.Jhd1313m1(0, 0x3E, 0x62) - -myLcd.setCursor(0,0) -# RGB Blue -#myLcd.setColor(53, 39, 249) - -# RGB Red -myLcd.setColor(255, 0, 0) - -myLcd.write('Hello World') -myLcd.setCursor(1,2) -myLcd.write('Hello World') diff --git a/peripheral/libupm/examples/python/joystick12.py b/peripheral/libupm/examples/python/joystick12.py deleted file mode 100644 index eaae149..0000000 --- a/peripheral/libupm/examples/python/joystick12.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_joystick12 as upmJoystick12 - -# Instantiate a joystick on analog pins A0 and A1 -myJoystick = upmJoystick12.Joystick12(0, 1) - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, including functions from myJoystick -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -# Print the X and Y input values every second -while(1): - XString = "Driving X:" + str(myJoystick.getXInput()) - YString = ": and Y:" + str(myJoystick.getYInput()) - print XString + YString - - time.sleep(1) diff --git a/peripheral/libupm/examples/python/l298-stepper.py b/peripheral/libupm/examples/python/l298-stepper.py deleted file mode 100644 index cfac86f..0000000 --- a/peripheral/libupm/examples/python/l298-stepper.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - -import time, sys, signal, atexit -import pyupm_l298 as upmL298 - -# Instantiate a Stepper motor on a L298 Dual H-Bridge. -# This was tested with the NEMA-17 12V, 350mA, with 200 steps per rev. -myHBridge = upmL298.L298(200, 3, 4, 7, 8, 9) - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This lets you run code on exit, -# including functions from myHBridge -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -myHBridge.setSpeed(10) # 10 RPMs -myHBridge.setDirection(upmL298.L298.DIR_CW) -myHBridge.enable(True) - -print "Rotating 1 full revolution at 10 RPM speed." -# move 200 steps, a full rev -myHBridge.stepperSteps(200) - -print "Sleeping for 2 seconds..." -time.sleep(2) - -print "Rotating 1/2 revolution in opposite direction at 10 RPM speed." -myHBridge.setDirection(upmL298.L298.DIR_CCW) -myHBridge.stepperSteps(100) - -# release -myHBridge.enable(False) - -# exitHandler is called automatically diff --git a/peripheral/libupm/examples/python/l298.py b/peripheral/libupm/examples/python/l298.py deleted file mode 100644 index f0b507c..0000000 --- a/peripheral/libupm/examples/python/l298.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - -import time, sys, signal, atexit -import pyupm_l298 as upmL298 - -# Instantiate one of the 2 possible DC motors on a L298 Dual -# H-Bridge. For controlling a stepper motor, see the l298-stepper -# example. -myHBridge = upmL298.L298(3, 4, 7) - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This lets you run code on exit, -# including functions from myHBridge -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -print "Starting motor at 50% for 3 seconds..." -myHBridge.setSpeed(50) -myHBridge.setDirection(upmL298.L298.DIR_CW) -myHBridge.enable(True) - -time.sleep(3) - -print "Reversing direction..." -myHBridge.setDirection(upmL298.L298.DIR_NONE) # fast stop -myHBridge.setDirection(upmL298.L298.DIR_CCW) -time.sleep(3); - -myHBridge.setSpeed(0) -myHBridge.enable(False) - -# exitHandler is called automatically diff --git a/peripheral/libupm/examples/python/ldt0028.py b/peripheral/libupm/examples/python/ldt0028.py deleted file mode 100644 index b6001a7..0000000 --- a/peripheral/libupm/examples/python/ldt0028.py +++ /dev/null @@ -1,66 +0,0 @@ -# Author: Sarah Knepper <sarah.knepper@intel.com> -# Copyright (c) 2014 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time -import array -import pyupm_ldt0028 as ldt0028 - -NUMBER_OF_SECONDS = 10 -SAMPLES_PER_SECOND = 50 -THRESHOLD = 100 - -# Create the LDT0-028 Piezo Vibration Sensor object using AIO pin 0 -sensor = ldt0028.LDT0028(0) - -# Read the signal every 20 milliseconds for 10 seconds -print 'For the next', NUMBER_OF_SECONDS, 'seconds,', \ - SAMPLES_PER_SECOND, 'samples will be taken every second.\n' -buffer = array.array('H') -for i in range(0, NUMBER_OF_SECONDS * SAMPLES_PER_SECOND): - buffer.append(sensor.getSample()) - time.sleep(1.0/SAMPLES_PER_SECOND) - -# Print the number of times the reading was greater than the threshold -count = 0 -for i in range(0, NUMBER_OF_SECONDS * SAMPLES_PER_SECOND): - if buffer[i] > THRESHOLD: - count += 1 -print sensor.name(), ' exceeded the threshold value of', \ - THRESHOLD, 'a total of', count, 'times,' -print 'out of a total of', NUMBER_OF_SECONDS*SAMPLES_PER_SECOND, \ - 'reading.\n' - -# Print a graphical representation of the average value sampled -# each second for the past 10 seconds, using a scale factor of 15 -print 'Now printing a graphical representation of the average reading ' -print 'each second for the last', NUMBER_OF_SECONDS, 'seconds.' -SCALE_FACTOR = 15 -for i in range(0, NUMBER_OF_SECONDS): - sum = 0 - for j in range(0, SAMPLES_PER_SECOND): - sum += buffer[i*SAMPLES_PER_SECOND+j] - average = sum / SAMPLES_PER_SECOND - stars_to_print = int(round(average / SCALE_FACTOR)) - print '(' + repr(int(round(average))).rjust(4) + ') |', '*' * stars_to_print - -# Delete the sensor object -del sensor diff --git a/peripheral/libupm/examples/python/lm35.py b/peripheral/libupm/examples/python/lm35.py deleted file mode 100644 index 342f0a9..0000000 --- a/peripheral/libupm/examples/python/lm35.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_lm35 as sensorObj - -# Instantiate a LM35 on analog pin A0, with a default analog -# reference voltage of 5.0 -sensor = sensorObj.LM35(0) - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - -# Every half second, sample the sensor and output the temperature - -while (1): - print "Temperature:", sensor.getTemperature(), "C" - time.sleep(.5) diff --git a/peripheral/libupm/examples/python/loudness.py b/peripheral/libupm/examples/python/loudness.py deleted file mode 100644 index 1b4101b..0000000 --- a/peripheral/libupm/examples/python/loudness.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_loudness as sensorObj - -# Instantiate a Loudness sensor on analog pin A0, with an analog -# reference voltage of 5.0 -sensor = sensorObj.Loudness(0, 5.0) - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - -# Every tenth of a second, sample the loudness and output it's -# corresponding analog voltage. - -while (1): - print "Detected loudness (volts): ", sensor.loudness() - time.sleep(.1) diff --git a/peripheral/libupm/examples/python/lsm303.py b/peripheral/libupm/examples/python/lsm303.py deleted file mode 100644 index adc4cd2..0000000 --- a/peripheral/libupm/examples/python/lsm303.py +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/python - -# Author: Brendan Le Foll <brendan.le.foll@intel.com> -# Contributions: Zion Orent <zorent@ics.com> -# Copyright (c) 2014 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE - -import time, sys, signal, atexit -import pyupm_lsm303 as lsm303 - -# Instantiate LSM303 compass on I2C -myAccelrCompass = lsm303.LSM303(0) - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This lets you run code on exit, -# including functions from myAccelrCompass -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -while(1): - # Load coordinates into LSM303 object - successFail = myAccelrCompass.getCoordinates() - # in XYZ order. The sensor returns XZY, - # but the driver compensates and makes it XYZ - coords = myAccelrCompass.getRawCoorData() - - # Print out the X, Y, and Z coordinate data - # using two different methods - outputStr = "coor: rX {0} - rY {1} - rZ {2}".format( - coords.__getitem__(0), coords.__getitem__(1), - coords.__getitem__(2)) - print outputStr - - outputStr = "coor: gX {0} - gY {1} - gZ {2}".format( - myAccelrCompass.getCoorX(), myAccelrCompass.getCoorY(), - myAccelrCompass.getCoorZ()) - print outputStr - - # Get and print out the heading - print "heading:", myAccelrCompass.getHeading() - - # Get the acceleration - myAccelrCompass.getAcceleration(); - accel = myAccelrCompass.getRawAccelData(); - - # Print out the X, Y, and Z acceleration data - # using two different methods - outputStr = "acc: rX {0} - rY {1} - Z {2}".format( - accel.__getitem__(0), accel.__getitem__(1), accel.__getitem__(2)) - print outputStr - - outputStr = "acc: gX {0} - gY {1} - gZ {2}".format( - myAccelrCompass.getAccelX(), myAccelrCompass.getAccelY(), - myAccelrCompass.getAccelZ()) - print outputStr - - print " " - time.sleep(1) diff --git a/peripheral/libupm/examples/python/lsm9ds0.py b/peripheral/libupm/examples/python/lsm9ds0.py deleted file mode 100644 index 10edc94..0000000 --- a/peripheral/libupm/examples/python/lsm9ds0.py +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_lsm9ds0 as sensorObj - -# Instantiate an LSM9DS0 using default parameters (bus 1, gyro addr 6b, -# xm addr 1d) -sensor = sensorObj.LSM9DS0() - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - -sensor.init() - -x = sensorObj.new_floatp() -y = sensorObj.new_floatp() -z = sensorObj.new_floatp() - -while (1): - sensor.update() - sensor.getAccelerometer(x, y, z) - print "Accelerometer: AX: ", sensorObj.floatp_value(x), - print " AY: ", sensorObj.floatp_value(y), - print " AZ: ", sensorObj.floatp_value(z) - - sensor.getGyroscope(x, y, z) - print "Gyroscope: GX: ", sensorObj.floatp_value(x), - print " GY: ", sensorObj.floatp_value(y), - print " GZ: ", sensorObj.floatp_value(z) - - sensor.getMagnetometer(x, y, z) - print "Magnetometer: MX: ", sensorObj.floatp_value(x), - print " MY: ", sensorObj.floatp_value(y), - print " MZ: ", sensorObj.floatp_value(z) - - print "Temperature: ", sensor.getTemperature() - print - - time.sleep(.5) diff --git a/peripheral/libupm/examples/python/m24lr64e.py b/peripheral/libupm/examples/python/m24lr64e.py deleted file mode 100644 index 848181e..0000000 --- a/peripheral/libupm/examples/python/m24lr64e.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import sys -import pyupm_m24lr64e as nfcTagObj - -# Instantiate a M24LR64E Grove NFC Tag Module on UART 0 -nfcTag = nfcTagObj.M24LR64E(nfcTagObj.M24LR64E_I2C_BUS) - -# This example accesses the device in the 'user' (default) mode, -# reads the last byte of data in the EEPROM, inverts it, writes -# it back, and then re-reads it. - -# Read the last byte of the EEPROM area -addr = (nfcTagObj.M24LR64E.EEPROM_I2C_LENGTH - 1) -print "Address: ", addr -byte = nfcTag.readByte(addr) - -print "Read byte: ", format(byte, '02x') - -# Now change it to it's opposite and write it -byte = (~byte & 0xff) -nfcTag.writeByte(addr, byte) -print "Wrote inverted byte: ", format(byte, '02x') - -# Now read it back. -byte = nfcTag.readByte(addr) -print "Read byte: ", format(byte, '02x') - diff --git a/peripheral/libupm/examples/python/make_oled_pic.py b/peripheral/libupm/examples/python/make_oled_pic.py deleted file mode 100755 index 85b3ca0..0000000 --- a/peripheral/libupm/examples/python/make_oled_pic.py +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env python - -# Author: Brendan Le Foll <brendan.le.foll@intel.com> -# Copyright (c) 2014 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE - -from __future__ import print_function - -from PIL import Image -import sys - -# Pixels are arranged in one byte for 8 vertical pixels and not addressed individually -# We convert the image to greysacle and end up making it monochrome where we -# consider that every pixel that is '40' is black. - -width = 128 -height = 64 - -if len(sys.argv) != 2: - print('Please specify an image to use as the only argument') - exit(1) - -im = Image.open(sys.argv[1]) -im = im.convert('L').resize((width, height)) - -data = list(im.getdata()) - -byteblock = [0 for i in range(width)] -widthblock = [list(byteblock) for i in range(int(height/8))] -numblock = 0 -pixcount = 0 -i = 0 - -# we split the list by width * 8, to create data chunks of 8rows -datachunks=[data[x:x+(width*8)] for x in range(0, len(data), (width*8))] - -# grab every pixel of image (or datachunk) -while i < len(widthblock): - pixcount = 0 - for y in datachunks[i]: - xcoor = pixcount % width - ycoor = int(pixcount/width) - blknum = xcoor % len(widthblock) - blkycoor = ycoor - - # 40 is what we consider 'black' - if y > 40: - widthblock[i][xcoor] |= (1 << blkycoor) - - pixcount += 1 - i += 1 - -flatlist = [y for x in widthblock for y in x] - -carray = 'static uint8_t image[] = {\n' + ', '.join(str(x) for x in flatlist) -print(carray + '\n};') diff --git a/peripheral/libupm/examples/python/maxsonarez.py b/peripheral/libupm/examples/python/maxsonarez.py deleted file mode 100644 index 645ca58..0000000 --- a/peripheral/libupm/examples/python/maxsonarez.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_maxsonarez as MaxSonarEZ - -# Instantiate a MaxSonar-EZ on analog pin A1, with an analog -# reference voltage of MAXSONAREZ_AREF -Sonar = MaxSonarEZ.MAXSONAREZ(1) - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This lets you run code on exit, -# including functions from Sonar -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -# analog voltage, usually 3.3 or 5.0 -MAXSONAREZ_AREF = 5.0; - -# Every second, sample the sonar and output the distance to an -# object in inches. - -# With the EZ3 version, the minimum and maximum ranges seemed to be -# between 6 and 33 inches - -while (1): - print "AREF: {0}, distance in inches: {1}".format( - MAXSONAREZ_AREF, - Sonar.inches()) - time.sleep(1) diff --git a/peripheral/libupm/examples/python/mg811.py b/peripheral/libupm/examples/python/mg811.py deleted file mode 100644 index 78a75d8..0000000 --- a/peripheral/libupm/examples/python/mg811.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_mg811 as sensorObj - -# Instantiate an MG811 on analog pin A0, and digital pin D2 with an -# analog reference voltage of MG811_AREF (5.0) - -sensor = sensorObj.MG811(0, 2, 5.0) - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - -# Every tenth of a second, sample the sensor and output it's -# detected CO2 concentration in parts per million (ppm) - -while (1): - print "CO2 concentration in PPM: ", sensor.ppm() - time.sleep(.1) diff --git a/peripheral/libupm/examples/python/mhz16.py b/peripheral/libupm/examples/python/mhz16.py deleted file mode 100644 index 4fa0615..0000000 --- a/peripheral/libupm/examples/python/mhz16.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_mhz16 as upmMhz16 - -# Instantiate a MHZ16 serial CO2 sensor on uart 0. -# This example was tested on the Grove CO2 sensor module. -myCO2 = upmMhz16.MHZ16(0) - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, -# including functions from myCO2 -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -# make sure port is initialized properly. 9600 baud is the default. -if (not myCO2.setupTty(upmMhz16.cvar.int_B9600)): - print "Failed to setup tty port parameters" - sys.exit(0) - -print ("Make sure that the sensor has had " -"at least 3 minutes to warm up\n" -"or you will not get valid results.\n" -"The temperature reported is not the ambient temperature,\n" -"but rather the temperature of the sensor elements.") - -time.sleep(1) - -while(1): - if (not myCO2.getData()): - print "Failed to retrieve data" - else: - outputStr = ("CO2 concentration: {0} PPM, " - "Temperature (in C): {1}".format( - myCO2.getGas(), myCO2.getTemperature())) - print outputStr - - time.sleep(2) diff --git a/peripheral/libupm/examples/python/mic.py b/peripheral/libupm/examples/python/mic.py deleted file mode 100644 index 240d61e..0000000 --- a/peripheral/libupm/examples/python/mic.py +++ /dev/null @@ -1,47 +0,0 @@ -# Author: John Van Drasek <john.r.van.drasek@intel.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time -import pyupm_mic as upmMicrophone - -# Attach microphone to analog port A0 -myMic = upmMicrophone.Microphone(0) -threshContext = upmMicrophone.thresholdContext() -threshContext.averageReading = 0 -threshContext.runningAverage = 0 -threshContext.averagedOver = 2 - -# Infinite loop, ends when script is cancelled -# Repeatedly, take a sample every 2 microseconds; -# find the average of 128 samples; and -# print a running graph of dots as averages -while(1): - buffer = upmMicrophone.uint16Array(128) - len = myMic.getSampledWindow(2, 128, buffer); - if len: - thresh = myMic.findThreshold(threshContext, 30, buffer, len) - myMic.printGraph(threshContext) - if(thresh): - print "Threshold is ", thresh - -# Delete the upmMicrophone object -del myMic diff --git a/peripheral/libupm/examples/python/mma7660.py b/peripheral/libupm/examples/python/mma7660.py deleted file mode 100644 index 1471a60..0000000 --- a/peripheral/libupm/examples/python/mma7660.py +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_mma7660 as upmMMA7660 - -# Instantiate an MMA7660 on I2C bus 0 -myDigitalAccelerometer = upmMMA7660.MMA7660( - upmMMA7660.MMA7660_I2C_BUS, - upmMMA7660.MMA7660_DEFAULT_I2C_ADDR); - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, including functions from myDigitalAccelerometer -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -# place device in standby mode so we can write registers -myDigitalAccelerometer.setModeStandby() - -# enable 64 samples per second -myDigitalAccelerometer.setSampleRate(upmMMA7660.MMA7660.AUTOSLEEP_64) - -# place device into active mode -myDigitalAccelerometer.setModeActive() - -x = upmMMA7660.new_intp() -y = upmMMA7660.new_intp() -z = upmMMA7660.new_intp() - -ax = upmMMA7660.new_floatp() -ay = upmMMA7660.new_floatp() -az = upmMMA7660.new_floatp() - -while (1): - myDigitalAccelerometer.getRawValues(x, y, z) - outputStr = ("Raw values: x = {0}" - " y = {1}" - " z = {2}").format(upmMMA7660.intp_value(x), - upmMMA7660.intp_value(y), - upmMMA7660.intp_value(z)) - print outputStr - - myDigitalAccelerometer.getAcceleration(ax, ay, az) - outputStr = ("Acceleration: x = {0}" - "g y = {1}" - "g z = {2}g").format(upmMMA7660.floatp_value(ax), - upmMMA7660.floatp_value(ay), - upmMMA7660.floatp_value(az)) - print outputStr - time.sleep(.5) diff --git a/peripheral/libupm/examples/python/mpr121.py b/peripheral/libupm/examples/python/mpr121.py deleted file mode 100644 index 8e38262..0000000 --- a/peripheral/libupm/examples/python/mpr121.py +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_mpr121 as upmMpr121 - -I2C_BUS = upmMpr121.MPR121_I2C_BUS -DEFAULT_I2C_ADDR = upmMpr121.MPR121_DEFAULT_I2C_ADDR - -# Instantiate an MPR121 touch sensor on I2C -myTouchSensor = upmMpr121.MPR121(I2C_BUS, DEFAULT_I2C_ADDR) - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, -# including functions from myTouchSensor -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - - -def printButtons(touchSensor): - buttonPressed = False - - outputStr = "Buttons Pressed: " - for i in range(12): - if (touchSensor.m_buttonStates & (1 << i)): - outputStr += (str(i) + " ") - buttonPressed = True - - if (not buttonPressed): - outputStr += "None" - - print outputStr - - if (touchSensor.m_overCurrentFault): - print "Over Current Fault detected!" - - -while(1): - myTouchSensor.readButtons() - printButtons(myTouchSensor) - - time.sleep(1) diff --git a/peripheral/libupm/examples/python/mpu60x0.py b/peripheral/libupm/examples/python/mpu60x0.py deleted file mode 100644 index 009e3ee..0000000 --- a/peripheral/libupm/examples/python/mpu60x0.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_mpu9150 as sensorObj - -# Instantiate an MPU60X0 on I2C bus 0 -sensor = sensorObj.MPU60X0() - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - -sensor.init() - -x = sensorObj.new_floatp() -y = sensorObj.new_floatp() -z = sensorObj.new_floatp() - -while (1): - sensor.update() - sensor.getAccelerometer(x, y, z) - print "Accelerometer: AX: ", sensorObj.floatp_value(x), - print " AY: ", sensorObj.floatp_value(y), - print " AZ: ", sensorObj.floatp_value(z) - - sensor.getGyroscope(x, y, z) - print "Gyroscope: GX: ", sensorObj.floatp_value(x), - print " GY: ", sensorObj.floatp_value(y), - print " GZ: ", sensorObj.floatp_value(z) - - print "Temperature: ", sensor.getTemperature() - print - - time.sleep(.5) diff --git a/peripheral/libupm/examples/python/mpu9150.py b/peripheral/libupm/examples/python/mpu9150.py deleted file mode 100644 index bba54b0..0000000 --- a/peripheral/libupm/examples/python/mpu9150.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_mpu9150 as sensorObj - -# Instantiate an MPU9150 on I2C bus 0 -sensor = sensorObj.MPU9150() - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - -sensor.init() - -x = sensorObj.new_floatp() -y = sensorObj.new_floatp() -z = sensorObj.new_floatp() - -while (1): - sensor.update() - sensor.getAccelerometer(x, y, z) - print "Accelerometer: AX: ", sensorObj.floatp_value(x), - print " AY: ", sensorObj.floatp_value(y), - print " AZ: ", sensorObj.floatp_value(z) - - sensor.getGyroscope(x, y, z) - print "Gyroscope: GX: ", sensorObj.floatp_value(x), - print " GY: ", sensorObj.floatp_value(y), - print " GZ: ", sensorObj.floatp_value(z) - - sensor.getMagnetometer(x, y, z) - print "Magnetometer: MX: ", sensorObj.floatp_value(x), - print " MY: ", sensorObj.floatp_value(y), - print " MZ: ", sensorObj.floatp_value(z) - - print "Temperature: ", sensor.getTemperature() - print - - time.sleep(.5) diff --git a/peripheral/libupm/examples/python/mpu9250.py b/peripheral/libupm/examples/python/mpu9250.py deleted file mode 100644 index 1653846..0000000 --- a/peripheral/libupm/examples/python/mpu9250.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_mpu9150 as sensorObj - -# Instantiate an MPU9250 on I2C bus 0 -sensor = sensorObj.MPU9250() - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - -sensor.init() - -x = sensorObj.new_floatp() -y = sensorObj.new_floatp() -z = sensorObj.new_floatp() - -while (1): - sensor.update() - sensor.getAccelerometer(x, y, z) - print "Accelerometer: AX: ", sensorObj.floatp_value(x), - print " AY: ", sensorObj.floatp_value(y), - print " AZ: ", sensorObj.floatp_value(z) - - sensor.getGyroscope(x, y, z) - print "Gyroscope: GX: ", sensorObj.floatp_value(x), - print " GY: ", sensorObj.floatp_value(y), - print " GZ: ", sensorObj.floatp_value(z) - - sensor.getMagnetometer(x, y, z) - print "Magnetometer: MX: ", sensorObj.floatp_value(x), - print " MY: ", sensorObj.floatp_value(y), - print " MZ: ", sensorObj.floatp_value(z) - - print "Temperature: ", sensor.getTemperature() - print - - time.sleep(.5) diff --git a/peripheral/libupm/examples/python/mq2.py b/peripheral/libupm/examples/python/mq2.py deleted file mode 100644 index 3073fda..0000000 --- a/peripheral/libupm/examples/python/mq2.py +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_gas as upmGas - -# Attach gas sensor to AIO0 -myMQ2 = upmGas.MQ2(0); - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, including functions from myMQ2 -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -threshContext = upmGas.thresholdContext() -threshContext.averageReading = 0 -threshContext.runningAverage = 0 -threshContext.averagedOver = 2 - -# Infinite loop, ends when script is cancelled -# Repeatedly, take a sample every 2 microseconds; -# find the average of 128 samples; and -# print a running graph of dots as averages -mybuffer = upmGas.uint16Array(128) -while(1): - samplelen = myMQ2.getSampledWindow(2, 128, mybuffer) - if samplelen: - thresh = myMQ2.findThreshold(threshContext, 30, mybuffer, samplelen) - myMQ2.printGraph(threshContext, 5) - if(thresh): - print "Threshold is ", thresh diff --git a/peripheral/libupm/examples/python/mq3.py b/peripheral/libupm/examples/python/mq3.py deleted file mode 100644 index c464cfc..0000000 --- a/peripheral/libupm/examples/python/mq3.py +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_gas as upmGas - -# Attach gas sensor to AIO0 -myMQ3 = upmGas.MQ3(0) - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, including functions from myMQ3 -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -threshContext = upmGas.thresholdContext() -threshContext.averageReading = 0 -threshContext.runningAverage = 0 -threshContext.averagedOver = 2 - -# Infinite loop, ends when script is cancelled -# Repeatedly, take a sample every 2 microseconds; -# find the average of 128 samples; and -# print a running graph of dots as averages -mybuffer = upmGas.uint16Array(128) -while(1): - samplelen = myMQ3.getSampledWindow(2, 128, mybuffer) - if samplelen: - thresh = myMQ3.findThreshold(threshContext, 30, mybuffer, samplelen) - myMQ3.printGraph(threshContext, 5) - if(thresh): - print "Threshold is ", thresh diff --git a/peripheral/libupm/examples/python/mq303a.py b/peripheral/libupm/examples/python/mq303a.py deleted file mode 100644 index de71bcf..0000000 --- a/peripheral/libupm/examples/python/mq303a.py +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit - -# Load alcohol sensor module -import pyupm_mq303a as upmMq303a - -# Instantiate an mq303a sensor on analog pin A0 -# This device uses a heater powered from an analog I/O pin. -# If using A0 as the data pin, then you need to use A1, as the heater -# pin (if using a grove mq303a). For A1, we can use the D15 gpio, -# setup as an output, and drive it low to power the heater. -myAlcoholSensor = upmMq303a.MQ303A(0, 15) - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, including functions from myAlcoholSensor -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -print "Enabling heater and waiting 2 minutes for warmup." - -# give time updates every 30 seconds until 2 minutes have passed -# for the alcohol sensor to warm up -def warmup(iteration): - totalSeconds = (30 * iteration) - time.sleep(30) - print totalSeconds, "seconds have passed" -warmup(1) -warmup(2) -warmup(3) -warmup(4) - -notice = ("This sensor may need to warm " -"until the value drops below about 450.") -print notice - -# Print the detected alcohol value every second -while(1): - val = myAlcoholSensor.value() - msg = "Alcohol detected " - msg += "(higher means stronger alcohol): " - print msg + str(val) - time.sleep(1) diff --git a/peripheral/libupm/examples/python/mq4.py b/peripheral/libupm/examples/python/mq4.py deleted file mode 100644 index 579246b..0000000 --- a/peripheral/libupm/examples/python/mq4.py +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_gas as upmGAS - -# Attach gas sensor to Analog A0 -sensor = upmGAS.MQ4(0) - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, including functions from sensor -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -threshContext = upmGAS.thresholdContext() -threshContext.averageReading = 0 -threshContext.runningAverage = 0 -threshContext.averagedOver = 2 - -# Infinite loop, ends when script is cancelled -# Repeatedly, take a sample every 2 microseconds; -# find the average of 128 samples; and -# print a running graph of asteriskss as averages -mybuffer = upmGAS.uint16Array(128) -while(1): - samplelen = sensor.getSampledWindow(2, 128, mybuffer) - if samplelen: - thresh = sensor.findThreshold(threshContext, 30, mybuffer, samplelen) - sensor.printGraph(threshContext, 5) -# if(thresh): -# print "Threshold is ", thresh diff --git a/peripheral/libupm/examples/python/mq5.py b/peripheral/libupm/examples/python/mq5.py deleted file mode 100644 index 5e7deb8..0000000 --- a/peripheral/libupm/examples/python/mq5.py +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_gas as upmGas - -# Attach gas sensor to AIO0 -myMQ5 = upmGas.MQ5(0) - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, including functions from myMQ5 -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -threshContext = upmGas.thresholdContext() -threshContext.averageReading = 0 -threshContext.runningAverage = 0 -threshContext.averagedOver = 2 - -# Infinite loop, ends when script is cancelled -# Repeatedly, take a sample every 2 microseconds; -# find the average of 128 samples; and -# print a running graph of dots as averages -mybuffer = upmGas.uint16Array(128) -while(1): - samplelen = myMQ5.getSampledWindow(2, 128, mybuffer) - if samplelen: - thresh = myMQ5.findThreshold(threshContext, 30, mybuffer, samplelen) - myMQ5.printGraph(threshContext, 5) - if(thresh): - print "Threshold is ", thresh diff --git a/peripheral/libupm/examples/python/mq6.py b/peripheral/libupm/examples/python/mq6.py deleted file mode 100644 index 8788e23..0000000 --- a/peripheral/libupm/examples/python/mq6.py +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_gas as upmGAS - -# Attach gas sensor to Analog A0 -sensor = upmGAS.MQ6(0) - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, including functions from sensor -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -threshContext = upmGAS.thresholdContext() -threshContext.averageReading = 0 -threshContext.runningAverage = 0 -threshContext.averagedOver = 2 - -# Infinite loop, ends when script is cancelled -# Repeatedly, take a sample every 2 microseconds; -# find the average of 128 samples; and -# print a running graph of asteriskss as averages -mybuffer = upmGAS.uint16Array(128) -while(1): - samplelen = sensor.getSampledWindow(2, 128, mybuffer) - if samplelen: - thresh = sensor.findThreshold(threshContext, 30, mybuffer, samplelen) - sensor.printGraph(threshContext, 5) -# if(thresh): -# print "Threshold is ", thresh diff --git a/peripheral/libupm/examples/python/mq7.py b/peripheral/libupm/examples/python/mq7.py deleted file mode 100644 index 62a9056..0000000 --- a/peripheral/libupm/examples/python/mq7.py +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_gas as upmGAS - -# Attach gas sensor to Analog A0 -sensor = upmGAS.MQ7(0) - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, including functions from sensor -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -threshContext = upmGAS.thresholdContext() -threshContext.averageReading = 0 -threshContext.runningAverage = 0 -threshContext.averagedOver = 2 - -# Infinite loop, ends when script is cancelled -# Repeatedly, take a sample every 2 microseconds; -# find the average of 128 samples; and -# print a running graph of asteriskss as averages -mybuffer = upmGAS.uint16Array(128) -while(1): - samplelen = sensor.getSampledWindow(2, 128, mybuffer) - if samplelen: - thresh = sensor.findThreshold(threshContext, 30, mybuffer, samplelen) - sensor.printGraph(threshContext, 5) -# if(thresh): -# print "Threshold is ", thresh diff --git a/peripheral/libupm/examples/python/mq8.py b/peripheral/libupm/examples/python/mq8.py deleted file mode 100644 index 5380018..0000000 --- a/peripheral/libupm/examples/python/mq8.py +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_gas as upmGAS - -# Attach gas sensor to Analog A0 -sensor = upmGAS.MQ8(0) - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, including functions from sensor -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -threshContext = upmGAS.thresholdContext() -threshContext.averageReading = 0 -threshContext.runningAverage = 0 -threshContext.averagedOver = 2 - -# Infinite loop, ends when script is cancelled -# Repeatedly, take a sample every 2 microseconds; -# find the average of 128 samples; and -# print a running graph of asteriskss as averages -mybuffer = upmGAS.uint16Array(128) -while(1): - samplelen = sensor.getSampledWindow(2, 128, mybuffer) - if samplelen: - thresh = sensor.findThreshold(threshContext, 30, mybuffer, samplelen) - sensor.printGraph(threshContext, 5) -# if(thresh): -# print "Threshold is ", thresh diff --git a/peripheral/libupm/examples/python/mq9.py b/peripheral/libupm/examples/python/mq9.py deleted file mode 100644 index f39cf39..0000000 --- a/peripheral/libupm/examples/python/mq9.py +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_gas as upmGas - -# Attach gas sensor to AIO0 -myMQ9 = upmGas.MQ9(0) - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, including functions from myMQ9 -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -threshContext = upmGas.thresholdContext() -threshContext.averageReading = 0 -threshContext.runningAverage = 0 -threshContext.averagedOver = 2 - -# Infinite loop, ends when script is cancelled -# Repeatedly, take a sample every 2 microseconds; -# find the average of 128 samples; and -# print a running graph of dots as averages -mybuffer = upmGas.uint16Array(128) -while(1): - samplelen = myMQ9.getSampledWindow(2, 128, mybuffer) - if samplelen: - thresh = myMQ9.findThreshold(threshContext, 30, mybuffer, samplelen) - myMQ9.printGraph(threshContext, 5) - if(thresh): - print "Threshold is ", thresh diff --git a/peripheral/libupm/examples/python/nlgpio16.py b/peripheral/libupm/examples/python/nlgpio16.py deleted file mode 100644 index 7be815d..0000000 --- a/peripheral/libupm/examples/python/nlgpio16.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import sys, signal, atexit -import pyupm_nlgpio16 as sensorObj - -# Instantiate a NLGPIO16 Module on the default UART (/dev/ttyACM0) -sensor = sensorObj.NLGPIO16() - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - -# get the Version -print "Device Version:", sensor.getVersion() -# read the gpio at pin 3 -print "GPIO 3 Value:", sensor.gpioRead(3) -# read the analog voltage at pin 5 -print "Analog 5 Voltage:", sensor.analogReadVolts(5) -# set the gpio at pin 14 to HIGH -sensor.gpioSet(14) diff --git a/peripheral/libupm/examples/python/nunchuck.py b/peripheral/libupm/examples/python/nunchuck.py deleted file mode 100644 index f7bc261..0000000 --- a/peripheral/libupm/examples/python/nunchuck.py +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_nunchuck as upmNunchuck - -# Instantiate a nunchuck controller bus 0 on I2C -myNunchuck = upmNunchuck.NUNCHUCK(0) - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, including functions from myNunchuck -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -# always do this first -print "Initializing... " -if (not myNunchuck.init()): - print "nunchuck->init() failed." - sys.exit(0); - -def buttonStateStr(buttonState): - return "pressed" if buttonState else "not pressed" - -# Print the X and Y input values every second -while(1): - myNunchuck.update() - - outputStr = "stickX: {0}, stickY: {1}".format( - myNunchuck.stickX, myNunchuck.stickY) - print outputStr - outputStr = "accelX: {0}, accelY: {1}, accelZ: {2}".format( - myNunchuck.accelX, myNunchuck.accelY, myNunchuck.accelZ) - print outputStr - - outputStr = "button C: {0}".format( - buttonStateStr(myNunchuck.buttonC)) - print outputStr - outputStr = "button Z: {0}".format( - buttonStateStr(myNunchuck.buttonZ)) - print outputStr - - time.sleep(.1) diff --git a/peripheral/libupm/examples/python/oled_ssd1308.py b/peripheral/libupm/examples/python/oled_ssd1308.py deleted file mode 100644 index 9ea1443..0000000 --- a/peripheral/libupm/examples/python/oled_ssd1308.py +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -# Load i2clcd display module -import time, signal, sys -import pyupm_i2clcd as upmLCD - -myLCD = upmLCD.SSD1308(0, 0x3C); - -logoArr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, 192, 192, 192, 224, -224, 224, 224, 240, 240, 248, 248, 120, 120, 120, 120, 60, 60, 60, 60, 60, -62, 30, 30, 30, 30, 30, 30, 30, 31, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 31, 31, 31, 31, 31, -30, 62, 62, 62, 62, 126, 126, 124, 124, 252, 252, 248, 248, 240, 240, 240, -224, 224, 224, 192, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128, 128, -128, 0, 56, 56, 28, 30, 14, 15, 15, 7, 7, 7, 7, 3, 3, 1, 1, 1, 1, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -192, 192, 192, 192, 192, 192, 192, 192, 0, 0, 0, 0, 192, 193, 195, 195, -195, 7, 15, 15, 63, 127, 255, 255, 255, 254, 252, 252, 240, 192, 0, 0, 0, -0, 0, 0, 0, 0, 128, 192, 192, 240, 248, 124, 124, 60, 0, 0, 0, 0, 159, 159, -159, 159, 159, 159, 159, 159, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128, -128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, -0, 0, 0, 0, 254, 254, 254, 254, 254, 254, 254, 254, 128, 128, 128, 128, -128, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 192, 192, 192, 192, 192, 192, 128, -128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, -0, 0, 0, 0, 3, 7, 3, 3, 3, 0, 0, 0, 0, 0, 1, 1, 255, 255, 255, 255, 255, -255, 255, 0, 0, 224, 248, 252, 252, 255, 127, 15, 15, 3, 1, 0, 0, 0, 0, 0, -0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, -255, 255, 255, 255, 255, 15, 15, 15, 15, 15, 15, 255, 255, 255, 255, 255, -255, 255, 252, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 15, 15, -15, 15, 15, 224, 224, 252, 254, 255, 255, 255, 255, 159, 159, 143, 143, -135, 135, 143, 159, 255, 255, 255, 255, 255, 255, 252, 248, 0, 0, 0, 255, -255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, -224, 248, 248, 255, 255, 255, 255, 255, 127, 15, 255, 255, 255, 255, 255, -255, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, -255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, -0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, -255, 255, 255, 255, 255, 192, 192, 192, 192, 192, 31, 31, 255, 255, 255, -255, 255, 255, 231, 231, 199, 199, 199, 199, 199, 199, 199, 199, 231, 231, -231, 231, 199, 135, 0, 0, 0, 63, 255, 255, 255, 255, 255, 255, 255, 0, 0, -0, 0, 224, 240, 248, 248, 252, 254, 255, 255, 255, 127, 63, 63, 31, 15, 7, -7, 1, 0, 0, 63, 63, 255, 255, 255, 255, 255, 240, 192, 192, 128, 0, 0, 0, -0, 0, 0, 0, 0, 1, 3, 3, 7, 7, 7, 7, 7, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, -0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 3, 3, 7, 7, 7, -7, 7, 7, 7, 7, 7, 0, 0, 0, 1, 3, 3, 3, 7, 7, 7, 7, 15, 15, 15, 15, 7, 7, 7, -7, 7, 3, 3, 3, 1, 0, 0, 0, 0, 1, 3, 3, 7, 135, 135, 135, 192, 192, 0, 0, 7, -7, 3, 3, 3, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 7, 15, 15, -31, 127, 127, 127, 255, 255, 252, 252, 252, 248, 240, 240, 240, 224, 224, -224, 192, 192, 192, 192, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128, 128, 192, 192, 192, 192, 192, -224, 224, 224, 224, 240, 240, 240, 240, 248, 248, 248, 248, 252, 252, 252, -254, 254, 255, 255, 255, 255, 255, 255, 127, 127, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -3, 3, 3, 7, 7, 7, 15, 15, 31, 31, 31, 63, 63, 63, 63, 63, 127, 127, 127, -127, 127, 255, 255, 255, 255, 254, 254, 254, 254, 254, 254, 254, 254, 254, -254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, -255, 255, 255, 255, 255, 255, 255, 127, 127, 127, 127, 127, 127, 127, 127, -63, 63, 63, 63, 63, 31, 31, 31, 31, 31, 15, 15, 15, 15, 7, 7, 7, 7, 3, 3, -3, 3, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0] - -intelLogo = upmLCD.uint8Array(len(logoArr)) - -for x in range(len(logoArr)): - intelLogo.__setitem__(x, logoArr[x]) -myLCD.clear() -myLCD.draw(intelLogo, 1024) - -del intelLogo -del myLCD -print "Exiting" diff --git a/peripheral/libupm/examples/python/oled_ssd1327.py b/peripheral/libupm/examples/python/oled_ssd1327.py deleted file mode 100644 index be19a95..0000000 --- a/peripheral/libupm/examples/python/oled_ssd1327.py +++ /dev/null @@ -1,189 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -# Load i2clcd display module -import time, signal, sys -import pyupm_i2clcd as upmLCD - -myLCD = upmLCD.SSD1327(0, 0x3C); - -logoArr = [0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x60, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x06, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x01, 0xC0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x01, 0xC0, 0x07, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x03, 0x80, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x03, 0x80, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x07, 0x80, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x01, 0xC0, -0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, -0x07, 0x80, 0x01, 0xE0, 0x08, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x20, 0x0F, 0x80, 0x01, 0xE0, -0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, -0x0F, 0x00, 0x01, 0xE0, 0x08, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x30, 0x0F, 0x00, 0x01, 0xE0, -0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, -0x0F, 0x00, 0x01, 0xE0, 0x18, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x30, 0x0F, 0x00, 0x01, 0xE0, -0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, -0x0F, 0x00, 0x01, 0xE0, 0x18, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x38, 0x0F, 0x00, 0x01, 0xE0, -0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, -0x0F, 0x80, 0x01, 0xE0, 0x38, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x3C, 0x0F, 0x80, 0x01, 0xE0, -0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, -0x0F, 0x80, 0x03, 0xE0, 0x78, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x1E, 0x07, 0x80, 0x03, 0xE0, -0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, -0x07, 0x80, 0x03, 0xE0, 0xF0, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x1F, 0x07, 0x80, 0x03, 0xC1, -0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, -0x87, 0xC0, 0x07, 0xC1, 0xF0, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x0F, 0x83, 0xC0, 0x07, 0x83, -0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, -0xC3, 0xC0, 0x07, 0x87, 0xE0, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x07, 0xE1, 0xE0, 0x07, 0x0F, -0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, -0xF0, 0xE0, 0x0F, 0x0F, 0x80, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x01, 0xF8, 0xF0, 0x0E, 0x1F, -0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, -0xF8, 0x70, 0x1C, 0x3F, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xFC, 0x30, 0x18, 0x7E, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x7F, 0x18, 0x30, 0xFC, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x1F, 0x88, 0x21, 0xF0, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x0F, 0xC4, 0x47, 0xE0, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x03, 0xE0, 0x0F, 0x80, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xF8, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0xE0, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, -0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x02, 0x00, 0x06, 0x00, 0x00, 0x6C, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x06, -0x00, 0x00, 0x60, 0x00, 0x7E, 0x3F, 0x0F, 0xC3, -0xF0, 0xFA, 0x0F, 0xDF, 0xE1, 0x9F, 0xEC, 0x7E, -0xE6, 0x73, 0x9C, 0xE7, 0x39, 0xCE, 0x1C, 0xDF, -0xE1, 0xB9, 0xEC, 0xE7, 0xE0, 0x61, 0xD8, 0x66, -0x1B, 0x86, 0x1C, 0x06, 0x61, 0xB0, 0x6D, 0xC3, -0x7C, 0x7F, 0xFF, 0xFF, 0xFF, 0x06, 0x0F, 0x86, -0x61, 0xB0, 0x6D, 0x83, 0x3E, 0x7F, 0xFF, 0xFF, -0xFF, 0x06, 0x07, 0xC6, 0x61, 0xB0, 0x6D, 0x83, -0xC3, 0x61, 0x18, 0x46, 0x03, 0x86, 0x18, 0x66, -0x61, 0xB0, 0x6D, 0xC3, 0xFE, 0x7F, 0x9F, 0xE7, -0xF9, 0xFE, 0x1F, 0xE6, 0x3F, 0x9F, 0xEC, 0xFE, -0x7E, 0x3F, 0x0F, 0xC3, 0xF0, 0xFA, 0x0F, 0xC6, -0x3F, 0x9F, 0xEC, 0x7E, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, -0x00, 0x20, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x44, 0x00, 0x00, 0x20, 0x82, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6C, 0xF3, -0xCF, 0x70, 0x9E, 0x79, 0xE7, 0x80, 0x00, 0x00, -0x00, 0x00, 0x7D, 0x9E, 0x68, 0x20, 0xB2, 0xC8, -0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x9E, -0x6F, 0x20, 0xB2, 0xF9, 0xE7, 0x80, 0x00, 0x00, -0x00, 0x00, 0x46, 0x9A, 0x61, 0x20, 0xB2, 0xCB, -0x60, 0x80, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xF3, -0xCF, 0x30, 0x9E, 0x79, 0xE7, 0x90, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x7C, 0x02, 0x00, 0x00, 0x82, 0x60, 0x00, 0x00, -0xF8, 0x00, 0x00, 0x40, 0x40, 0x02, 0x00, 0x00, -0x83, 0x60, 0x00, 0x00, 0x8C, 0x00, 0x00, 0x40, -0x60, 0xB7, 0x79, 0xE7, 0x81, 0xC7, 0x92, 0x70, -0x89, 0xE7, 0x9E, 0x78, 0x7C, 0xE2, 0xC9, 0x2C, -0x81, 0xCC, 0xD2, 0x40, 0xFB, 0x21, 0xB2, 0x48, -0x40, 0x62, 0xF9, 0x2C, 0x80, 0x8C, 0xD2, 0x40, -0x8B, 0xE7, 0xB0, 0x48, 0x40, 0xE2, 0xC9, 0x2C, -0x80, 0x84, 0xD2, 0x40, 0x8B, 0x2D, 0x92, 0x48, -0x7D, 0xB3, 0x79, 0x27, 0x80, 0x87, 0x9E, 0x40, -0x8D, 0xE7, 0x9E, 0x48, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] - -SeeedLogo = upmLCD.uint8Array(len(logoArr)) - -for x in range(len(logoArr)): - SeeedLogo.__setitem__(x, logoArr[x]) - -# If you don't set the display to be white, the seeed logo will appear jagged -myLCD.setGrayLevel(12) -myLCD.draw(SeeedLogo, 96 * 96 / 8); - -for i in range(12): - myLCD.setCursor(i, 0) - myLCD.setGrayLevel(i) - myLCD.write('Hello World') - -print "Exiting" diff --git a/peripheral/libupm/examples/python/otp538u.py b/peripheral/libupm/examples/python/otp538u.py deleted file mode 100644 index a7713b1..0000000 --- a/peripheral/libupm/examples/python/otp538u.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_otp538u as upmOtp538u - -# analog voltage, usually 3.3 or 5.0 -OTP538U_AREF = 5.0 - -# Instantiate a OTP538U on analog pins A0 and A1 -# A0 is used for the Ambient Temperature and A1 is used for the -# Object temperature. -myTempIR = upmOtp538u.OTP538U(0, 1, OTP538U_AREF) - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This lets you run code on exit, including functions from myTempIR -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -while(1): - outputStr = ("Ambient temp: {0}" - " C, Object temp: {1}" - " C".format(myTempIR.ambientTemperature(), - myTempIR.objectTemperature())) - print outputStr - - time.sleep(1) diff --git a/peripheral/libupm/examples/python/ozw.py b/peripheral/libupm/examples/python/ozw.py deleted file mode 100644 index 010c1fc..0000000 --- a/peripheral/libupm/examples/python/ozw.py +++ /dev/null @@ -1,126 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_ozw as sensorObj - -# Instantiate an OZW instance -sensor = sensorObj.OZW() - -# This function lets you run code on exit -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) - -defaultDev = "/dev/ttyACM0" -if (len(sys.argv) > 1): - defaultDev = sys.argv[1] - -# The first thing to do is create options, then lock them when done. -sensor.optionsCreate() -sensor.optionsLock() - -# Next, initialize it. -print "Initializing, this may take awhile depending on your ZWave network" - -if (not sensor.init(defaultDev)): - print "Init failed." - sys.exit(1) - -print "Initialization complete" - -print "Dumping nodes..." - -sensor.dumpNodes() - -# The following is example output of dumpNodes: -# -# Dumping nodes... -# Node 1: Z-Stick Gen5 -# Node 2: Smart Switch 6 -# Index: 0, Type: bool, Label: Switch, Value: False -# Index: 2, Type: float, Label: Energy, Value: 1.190 kWh -# Index: 3, Type: float, Label: Previous Reading, Value: 1.190 kWh -# Index: 4, Type: int32, Label: Interval, Value: 1521 seconds -# Index: 5, Type: float, Label: Power, Value: 0.000 W -# Index: 6, Type: float, Label: Voltage, Value: 121.256 V -# Index: 7, Type: float, Label: Current, Value: 0.000 A -# Index: 8, Type: bool, Label: Exporting, Value: False -# Index: 45, Type: list, Label: Day, Value: Friday -# Index: 46, Type: byte, Label: Hour, Value: 5 -# Index: 47, Type: byte, Label: Minute, Value: 53 -# Node 3: Multi Sensor -# Index: 0, Type: bool, Label: Sensor, Value: True -# Index: 1, Type: float, Label: Temperature, Value: 72.8 F -# Index: 2, Type: float, Label: Luminance, Value: 4 lux -# Index: 3, Type: float, Label: Relative Humidity, Value: 22 % -# Index: 17, Type: byte, Label: Battery Level, Value: 98 % -# Node 5: Minimote -# Node 6: Smart Energy Switch -# Index: 0, Type: bool, Label: Switch, Value: False -# Index: 2, Type: float, Label: Power, Value: 0.000 W -# Index: 3, Type: float, Label: Energy, Value: 1.609 kWh -# Index: 4, Type: float, Label: Previous Reading, Value: 1.609 kWh -# Index: 5, Type: int32, Label: Interval, Value: 1521 seconds -# Index: 6, Type: float, Label: Power, Value: 0.000 W -# Index: 7, Type: float, Label: Previous Reading, Value: 1.609 W -# Index: 8, Type: int32, Label: Interval, Value: 1521 seconds -# Index: 9, Type: bool, Label: Exporting, Value: False -# Node 7: Smart Energy Switch -# Index: 0, Type: bool, Label: Switch, Value: False -# Index: 2, Type: float, Label: Power, Value: 0.000 W -# Index: 3, Type: float, Label: Energy, Value: 0.000 kWh -# Index: 4, Type: float, Label: Previous Reading, Value: 0.000 kWh -# Index: 5, Type: int32, Label: Interval, Value: 1521 seconds -# Index: 6, Type: float, Label: Power, Value: 0.000 W -# Index: 7, Type: float, Label: Previous Reading, Value: 0.000 W -# Index: 8, Type: int32, Label: Interval, Value: 1521 seconds -# Index: 9, Type: bool, Label: Exporting, Value: False -# -# So, with the above in mind: -# -# 1. Query the temperature on node 3 and print it out (as a -# string), along with the units of measure: -# -# print "Temperature:", sensor.getValueAsString(3, 1), -# sensor->getValueUnits(3, 1) -# -# 2. query the same temperature as a float: -# -# temperature = sensor.getValueAsFloat(3, 1) -# -# 3. Turn on the light plugged into the switch on Node 7, wait 5 -# seconds, then turn it back off again: -# -# print "Turning ON node 7" -# sensor.setValueAsBool(7, 0, true) -# -# print "Sleeping for 5 seconds"; -# time.sleep(5) -# -# print "Turning OFF node 7" -# sensor.setValueAsBool(7, 0, false); - diff --git a/peripheral/libupm/examples/python/pn532-writeurl.py b/peripheral/libupm/examples/python/pn532-writeurl.py deleted file mode 100644 index b3abc41..0000000 --- a/peripheral/libupm/examples/python/pn532-writeurl.py +++ /dev/null @@ -1,105 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_pn532 as upmPn532 - -# Instantiate an PN532 on I2C bus 0 (default) using gpio 3 for the -# IRQ, and gpio 2 for the reset pin. -myNFC = upmPn532.PN532(3, 2) - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This lets you run code on exit -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -if (not myNFC.init()): - print "init() failed" - sys.exit(0) - -vers = myNFC.getFirmwareVersion() - -if (vers): - print "Got firmware version: %08x" % vers -else: - print "Could not identify PN532" - sys.exit(0) - -# Now scan and identify any cards that come in range (1 for now) - -# Retry forever -myNFC.setPassiveActivationRetries(0xff) - -myNFC.SAMConfig() - -uidSize = upmPn532.uint8Array(0) -uid = upmPn532.uint8Array(7) - -# the URL we want to add as an NDEF record -# NOTE: this cannot exceed 34 characters. -url = "iotdk.intel.com" - -foundCard = False - -while (not foundCard): - for i in range(7): - uid.__setitem__(i, 0) - if (myNFC.readPassiveTargetID(upmPn532.PN532.BAUD_MIFARE_ISO14443A, - uid, uidSize, 2000)): - # found a card - print "Found a card: UID len", uidSize.__getitem__(0) - print "UID: ", - for i in range(uidSize.__getitem__(0)): - print "%02x" % uid.__getitem__(i), - print - print "SAK: %02x" % myNFC.getSAK() - print "ATQA: %04x" % myNFC.getATQA() - print - foundCard = True - else: - print "Waiting for a card...\n" - -if (uidSize.__getitem__(0) != 7): - print "This example will only write an NDEF URI to preformatted" - print "Mifare Ultralight or NTAG2XX tags" - sys.exit(1) - -# 48 bytes is maximum data area on ultralight cards, so we use that -# as the maximum datasize here. Obviously if you have a bigger -# card, you can write more data. -if (not myNFC.ntag2xx_WriteNDEFURI(upmPn532.PN532.NDEF_URIPREFIX_HTTP, url, 48)): - # failure - print "Failed to write NDEF record tag." - sys.exit(1) - -print "Success, URL record written to tag." diff --git a/peripheral/libupm/examples/python/pn532.py b/peripheral/libupm/examples/python/pn532.py deleted file mode 100644 index bb000d4..0000000 --- a/peripheral/libupm/examples/python/pn532.py +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_pn532 as upmPn532 - -# Instantiate an PN532 on I2C bus 0 (default) using gpio 3 for the -# IRQ, and gpio 2 for the reset pin. -myNFC = upmPn532.PN532(3, 2) - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This lets you run code on exit -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -if (not myNFC.init()): - print "init() failed" - sys.exit(0) - -vers = myNFC.getFirmwareVersion() - -if (vers): - print "Got firmware version: %08x" % vers -else: - print "Could not identify PN532" - sys.exit(0) - -# Now scan and identify any cards that come in range (1 for now) - -# Retry forever -myNFC.setPassiveActivationRetries(0xff) - -myNFC.SAMConfig() - -uidSize = upmPn532.uint8Array(0) -uid = upmPn532.uint8Array(7) - - -while (1): - for i in range(7): - uid.__setitem__(i, 0) - if (myNFC.readPassiveTargetID(upmPn532.PN532.BAUD_MIFARE_ISO14443A, - uid, uidSize, 2000)): - # found a card - print "Found a card: UID len", uidSize.__getitem__(0) - print "UID: ", - for i in range(uidSize.__getitem__(0)): - print "%02x" % uid.__getitem__(i), - print - print "SAK: %02x" % myNFC.getSAK() - print "ATQA: %04x" % myNFC.getATQA() - print - time.sleep(1) - else: - print "Waiting for a card...\n" diff --git a/peripheral/libupm/examples/python/ppd42ns.py b/peripheral/libupm/examples/python/ppd42ns.py deleted file mode 100644 index 86e037d..0000000 --- a/peripheral/libupm/examples/python/ppd42ns.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_ppd42ns as upmPpd42ns - -# Instantiate a dust sensor on digital pin D8 -myDustSensor = upmPpd42ns.PPD42NS(8) - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, including functions from myDustSensor -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -notice = ("This program will give readings " -"every 30 seconds until you stop it") -print notice - -while(1): - data = myDustSensor.getData() - # we need to sleep for a bit for the data to print out - time.sleep(.1) - print "Low pulse occupancy: " + str(data.lowPulseOccupancy) - print "Ratio: " + str(data.ratio) - print "Concentration: " + str(data.concentration) diff --git a/peripheral/libupm/examples/python/rfr359f.py b/peripheral/libupm/examples/python/rfr359f.py deleted file mode 100644 index 349821d..0000000 --- a/peripheral/libupm/examples/python/rfr359f.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_rfr359f as upmRfr359f - -# Instantiate an RFR359F digital pin D2 -# This was tested on the Grove IR Distance Interrupter -myDistInterrupter = upmRfr359f.RFR359F(2) - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, including functions from myDistInterrupter -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -while(1): - if (myDistInterrupter.objectDetected()): - print "Object detected" - else: - print "Area is clear" - time.sleep(.1) diff --git a/peripheral/libupm/examples/python/rgbringcoder.py b/peripheral/libupm/examples/python/rgbringcoder.py deleted file mode 100644 index 5c0b1fb..0000000 --- a/peripheral/libupm/examples/python/rgbringcoder.py +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_rgbringcoder as upmRGBRingCoder - -# There are a lot of pins to hook up. These pins are valid for the -# Edison board, but may need to be adjusted for other platforms. - -# In order: -# enable - 4 -# latch - 10 -# clear - 11 -# clock - 2 -# data - 9 -# switch - 7 - -# red pwm - 3 -# green pwm - 5 -# blue pwm - 6 - -# encA - 12 -# encB - 13 -ringCoder = upmRGBRingCoder.RGBRingCoder(4, 10, 11, 2, 9, 7, 12, 13, 3, - 5, 6) - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, -# including functions from ringCoder -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -spin = 0x0001; -oldState = False; -oldPos = 0; - -# Lets go green -ringCoder.setRGBLED(0.99, 0.01, 0.99); - -while(1): - # you spin me round... - if ((spin & 0xffff) == 0): - spin = 0x0001 - - ringCoder.setRingLEDS(spin) - spin <<= 1 - - # check button state - bstate = ringCoder.getButtonState() - if (bstate != oldState): - print "Button state changed from", oldState, " to ", bstate - oldState = bstate - - # check encoder position - epos = ringCoder.getEncoderPosition() - if (epos != oldPos): - print "Encoder position changed from", oldPos, "to", epos - oldPos = epos - - time.sleep(0.1) diff --git a/peripheral/libupm/examples/python/rhusb.py b/peripheral/libupm/examples/python/rhusb.py deleted file mode 100644 index 70198e0..0000000 --- a/peripheral/libupm/examples/python/rhusb.py +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2016 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_rhusb as sensorObj - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit -def exitHandler(): - print "Exiting..." - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - -defaultDev = "/dev/ttyUSB0" - -# if an argument was specified, use it as the device instead -if (len(sys.argv) > 1): - defaultDev = sys.argv[1] - -print "Using device", defaultDev -print "Initializing..." - -# Instantiate an RHUSB instance on defaultDev -sensor = sensorObj.RHUSB(defaultDev) - -# output the firmware ID -print "Firmware ID:", sensor.getFirmwareID() -print - -# update and print available values every second -while (1): - # update our values from the sensor - sensor.update() - - # we show both C and F for temperature - print "Temperature:", sensor.getTemperature(), "C /", - print sensor.getTemperature(True), "F" - - print "Humidity:", sensor.getHumidity(), "%" - - print - time.sleep(1) diff --git a/peripheral/libupm/examples/python/rotaryencoder.py b/peripheral/libupm/examples/python/rotaryencoder.py deleted file mode 100644 index 89738fd..0000000 --- a/peripheral/libupm/examples/python/rotaryencoder.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_rotaryencoder as upmRotaryEncoder - -# Instantiate a Grove Rotary Encoder, using signal pins D2 and D3 -myRotaryEncoder = upmRotaryEncoder.RotaryEncoder(2, 3); - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, including functions from myRotaryEncoder -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -# Read the value every second and detect motion -while(1): - print "Position: {0}".format(myRotaryEncoder.position()) - time.sleep(.1) diff --git a/peripheral/libupm/examples/python/rpr220.py b/peripheral/libupm/examples/python/rpr220.py deleted file mode 100644 index edf14ca..0000000 --- a/peripheral/libupm/examples/python/rpr220.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_rpr220 as upmRpr220 - -# This example uses a simple method to determine current status - -# Instantiate an RPR220 digital pin D2 -# This was tested on the Grove IR Reflective Sensor -myReflectiveSensor = upmRpr220.RPR220(2) - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This lets you run code on exit, -# including functions from myReflectiveSensor -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -while(1): - if (myReflectiveSensor.blackDetected()): - print "Black detected" - else: - print "Black NOT detected" - - time.sleep(.1) diff --git a/peripheral/libupm/examples/python/sainsmartks.py b/peripheral/libupm/examples/python/sainsmartks.py deleted file mode 100644 index 7763de9..0000000 --- a/peripheral/libupm/examples/python/sainsmartks.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_i2clcd as sainsmartObj - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, -# including functions from ringCoder -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - -# Instantiate a Sainsmart LCD Keypad Shield using default pins -lcd = sainsmartObj.SAINSMARTKS() - -lcd.setCursor(0,0) -lcd.write("Sainsmart KS") -lcd.setCursor(1,2) -lcd.write("Hello World") - -# output current key value every second. -while(1): - print "Button value: ", lcd.getRawKeyValue() - time.sleep(1) - diff --git a/peripheral/libupm/examples/python/si114x.py b/peripheral/libupm/examples/python/si114x.py deleted file mode 100644 index 4264620..0000000 --- a/peripheral/libupm/examples/python/si114x.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_si114x as upmSi114x - -# Instantiate a SI114x UV Sensor on I2C bus 0 -myUVSensor = upmSi114x.SI114X(0) - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, -# including functions from myUVSensor -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -# First initialize it -myUVSensor.initialize() - -print "UV Index Scale:" -print "---------------" -print "11+ Extreme" -print "8-10 Very High" -print "6-7 High" -print "3-5 Moderate" -print "0-2 Low\n" - -# update every second and print the currently measured UV Index -while (1): - # update current value(s) - myUVSensor.update() - - # print detected value - print "UV Index:", myUVSensor.getUVIndex() - - time.sleep(1) diff --git a/peripheral/libupm/examples/python/sm130.py b/peripheral/libupm/examples/python/sm130.py deleted file mode 100644 index ce6ae1b..0000000 --- a/peripheral/libupm/examples/python/sm130.py +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_sm130 as sensorObj - -# Instantiate a UART based SM130 RFID Module using defaults -sensor = sensorObj.SM130() - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - -# Set the baud rate, 19200 baud is the default. -if (sensor.setBaudRate(19200)): - print "Failed to set baud rate" - sys.exit(0) - -print "Resetting..." -sensor.reset() - -print "Firmware revision: " + sensor.getFirmwareVersion() - -print "Waiting up to 5 seconds for a tag..." - -if (sensor.waitForTag(5000)): - print "Found tag, UID:", - print sensor.string2HexString(sensor.getUID()) - print "Tag Type:", - print sensor.tag2String(sensor.getTagType()) -else: - # error - print "waitForTag failed: " + sensor.getLastErrorString() diff --git a/peripheral/libupm/examples/python/stepmotor.py b/peripheral/libupm/examples/python/stepmotor.py deleted file mode 100644 index 125ac71..0000000 --- a/peripheral/libupm/examples/python/stepmotor.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/python -# Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - -import time, sys, signal, atexit -import pyupm_stepmotor as mylib - -# Instantiate a StepMotor object on pins 2 (dir) and 3 (step) -stepper = mylib.StepMotor(2, 3) - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This lets you run code on exit -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - -print "Rotating 1 revolution forward and back at 60 rpm." -stepper.setSpeed(60) -stepper.stepForward(200) -time.sleep(1) -stepper.stepBackward(200) -time.sleep(1) - -print "Rotating 1 revolution forward and back at 150 rpm." -stepper.setSpeed(150) -stepper.stepForward(200) -time.sleep(1) -stepper.stepBackward(200) -time.sleep(1) - -print "Rotating 1 revolution forward and back at 300 rpm." -stepper.setSpeed(300) -stepper.stepForward(200) -time.sleep(1) -stepper.stepBackward(200) -time.sleep(1) diff --git a/peripheral/libupm/examples/python/sx1276-fsk.py b/peripheral/libupm/examples/python/sx1276-fsk.py deleted file mode 100644 index 6899699..0000000 --- a/peripheral/libupm/examples/python/sx1276-fsk.py +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_sx1276 as sensorObj - -# Instantiate an SX1276 using default parameters -sensor = sensorObj.SX1276() - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - -print "Specify an argument to go into receive mode. Default is transmit" - -# 915Mhz -sensor.setChannel(915000000) - -# FSK configuration (rx and tx must be configured the same): -# Tx output power = 14 dBm -# FSK freq deviation = 25000 Hz -# FSK bandwidth = 50000 bps -# FSK AFC bandwidth = 83333 Hz -# FSK datarate = 50000 bps -# FSK preamble len = 5 -# FSK fixed length payload = false -# FSK CRC check = true -# FSK (rx) continuous Rx mode = False - -sensor.setTxConfig(sensor.MODEM_FSK, 14, 25000, 0, - 50000, 0, 5, False, True, False, 0, False) - -sensor.setRxConfig(sensor.MODEM_FSK, 50000, 50000, - 0, 83333, 5, 0, False, 0, True, - False, 0, False, True) - -count = 0 - -while True: - if (len(sys.argv) > 1): - # receive mode - print "Attempting to receive..." - rv = sensor.setRx(3000) - if (rv): - print "setRx returned ", rv - else: - print "Received Buffer: ", sensor.getRxBufferStr(); - # go back to sleep when done - - sensor.setSleep() - time.sleep(.25) - else: - # transmit mode - buffer = "Ping " + str(count) - count += 1 - print "Sending..." + buffer - sensor.sendStr(buffer, 3000) - sensor.setSleep(); - time.sleep(1); diff --git a/peripheral/libupm/examples/python/sx1276-lora.py b/peripheral/libupm/examples/python/sx1276-lora.py deleted file mode 100644 index 05d9700..0000000 --- a/peripheral/libupm/examples/python/sx1276-lora.py +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_sx1276 as sensorObj - -# Instantiate an SX1276 using default parameters -sensor = sensorObj.SX1276() - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - -print "Specify an argument to go into receive mode. Default is transmit" - -# 915Mhz -sensor.setChannel(915000000) - -# LORA configuration (rx and tx must be configured the same): -# Tx output power = 14 dBm -# LORA bandwidth = 125000 (can also be 250K and 500K) -# LORA spreading factor = 7 -# LORA coding rate = 1 (4/5) -# LORA preamble len = 8 -# LORA symbol timeout = 5 -# LORA fixed payload = false -# LORA IQ inversion = false -# LORA (rx) continuous Rx mode = true - -sensor.setTxConfig(sensor.MODEM_LORA, 14, 0, 125000, - 7, 1, 8, False, True, False, 0, False) - -sensor.setRxConfig(sensor.MODEM_LORA, 125000, 7, - 1, 0, 8, 5, False, 0, True, False, 0, False, True) - -count = 0 - -while True: - if (len(sys.argv) > 1): - # receive mode - print "Attempting to receive..." - rv = sensor.setRx(3000) - if (rv): - print "setRx returned ", rv - else: - print "Received Buffer: ", sensor.getRxBufferStr(); - # go back to sleep when done - - sensor.setSleep() - time.sleep(.25) - else: - # transmit mode - buffer = "Ping " + str(count) - count += 1 - print "Sending..." + buffer - sensor.sendStr(buffer, 3000) - sensor.setSleep(); - time.sleep(1); diff --git a/peripheral/libupm/examples/python/sx6119.py b/peripheral/libupm/examples/python/sx6119.py deleted file mode 100644 index a849836..0000000 --- a/peripheral/libupm/examples/python/sx6119.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import sys -import pyupm_sx6119 as upmSx6119 - -# Instantiate a SX6119 on digital pins 2 (power) and 3 (seek) -# This example was tested on the Grove FM Receiver. -myFM_receiver_obj = upmSx6119.SX6119(2, 3) - -# if an argument was specified (any argument), seek to the next -# station, else just toggle the power. - -print "Supply any argument to the command line to seek to the" -print "next station." -print "Running the example without an argument will toggle the" -print "power on or off.\n" - -doSeek = False - -if (len(sys.argv) > 1): - doSeek = True - -# depending on what was selected, do it -if (doSeek): - myFM_receiver_obj.seek() -else: - myFM_receiver_obj.togglePower() - -print "Exiting"; diff --git a/peripheral/libupm/examples/python/t3311.py b/peripheral/libupm/examples/python/t3311.py deleted file mode 100644 index 0c568df..0000000 --- a/peripheral/libupm/examples/python/t3311.py +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2016 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_t3311 as sensorObj - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - -defaultDev = "/dev/ttyUSB0" - -# if an argument was specified, use it as the device instead -if (len(sys.argv) > 1): - defaultDev = sys.argv[1] - -print "Initializing..." - -# Instantiate an T3311 instance, using MODBUS slave address 1, and -# default comm parameters (9600, 8, N, 2) -sensor = sensorObj.T3311(defaultDev, 1) - -# output the serial number and firmware revision -print "Serial Number:", sensor.getSerialNumber() -print "Firmware Revision: {0}.{1}".format(sensor.getFirmwareMajor(), - sensor.getFirmwareMinor()) -print - -# update and print available values every second -while (1): - # update our values from the sensor - sensor.update() - - # we show both C and F for temperature - print "Temperature:", sensor.getTemperature(), "C /", - print sensor.getTemperature(True), "F" - - print "Humidity:", sensor.getHumidity(), "%" - - # this value depends on the sensor configuration -- by default - # it is the dew point temperature - print "Computed Value:", sensor.getComputedValue() - - # with FW revisions > 2.44, extended computed data is available - if (sensor.extendedDataAvailable()): - print "Dew Point Temperature:", sensor.getDewPointTemperature(), - print "C /", sensor.getDewPointTemperature(True), "F" - - print "Absolute Humidity:", sensor.getAbsoluteHumidity(), "g/m3" - - print "Specific Humidity:", sensor.getSpecificHumidity(), - print "g/kg" - - print "Mixing Ratio:", sensor.getMixingRatio(), "g/kg" - - print "Specific Enthalpy:", sensor.getSpecificEnthalpy(), - print "kJ/kg" - - print - time.sleep(1) diff --git a/peripheral/libupm/examples/python/ta12200.py b/peripheral/libupm/examples/python/ta12200.py deleted file mode 100644 index 7fce6ab..0000000 --- a/peripheral/libupm/examples/python/ta12200.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_ta12200 as upmTa12200 - -# Instantiate a TA12-200 sensor on analog pin A0 -myElectricitySensor = upmTa12200.TA12200(0) - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This lets you run code on exit, -# including functions from myElectricitySensor -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -# get the data every 50 milliseconds -while(1): - maxVal = myElectricitySensor.highestValue() - current = myElectricitySensor.milliAmps(maxVal) - - outputStr = "Max ADC Value: %s, current: %smA" % (maxVal, current) - print outputStr - time.sleep(.1) diff --git a/peripheral/libupm/examples/python/tcs3414cs.py b/peripheral/libupm/examples/python/tcs3414cs.py deleted file mode 100644 index 7b7fae0..0000000 --- a/peripheral/libupm/examples/python/tcs3414cs.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_tcs3414cs as upmTcs3414cs - -# Instantiate the color sensor on I2C -myColorSensor = upmTcs3414cs.TCS3414CS() - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This lets you run code on exit, -# including functions from myColorSensor -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -myrgb = upmTcs3414cs.tcs3414sc_rgb_t() - -# Print out the r, g, b, and clr value every 0.5 seconds -while(1): - myColorSensor.readRGB(myrgb) - print "{0}, {1}, {2}, {3}".format(myrgb.r, - myrgb.g, myrgb.b, myrgb.clr) - - time.sleep(.5) diff --git a/peripheral/libupm/examples/python/tm1637.py b/peripheral/libupm/examples/python/tm1637.py deleted file mode 100644 index 8c75744..0000000 --- a/peripheral/libupm/examples/python/tm1637.py +++ /dev/null @@ -1,54 +0,0 @@ -# Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com> -# Copyright (c) 2014 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, signal -import pyupm_tm1637 as tm1637 - -# Register exit handler for normal Ctrl+C exit -def SIGINTHandler(signum, frame): - raise SystemExit -signal.signal(signal.SIGINT, SIGINTHandler) - -# Create a display object on pins 0 CLK and 1 DIO -display = tm1637.TM1637(0, 1) -dots = True - -# Get local time -myTime = time.localtime(time.time()) -print time.strftime("System time: %H:%M", myTime) -print ("You can adjust your time zone by setting the TZ environment variable.") - -# Draw a box for 3 seconds using 7-segment encoding -display.write(0x39, 0x09, 0x09, 0x0f) -time.sleep(3) - -# Loop indefinitely -while True: - # Update and display time - timeString = time.strftime("%H%M", time.localtime(time.time())) - display.write(timeString) - # Toggle colon - display.setColon(dots) - dots = not dots - - # Sleep for 1 s - time.sleep(1) diff --git a/peripheral/libupm/examples/python/tp401.py b/peripheral/libupm/examples/python/tp401.py deleted file mode 100644 index 5519508..0000000 --- a/peripheral/libupm/examples/python/tp401.py +++ /dev/null @@ -1,54 +0,0 @@ -# Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com> -# Copyright (c) 2014 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -from time import sleep -import pyupm_gas as TP401 - -# Give a qualitative meaning to the value from the sensor -def airQuality(value): - if(value < 50): return "Fresh Air" - if(value < 200): return "Normal Indoor Air" - if(value < 400): return "Low Pollution" - if(value < 600): return "High Pollution - Action Recommended" - return "Very High Pollution - Take Action Immediately" - -# New Grove Air Quality Sensor on AIO pin 0 -airSensor = TP401.TP401(0) - -# Wait for sensor to warm up -print "Sensor is warming up for 3 minutes..." -for i in range (1, 4): - sleep(60) - print i, "minute(s) passed." -print "Sensor is ready!" - -# Loop indefinitely -while True: - - # Read values (consecutive reads might vary slightly) - value = airSensor.getSample() - ppm = airSensor.getPPM() - - print "raw: %4d" % value , " ppm: %5.2f " % ppm , airQuality(value) - - # Sleep for 2.5 s - sleep(2.5) diff --git a/peripheral/libupm/examples/python/tsl2561.py b/peripheral/libupm/examples/python/tsl2561.py deleted file mode 100644 index 35a3336..0000000 --- a/peripheral/libupm/examples/python/tsl2561.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_tsl2561 as upmTsl2561 - -# Instantiate a digital light sensor TSL2561 on I2C -myDigitalLightSensor = upmTsl2561.TSL2561() - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, including functions from myDigitalLightSensor -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -while(1): - print "Light value is " + str(myDigitalLightSensor.getLux()) - time.sleep(1) diff --git a/peripheral/libupm/examples/python/ttp223.py b/peripheral/libupm/examples/python/ttp223.py deleted file mode 100644 index 7d1c847..0000000 --- a/peripheral/libupm/examples/python/ttp223.py +++ /dev/null @@ -1,39 +0,0 @@ -# Author: Sarah Knepper <sarah.knepper@intel.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time -import pyupm_ttp223 as ttp223 - -# Create the TTP223 touch sensor object using GPIO pin 0 -touch = ttp223.TTP223(0) - -# Check whether or not a finger is near the touch sensor and -# print accordingly, waiting one second between readings -while 1: - if touch.isPressed(): - print touch.name(), 'is pressed' - else: - print touch.name(), 'is not pressed' - time.sleep(1) - -# Delete the touch sensor object -del touch diff --git a/peripheral/libupm/examples/python/ublox6.py b/peripheral/libupm/examples/python/ublox6.py deleted file mode 100644 index bb98d2b..0000000 --- a/peripheral/libupm/examples/python/ublox6.py +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_ublox6 as upmUblox6 - -# Instantiate a Ublox6 GPS device on uart 0. -myGPSSensor = upmUblox6.Ublox6(0) - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, including functions from myGPSSensor -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -if (not myGPSSensor.setupTty(upmUblox6.cvar.int_B9600)): - print "Failed to setup tty port parameters" - sys.exit(0) - -# Collect and output NMEA data. - -# This device also supports numerous configuration options, which -# you can set with writeData(). Please refer to the Ublox-6 data -# sheet for further information on the formats of the data sent and -# received, and the various operating modes available. - - -bufferLength = 256 -nmeaBuffer = upmUblox6.charArray(bufferLength) - -def getGPSInfo(): - # we don't want the read to block in this example, so always - # check to see if data is available first. - if (myGPSSensor.dataAvailable()): - rv = myGPSSensor.readData(nmeaBuffer, bufferLength) - - numlines= 0 - if (rv > 0): - GPSData = "" - # read only the number of characters - # specified by myGPSSensor.readData - for x in range(rv): - GPSData += nmeaBuffer.__getitem__(x) - sys.stdout.write(GPSData) - - if (rv < 0): # some sort of read error occured - print "Port read error." - sys.exit(0) - -while (1): - getGPSInfo() - time.sleep(.1) diff --git a/peripheral/libupm/examples/python/uln200xa.py b/peripheral/libupm/examples/python/uln200xa.py deleted file mode 100644 index e926e46..0000000 --- a/peripheral/libupm/examples/python/uln200xa.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - -import time, sys, signal, atexit -import pyupm_uln200xa as upmULN200XA - -# Instantiate a Stepper motor on a ULN200XA Darlington Motor Driver -# This was tested with the Grove Geared Step Motor with Driver - -# Instantiate a ULN2003XA stepper object -myUln200xa = upmULN200XA.ULN200XA(4096, 8, 9, 10, 11) - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This lets you run code on exit, -# including functions from myUln200xa -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -myUln200xa.setSpeed(5) # 5 RPMs -myUln200xa.setDirection(upmULN200XA.ULN200XA.DIR_CW) - -print "Rotating 1 revolution clockwise." -myUln200xa.stepperSteps(4096) - -print "Sleeping for 2 seconds..." -time.sleep(2) - -print "Rotating 1/2 revolution counter clockwise." -myUln200xa.setDirection(upmULN200XA.ULN200XA.DIR_CCW) -myUln200xa.stepperSteps(2048) - -# release -myUln200xa.release() - -# exitHandler is called automatically diff --git a/peripheral/libupm/examples/python/urm37-uart.py b/peripheral/libupm/examples/python/urm37-uart.py deleted file mode 100644 index 8e6ee80..0000000 --- a/peripheral/libupm/examples/python/urm37-uart.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_urm37 as sensorObj - -# Instantiate a URM37 sensor on UART 0, with the reset pin on D2 -sensor = sensorObj.URM37(0, 2) - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - -# Every half a second, sample the URM37 and output the measured -# distance in cm, and temperature in degrees C - -while (1): - print "Detected distance (cm):", sensor.getDistance() - print "Temperature (C):", sensor.getTemperature() - time.sleep(.5) diff --git a/peripheral/libupm/examples/python/urm37.py b/peripheral/libupm/examples/python/urm37.py deleted file mode 100644 index fa977aa..0000000 --- a/peripheral/libupm/examples/python/urm37.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_urm37 as sensorObj - -# Instantiate a URM37 sensor on analog pin A0, reset pin on D2, -# trigger pin on D3 with an analog reference voltage of 5.0 -sensor = sensorObj.URM37(0, 2, 3, 5.0) - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - -# Every half a second, sample the URM37 and output the measured -# distance in cm. - -while (1): - print "Detected distance (cm):", sensor.getDistance() - time.sleep(.5) diff --git a/peripheral/libupm/examples/python/using_carrays.py b/peripheral/libupm/examples/python/using_carrays.py deleted file mode 100644 index 730cb36..0000000 --- a/peripheral/libupm/examples/python/using_carrays.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env python - -# Author: Brendan Le Foll <brendan.le.foll@intel.com> -# Copyright (c) 2014 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE - -import pyupm_mic - -mymic = pyupm_mic.Microphone(1) -# careful this is an unitialised array with no bounds checking! -x = pyupm_mic.uint16Array(3) -mymic.getSampledWindow(100, 3, x) - diff --git a/peripheral/libupm/examples/python/waterlevel.py b/peripheral/libupm/examples/python/waterlevel.py deleted file mode 100644 index 18309e4..0000000 --- a/peripheral/libupm/examples/python/waterlevel.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_waterlevel as upmWaterlevel - -# The was tested with the Water Level Sensor -# Instantiate a Water Level Sensor on digital pin D2 -myWaterLevel = upmWaterlevel.WaterLevel(2) - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, -# including functions from myWaterLevel -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -while(1): - if (myWaterLevel.isSubmerged()): - print "Sensor is submerged in liquid" - else: - print "Liquid is below water level sensor" - - time.sleep(1) diff --git a/peripheral/libupm/examples/python/wheelencoder.py b/peripheral/libupm/examples/python/wheelencoder.py deleted file mode 100644 index b61cc87..0000000 --- a/peripheral/libupm/examples/python/wheelencoder.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_wheelencoder as sensorObj - -# Instantiate a DFRobot Wheel Encoder on digital pin D2 -sensor = sensorObj.WheelEncoder(2) - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - -# set the counter to 0 and start counting -sensor.clearCounter(); -sensor.startCounter(); - -while (1): - print "Millis:", sensor.getMillis(), "Count:", sensor.counter() - time.sleep(1) diff --git a/peripheral/libupm/examples/python/wt5001.py b/peripheral/libupm/examples/python/wt5001.py deleted file mode 100644 index 315799c..0000000 --- a/peripheral/libupm/examples/python/wt5001.py +++ /dev/null @@ -1,107 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, signal, sys -import pyupm_wt5001 as upmWt5001 - -# Instantiate a WT5001 serial MP3 player on uart 0. -# This example was tested on the Grove Serial MP3 module. -myMP3Player = upmWt5001.WT5001(0) - - -def printUsage(progname): - print ("Usage: python " + progname + " <command>\n" - "Commands:\n" - "0 - stop playing\n" - "1 - start playing track 1\n" - "2 - pause/un-pause playback\n" - "3 - next track\n" - "4 - previous track") - - -cmd = -1; -if (len(sys.argv) > 1): - cmd = int(sys.argv[1]) - -if (not myMP3Player.setupTty(upmWt5001.cvar.int_B9600)): - print "Failed to setup tty port parameters" - sys.exit(0) - -if cmd == 0: - myMP3Player.stop() -elif cmd == 1: - myMP3Player.play(upmWt5001.WT5001.SD, 1) -elif cmd == 2: - myMP3Player.pause() -elif cmd == 3: - myMP3Player.next() -elif cmd == 4: - myMP3Player.previous() -else: - # nothing, just output usage, and info below - printUsage(sys.argv[0]) - - -# print out some information -vol = upmWt5001.uint8Array(0) -myMP3Player.getVolume(vol) -print "The current volume is: " + str(vol.__getitem__(0)) - -ps = upmWt5001.uint8Array(0) -myMP3Player.getPlayState(ps) -print "The current play state is: " + str(ps.__getitem__(0)) - -numf = upmWt5001.uint16Array(0) -myMP3Player.getNumFiles(upmWt5001.WT5001.SD, numf) -print "The number of files on the SD card is: " + str(numf.__getitem__(0)) - -curf = upmWt5001.uint16Array(0) -myMP3Player.getCurrentFile(curf) -print "The current file is: " + str(curf.__getitem__(0)) - - -# set the date -myMP3Player.setDate(2015, 3, 14) - -# set the time -myMP3Player.setTime(9, 26, 53) - - -year = upmWt5001.uint16Array(0) -month = upmWt5001.uint8Array(0) -day = upmWt5001.uint8Array(0) - -myMP3Player.getDate(year, month, day) -mp3date = str(month.__getitem__(0)) + "/" -mp3date += (str(day.__getitem__(0)) + "/") -mp3date += str(year.__getitem__(0)) -print "The device date is: " + mp3date - -hour = upmWt5001.uint8Array(0) -minute = upmWt5001.uint8Array(0) -second = upmWt5001.uint8Array(0) -myMP3Player.getTime(hour, minute, second) -mp3time = str(hour.__getitem__(0)) + ":" -mp3time += (str(minute.__getitem__(0)) + ":") -mp3time += str(second.__getitem__(0)) -print "The device time is: " + mp3time diff --git a/peripheral/libupm/examples/python/xbee.py b/peripheral/libupm/examples/python/xbee.py deleted file mode 100644 index 3ca3720..0000000 --- a/peripheral/libupm/examples/python/xbee.py +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/python -# Author: Jon Trulson <jtrulson@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_xbee as sensorObj - -# Instantiate a XBee Module on UART 0 -sensor = sensorObj.XBee(0) - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - -# Set the baud rate, 9600 baud is the default. -if (sensor.setBaudRate(9600)): - print "Failed to set baud rate" - sys.exit(0) - - -usageStr = ("Usage:\n" -"If an argument is supplied on the command line, that argument is\n" -"sent to the module and the response is printed out.\n\n" -"If no argument is used, then the firmware revision, serial number\n" -"and the current IP address (if set) are queried.\n\n") -print usageStr - -# simple helper function to send a command and wait for a response -def sendCommand(sensor, cmd): - # commands need to be terminated with a carriage return - cmd += "\r" - sensor.writeDataStr(cmd) - - resp = "" - while sensor.dataAvailable(2000): - resp += sensor.readDataStr(1024) - - if not resp: - print "Timed out waiting for response" - else: - resp = sensor.stringCR2LF(resp) - print "Returned (", len(resp), "bytes):" - print resp - - -if (len(sys.argv) > 1): - # enable command mode - sensor.commandMode() - print "Sending command line argument (" + sys.argv[1] + ")..." - sendCommand(sensor, sys.argv[1]) -else: - # enable command mode - sensor.commandMode() - # query the verbose firmware revision - print "Querying verbose firmware revision (ATVL)..." - sendCommand(sensor, "ATVL") - # query the number - print "Querying Serial Number High (ATSH)..." - sendCommand(sensor, "ATSH") - print "Querying Serial Number Low (ATSL)..." - sendCommand(sensor, "ATSL") - - print "Querying address, if set (ATMY)..." - sendCommand(sensor, "ATMY"); - - # For the XBee WiFi S6B - # A comprehensive list of commands and command modes is - # available from the datasheet at: - # ftp1.digi.com/support/documentation/90002180_L.pdf - - # For the XBee S1 - # A comprehensive list of commands and command modes is - # available from the datasheet at: - # http://www.sparkfun.com/datasheets/Wireless/Zigbee/XBee-Datasheet.pdf - - # For the XBee WiFi module: - # An example using AT commands to connect to an AP, with a - # private Key using WPA2: - - # Connect to AP with SSID 'mySSID': - # ATIDmySSID - - # Provide the private key 'secret': - # ATPKsecret - - # Use WPA2 encryption - # ATEE2 - diff --git a/peripheral/libupm/examples/python/yg1006.py b/peripheral/libupm/examples/python/yg1006.py deleted file mode 100644 index 6f21c1d..0000000 --- a/peripheral/libupm/examples/python/yg1006.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_yg1006 as upmYG1006 - -# Instantiate a flame sensor on digital pin D2 -myFlameSensor = upmYG1006.YG1006(2) - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, including functions from myFlameSensor -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -while(1): - if (myFlameSensor.flameDetected()): - print "Flame detected." - else: - print "No flame detected." - - time.sleep(1) diff --git a/peripheral/libupm/examples/python/zfm20-register.py b/peripheral/libupm/examples/python/zfm20-register.py deleted file mode 100644 index 589a4df..0000000 --- a/peripheral/libupm/examples/python/zfm20-register.py +++ /dev/null @@ -1,132 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_zfm20 as upmZfm20 - -# Instantiate a ZFM20 Fingerprint reader on UART 0 -myFingerprintSensor = upmZfm20.ZFM20(0) - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, -# including functions from myFingerprintSensor -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -# make sure port is initialized properly. 57600 baud is the default. -if (not myFingerprintSensor.setupTty(upmZfm20.cvar.int_B57600)): - print "Failed to setup tty port parameters" - sys.exit(1) - - -# This example demonstrates registering a fingerprint on the zfm20 -# module. The procedure is as follows: -# -# 1. get an image, store it in characteristics buffer 1 -# 2. get another image, store it in characteristics buffer 2 -# 3. store the image, assuming the two fingerprints match - -# first, we need to register our address and password - -myFingerprintSensor.setPassword(upmZfm20.ZFM20_DEFAULT_PASSWORD) -myFingerprintSensor.setAddress(upmZfm20.ZFM20_DEFAULT_ADDRESS) - -# now verify the password. If this fails, any other commands -# will be ignored, so we just bail. -if (myFingerprintSensor.verifyPassword()): - print "Password verified." -else: - print "Password verification failed." - sys.exit(1) - - -print " " - -# get the first image -print "Place a finger on the sensor." -while (myFingerprintSensor.generateImage() != upmZfm20.ZFM20.ERR_OK): - pass - -# in theory, we have an image -print "Image captured, converting..." - -rv = myFingerprintSensor.image2Tz(1) - -if (rv != upmZfm20.ZFM20.ERR_OK): - print "Image conversion failed with error code %d" % rv - sys.exit(1) - -print "Image conversion succeeded, remove finger." -time.sleep(1) - -while (myFingerprintSensor.generateImage() != upmZfm20.ZFM20.ERR_NO_FINGER): - pass - -print " " -print "Now place the same finger on the sensor." - -while (myFingerprintSensor.generateImage() == upmZfm20.ZFM20.ERR_NO_FINGER): - pass - -print "Image captured, converting..." - -# save this one in slot 2 -rv = myFingerprintSensor.image2Tz(2) -if (rv != upmZfm20.ZFM20.ERR_OK): - print "Image conversion failed with error code %d" % rv - sys.exit(1) - -print "Image conversion succeeded, remove finger." -print " " - -print "Storing fingerprint at id 1" - -# create the model -rv = myFingerprintSensor.createModel() -if (rv != upmZfm20.ZFM20.ERR_OK): - if (rv == upmZfm20.ZFM20.ERR_FP_ENROLLMISMATCH): - print "Fingerprints did not match." - else: - print "createModel failed with error code %d" % rv - sys.exit(1) - -# now store it, we hard code the id (second arg) to 1 here -rv = myFingerprintSensor.storeModel(1, 1) -if (rv != upmZfm20.ZFM20.ERR_OK): - print "storeModel failed with error code %d" % rv - sys.exit(1) - -print " " -print "Fingerprint stored at id 1." - diff --git a/peripheral/libupm/examples/python/zfm20.py b/peripheral/libupm/examples/python/zfm20.py deleted file mode 100644 index e813e47..0000000 --- a/peripheral/libupm/examples/python/zfm20.py +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent <zorent@ics.com> -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_zfm20 as upmZfm20 - -# Instantiate a ZFM20 Fingerprint reader on UART 0 -myFingerprintSensor = upmZfm20.ZFM20(0) - - -## Exit handlers ## -# This stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, -# including functions from myFingerprintSensor -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -# make sure port is initialized properly. 57600 baud is the default. -if (not myFingerprintSensor.setupTty(upmZfm20.cvar.int_B57600)): - print "Failed to setup tty port parameters" - sys.exit(1) - -# how many valid stored templates (fingerprints) do we have? -print "Total stored templates: %d" % myFingerprintSensor.getNumTemplates() -print " " - -# now spin waiting for a fingerprint to successfully image -print "Waiting for finger print..." - -while (myFingerprintSensor.generateImage() == upmZfm20.ZFM20.ERR_NO_FINGER): - pass - -# in theory, we have an image -print "Image captured, converting..." - -rv = myFingerprintSensor.image2Tz(1) -if (rv != upmZfm20.ZFM20.ERR_OK): - print "Image conversion failed with error code %d" % rv - sys.exit(1) - -print "Image conversion succeeded." -print "Searching database..." - -myid = upmZfm20.uint16Array(0) -myid.__setitem__(0, 0) -myscore = upmZfm20.uint16Array(0) -myscore.__setitem__(0, 0) - -# we search for a print matching slot 1, where we stored our last -# converted fingerprint -rv = myFingerprintSensor.search(1, myid, myscore) -if (rv != upmZfm20.ZFM20.ERR_OK): - if (rv == upmZfm20.ZFM20.ERR_FP_NOTFOUND): - print "Finger Print not found" - sys.exit(0) - else: - print "Search failed with error code %d" % rv - sys.exit(1) - -print "Fingerprint found!" -print "ID: %d, Score: %d" % (myid.__getitem__(0), myscore.__getitem__(0)) |