mirror of
https://github.com/eclipse/upm.git
synced 2025-03-14 20:47:30 +03:00
python: Added upm directory for python modules
* Grouped UPM python modules into upm directory, for example: /usr/local/lib/python2.7/dist-packages/upm * Updated UPM example import statements * Removed unused RPATH statements from UPM src CMakeLists.txt, currently build collateral contains an explicit RPATH which is stripped from the install collateral. * Converted python examples to work on both python2 AND python3 * Added ctest for loading examples w/python3 * Removed returns from swig macros * UPM python module use will change... Before: import pyupm_dfrph After: from upm import pyupm_dfrph or import upm.pyupm_dfrph etc... * This commit fixes #468 Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
parent
8624a07b77
commit
bf425014ab
16
.travis.yml
16
.travis.yml
@ -3,10 +3,8 @@ env:
|
||||
global:
|
||||
- MRAA_ROOT=/tmp/mraa
|
||||
- MRAA_BUILD=$MRAA_ROOT/build
|
||||
- MRAA_INSTALL=$MRAA_ROOT/install
|
||||
- UPM_ROOT=$TRAVIS_BUILD_DIR
|
||||
- UPM_BUILD=$UPM_ROOT/build
|
||||
- UPM_INSTALL=$UPM_ROOT/install
|
||||
- JAVA_HOME=/usr/lib/jvm/java-8-oracle
|
||||
matrix:
|
||||
- NODE010=true
|
||||
@ -31,12 +29,18 @@ before_script:
|
||||
# Handle 0.10 NODE_ROOT_DIR differently than other versions
|
||||
- if [ -z ${NODE010} ]; then export NODE_ROOT_DIR="/home/travis/.nvm/versions/node/`nvm version`"; else export NODE_ROOT_DIR=/home/travis/.nvm/v0.10.36; fi
|
||||
script:
|
||||
# Build/install MRAA
|
||||
- echo "CC=$CC BUILDJAVA=$BUILDJAVA NODE010=$NODE010 NODE012=$NODE012 NODE4=$NODE4 NODE5=$NODE5 NODE_ROOT_DIR=$NODE_ROOT_DIR"
|
||||
- git clone https://github.com/intel-iot-devkit/mraa.git $MRAA_ROOT
|
||||
- mkdir -p $MRAA_BUILD && cd $_ && cmake -DBUILDSWIGJAVA=$BUILDJAVA -DBUILDSWIGNODE=OFF -DBUILDSWIGPYTHON=ON -DFIRMATA=ON -DENABLEEXAMPLES=OFF -DCMAKE_INSTALL_PREFIX:PATH=$MRAA_INSTALL $MRAA_ROOT && make install
|
||||
- cd $UPM_ROOT && mkdir $UPM_BUILD && cd $_ && PKG_CONFIG_PATH=$MRAA_INSTALL/lib/pkgconfig cmake -DNODE_ROOT_DIR:PATH="${NODE_ROOT_DIR}" -DBUILDSWIGJAVA=$BUILDJAVA -DBUILDEXAMPLES=ON -DBUILDJAVAEXAMPLES=$BUILDJAVA -DBUILDTESTS=ON -DCMAKE_INSTALL_PREFIX:PATH=$UPM_INSTALL ..
|
||||
- make install
|
||||
- LD_LIBRARY_PATH=$MRAA_INSTALL/lib:$UPM_INSTALL/lib:$LD_LIBRARY_PATH PYTHONPATH=$UPM_INSTALL/lib/python2.7/site-packages/:$MRAA_INSTALL/lib/python2.7/dist-packages/ ctest --output-on-failure -E examplenames_js
|
||||
- mkdir -p $MRAA_BUILD && cd $_ && cmake -DBUILDSWIGJAVA=$BUILDJAVA -DBUILDSWIGNODE=OFF -DBUILDSWIGPYTHON=ON -DFIRMATA=ON -DENABLEEXAMPLES=OFF $MRAA_ROOT
|
||||
- sudo make install
|
||||
- sudo ldconfig
|
||||
# Build/install UPM
|
||||
- cd $UPM_ROOT && mkdir $UPM_BUILD && cd $_ && cmake -DNODE_ROOT_DIR:PATH="${NODE_ROOT_DIR}" -DBUILDSWIGJAVA=$BUILDJAVA -DBUILDEXAMPLES=ON -DBUILDJAVAEXAMPLES=$BUILDJAVA -DBUILDTESTS=ON ..
|
||||
- sudo make install
|
||||
- sudo ldconfig
|
||||
# Run UPM ctests
|
||||
- ctest --output-on-failure -E examplenames_js
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_a110x as upmA110x
|
||||
from upm import pyupm_a110x as upmA110x
|
||||
|
||||
def main():
|
||||
# Instantiate a Hall Effect magnet sensor on digital pin D2
|
||||
@ -35,7 +36,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit, including functions from myHallEffectSensor
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -44,9 +45,9 @@ def main():
|
||||
|
||||
while(1):
|
||||
if (myHallEffectSensor.magnetDetected()):
|
||||
print "Magnet (south polarity) detected."
|
||||
print("Magnet (south polarity) detected.")
|
||||
else:
|
||||
print "No magnet detected."
|
||||
print("No magnet detected.")
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_ad8232 as upmAD8232
|
||||
from upm import pyupm_ad8232 as upmAD8232
|
||||
|
||||
def main():
|
||||
# Instantiate a AD8232 sensor on digital pins 10 (LO+), 11 (LO-)
|
||||
@ -36,7 +37,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit, including functions from myAD8232
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -49,7 +50,7 @@ def main():
|
||||
# (https://www.processing.org/) to plot the data just like an
|
||||
# EKG you would see in a hospital.
|
||||
while(1):
|
||||
print myAD8232.value()
|
||||
print(myAD8232.value())
|
||||
time.sleep(.001)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_adafruitms1438 as upmAdafruitms1438
|
||||
from upm import pyupm_adafruitms1438 as upmAdafruitms1438
|
||||
|
||||
def main():
|
||||
# Import header values
|
||||
@ -45,7 +46,7 @@ def main():
|
||||
# including functions from myMotorShield
|
||||
def exitHandler():
|
||||
myMotorShield.disableStepper(M12Motor)
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -67,20 +68,20 @@ def main():
|
||||
myMotorShield.setStepperDirection(M12Motor, MotorDirCW)
|
||||
|
||||
# enable
|
||||
print "Enabling..."
|
||||
print("Enabling...")
|
||||
myMotorShield.enableStepper(M12Motor)
|
||||
|
||||
print "Rotating 1 full revolution at 10 RPM speed."
|
||||
print("Rotating 1 full revolution at 10 RPM speed.")
|
||||
myMotorShield.stepperSteps(M12Motor, 200)
|
||||
|
||||
print "Sleeping for 2 seconds..."
|
||||
print("Sleeping for 2 seconds...")
|
||||
time.sleep(2)
|
||||
print "Rotating 1/2 revolution in opposite direction at 10 RPM speed."
|
||||
print("Rotating 1/2 revolution in opposite direction at 10 RPM speed.")
|
||||
|
||||
myMotorShield.setStepperDirection(M12Motor, MotorDirCCW)
|
||||
myMotorShield.stepperSteps(M12Motor, 100)
|
||||
|
||||
print "Disabling..."
|
||||
print("Disabling...")
|
||||
|
||||
# exitHandler runs automatically
|
||||
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_adafruitms1438 as upmAdafruitms1438
|
||||
from upm import pyupm_adafruitms1438 as upmAdafruitms1438
|
||||
|
||||
def main():
|
||||
# Import header values
|
||||
@ -45,7 +46,7 @@ def main():
|
||||
# including functions from myMotorShield
|
||||
def exitHandler():
|
||||
myMotorShield.disableMotor(M3Motor)
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -70,12 +71,12 @@ def main():
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
print "Reversing M3"
|
||||
print("Reversing M3")
|
||||
myMotorShield.setMotorDirection(M3Motor, MotorDirCCW)
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
print "Stopping M3"
|
||||
print("Stopping M3")
|
||||
|
||||
# exitHandler runs automatically
|
||||
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_adc121c021 as upmAdc121c021
|
||||
from upm import pyupm_adc121c021 as upmAdc121c021
|
||||
|
||||
def main():
|
||||
# Instantiate an ADC121C021 on I2C bus 0
|
||||
@ -39,7 +40,7 @@ def main():
|
||||
# This lets you run code on exit,
|
||||
# including functions from myAnalogDigitalConv
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -50,7 +51,7 @@ def main():
|
||||
while(1):
|
||||
val = myAnalogDigitalConv.value()
|
||||
voltsVal = myAnalogDigitalConv.valueToVolts(val)
|
||||
print "ADC value: %s Volts = %s" % (val, voltsVal)
|
||||
print("ADC value: %s Volts = %s" % (val, voltsVal))
|
||||
time.sleep(.05)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,14 +21,15 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_adxl335 as upmAdxl335
|
||||
from upm import pyupm_adxl335 as upmAdxl335
|
||||
|
||||
def main():
|
||||
myAnalogAccel = upmAdxl335.ADXL335(0, 1, 2)
|
||||
|
||||
print "Please make sure the sensor is completely still."
|
||||
print "Sleeping for 2 seconds"
|
||||
print("Please make sure the sensor is completely still.")
|
||||
print("Sleeping for 2 seconds")
|
||||
time.sleep(2)
|
||||
|
||||
## Exit handlers ##
|
||||
@ -39,14 +40,14 @@ def main():
|
||||
# This function lets you run code on exit,
|
||||
# including functions from myAnalogAccel
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
atexit.register(exitHandler)
|
||||
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||
|
||||
print "Calibrating..."
|
||||
print("Calibrating...")
|
||||
myAnalogAccel.calibrate()
|
||||
|
||||
x = upmAdxl335.new_intPointer()
|
||||
@ -62,7 +63,7 @@ def main():
|
||||
outputStr = "Raw Values: X: {0} Y: {1} Z: {2}".format(
|
||||
upmAdxl335.intPointer_value(x), upmAdxl335.intPointer_value(y),
|
||||
upmAdxl335.intPointer_value(z))
|
||||
print outputStr
|
||||
print(outputStr)
|
||||
|
||||
myAnalogAccel.acceleration(aX, aY, aZ)
|
||||
outputStr = ("Acceleration: X: {0}g\n"
|
||||
@ -70,9 +71,9 @@ def main():
|
||||
"Acceleration: Z: {2}g").format(upmAdxl335.floatPointer_value(aX),
|
||||
upmAdxl335.floatPointer_value(aY),
|
||||
upmAdxl335.floatPointer_value(aZ))
|
||||
print outputStr
|
||||
print(outputStr)
|
||||
|
||||
print " "
|
||||
print(" ")
|
||||
|
||||
time.sleep(.2)
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
# Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
|
||||
# Copyright (c) 2014 Intel Corporation.
|
||||
#
|
||||
@ -21,7 +22,7 @@
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from time import sleep
|
||||
import pyupm_adxl345 as adxl345
|
||||
from upm import pyupm_adxl345 as adxl345
|
||||
|
||||
def main():
|
||||
# Create an I2C accelerometer object
|
||||
@ -32,10 +33,10 @@ def main():
|
||||
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])
|
||||
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)
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_adxrs610 as sensorObj
|
||||
from upm import pyupm_adxrs610 as sensorObj
|
||||
|
||||
def main():
|
||||
# Instantiate a ADXRS610 sensor on analog pin A0 (dataout), and
|
||||
@ -37,7 +38,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -51,8 +52,8 @@ def main():
|
||||
# corresponding temperature and angular velocity
|
||||
|
||||
while (1):
|
||||
print "Vel (deg/s):", sensor.getAngularVelocity()
|
||||
print "Temp (C):", sensor.getTemperature()
|
||||
print("Vel (deg/s):", sensor.getAngularVelocity())
|
||||
print("Temp (C):", sensor.getTemperature())
|
||||
time.sleep(.1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,13 +21,14 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_ozw as sensorObj
|
||||
from upm import pyupm_ozw as sensorObj
|
||||
|
||||
def main():
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -36,7 +37,7 @@ def main():
|
||||
defaultDev = "/dev/ttyACM0"
|
||||
if (len(sys.argv) > 1):
|
||||
defaultDev = sys.argv[1]
|
||||
print "Using device", defaultDev
|
||||
print("Using device", defaultDev)
|
||||
|
||||
# Instantiate an Aeotec DSB09104 instance, on device node 12. You
|
||||
# will almost certainly need to change this to reflect your own
|
||||
@ -48,25 +49,25 @@ def main():
|
||||
sensor.optionsLock()
|
||||
|
||||
# Next, initialize it.
|
||||
print "Initializing, this may take awhile depending on your ZWave network"
|
||||
print("Initializing, this may take awhile depending on your ZWave network")
|
||||
|
||||
sensor.init(defaultDev)
|
||||
print "Initialization complete"
|
||||
print("Initialization complete")
|
||||
|
||||
print "Querying data..."
|
||||
print("Querying data...")
|
||||
|
||||
while (True):
|
||||
sensor.update()
|
||||
|
||||
print "Watts, Channel 1: %0.03f W" % sensor.getWattsC1()
|
||||
print "Watts, Channel 2: %0.03f W" % sensor.getWattsC2()
|
||||
print "Watts, Channel 3: %0.03f W" % sensor.getWattsC3()
|
||||
print("Watts, Channel 1: %0.03f W" % sensor.getWattsC1())
|
||||
print("Watts, Channel 2: %0.03f W" % sensor.getWattsC2())
|
||||
print("Watts, Channel 3: %0.03f W" % sensor.getWattsC3())
|
||||
|
||||
print "Energy, Channel 1: %0.03f kWh" % sensor.getEnergyC1()
|
||||
print "Energy, Channel 2: %0.03f kWh" % sensor.getEnergyC2()
|
||||
print "Energy, Channel 3: %0.03f kWh" % sensor.getEnergyC3()
|
||||
print("Energy, Channel 1: %0.03f kWh" % sensor.getEnergyC1())
|
||||
print("Energy, Channel 2: %0.03f kWh" % sensor.getEnergyC2())
|
||||
print("Energy, Channel 3: %0.03f kWh" % sensor.getEnergyC3())
|
||||
|
||||
print "Battery Level: %d\n" % sensor.getBatteryLevel()
|
||||
print("Battery Level: %d\n" % sensor.getBatteryLevel())
|
||||
time.sleep(3)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,13 +21,14 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_ozw as sensorObj
|
||||
from upm import pyupm_ozw as sensorObj
|
||||
|
||||
def main():
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -36,7 +37,7 @@ def main():
|
||||
defaultDev = "/dev/ttyACM0"
|
||||
if (len(sys.argv) > 1):
|
||||
defaultDev = sys.argv[1]
|
||||
print "Using device", defaultDev
|
||||
print("Using device", defaultDev)
|
||||
|
||||
# Instantiate an Aeotec Door/Window 2nd Edition sensor instance, on
|
||||
# device node 10. You will almost certainly need to change this to
|
||||
@ -49,32 +50,32 @@ def main():
|
||||
sensor.optionsLock()
|
||||
|
||||
# Next, initialize it.
|
||||
print "Initializing, this may take awhile depending on your ZWave network"
|
||||
print("Initializing, this may take awhile depending on your ZWave network")
|
||||
|
||||
sensor.init(defaultDev)
|
||||
print "Initialization complete"
|
||||
print("Initialization complete")
|
||||
|
||||
print "Querying data..."
|
||||
print("Querying data...")
|
||||
|
||||
while (True):
|
||||
if (sensor.isDeviceAvailable()):
|
||||
print "Alarm status:",
|
||||
print sensor.isAlarmTripped()
|
||||
print("Alarm status:", end=' ')
|
||||
print(sensor.isAlarmTripped())
|
||||
|
||||
print "Tamper Switch status:",
|
||||
print sensor.isTamperTripped()
|
||||
print("Tamper Switch status:", end=' ')
|
||||
print(sensor.isTamperTripped())
|
||||
|
||||
print "Battery Level:",
|
||||
print sensor.getBatteryLevel(),
|
||||
print "%"
|
||||
print("Battery Level:", end=' ')
|
||||
print(sensor.getBatteryLevel(), end=' ')
|
||||
print("%")
|
||||
|
||||
print
|
||||
print()
|
||||
else:
|
||||
print "Device has not yet responded to probe."
|
||||
print "Try waking it, or wait until it wakes itself if ",
|
||||
print "configured to do so."
|
||||
print("Device has not yet responded to probe.")
|
||||
print("Try waking it, or wait until it wakes itself if ", end=' ')
|
||||
print("configured to do so.")
|
||||
|
||||
print
|
||||
print()
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
|
@ -21,16 +21,17 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_ozw as sensorObj
|
||||
from upm import pyupm_ozw as sensorObj
|
||||
|
||||
def main():
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Turning switch off and sleeping for 5 seconds..."
|
||||
print("Turning switch off and sleeping for 5 seconds...")
|
||||
sensor.off()
|
||||
time.sleep(5)
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -39,7 +40,7 @@ def main():
|
||||
defaultDev = "/dev/ttyACM0"
|
||||
if (len(sys.argv) > 1):
|
||||
defaultDev = sys.argv[1]
|
||||
print "Using device", defaultDev
|
||||
print("Using device", defaultDev)
|
||||
|
||||
# Instantiate an Aeotec Smart Dimmer Gen2 instance, on device node
|
||||
# 9. You will almost certainly need to change this to reflect your
|
||||
@ -52,17 +53,17 @@ def main():
|
||||
sensor.optionsLock()
|
||||
|
||||
# Next, initialize it.
|
||||
print "Initializing, this may take awhile depending on your ZWave network"
|
||||
print("Initializing, this may take awhile depending on your ZWave network")
|
||||
|
||||
sensor.init(defaultDev)
|
||||
print "Initialization complete"
|
||||
print("Initialization complete")
|
||||
|
||||
# turn light on
|
||||
print "Turning switch on, then sleeping for 5 secs"
|
||||
print("Turning switch on, then sleeping for 5 secs")
|
||||
sensor.on();
|
||||
time.sleep(5);
|
||||
|
||||
print "Querying data..."
|
||||
print("Querying data...")
|
||||
dim = False;
|
||||
while (True):
|
||||
# put on a light show...
|
||||
@ -75,25 +76,25 @@ def main():
|
||||
|
||||
sensor.update()
|
||||
|
||||
print "Current Level:",
|
||||
print sensor.getLevel()
|
||||
print("Current Level:", end=' ')
|
||||
print(sensor.getLevel())
|
||||
|
||||
print "Volts:",
|
||||
print sensor.getVolts(),
|
||||
print "volts"
|
||||
print("Volts:", end=' ')
|
||||
print(sensor.getVolts(), end=' ')
|
||||
print("volts")
|
||||
|
||||
print "Energy Consumption:",
|
||||
print sensor.getEnergy(),
|
||||
print "kWh"
|
||||
print("Energy Consumption:", end=' ')
|
||||
print(sensor.getEnergy(), end=' ')
|
||||
print("kWh")
|
||||
|
||||
print "Watts:",
|
||||
print sensor.getWatts()
|
||||
print("Watts:", end=' ')
|
||||
print(sensor.getWatts())
|
||||
|
||||
print "Current:",
|
||||
print sensor.getCurrent(),
|
||||
print "amps"
|
||||
print("Current:", end=' ')
|
||||
print(sensor.getCurrent(), end=' ')
|
||||
print("amps")
|
||||
|
||||
print
|
||||
print()
|
||||
time.sleep(5)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,16 +21,17 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_ozw as sensorObj
|
||||
from upm import pyupm_ozw as sensorObj
|
||||
|
||||
def main():
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Turning switch off and sleeping for 5 seconds..."
|
||||
print("Turning switch off and sleeping for 5 seconds...")
|
||||
sensor.off()
|
||||
time.sleep(5)
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -39,7 +40,7 @@ def main():
|
||||
defaultDev = "/dev/ttyACM0"
|
||||
if (len(sys.argv) > 1):
|
||||
defaultDev = sys.argv[1]
|
||||
print "Using device", defaultDev
|
||||
print("Using device", defaultDev)
|
||||
|
||||
# Instantiate an Aeotec Smart Switch 6 instance, on device node 11.
|
||||
# You will almost certainly need to change this to reflect your own
|
||||
@ -51,40 +52,40 @@ def main():
|
||||
sensor.optionsLock()
|
||||
|
||||
# Next, initialize it.
|
||||
print "Initializing, this may take awhile depending on your ZWave network"
|
||||
print("Initializing, this may take awhile depending on your ZWave network")
|
||||
|
||||
sensor.init(defaultDev)
|
||||
print "Initialization complete"
|
||||
print("Initialization complete")
|
||||
|
||||
# turn light on
|
||||
print "Turning switch on, then sleeping for 5 secs"
|
||||
print("Turning switch on, then sleeping for 5 secs")
|
||||
sensor.on();
|
||||
time.sleep(5);
|
||||
|
||||
print "Querying data..."
|
||||
print("Querying data...")
|
||||
|
||||
while (True):
|
||||
sensor.update()
|
||||
|
||||
print "Switch status:",
|
||||
print sensor.isOn()
|
||||
print("Switch status:", end=' ')
|
||||
print(sensor.isOn())
|
||||
|
||||
print "Volts:",
|
||||
print sensor.getVolts(),
|
||||
print "volts"
|
||||
print("Volts:", end=' ')
|
||||
print(sensor.getVolts(), end=' ')
|
||||
print("volts")
|
||||
|
||||
print "Energy Consumption:",
|
||||
print sensor.getEnergy(),
|
||||
print "kWh"
|
||||
print("Energy Consumption:", end=' ')
|
||||
print(sensor.getEnergy(), end=' ')
|
||||
print("kWh")
|
||||
|
||||
print "Watts:",
|
||||
print sensor.getWatts()
|
||||
print("Watts:", end=' ')
|
||||
print(sensor.getWatts())
|
||||
|
||||
print "Current:",
|
||||
print sensor.getCurrent(),
|
||||
print "amps"
|
||||
print("Current:", end=' ')
|
||||
print(sensor.getCurrent(), end=' ')
|
||||
print("amps")
|
||||
|
||||
print
|
||||
print()
|
||||
time.sleep(3)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_mpu9150 as sensorObj
|
||||
from upm import pyupm_mpu9150 as sensorObj
|
||||
|
||||
def main():
|
||||
# Instantiate an AK8975 on I2C bus 0
|
||||
@ -35,7 +36,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -51,11 +52,11 @@ def main():
|
||||
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("Magnetometer: MX: ", sensorObj.floatp_value(x), end=' ')
|
||||
print(" MY: ", sensorObj.floatp_value(y), end=' ')
|
||||
print(" MZ: ", sensorObj.floatp_value(z))
|
||||
|
||||
print
|
||||
print()
|
||||
|
||||
time.sleep(.5)
|
||||
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_apa102 as mylib
|
||||
from upm import pyupm_apa102 as mylib
|
||||
|
||||
def main():
|
||||
# Instantiate a strip of 30 LEDs on SPI bus 0
|
||||
@ -36,13 +37,13 @@ def main():
|
||||
# Register exit handlers
|
||||
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||
|
||||
print "Setting all LEDs to Green"
|
||||
print("Setting all LEDs to Green")
|
||||
ledStrip.setAllLeds(31, 0, 255, 0)
|
||||
|
||||
print "Setting LEDs between 10 and 20 to Red"
|
||||
print("Setting LEDs between 10 and 20 to Red")
|
||||
ledStrip.setLeds(10, 20, 31, 255, 0, 0)
|
||||
|
||||
print "Setting LED 15 to Blue"
|
||||
print("Setting LED 15 to Blue")
|
||||
ledStrip.setLed(15, 31, 0, 0, 255)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_apds9002 as upmApds9002
|
||||
from upm import pyupm_apds9002 as upmApds9002
|
||||
|
||||
def main():
|
||||
# Instantiate a Grove Luminance sensor on analog pin A0
|
||||
@ -35,7 +36,7 @@ def main():
|
||||
|
||||
# This lets you run code on exit, including functions from myLuminance
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -43,8 +44,8 @@ def main():
|
||||
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||
|
||||
while(1):
|
||||
print "Luminance value is {0}".format(
|
||||
myLuminance.value())
|
||||
print("Luminance value is {0}".format(
|
||||
myLuminance.value()))
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_at42qt1070 as upmAt42qt1070
|
||||
from upm import pyupm_at42qt1070 as upmAt42qt1070
|
||||
|
||||
def main():
|
||||
# functions
|
||||
@ -39,13 +40,13 @@ def main():
|
||||
if (not buttonPressed):
|
||||
sys.stdout.write("None")
|
||||
|
||||
print " "
|
||||
print(" ")
|
||||
|
||||
if (touchObj.isCalibrating()):
|
||||
print "Calibration is occurring."
|
||||
print("Calibration is occurring.")
|
||||
|
||||
if (touchObj.isOverflowed()):
|
||||
print "Overflow was detected."
|
||||
print("Overflow was detected.")
|
||||
|
||||
# Global code that runs on startup
|
||||
|
||||
@ -61,7 +62,7 @@ def main():
|
||||
raise SystemExit
|
||||
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# This function lets you run code on exit, including functions from myTouchSensor
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_bh1750 as sensorObj
|
||||
from upm import pyupm_bh1750 as sensorObj
|
||||
|
||||
def main():
|
||||
# Instantiate a BH1750 sensor using defaults (I2C bus (0), using
|
||||
@ -37,7 +38,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -47,7 +48,7 @@ def main():
|
||||
# Every second, sample the BH1750 and output the measured lux value
|
||||
|
||||
while (True):
|
||||
print "Detected Light Level (lux):", sensor.getLux()
|
||||
print("Detected Light Level (lux):", sensor.getLux())
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_biss0001 as upmMotion
|
||||
from upm import pyupm_biss0001 as upmMotion
|
||||
|
||||
def main():
|
||||
# Instantiate a Grove Motion sensor on GPIO pin D2
|
||||
@ -35,7 +36,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit, including functions from myMotion
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -45,9 +46,9 @@ def main():
|
||||
# Read the value every second and detect motion
|
||||
while(1):
|
||||
if (myMotion.value()):
|
||||
print "Detecting moving object"
|
||||
print("Detecting moving object")
|
||||
else:
|
||||
print "No moving objects detected"
|
||||
print("No moving objects detected")
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_bma220 as sensorObj
|
||||
from upm import pyupm_bma220 as sensorObj
|
||||
|
||||
def main():
|
||||
# Instantiate an BMA220 using default parameters (bus 0, addr 0x0a)
|
||||
@ -35,7 +36,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -49,9 +50,9 @@ def main():
|
||||
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)
|
||||
print("Accelerometer: AX:", sensorObj.floatp_value(x), end=' ')
|
||||
print(" AY:", sensorObj.floatp_value(y), end=' ')
|
||||
print(" AZ:", sensorObj.floatp_value(z))
|
||||
|
||||
time.sleep(.5)
|
||||
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_bmx055 as sensorObj
|
||||
from upm import pyupm_bmx055 as sensorObj
|
||||
|
||||
def main():
|
||||
# Instantiate a BMP250E instance using default i2c bus and address
|
||||
@ -38,7 +39,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -54,16 +55,16 @@ def main():
|
||||
sensor.update()
|
||||
|
||||
sensor.getAccelerometer(x, y, z)
|
||||
print "Accelerometer x:", sensorObj.floatp_value(x),
|
||||
print " y:", sensorObj.floatp_value(y),
|
||||
print " z:", sensorObj.floatp_value(z),
|
||||
print " g"
|
||||
print("Accelerometer x:", sensorObj.floatp_value(x), end=' ')
|
||||
print(" y:", sensorObj.floatp_value(y), end=' ')
|
||||
print(" z:", sensorObj.floatp_value(z), end=' ')
|
||||
print(" g")
|
||||
|
||||
# we show both C and F for temperature
|
||||
print "Compensation Temperature:", sensor.getTemperature(), "C /",
|
||||
print sensor.getTemperature(True), "F"
|
||||
print("Compensation Temperature:", sensor.getTemperature(), "C /", end=' ')
|
||||
print(sensor.getTemperature(True), "F")
|
||||
|
||||
print
|
||||
print()
|
||||
time.sleep(.250)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_bmx055 as sensorObj
|
||||
from upm import pyupm_bmx055 as sensorObj
|
||||
|
||||
def main():
|
||||
# Instantiate a BMC150 instance using default i2c bus and address
|
||||
@ -35,7 +36,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -51,18 +52,18 @@ def main():
|
||||
sensor.update()
|
||||
|
||||
sensor.getAccelerometer(x, y, z)
|
||||
print "Accelerometer x:", sensorObj.floatp_value(x),
|
||||
print " y:", sensorObj.floatp_value(y),
|
||||
print " z:", sensorObj.floatp_value(z),
|
||||
print " g"
|
||||
print("Accelerometer x:", sensorObj.floatp_value(x), end=' ')
|
||||
print(" y:", sensorObj.floatp_value(y), end=' ')
|
||||
print(" z:", sensorObj.floatp_value(z), end=' ')
|
||||
print(" g")
|
||||
|
||||
sensor.getMagnetometer(x, y, z)
|
||||
print "Magnetometer x:", sensorObj.floatp_value(x),
|
||||
print " y:", sensorObj.floatp_value(y),
|
||||
print " z:", sensorObj.floatp_value(z),
|
||||
print " uT"
|
||||
print("Magnetometer x:", sensorObj.floatp_value(x), end=' ')
|
||||
print(" y:", sensorObj.floatp_value(y), end=' ')
|
||||
print(" z:", sensorObj.floatp_value(z), end=' ')
|
||||
print(" uT")
|
||||
|
||||
print
|
||||
print()
|
||||
time.sleep(.250)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_bmp280 as sensorObj
|
||||
from upm import pyupm_bmp280 as sensorObj
|
||||
|
||||
def main():
|
||||
# Instantiate a BME280 instance using default i2c bus and address
|
||||
@ -38,7 +39,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -48,16 +49,16 @@ def main():
|
||||
while (1):
|
||||
sensor.update()
|
||||
|
||||
print "Compensation Temperature:", sensor.getTemperature(), "C /",
|
||||
print sensor.getTemperature(True), "F"
|
||||
print("Compensation Temperature:", sensor.getTemperature(), "C /", end=' ')
|
||||
print(sensor.getTemperature(True), "F")
|
||||
|
||||
print "Pressure: ", sensor.getPressure(), "Pa"
|
||||
print("Pressure: ", sensor.getPressure(), "Pa")
|
||||
|
||||
print "Computed Altitude:", sensor.getAltitude(), "m"
|
||||
print("Computed Altitude:", sensor.getAltitude(), "m")
|
||||
|
||||
print "Humidity:", sensor.getHumidity(), "%RH"
|
||||
print("Humidity:", sensor.getHumidity(), "%RH")
|
||||
|
||||
print
|
||||
print()
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_bmx055 as sensorObj
|
||||
from upm import pyupm_bmx055 as sensorObj
|
||||
|
||||
def main():
|
||||
# Instantiate a BMP250E instance using default i2c bus and address
|
||||
@ -38,7 +39,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -54,16 +55,16 @@ def main():
|
||||
sensor.update()
|
||||
|
||||
sensor.getGyroscope(x, y, z)
|
||||
print "Gyroscope x:", sensorObj.floatp_value(x),
|
||||
print " y:", sensorObj.floatp_value(y),
|
||||
print " z:", sensorObj.floatp_value(z),
|
||||
print " degrees/s"
|
||||
print("Gyroscope x:", sensorObj.floatp_value(x), end=' ')
|
||||
print(" y:", sensorObj.floatp_value(y), end=' ')
|
||||
print(" z:", sensorObj.floatp_value(z), end=' ')
|
||||
print(" degrees/s")
|
||||
|
||||
# we show both C and F for temperature
|
||||
print "Compensation Temperature:", sensor.getTemperature(), "C /",
|
||||
print sensor.getTemperature(True), "F"
|
||||
print("Compensation Temperature:", sensor.getTemperature(), "C /", end=' ')
|
||||
print(sensor.getTemperature(True), "F")
|
||||
|
||||
print
|
||||
print()
|
||||
time.sleep(.250)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_bmx055 as sensorObj
|
||||
from upm import pyupm_bmx055 as sensorObj
|
||||
|
||||
def main():
|
||||
# Instantiate a BMI055 instance using default i2c bus and address
|
||||
@ -35,7 +36,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -51,18 +52,18 @@ def main():
|
||||
sensor.update()
|
||||
|
||||
sensor.getAccelerometer(x, y, z)
|
||||
print "Accelerometer x:", sensorObj.floatp_value(x),
|
||||
print " y:", sensorObj.floatp_value(y),
|
||||
print " z:", sensorObj.floatp_value(z),
|
||||
print " g"
|
||||
print("Accelerometer x:", sensorObj.floatp_value(x), end=' ')
|
||||
print(" y:", sensorObj.floatp_value(y), end=' ')
|
||||
print(" z:", sensorObj.floatp_value(z), end=' ')
|
||||
print(" g")
|
||||
|
||||
sensor.getGyroscope(x, y, z)
|
||||
print "Gyroscope x:", sensorObj.floatp_value(x),
|
||||
print " y:", sensorObj.floatp_value(y),
|
||||
print " z:", sensorObj.floatp_value(z),
|
||||
print " degrees/s"
|
||||
print("Gyroscope x:", sensorObj.floatp_value(x), end=' ')
|
||||
print(" y:", sensorObj.floatp_value(y), end=' ')
|
||||
print(" z:", sensorObj.floatp_value(z), end=' ')
|
||||
print(" degrees/s")
|
||||
|
||||
print
|
||||
print()
|
||||
time.sleep(.250)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_bmi160 as sensorObj
|
||||
from upm import pyupm_bmi160 as sensorObj
|
||||
|
||||
def main():
|
||||
# Instantiate a BMI160 instance using default i2c bus and address
|
||||
@ -35,7 +36,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -49,21 +50,21 @@ def main():
|
||||
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)
|
||||
print("Accelerometer: AX: ", sensorObj.floatp_value(x), end=' ')
|
||||
print(" AY: ", sensorObj.floatp_value(y), end=' ')
|
||||
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("Gyroscope: GX: ", sensorObj.floatp_value(x), end=' ')
|
||||
print(" GY: ", sensorObj.floatp_value(y), end=' ')
|
||||
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("Magnetometer: MX: ", sensorObj.floatp_value(x), end=' ')
|
||||
print(" MY: ", sensorObj.floatp_value(y), end=' ')
|
||||
print(" MZ: ", sensorObj.floatp_value(z))
|
||||
|
||||
print
|
||||
print()
|
||||
time.sleep(.5)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_bmx055 as sensorObj
|
||||
from upm import pyupm_bmx055 as sensorObj
|
||||
|
||||
def main():
|
||||
# Instantiate a BMP250E instance using default i2c bus and address
|
||||
@ -38,7 +39,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -54,12 +55,12 @@ def main():
|
||||
sensor.update()
|
||||
|
||||
sensor.getMagnetometer(x, y, z)
|
||||
print "Magnetometer x:", sensorObj.floatp_value(x),
|
||||
print " y:", sensorObj.floatp_value(y),
|
||||
print " z:", sensorObj.floatp_value(z),
|
||||
print " uT"
|
||||
print("Magnetometer x:", sensorObj.floatp_value(x), end=' ')
|
||||
print(" y:", sensorObj.floatp_value(y), end=' ')
|
||||
print(" z:", sensorObj.floatp_value(z), end=' ')
|
||||
print(" uT")
|
||||
|
||||
print
|
||||
print()
|
||||
time.sleep(.250)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_bmp280 as sensorObj
|
||||
from upm import pyupm_bmp280 as sensorObj
|
||||
|
||||
def main():
|
||||
# Instantiate a BMP280 instance using default i2c bus and address
|
||||
@ -38,7 +39,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -48,14 +49,14 @@ def main():
|
||||
while (1):
|
||||
sensor.update()
|
||||
|
||||
print "Compensation Temperature:", sensor.getTemperature(), "C /",
|
||||
print sensor.getTemperature(True), "F"
|
||||
print("Compensation Temperature:", sensor.getTemperature(), "C /", end=' ')
|
||||
print(sensor.getTemperature(True), "F")
|
||||
|
||||
print "Pressure: ", sensor.getPressure(), "Pa"
|
||||
print("Pressure: ", sensor.getPressure(), "Pa")
|
||||
|
||||
print "Computed Altitude:", sensor.getAltitude(), "m"
|
||||
print("Computed Altitude:", sensor.getAltitude(), "m")
|
||||
|
||||
print
|
||||
print()
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_bmpx8x as upmBmpx8x
|
||||
from upm import pyupm_bmpx8x as upmBmpx8x
|
||||
|
||||
def main():
|
||||
# Load Barometer module on i2c
|
||||
@ -35,7 +36,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit, including functions from myBarometer
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -54,7 +55,7 @@ def main():
|
||||
myBarometer.getAltitude(),
|
||||
myBarometer.getSealevelPressure()))
|
||||
|
||||
print outputStr
|
||||
print(outputStr)
|
||||
time.sleep(.1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_bmx055 as sensorObj
|
||||
from upm import pyupm_bmx055 as sensorObj
|
||||
|
||||
def main():
|
||||
# Instantiate a BMX055 instance using default i2c bus and address
|
||||
@ -35,7 +36,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -51,24 +52,24 @@ def main():
|
||||
sensor.update()
|
||||
|
||||
sensor.getAccelerometer(x, y, z)
|
||||
print "Accelerometer x:", sensorObj.floatp_value(x),
|
||||
print " y:", sensorObj.floatp_value(y),
|
||||
print " z:", sensorObj.floatp_value(z),
|
||||
print " g"
|
||||
print("Accelerometer x:", sensorObj.floatp_value(x), end=' ')
|
||||
print(" y:", sensorObj.floatp_value(y), end=' ')
|
||||
print(" z:", sensorObj.floatp_value(z), end=' ')
|
||||
print(" g")
|
||||
|
||||
sensor.getGyroscope(x, y, z)
|
||||
print "Gyroscope x:", sensorObj.floatp_value(x),
|
||||
print " y:", sensorObj.floatp_value(y),
|
||||
print " z:", sensorObj.floatp_value(z),
|
||||
print " degrees/s"
|
||||
print("Gyroscope x:", sensorObj.floatp_value(x), end=' ')
|
||||
print(" y:", sensorObj.floatp_value(y), end=' ')
|
||||
print(" z:", sensorObj.floatp_value(z), end=' ')
|
||||
print(" degrees/s")
|
||||
|
||||
sensor.getMagnetometer(x, y, z)
|
||||
print "Magnetometer x:", sensorObj.floatp_value(x),
|
||||
print " y:", sensorObj.floatp_value(y),
|
||||
print " z:", sensorObj.floatp_value(z),
|
||||
print " uT"
|
||||
print("Magnetometer x:", sensorObj.floatp_value(x), end=' ')
|
||||
print(" y:", sensorObj.floatp_value(y), end=' ')
|
||||
print(" z:", sensorObj.floatp_value(z), end=' ')
|
||||
print(" uT")
|
||||
|
||||
print
|
||||
print()
|
||||
time.sleep(.250)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_bno055 as sensorObj
|
||||
from upm import pyupm_bno055 as sensorObj
|
||||
|
||||
def main():
|
||||
# Instantiate an BNO055 using default parameters (bus 0, addr
|
||||
@ -37,7 +38,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting..."
|
||||
print("Exiting...")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -54,24 +55,24 @@ def main():
|
||||
y = sensorObj.new_floatp()
|
||||
z = sensorObj.new_floatp()
|
||||
|
||||
print "First we need to calibrate. 4 numbers will be output every"
|
||||
print "second for each sensor. 0 means uncalibrated, and 3 means"
|
||||
print "fully calibrated."
|
||||
print "See the UPM documentation on this sensor for instructions on"
|
||||
print "what actions are required to calibrate."
|
||||
print
|
||||
print("First we need to calibrate. 4 numbers will be output every")
|
||||
print("second for each sensor. 0 means uncalibrated, and 3 means")
|
||||
print("fully calibrated.")
|
||||
print("See the UPM documentation on this sensor for instructions on")
|
||||
print("what actions are required to calibrate.")
|
||||
print()
|
||||
|
||||
while (not sensor.isFullyCalibrated()):
|
||||
sensor.getCalibrationStatus(mag, acc, gyr, syst)
|
||||
print "Magnetometer:", sensorObj.intp_value(mag),
|
||||
print " Accelerometer:", sensorObj.intp_value(acc),
|
||||
print " Gyroscope:", sensorObj.intp_value(gyr),
|
||||
print " System:", sensorObj.intp_value(syst),
|
||||
print("Magnetometer:", sensorObj.intp_value(mag), end=' ')
|
||||
print(" Accelerometer:", sensorObj.intp_value(acc), end=' ')
|
||||
print(" Gyroscope:", sensorObj.intp_value(gyr), end=' ')
|
||||
print(" System:", sensorObj.intp_value(syst), end=' ')
|
||||
time.sleep(1)
|
||||
|
||||
print
|
||||
print "Calibration complete."
|
||||
print
|
||||
print()
|
||||
print("Calibration complete.")
|
||||
print()
|
||||
|
||||
# now output various fusion data every 250 milliseconds
|
||||
|
||||
@ -79,30 +80,30 @@ def main():
|
||||
sensor.update()
|
||||
|
||||
sensor.getEulerAngles(x, y, z)
|
||||
print "Euler: Heading:", sensorObj.floatp_value(x),
|
||||
print " Roll:", sensorObj.floatp_value(y),
|
||||
print " Pitch:", sensorObj.floatp_value(z),
|
||||
print " degrees"
|
||||
print("Euler: Heading:", sensorObj.floatp_value(x), end=' ')
|
||||
print(" Roll:", sensorObj.floatp_value(y), end=' ')
|
||||
print(" Pitch:", sensorObj.floatp_value(z), end=' ')
|
||||
print(" degrees")
|
||||
|
||||
sensor.getQuaternions(w, x, y, z)
|
||||
print "Quaternion: W:", sensorObj.floatp_value(w),
|
||||
print " X:", sensorObj.floatp_value(x),
|
||||
print " Y:", sensorObj.floatp_value(y),
|
||||
print " Z:", sensorObj.floatp_value(z)
|
||||
print("Quaternion: W:", sensorObj.floatp_value(w), end=' ')
|
||||
print(" X:", sensorObj.floatp_value(x), end=' ')
|
||||
print(" Y:", sensorObj.floatp_value(y), end=' ')
|
||||
print(" Z:", sensorObj.floatp_value(z))
|
||||
|
||||
sensor.getLinearAcceleration(x, y, z)
|
||||
print "Linear Acceleration: X:", sensorObj.floatp_value(x),
|
||||
print " Y:", sensorObj.floatp_value(y),
|
||||
print " Z:", sensorObj.floatp_value(z),
|
||||
print " m/s^2"
|
||||
print("Linear Acceleration: X:", sensorObj.floatp_value(x), end=' ')
|
||||
print(" Y:", sensorObj.floatp_value(y), end=' ')
|
||||
print(" Z:", sensorObj.floatp_value(z), end=' ')
|
||||
print(" m/s^2")
|
||||
|
||||
sensor.getGravityVectors(x, y, z)
|
||||
print "Gravity Vector: X:", sensorObj.floatp_value(x),
|
||||
print " Y:", sensorObj.floatp_value(y),
|
||||
print " Z:", sensorObj.floatp_value(z),
|
||||
print " m/s^2"
|
||||
print("Gravity Vector: X:", sensorObj.floatp_value(x), end=' ')
|
||||
print(" Y:", sensorObj.floatp_value(y), end=' ')
|
||||
print(" Z:", sensorObj.floatp_value(z), end=' ')
|
||||
print(" m/s^2")
|
||||
|
||||
print
|
||||
print()
|
||||
time.sleep(.25);
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
# Author: Sarah Knepper <sarah.knepper@intel.com>
|
||||
# Copyright (c) 2014 Intel Corporation.
|
||||
#
|
||||
@ -21,7 +22,7 @@
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import time
|
||||
import pyupm_grove as grove
|
||||
from upm import pyupm_grove as grove
|
||||
|
||||
def main():
|
||||
# Create the button object using GPIO pin 0
|
||||
@ -29,7 +30,7 @@ def main():
|
||||
|
||||
# Read the input and print, waiting one second between readings
|
||||
while 1:
|
||||
print button.name(), ' value is ', button.value()
|
||||
print(button.name(), ' value is ', button.value())
|
||||
time.sleep(1)
|
||||
|
||||
# Delete the button object
|
||||
|
@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
# Author: Sarah Knepper <sarah.knepper@intel.com>
|
||||
# Copyright (c) 2015 Intel Corporation.
|
||||
#
|
||||
@ -21,7 +22,7 @@
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import time
|
||||
import pyupm_buzzer as upmBuzzer
|
||||
from upm import pyupm_buzzer as upmBuzzer
|
||||
|
||||
def main():
|
||||
# Create the buzzer object using GPIO pin 5
|
||||
@ -32,15 +33,15 @@ def main():
|
||||
upmBuzzer.SI];
|
||||
|
||||
# Print sensor name
|
||||
print buzzer.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)
|
||||
print(buzzer.playSound(chords[chord_ind], 1000000))
|
||||
time.sleep(0.1)
|
||||
|
||||
print "exiting application"
|
||||
print("exiting application")
|
||||
|
||||
# Delete the buzzer object
|
||||
del buzzer
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
from __future__ import division
|
||||
import time
|
||||
import pyupm_cjq4435 as upmCjq4435
|
||||
from upm import pyupm_cjq4435 as upmCjq4435
|
||||
|
||||
def main():
|
||||
# Instantiate a CJQ4435 MOSFET on a PWM capable digital pin D3
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_collision as upmcollision
|
||||
from upm import pyupm_collision as upmcollision
|
||||
|
||||
def main():
|
||||
# The was tested with the Collision Sensor
|
||||
@ -37,7 +38,7 @@ def main():
|
||||
# This lets you run code on exit,
|
||||
# including functions from myGrovecollision
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -45,14 +46,14 @@ def main():
|
||||
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||
|
||||
collisionState = False
|
||||
print "No collision"
|
||||
print("No collision")
|
||||
|
||||
while(1):
|
||||
if (mycollision.isColliding() and not collisionState):
|
||||
print "Collision!"
|
||||
print("Collision!")
|
||||
collisionState = True
|
||||
elif (not mycollision.isColliding() and collisionState):
|
||||
print "No collision"
|
||||
print("No collision")
|
||||
collisionState = False
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -22,6 +22,7 @@
|
||||
# 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
|
||||
import mraa
|
||||
print (mraa.getVersion())
|
||||
|
||||
@ -29,7 +30,7 @@ print (mraa.getVersion())
|
||||
mraa.addSubplatform(mraa.GENERIC_FIRMATA, "/dev/ttyACM0")
|
||||
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_curieimu as curieimu
|
||||
from upm import pyupm_curieimu as curieimu
|
||||
|
||||
def main():
|
||||
sensor = curieimu.CurieImu()
|
||||
@ -39,7 +40,7 @@ def main():
|
||||
raise SystemExit
|
||||
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -52,7 +53,7 @@ def main():
|
||||
outputStr = "acc: gX {0} - gY {1} - gZ {2}".format(
|
||||
sensor.getAccelX(), sensor.getAccelY(),
|
||||
sensor.getAccelZ())
|
||||
print outputStr
|
||||
print(outputStr)
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_cwlsxxa as sensorObj
|
||||
from upm import pyupm_cwlsxxa as sensorObj
|
||||
|
||||
def main():
|
||||
## Exit handlers ##
|
||||
@ -32,14 +33,14 @@ def main():
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
atexit.register(exitHandler)
|
||||
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||
|
||||
print "Initializing..."
|
||||
print("Initializing...")
|
||||
|
||||
# Instantiate an CWLSXXA instance, using A0 for CO2, A1 for
|
||||
# humidity and A2 for temperature
|
||||
@ -51,14 +52,14 @@ def main():
|
||||
sensor.update()
|
||||
|
||||
# we show both C and F for temperature
|
||||
print "Temperature:", sensor.getTemperature(), "C /",
|
||||
print sensor.getTemperature(True), "F"
|
||||
print("Temperature:", sensor.getTemperature(), "C /", end=' ')
|
||||
print(sensor.getTemperature(True), "F")
|
||||
|
||||
print "Humidity:", sensor.getHumidity(), "%"
|
||||
print("Humidity:", sensor.getHumidity(), "%")
|
||||
|
||||
print "CO2:", sensor.getCO2(), "ppm"
|
||||
print("CO2:", sensor.getCO2(), "ppm")
|
||||
|
||||
print
|
||||
print()
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_dfrec as sensorObj
|
||||
from upm import pyupm_dfrec as sensorObj
|
||||
|
||||
def main():
|
||||
# Instantiate a DFRobot EC sensor on analog pin A0, with a ds18b20
|
||||
@ -38,7 +39,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -49,10 +50,10 @@ def main():
|
||||
while (True):
|
||||
sensor.update()
|
||||
|
||||
print "EC =", sensor.getEC(), "ms/cm"
|
||||
print "Volts =", sensor.getVolts(),
|
||||
print ", Temperature = ", sensor.getTemperature(), "C"
|
||||
print
|
||||
print("EC =", sensor.getEC(), "ms/cm")
|
||||
print("Volts =", sensor.getVolts(), end=' ')
|
||||
print(", Temperature = ", sensor.getTemperature(), "C")
|
||||
print()
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_dfrorp as sensorObj
|
||||
from upm import pyupm_dfrorp as sensorObj
|
||||
|
||||
def main():
|
||||
# Instantiate a DFRobot ORP sensor on analog pin A0 with an analog
|
||||
@ -51,7 +52,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -62,9 +63,9 @@ def main():
|
||||
while (True):
|
||||
sensor.update()
|
||||
|
||||
print "ORP:", sensor.getORP(), "mV"
|
||||
print("ORP:", sensor.getORP(), "mV")
|
||||
|
||||
print
|
||||
print()
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_dfrph as sensorObj
|
||||
from upm import pyupm_dfrph as sensorObj
|
||||
|
||||
def main():
|
||||
# Instantiate a DFRPH sensor on analog pin A0, with an analog
|
||||
@ -36,7 +37,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -52,8 +53,8 @@ def main():
|
||||
# analog voltage.
|
||||
|
||||
while (1):
|
||||
print "Detected volts: ", sensor.volts()
|
||||
print "pH value: ", sensor.pH()
|
||||
print("Detected volts: ", sensor.volts())
|
||||
print("pH value: ", sensor.pH())
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_ds1307 as upmDs1307
|
||||
from upm import pyupm_ds1307 as upmDs1307
|
||||
|
||||
def main():
|
||||
# load RTC clock on i2c bus 0
|
||||
@ -36,22 +37,22 @@ def main():
|
||||
if (RTCObj.amPmMode):
|
||||
timeStr += (" PM " if RTCObj.pm else " AM ")
|
||||
|
||||
print timeStr
|
||||
print(timeStr)
|
||||
|
||||
print "Clock is in", ("AM/PM mode"
|
||||
if RTCObj.amPmMode else "24hr mode")
|
||||
print("Clock is in", ("AM/PM mode"
|
||||
if RTCObj.amPmMode else "24hr mode"))
|
||||
|
||||
# always do this first
|
||||
print "Loading the current time... "
|
||||
print("Loading the current time... ")
|
||||
result = myRTCClock.loadTime()
|
||||
if (not result):
|
||||
print "myRTCClock.loadTime() failed."
|
||||
print("myRTCClock.loadTime() failed.")
|
||||
sys.exit(0)
|
||||
|
||||
printTime(myRTCClock);
|
||||
|
||||
# set the year as an example
|
||||
print "setting the year to 50"
|
||||
print("setting the year to 50")
|
||||
myRTCClock.year = 50
|
||||
myRTCClock.setTime()
|
||||
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_ds18b20 as sensorObj
|
||||
from upm import pyupm_ds18b20 as sensorObj
|
||||
|
||||
def main():
|
||||
## Exit handlers ##
|
||||
@ -32,14 +33,14 @@ def main():
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting..."
|
||||
print("Exiting...")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
atexit.register(exitHandler)
|
||||
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||
|
||||
print "Initializing..."
|
||||
print("Initializing...")
|
||||
|
||||
# Instantiate an DS18B20 instance using the default values (uart 0)
|
||||
sensor = sensorObj.DS18B20(0)
|
||||
@ -47,8 +48,8 @@ def main():
|
||||
# locate and setup our devices
|
||||
sensor.init()
|
||||
|
||||
print "Found", sensor.devicesFound(), "device(s)"
|
||||
print
|
||||
print("Found", sensor.devicesFound(), "device(s)")
|
||||
print()
|
||||
|
||||
if (not sensor.devicesFound()):
|
||||
sys.exit(1);
|
||||
@ -59,8 +60,8 @@ def main():
|
||||
sensor.update(0)
|
||||
|
||||
# we show both C and F for temperature for the first sensor
|
||||
print "Temperature:", sensor.getTemperature(0), "C /",
|
||||
print sensor.getTemperature(0, True), "F"
|
||||
print("Temperature:", sensor.getTemperature(0), "C /", end=' ')
|
||||
print(sensor.getTemperature(0, True), "F")
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_ds2413 as sensorObj
|
||||
from upm import pyupm_ds2413 as sensorObj
|
||||
|
||||
def main():
|
||||
# Instantiate a DS2413 Module on a Dallas 1-wire bus connected to UART 0
|
||||
@ -35,7 +36,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting..."
|
||||
print("Exiting...")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -46,15 +47,15 @@ def main():
|
||||
sensor.init();
|
||||
|
||||
# how many devices were found?
|
||||
print "Found", sensor.devicesFound(), "device(s)"
|
||||
print("Found", sensor.devicesFound(), "device(s)")
|
||||
|
||||
# read the gpio and latch values from the first device
|
||||
# the lower 4 bits are of the form:
|
||||
# <gpioB latch> <gpioB value> <gpioA latch> <gpioA value>
|
||||
print "GPIO device 0 values:", sensor.readGpios(0)
|
||||
print("GPIO device 0 values:", sensor.readGpios(0))
|
||||
|
||||
# set the gpio latch values of the first device
|
||||
print "Setting GPIO latches to on"
|
||||
print("Setting GPIO latches to on")
|
||||
sensor.writeGpios(0, 0x03);
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_e50hx as sensorObj
|
||||
from upm import pyupm_e50hx as sensorObj
|
||||
|
||||
def main():
|
||||
## Exit handlers ##
|
||||
@ -32,7 +33,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting..."
|
||||
print("Exiting...")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -50,8 +51,8 @@ def main():
|
||||
if (len(sys.argv) > 1):
|
||||
defaultDev = sys.argv[1]
|
||||
|
||||
print "Using device", defaultDev
|
||||
print "Initializing..."
|
||||
print("Using device", defaultDev)
|
||||
print("Initializing...")
|
||||
|
||||
# Instantiate an E50HX object for an E50HX device that has 1075425
|
||||
# as it's unique Device Object Instance ID. NOTE: You will
|
||||
@ -69,30 +70,30 @@ def main():
|
||||
# sensor.setDebug(True);
|
||||
|
||||
# output the serial number and firmware revision
|
||||
print
|
||||
print "Device Description:", sensor.getDeviceDescription()
|
||||
print "Device Location:", sensor.getDeviceLocation()
|
||||
print
|
||||
print()
|
||||
print("Device Description:", sensor.getDeviceDescription())
|
||||
print("Device Location:", sensor.getDeviceLocation())
|
||||
print()
|
||||
|
||||
# update and print available values every second
|
||||
while (1):
|
||||
print "System Voltage:",
|
||||
print sensor.getAnalogValue(sensorObj.E50HX.AV_System_Voltage),
|
||||
print " ",
|
||||
print sensor.getAnalogValueUnits(sensorObj.E50HX.AV_System_Voltage)
|
||||
print("System Voltage:", end=' ')
|
||||
print(sensor.getAnalogValue(sensorObj.E50HX.AV_System_Voltage), end=' ')
|
||||
print(" ", end=' ')
|
||||
print(sensor.getAnalogValueUnits(sensorObj.E50HX.AV_System_Voltage))
|
||||
|
||||
print "System Type:",
|
||||
print sensor.getAnalogValue(sensorObj.E50HX.AV_System_Type)
|
||||
print("System Type:", end=' ')
|
||||
print(sensor.getAnalogValue(sensorObj.E50HX.AV_System_Type))
|
||||
|
||||
print "Energy Consumption:",
|
||||
print sensor.getAnalogInput(sensorObj.E50HX.AI_Energy),
|
||||
print " ",
|
||||
print sensor.getAnalogInputUnits(sensorObj.E50HX.AI_Energy)
|
||||
print("Energy Consumption:", end=' ')
|
||||
print(sensor.getAnalogInput(sensorObj.E50HX.AI_Energy), end=' ')
|
||||
print(" ", end=' ')
|
||||
print(sensor.getAnalogInputUnits(sensorObj.E50HX.AI_Energy))
|
||||
|
||||
print "Power Up Counter:",
|
||||
print sensor.getAnalogInput(sensorObj.E50HX.AI_Power_Up_Count)
|
||||
print("Power Up Counter:", end=' ')
|
||||
print(sensor.getAnalogInput(sensorObj.E50HX.AI_Power_Up_Count))
|
||||
|
||||
print
|
||||
print()
|
||||
time.sleep(5)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,9 +21,10 @@
|
||||
# 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
|
||||
import time, sys
|
||||
|
||||
import pyupm_i2clcd as lcdObj
|
||||
from upm import pyupm_i2clcd as lcdObj
|
||||
|
||||
def main():
|
||||
# setup with default values
|
||||
@ -35,7 +36,7 @@ def main():
|
||||
lcd.setCursor(30, 15);
|
||||
lcd.write("World!");
|
||||
lcd.refresh();
|
||||
print "Sleeping for 5 seconds..."
|
||||
print("Sleeping for 5 seconds...")
|
||||
time.sleep(5)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_ehr as upmehr
|
||||
from upm import pyupm_ehr as upmehr
|
||||
|
||||
def main():
|
||||
# Instantiate a Ear-clip Heart Rate sensor on digital pin D2
|
||||
@ -37,7 +38,7 @@ def main():
|
||||
# including functions from myHeartRateSensor
|
||||
def exitHandler():
|
||||
myHeartRateSensor.stopBeatCounter()
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -62,7 +63,7 @@ def main():
|
||||
# output milliseconds passed, beat count, and computed heart rate
|
||||
outputStr = "Millis: {0} Beats: {1} Heart Rate: {2}".format(
|
||||
millis, beats, fr)
|
||||
print outputStr
|
||||
print(outputStr)
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_eldriver as upmeldriver
|
||||
from upm import pyupm_eldriver as upmeldriver
|
||||
|
||||
def main():
|
||||
# The was tested with the El Driver Module
|
||||
@ -36,7 +37,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit, including functions from myEldriver
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
myEldriver.off()
|
||||
sys.exit(0)
|
||||
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_electromagnet as upmelectromagnet
|
||||
from upm import pyupm_electromagnet as upmelectromagnet
|
||||
|
||||
def main():
|
||||
# This was tested with the Electromagnetic Module
|
||||
@ -37,7 +38,7 @@ def main():
|
||||
# This lets you run code on exit,
|
||||
# including functions from myElectromagnet
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
myElectromagnet.off()
|
||||
sys.exit(0)
|
||||
|
||||
@ -54,7 +55,7 @@ def main():
|
||||
myElectromagnet.on()
|
||||
else:
|
||||
myElectromagnet.off()
|
||||
print "Turning magnet", ("on" if magnetState else "off")
|
||||
print("Turning magnet", ("on" if magnetState else "off"))
|
||||
|
||||
time.sleep(5)
|
||||
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_emg as upmEmg
|
||||
from upm import pyupm_emg as upmEmg
|
||||
|
||||
def main():
|
||||
# Tested with the EMG Muscle Signal Reader Sensor Module
|
||||
@ -36,18 +37,18 @@ def main():
|
||||
|
||||
# This lets you run code on exit, including functions from myEMG
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
atexit.register(exitHandler)
|
||||
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||
|
||||
print "Calibrating...."
|
||||
print("Calibrating....")
|
||||
myEMG.calibrate()
|
||||
|
||||
while (1):
|
||||
print myEMG.value()
|
||||
print(myEMG.value())
|
||||
time.sleep(.1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_enc03r as upmEnc03r
|
||||
from upm import pyupm_enc03r as upmEnc03r
|
||||
|
||||
def main():
|
||||
# Instantiate an ENC03R on analog pin A0
|
||||
@ -36,7 +37,7 @@ def main():
|
||||
# This function lets you run code on exit,
|
||||
# including functions from myAnalogGyro
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -50,15 +51,15 @@ def main():
|
||||
"This may take a couple of minutes.")
|
||||
|
||||
myAnalogGyro.calibrate(CALIBRATION_SAMPLES)
|
||||
print "Calibration complete. "
|
||||
print "Reference value: ", myAnalogGyro.calibrationValue()
|
||||
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
|
||||
print(outputStr)
|
||||
|
||||
time.sleep(.1)
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
# Author: John Van Drasek <john.r.van.drasek@intel.com>
|
||||
# Copyright (c) 2015 Intel Corporation.
|
||||
#
|
||||
@ -21,7 +22,7 @@
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import time
|
||||
import pyupm_servo as servo
|
||||
from upm import pyupm_servo as servo
|
||||
|
||||
def main():
|
||||
# Create the servo object using D5
|
||||
@ -30,17 +31,17 @@ def main():
|
||||
for i in range(0,10):
|
||||
# Set the servo arm to 0 degrees
|
||||
gServo.setAngle(0)
|
||||
print 'Set angle to 0'
|
||||
print('Set angle to 0')
|
||||
time.sleep(1)
|
||||
|
||||
# Set the servo arm to 90 degrees
|
||||
gServo.setAngle(90)
|
||||
print 'Set angle to 90'
|
||||
print('Set angle to 90')
|
||||
time.sleep(1)
|
||||
|
||||
# Set the servo arm to 180 degrees
|
||||
gServo.setAngle(180)
|
||||
print 'Set angle to 180'
|
||||
print('Set angle to 180')
|
||||
time.sleep(1)
|
||||
|
||||
# Delete the servo object
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_gp2y0a as upmGp2y0a
|
||||
from upm import pyupm_gp2y0a as upmGp2y0a
|
||||
|
||||
def main():
|
||||
# Note, for the Grove 80cm version of this sensor, due to the way it is wired,
|
||||
@ -39,7 +40,7 @@ def main():
|
||||
# This lets you run code on exit,
|
||||
# including functions from myIRProximity
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -55,9 +56,9 @@ def main():
|
||||
# Every second, print the averaged voltage value
|
||||
# (averaged over 20 samples).
|
||||
while (1):
|
||||
print "AREF: {0}, Voltage value (higher means closer): {1}".format(
|
||||
print("AREF: {0}, Voltage value (higher means closer): {1}".format(
|
||||
GP2Y0A_AREF,
|
||||
myIRProximity.value(GP2Y0A_AREF, SAMPLES_PER_QUERY))
|
||||
myIRProximity.value(GP2Y0A_AREF, SAMPLES_PER_QUERY)))
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_gprs as sensorObj
|
||||
from upm import pyupm_gprs as sensorObj
|
||||
|
||||
def main():
|
||||
# Instantiate a GPRS Module on UART 0
|
||||
@ -35,7 +36,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -44,7 +45,7 @@ def main():
|
||||
|
||||
# Set the baud rate, 19200 baud is the default.
|
||||
if (sensor.setBaudRate(19200)):
|
||||
print "Failed to set baud rate"
|
||||
print("Failed to set baud rate")
|
||||
sys.exit(0)
|
||||
|
||||
usageStr = ("Usage:\n"
|
||||
@ -52,7 +53,7 @@ def main():
|
||||
"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
|
||||
print(usageStr)
|
||||
|
||||
# simple helper function to send a command and wait for a response
|
||||
def sendCommand(sensor, cmd):
|
||||
@ -62,23 +63,23 @@ def main():
|
||||
|
||||
# wait up to 1 second
|
||||
if (sensor.dataAvailable(1000)):
|
||||
print "Returned: ",
|
||||
print sensor.readDataStr(1024)
|
||||
print("Returned: ", end=' ')
|
||||
print(sensor.readDataStr(1024))
|
||||
else:
|
||||
print "Timed out waiting for response"
|
||||
print("Timed out waiting for response")
|
||||
|
||||
if (len(sys.argv) > 1):
|
||||
print "Sending command line argument (" + 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)..."
|
||||
print("Querying module manufacturer (AT+CGMI)...")
|
||||
sendCommand(sensor, "AT+CGMI");
|
||||
|
||||
time.sleep(1);
|
||||
|
||||
# query the saved profiles
|
||||
print "Querying the saved profiles (AT&V)..."
|
||||
print("Querying the saved profiles (AT&V)...")
|
||||
sendCommand(sensor, "AT&V");
|
||||
|
||||
# A comprehensive list is available from the datasheet at:
|
||||
|
@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
# Author: Sarah Knepper <sarah.knepper@intel.com>
|
||||
# Copyright (c) 2014 Intel Corporation.
|
||||
#
|
||||
@ -21,7 +22,7 @@
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import time
|
||||
import pyupm_grove as grove
|
||||
from upm import pyupm_grove as grove
|
||||
|
||||
def main():
|
||||
# Create the button object using GPIO pin 0
|
||||
@ -29,7 +30,7 @@ def main():
|
||||
|
||||
# Read the input and print, waiting one second between readings
|
||||
while 1:
|
||||
print button.name(), ' value is ', button.value()
|
||||
print(button.name(), ' value is ', button.value())
|
||||
time.sleep(1)
|
||||
|
||||
# Delete the button object
|
||||
|
@ -22,8 +22,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_my9221 as upmGroveCircularLED
|
||||
from upm import pyupm_my9221 as upmGroveCircularLED
|
||||
|
||||
def main():
|
||||
# Exit handlers
|
||||
@ -32,7 +33,7 @@ def main():
|
||||
|
||||
def exitHandler():
|
||||
circle.setLevel(0, True)
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# This function lets you run code on exit
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_grovecollision as upmGrovecollision
|
||||
from upm import pyupm_grovecollision as upmGrovecollision
|
||||
|
||||
def main():
|
||||
# The was tested with the Grove Collision Sensor
|
||||
@ -37,7 +38,7 @@ def main():
|
||||
# This lets you run code on exit,
|
||||
# including functions from myGrovecollision
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -45,14 +46,14 @@ def main():
|
||||
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||
|
||||
collisionState = False
|
||||
print "No collision"
|
||||
print("No collision")
|
||||
|
||||
while(1):
|
||||
if (myGrovecollision.isColliding() and not collisionState):
|
||||
print "Collision!"
|
||||
print("Collision!")
|
||||
collisionState = True
|
||||
elif (not myGrovecollision.isColliding() and collisionState):
|
||||
print "No collision"
|
||||
print("No collision")
|
||||
collisionState = False
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_groveehr as upmGroveehr
|
||||
from upm import pyupm_groveehr as upmGroveehr
|
||||
|
||||
def main():
|
||||
# Instantiate a Grove Ear-clip Heart Rate sensor on digital pin D2
|
||||
@ -37,7 +38,7 @@ def main():
|
||||
# including functions from myHeartRateSensor
|
||||
def exitHandler():
|
||||
myHeartRateSensor.stopBeatCounter()
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -62,7 +63,7 @@ def main():
|
||||
# output milliseconds passed, beat count, and computed heart rate
|
||||
outputStr = "Millis: {0} Beats: {1} Heart Rate: {2}".format(
|
||||
millis, beats, fr)
|
||||
print outputStr
|
||||
print(outputStr)
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_groveeldriver as upmGroveeldriver
|
||||
from upm import pyupm_groveeldriver as upmGroveeldriver
|
||||
|
||||
def main():
|
||||
# The was tested with the Grove El Driver Module
|
||||
@ -36,7 +37,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit, including functions from myEldriver
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
myEldriver.off()
|
||||
sys.exit(0)
|
||||
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_groveelectromagnet as upmGroveelectromagnet
|
||||
from upm import pyupm_groveelectromagnet as upmGroveelectromagnet
|
||||
|
||||
def main():
|
||||
# This was tested with the Grove Electromagnetic Module
|
||||
@ -37,7 +38,7 @@ def main():
|
||||
# This lets you run code on exit,
|
||||
# including functions from myElectromagnet
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
myElectromagnet.off()
|
||||
sys.exit(0)
|
||||
|
||||
@ -54,7 +55,7 @@ def main():
|
||||
myElectromagnet.on()
|
||||
else:
|
||||
myElectromagnet.off()
|
||||
print "Turning magnet", ("on" if magnetState else "off")
|
||||
print("Turning magnet", ("on" if magnetState else "off"))
|
||||
|
||||
time.sleep(5)
|
||||
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_groveemg as upmGroveemg
|
||||
from upm import pyupm_groveemg as upmGroveemg
|
||||
|
||||
def main():
|
||||
# Tested with the GroveEMG Muscle Signal Reader Sensor Module
|
||||
@ -36,18 +37,18 @@ def main():
|
||||
|
||||
# This lets you run code on exit, including functions from myEMG
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
atexit.register(exitHandler)
|
||||
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||
|
||||
print "Calibrating...."
|
||||
print("Calibrating....")
|
||||
myEMG.calibrate()
|
||||
|
||||
while (1):
|
||||
print myEMG.value()
|
||||
print(myEMG.value())
|
||||
time.sleep(.1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_grovegprs as sensorObj
|
||||
from upm import pyupm_grovegprs as sensorObj
|
||||
|
||||
def main():
|
||||
# Instantiate a GroveGPRS Module on UART 0
|
||||
@ -35,7 +36,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -44,7 +45,7 @@ def main():
|
||||
|
||||
# Set the baud rate, 19200 baud is the default.
|
||||
if (sensor.setBaudRate(19200)):
|
||||
print "Failed to set baud rate"
|
||||
print("Failed to set baud rate")
|
||||
sys.exit(0)
|
||||
|
||||
usageStr = ("Usage:\n"
|
||||
@ -52,7 +53,7 @@ def main():
|
||||
"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
|
||||
print(usageStr)
|
||||
|
||||
# simple helper function to send a command and wait for a response
|
||||
def sendCommand(sensor, cmd):
|
||||
@ -62,23 +63,23 @@ def main():
|
||||
|
||||
# wait up to 1 second
|
||||
if (sensor.dataAvailable(1000)):
|
||||
print "Returned: ",
|
||||
print sensor.readDataStr(1024)
|
||||
print("Returned: ", end=' ')
|
||||
print(sensor.readDataStr(1024))
|
||||
else:
|
||||
print "Timed out waiting for response"
|
||||
print("Timed out waiting for response")
|
||||
|
||||
if (len(sys.argv) > 1):
|
||||
print "Sending command line argument (" + 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)..."
|
||||
print("Querying module manufacturer (AT+CGMI)...")
|
||||
sendCommand(sensor, "AT+CGMI");
|
||||
|
||||
time.sleep(1);
|
||||
|
||||
# query the saved profiles
|
||||
print "Querying the saved profiles (AT&V)..."
|
||||
print("Querying the saved profiles (AT&V)...")
|
||||
sendCommand(sensor, "AT&V");
|
||||
|
||||
# A comprehensive list is available from the datasheet at:
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_grovegsr as upmGrovegsr
|
||||
from upm import pyupm_grovegsr as upmGrovegsr
|
||||
|
||||
def main():
|
||||
# Tested with the GroveGSR Galvanic Skin Response Sensor module.
|
||||
@ -37,18 +38,18 @@ def main():
|
||||
|
||||
# This lets you run code on exit, including functions from myGSR
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
atexit.register(exitHandler)
|
||||
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||
|
||||
print "Calibrating...."
|
||||
print("Calibrating....")
|
||||
myGSR.calibrate()
|
||||
|
||||
while (1):
|
||||
print myGSR.value()
|
||||
print(myGSR.value())
|
||||
time.sleep(.5)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
# Author: Sarah Knepper <sarah.knepper@intel.com>
|
||||
# Copyright (c) 2015 Intel Corporation.
|
||||
#
|
||||
@ -21,14 +22,14 @@
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import time
|
||||
import pyupm_grove as grove
|
||||
from upm import pyupm_grove as grove
|
||||
|
||||
def main():
|
||||
# Create the Grove LED object using GPIO pin 2
|
||||
led = grove.GroveLed(2)
|
||||
|
||||
# Print the name
|
||||
print led.name()
|
||||
print(led.name())
|
||||
|
||||
# Turn the LED on and off 10 times, pausing one second
|
||||
# between transitions
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_my9221 as upmMy9221
|
||||
from upm import pyupm_my9221 as upmMy9221
|
||||
|
||||
def main():
|
||||
# Instantiate a MY9221, we use D8 for the data, and D9 for the
|
||||
@ -35,7 +36,7 @@ def main():
|
||||
|
||||
def exitHandler():
|
||||
myLEDBar.setBarLevel(0, True)
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# This function lets you run code on exit
|
||||
|
@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
# Author: Sarah Knepper <sarah.knepper@intel.com>
|
||||
# Copyright (c) 2014 Intel Corporation.
|
||||
#
|
||||
@ -21,7 +22,7 @@
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import time
|
||||
import pyupm_grove as grove
|
||||
from upm import pyupm_grove as grove
|
||||
|
||||
def main():
|
||||
# Create the light sensor object using AIO pin 0
|
||||
@ -30,8 +31,8 @@ def main():
|
||||
# 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";
|
||||
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
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_grovelinefinder as upmGrovelinefinder
|
||||
from upm import pyupm_grovelinefinder as upmGrovelinefinder
|
||||
|
||||
def main():
|
||||
# Instantiate a Grove line finder sensor on digital pin D2
|
||||
@ -35,7 +36,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit, including functions from myLineFinder
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -44,9 +45,9 @@ def main():
|
||||
|
||||
while(1):
|
||||
if (myLineFinder.whiteDetected()):
|
||||
print "White detected."
|
||||
print("White detected.")
|
||||
else:
|
||||
print "Black detected."
|
||||
print("Black detected.")
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -22,7 +22,7 @@
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import time
|
||||
import pyupm_grovemd as upmGrovemd
|
||||
from upm import pyupm_grovemd as upmGrovemd
|
||||
|
||||
def main():
|
||||
I2C_BUS = upmGrovemd.GROVEMD_I2C_BUS
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time
|
||||
import pyupm_grovemd as upmGrovemd
|
||||
from upm import pyupm_grovemd as upmGrovemd
|
||||
|
||||
def main():
|
||||
I2C_BUS = upmGrovemd.GROVEMD_I2C_BUS
|
||||
@ -32,18 +33,18 @@ def main():
|
||||
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"
|
||||
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"
|
||||
print("Reversing M1 and M2 for 3 seconds")
|
||||
myMotorDriver.setMotorDirections(upmGrovemd.GroveMD.DIR_CCW,
|
||||
upmGrovemd.GroveMD.DIR_CCW)
|
||||
time.sleep(3)
|
||||
|
||||
print "Stopping motors"
|
||||
print("Stopping motors")
|
||||
myMotorDriver.setMotorSpeeds(0, 0)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_grovemoisture as upmMoisture
|
||||
from upm import pyupm_grovemoisture as upmMoisture
|
||||
|
||||
def main():
|
||||
# Instantiate a Grove Moisture sensor on analog pin A0
|
||||
@ -35,7 +36,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit, including functions from myMoisture
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -56,7 +57,7 @@ def main():
|
||||
result = "Moist"
|
||||
else:
|
||||
result = "Wet"
|
||||
print "Moisture value: {0}, {1}".format(moisture_val, result)
|
||||
print("Moisture value: {0}, {1}".format(moisture_val, result))
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_groveo2 as upmGroveo2
|
||||
from upm import pyupm_groveo2 as upmGroveo2
|
||||
|
||||
def main():
|
||||
# This was tested with the O2 Oxygen Concentration Sensor Module
|
||||
@ -36,7 +37,7 @@ def main():
|
||||
|
||||
# This lets you run code on exit, including functions from myGroveO2
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -44,8 +45,8 @@ def main():
|
||||
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||
|
||||
while(1):
|
||||
print "The output voltage is: {0}mV".format(
|
||||
myGroveO2.voltageValue())
|
||||
print("The output voltage is: {0}mV".format(
|
||||
myGroveO2.voltageValue()))
|
||||
|
||||
time.sleep(.1)
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
# Author: Sarah Knepper <sarah.knepper@intel.com>
|
||||
# Copyright (c) 2015 Intel Corporation.
|
||||
#
|
||||
@ -21,7 +22,7 @@
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import time
|
||||
import pyupm_grove as grove
|
||||
from upm import pyupm_grove as grove
|
||||
|
||||
def main():
|
||||
# Create the relay switch object using GPIO pin 0
|
||||
@ -34,11 +35,11 @@ def main():
|
||||
for i in range (0,3):
|
||||
relay.on()
|
||||
if relay.isOn():
|
||||
print relay.name(), 'is on'
|
||||
print(relay.name(), 'is on')
|
||||
time.sleep(1)
|
||||
relay.off()
|
||||
if relay.isOff():
|
||||
print relay.name(), 'is off'
|
||||
print(relay.name(), 'is off')
|
||||
time.sleep(1)
|
||||
|
||||
# Delete the relay switch object
|
||||
|
@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
# Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
|
||||
# Copyright (c) 2014 Intel Corporation.
|
||||
#
|
||||
@ -21,7 +22,7 @@
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from time import sleep
|
||||
import pyupm_grove as grove
|
||||
from upm import pyupm_grove as grove
|
||||
|
||||
def main():
|
||||
# New knob on AIO pin 0
|
||||
@ -38,8 +39,8 @@ def main():
|
||||
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"
|
||||
print("Abs values: %4d" % int(abs) , " raw %4d" % int(absdeg), "deg = %5.2f" % absrad , " rad ", end=' ')
|
||||
print("Rel values: %4d" % int(rel) , " raw %4d" % int(reldeg), "deg = %5.2f" % relrad , " rad")
|
||||
|
||||
# Sleep for 2.5 s
|
||||
sleep(2.5)
|
||||
|
@ -22,8 +22,9 @@
|
||||
# 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
|
||||
import sys
|
||||
import pyupm_grovescam as upmGrovescam
|
||||
from upm import pyupm_grovescam as upmGrovescam
|
||||
|
||||
def main():
|
||||
# Instantiate a Grove Serial Camera on UART 0
|
||||
@ -31,34 +32,34 @@ def main():
|
||||
|
||||
# make sure port is initialized properly. 115200 baud is the default.
|
||||
if (not camera.setupTty()):
|
||||
print "Failed to setup tty port parameters"
|
||||
print("Failed to setup tty port parameters")
|
||||
sys.exit(1)
|
||||
|
||||
if (camera.init()):
|
||||
print "Initialized..."
|
||||
print("Initialized...")
|
||||
else:
|
||||
print "init() failed"
|
||||
print("init() failed")
|
||||
|
||||
if (camera.preCapture()):
|
||||
print "preCapture succeeded..."
|
||||
print("preCapture succeeded...")
|
||||
else:
|
||||
print "preCapture failed."
|
||||
print("preCapture failed.")
|
||||
|
||||
if (camera.doCapture()):
|
||||
print "doCapture succeeded..."
|
||||
print("doCapture succeeded...")
|
||||
else:
|
||||
print "doCapture failed."
|
||||
print("doCapture failed.")
|
||||
|
||||
print "Image size is", camera.getImageSize(), "bytes"
|
||||
print("Image size is", camera.getImageSize(), "bytes")
|
||||
|
||||
if (camera.getImageSize() > 0):
|
||||
print "Storing image.jpg..."
|
||||
print("Storing image.jpg...")
|
||||
if (camera.storeImage("image.jpg")):
|
||||
print "storeImage succeeded..."
|
||||
print("storeImage succeeded...")
|
||||
else:
|
||||
print "storeImage failed."
|
||||
print("storeImage failed.")
|
||||
|
||||
print "Exiting."
|
||||
print("Exiting.")
|
||||
sys.exit(0)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
# Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
|
||||
# Copyright (c) 2014 Intel Corporation.
|
||||
#
|
||||
@ -21,7 +22,7 @@
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from time import sleep
|
||||
import pyupm_grove as grove
|
||||
from upm import pyupm_grove as grove
|
||||
|
||||
def main():
|
||||
# New Grove Slider on AIO pin 0
|
||||
@ -33,7 +34,7 @@ def main():
|
||||
raw = slider.raw_value()
|
||||
volts = slider.voltage_value()
|
||||
|
||||
print "Slider value: ", raw , " = %.2f" % volts , " V"
|
||||
print("Slider value: ", raw , " = %.2f" % volts , " V")
|
||||
|
||||
# Sleep for 2.5 s
|
||||
sleep(2.5)
|
||||
|
@ -22,7 +22,7 @@
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_grovespeaker as upmGrovespeaker
|
||||
from upm import pyupm_grovespeaker as upmGrovespeaker
|
||||
|
||||
def main():
|
||||
# Instantiate a Grove Speaker on digital pin D2
|
||||
|
@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
# Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
# Contributions: Sarah Knepper <sarah.knepper@intel.com>
|
||||
# Copyright (c) 2014 Intel Corporation.
|
||||
@ -22,20 +23,20 @@
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import time
|
||||
import pyupm_grove as grove
|
||||
from upm import pyupm_grove as grove
|
||||
|
||||
def main():
|
||||
# Create the temperature sensor object using AIO pin 0
|
||||
temp = grove.GroveTemp(0)
|
||||
print temp.name()
|
||||
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)
|
||||
print("%d degrees Celsius, or %d degrees Fahrenheit" \
|
||||
% (celsius, fahrenheit))
|
||||
time.sleep(1)
|
||||
|
||||
# Delete the temperature sensor object
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_grovevdiv as upmGrovevdiv
|
||||
from upm import pyupm_grovevdiv as upmGrovevdiv
|
||||
|
||||
def main():
|
||||
# Instantiate a Grove Voltage Divider sensor on analog pin A0
|
||||
@ -36,7 +37,7 @@ def main():
|
||||
# This function lets you run code on exit,
|
||||
# including functions from myVoltageDivider
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -47,8 +48,8 @@ def main():
|
||||
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)
|
||||
print("ADC value: {0} Gain 3: {1}v Gain 10: {2}v".format(
|
||||
val, gain3val, gain10val))
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_grovewater as upmGrovewater
|
||||
from upm import pyupm_grovewater as upmGrovewater
|
||||
|
||||
def main():
|
||||
# Instantiate a Grove Water sensor on digital pin D2
|
||||
@ -35,7 +36,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit, including functions from myWaterSensor
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -44,9 +45,9 @@ def main():
|
||||
|
||||
while(1):
|
||||
if (myWaterSensor.isWet()):
|
||||
print "Sensor is wet"
|
||||
print("Sensor is wet")
|
||||
else:
|
||||
print "Sensor is dry"
|
||||
print("Sensor is dry")
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_grovewfs as upmGrovewfs
|
||||
from upm import pyupm_grovewfs as upmGrovewfs
|
||||
|
||||
def main():
|
||||
# Instantiate a Grove Water Flow Sensor on digital pin D2
|
||||
@ -37,7 +38,7 @@ def main():
|
||||
# including functions from myWaterFlow
|
||||
def exitHandler():
|
||||
myWaterFlow.stopFlowCounter()
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -59,7 +60,7 @@ def main():
|
||||
# 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
|
||||
print(outputStr)
|
||||
time.sleep(2)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_gsr as upmGsr
|
||||
from upm import pyupm_gsr as upmGsr
|
||||
|
||||
def main():
|
||||
# Tested with the GSR Galvanic Skin Response Sensor module.
|
||||
@ -37,18 +38,18 @@ def main():
|
||||
|
||||
# This lets you run code on exit, including functions from myGSR
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
atexit.register(exitHandler)
|
||||
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||
|
||||
print "Calibrating...."
|
||||
print("Calibrating....")
|
||||
myGSR.calibrate()
|
||||
|
||||
while (1):
|
||||
print myGSR.value()
|
||||
print(myGSR.value())
|
||||
time.sleep(.5)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_guvas12d as upmUV
|
||||
from upm import pyupm_guvas12d as upmUV
|
||||
|
||||
def main():
|
||||
# Instantiate a UV sensor on analog pin A0
|
||||
@ -39,7 +40,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit, including functions from myUVSensor
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -51,7 +52,7 @@ def main():
|
||||
"Voltage value (higher means more UV): "
|
||||
"{1}".format(GUVAS12D_AREF,
|
||||
myUVSensor.value(GUVAS12D_AREF, SAMPLES_PER_QUERY)))
|
||||
print s
|
||||
print(s)
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_h3lis331dl as upmH3LIS331DL
|
||||
from upm import pyupm_h3lis331dl as upmH3LIS331DL
|
||||
|
||||
def main():
|
||||
# Instantiate an H3LIS331DL on I2C bus 0
|
||||
@ -37,7 +38,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit, including functions from myDigitalAccelerometer
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -63,7 +64,7 @@ def main():
|
||||
" Z = {2}").format(upmH3LIS331DL.intp_value(x),
|
||||
upmH3LIS331DL.intp_value(y),
|
||||
upmH3LIS331DL.intp_value(z))
|
||||
print outputStr
|
||||
print(outputStr)
|
||||
|
||||
myDigitalAccelerometer.getAcceleration(ax, ay, az)
|
||||
outputStr = ("Acceleration: AX = {0}"
|
||||
@ -71,7 +72,7 @@ def main():
|
||||
" AZ = {2}").format(upmH3LIS331DL.floatp_value(ax),
|
||||
upmH3LIS331DL.floatp_value(ay),
|
||||
upmH3LIS331DL.floatp_value(az))
|
||||
print outputStr
|
||||
print(outputStr)
|
||||
time.sleep(.5)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_h803x as sensorObj
|
||||
from upm import pyupm_h803x as sensorObj
|
||||
|
||||
def main():
|
||||
## Exit handlers ##
|
||||
@ -32,7 +33,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting..."
|
||||
print("Exiting...")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -45,17 +46,17 @@ def main():
|
||||
if (len(sys.argv) > 1):
|
||||
defaultDev = sys.argv[1]
|
||||
|
||||
print "Using device", defaultDev
|
||||
print "Initializing..."
|
||||
print("Using device", defaultDev)
|
||||
print("Initializing...")
|
||||
|
||||
# Instantiate an H803X instance, using MODBUS slave address 1, and
|
||||
# default comm parameters (9600, 8, N, 2)
|
||||
sensor = sensorObj.H803X(defaultDev, 1)
|
||||
|
||||
# output the serial number and firmware revision
|
||||
print "Slave ID:", sensor.getSlaveID()
|
||||
print("Slave ID:", sensor.getSlaveID())
|
||||
|
||||
print
|
||||
print()
|
||||
|
||||
# update and print available values every second
|
||||
while (1):
|
||||
@ -63,47 +64,47 @@ def main():
|
||||
sensor.update()
|
||||
|
||||
# H8035 / H8036
|
||||
print "Consumption (kWh):", sensor.getConsumption()
|
||||
print "Real Power (kW):", sensor.getRealPower()
|
||||
print("Consumption (kWh):", sensor.getConsumption())
|
||||
print("Real Power (kW):", sensor.getRealPower())
|
||||
|
||||
if (sensor.isH8036()):
|
||||
# The H8036 has much more data available...
|
||||
|
||||
print "Reactive Power (kVAR):", sensor.getReactivePower()
|
||||
print "Apparent Power (kVA):", sensor.getApparentPower()
|
||||
print "Power Factor:", sensor.getPowerFactor()
|
||||
print "Volts Line to Line:", sensor.getVoltsLineToLine()
|
||||
print "Volts Line to Neutral:", sensor.getVoltsLineToNeutral()
|
||||
print("Reactive Power (kVAR):", sensor.getReactivePower())
|
||||
print("Apparent Power (kVA):", sensor.getApparentPower())
|
||||
print("Power Factor:", sensor.getPowerFactor())
|
||||
print("Volts Line to Line:", sensor.getVoltsLineToLine())
|
||||
print("Volts Line to Neutral:", sensor.getVoltsLineToNeutral())
|
||||
|
||||
print "Current:", sensor.getCurrent()
|
||||
print("Current:", sensor.getCurrent())
|
||||
|
||||
print "Real Power Phase A (kW):", sensor.getRealPowerPhaseA()
|
||||
print "Real Power Phase B (kW):", sensor.getRealPowerPhaseB()
|
||||
print "Real Power Phase C (kW):", sensor.getRealPowerPhaseC()
|
||||
print("Real Power Phase A (kW):", sensor.getRealPowerPhaseA())
|
||||
print("Real Power Phase B (kW):", sensor.getRealPowerPhaseB())
|
||||
print("Real Power Phase C (kW):", sensor.getRealPowerPhaseC())
|
||||
|
||||
print "Power Factor Phase A:", sensor.getPowerFactorPhaseA()
|
||||
print "Power Factor Phase B:", sensor.getPowerFactorPhaseB()
|
||||
print "Power Factor Phase C:", sensor.getPowerFactorPhaseC()
|
||||
print("Power Factor Phase A:", sensor.getPowerFactorPhaseA())
|
||||
print("Power Factor Phase B:", sensor.getPowerFactorPhaseB())
|
||||
print("Power Factor Phase C:", sensor.getPowerFactorPhaseC())
|
||||
|
||||
print "Volts Phase A to B:", sensor.getVoltsPhaseAToB()
|
||||
print "Volts Phase B to C:", sensor.getVoltsPhaseBToC()
|
||||
print "Volts Phase A to C:", sensor.getVoltsPhaseAToC()
|
||||
print "Volts Phase A to Neutral: ",
|
||||
print sensor.getVoltsPhaseAToNeutral()
|
||||
print "Volts Phase B to Neutral: ",
|
||||
print sensor.getVoltsPhaseBToNeutral()
|
||||
print "Volts Phase C to Neutral: ",
|
||||
print sensor.getVoltsPhaseCToNeutral()
|
||||
print("Volts Phase A to B:", sensor.getVoltsPhaseAToB())
|
||||
print("Volts Phase B to C:", sensor.getVoltsPhaseBToC())
|
||||
print("Volts Phase A to C:", sensor.getVoltsPhaseAToC())
|
||||
print("Volts Phase A to Neutral: ", end=' ')
|
||||
print(sensor.getVoltsPhaseAToNeutral())
|
||||
print("Volts Phase B to Neutral: ", end=' ')
|
||||
print(sensor.getVoltsPhaseBToNeutral())
|
||||
print("Volts Phase C to Neutral: ", end=' ')
|
||||
print(sensor.getVoltsPhaseCToNeutral())
|
||||
|
||||
print "Current Phase A:", sensor.getCurrentPhaseA()
|
||||
print "Current Phase B:", sensor.getCurrentPhaseB()
|
||||
print "Current Phase C:", sensor.getCurrentPhaseC()
|
||||
print("Current Phase A:", sensor.getCurrentPhaseA())
|
||||
print("Current Phase B:", sensor.getCurrentPhaseB())
|
||||
print("Current Phase C:", sensor.getCurrentPhaseC())
|
||||
|
||||
print "Avg Real Power (kW):", sensor.getAvgRealPower()
|
||||
print "Min Real Power (kW):", sensor.getMinRealPower()
|
||||
print "Max Real Power (kW):", sensor.getMaxRealPower()
|
||||
print("Avg Real Power (kW):", sensor.getAvgRealPower())
|
||||
print("Min Real Power (kW):", sensor.getMinRealPower())
|
||||
print("Max Real Power (kW):", sensor.getMaxRealPower())
|
||||
|
||||
print
|
||||
print()
|
||||
time.sleep(2)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_hdxxvxta as sensorObj
|
||||
from upm import pyupm_hdxxvxta as sensorObj
|
||||
|
||||
def main():
|
||||
## Exit handlers ##
|
||||
@ -32,14 +33,14 @@ def main():
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
atexit.register(exitHandler)
|
||||
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||
|
||||
print "Initializing..."
|
||||
print("Initializing...")
|
||||
|
||||
# Instantiate an HDXXVXTA instance, using A1 for humidity and A0
|
||||
# for temperature
|
||||
@ -51,12 +52,12 @@ def main():
|
||||
sensor.update()
|
||||
|
||||
# we show both C and F for temperature
|
||||
print "Temperature:", sensor.getTemperature(), "C /",
|
||||
print sensor.getTemperature(True), "F"
|
||||
print("Temperature:", sensor.getTemperature(), "C /", end=' ')
|
||||
print(sensor.getTemperature(True), "F")
|
||||
|
||||
print "Humidity:", sensor.getHumidity(), "%"
|
||||
print("Humidity:", sensor.getHumidity(), "%")
|
||||
|
||||
print
|
||||
print()
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_hka5 as sensorObj
|
||||
from upm import pyupm_hka5 as sensorObj
|
||||
|
||||
def main():
|
||||
# Instantiate a HKA5 sensor on uart 0. We don't use the set or
|
||||
@ -36,7 +37,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -47,19 +48,19 @@ def main():
|
||||
while (True):
|
||||
sensor.update()
|
||||
|
||||
print "PM 1 :",
|
||||
print sensor.getPM1(),
|
||||
print " ug/m3"
|
||||
print("PM 1 :", end=' ')
|
||||
print(sensor.getPM1(), end=' ')
|
||||
print(" ug/m3")
|
||||
|
||||
print "PM 2.5:",
|
||||
print sensor.getPM2_5(),
|
||||
print " ug/m3"
|
||||
print("PM 2.5:", end=' ')
|
||||
print(sensor.getPM2_5(), end=' ')
|
||||
print(" ug/m3")
|
||||
|
||||
print "PM 10 :",
|
||||
print sensor.getPM10(),
|
||||
print " ug/m3"
|
||||
print("PM 10 :", end=' ')
|
||||
print(sensor.getPM10(), end=' ')
|
||||
print(" ug/m3")
|
||||
|
||||
print
|
||||
print()
|
||||
time.sleep(2)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_hm11 as upmHm11
|
||||
from upm import pyupm_hm11 as upmHm11
|
||||
|
||||
def main():
|
||||
# Instantiate a HM11 BLE Module on UART 0
|
||||
@ -36,7 +37,7 @@ def main():
|
||||
# This function lets you run code on exit,
|
||||
# including functions from my_ble_obj
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -47,7 +48,7 @@ def main():
|
||||
|
||||
# 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"
|
||||
print("Failed to setup tty port parameters")
|
||||
sys.exit(0)
|
||||
|
||||
usageStr = ("Usage:\n"
|
||||
@ -57,7 +58,7 @@ def main():
|
||||
"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
|
||||
print(usageStr)
|
||||
|
||||
# simple helper function to send a command and wait for a response
|
||||
def sendCommand(bleObj, cmd):
|
||||
@ -75,23 +76,23 @@ def main():
|
||||
break
|
||||
else:
|
||||
bleData += bleBuffer.__getitem__(x)
|
||||
print bleData
|
||||
print(bleData)
|
||||
else:
|
||||
print "Timed out waiting for response"
|
||||
print("Timed out waiting for response")
|
||||
|
||||
if (len(sys.argv) > 1):
|
||||
print "Sending command line argument (" + 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 + ")..."
|
||||
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 + ")..."
|
||||
print("Querying module PIN (" + pin + ")...")
|
||||
sendCommand(my_ble_obj, pin)
|
||||
|
||||
# Other potentially useful commands are:
|
||||
|
@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
# Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
|
||||
# Copyright (c) 2015 Intel Corporation.
|
||||
#
|
||||
@ -21,7 +22,7 @@
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from time import sleep
|
||||
import pyupm_hmc5883l as hmc5883l
|
||||
from upm import pyupm_hmc5883l as hmc5883l
|
||||
|
||||
def main():
|
||||
# Create an I2C compass object and set declination
|
||||
@ -36,9 +37,9 @@ def main():
|
||||
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)
|
||||
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)
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_hmtrp as upmHmtrp
|
||||
from upm import pyupm_hmtrp as upmHmtrp
|
||||
|
||||
def main():
|
||||
# Instantiate a HMTRP radio device on uart 0
|
||||
@ -36,7 +37,7 @@ def main():
|
||||
# This function lets you run code on exit,
|
||||
# including functions from my_HMTRP_Radio
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -51,7 +52,7 @@ def main():
|
||||
|
||||
# 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"
|
||||
print("Failed to setup tty port parameters")
|
||||
sys.exit(0)
|
||||
|
||||
usageStr = ("Usage:\n"
|
||||
@ -61,7 +62,7 @@ def main():
|
||||
"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
|
||||
print(usageStr)
|
||||
|
||||
'''
|
||||
By default, this radio simply transmits data sent via writeData()
|
||||
@ -91,23 +92,23 @@ def main():
|
||||
|
||||
if (my_HMTRP_Radio.getConfig(freq, dataRate, rxBandwidth,
|
||||
modulation, txPower, uartBaud)):
|
||||
print "Radio configuration:"
|
||||
print("Radio configuration:")
|
||||
outputStr = ("freq: {0} dataRate: {1} "
|
||||
"rxBandwidth: {2}Khz").format(freq.__getitem__(0),
|
||||
dataRate.__getitem__(0),
|
||||
rxBandwidth.__getitem__(0))
|
||||
print outputStr
|
||||
print(outputStr)
|
||||
|
||||
outputStr = "modulation: %d Khz txPower: %d uartBaud: %d" % (
|
||||
modulation.__getitem__(0), txPower.__getitem__(0),
|
||||
uartBaud.__getitem__(0))
|
||||
print outputStr
|
||||
print(outputStr)
|
||||
else:
|
||||
errString = ("getConfig() failed. Make sure the radio "
|
||||
"is in CONFIG mode.")
|
||||
print errString
|
||||
print(errString)
|
||||
else:
|
||||
print "Running in normal read/write mode."
|
||||
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.
|
||||
@ -118,17 +119,17 @@ def main():
|
||||
resultStr = "";
|
||||
for x in range(rv):
|
||||
resultStr += radioBuffer.__getitem__(x)
|
||||
print "Received:", resultStr
|
||||
print("Received:", resultStr)
|
||||
|
||||
if (rv < 0): # some sort of read error occurred
|
||||
print "Port read error."
|
||||
print("Port read error.")
|
||||
sys.exit(0)
|
||||
myCounter += 1
|
||||
# every second, transmit "Hello World"
|
||||
if (myCounter > 10):
|
||||
msg = "Hello World!"
|
||||
|
||||
print "Transmitting %s..." % msg
|
||||
print("Transmitting %s..." % msg)
|
||||
|
||||
# Adding 1 for NULL terminator.
|
||||
# Note that SWIG automatically adds a NULL terminator,
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_hp20x as barometerObj
|
||||
from upm import pyupm_hp20x as barometerObj
|
||||
|
||||
def main():
|
||||
## Exit handlers ##
|
||||
@ -33,7 +34,7 @@ def main():
|
||||
# This function lets you run code on exit,
|
||||
# including functions from ringCoder
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -47,10 +48,10 @@ def main():
|
||||
bar.init()
|
||||
|
||||
while(1):
|
||||
print "Temperature:", bar.getTemperature(), "Celsius"
|
||||
print "Pressure: ", bar.getPressure(), "Millibars"
|
||||
print "Altitude: ", bar.getAltitude(), "Meters"
|
||||
print
|
||||
print("Temperature:", bar.getTemperature(), "Celsius")
|
||||
print("Pressure: ", bar.getPressure(), "Millibars")
|
||||
print("Altitude: ", bar.getAltitude(), "Meters")
|
||||
print()
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_ht9170 as upmHt9170
|
||||
from upm import pyupm_ht9170 as upmHt9170
|
||||
|
||||
def main():
|
||||
# Instantiate a DTMF decoder
|
||||
@ -35,7 +36,7 @@ def main():
|
||||
|
||||
# This lets you run code on exit, including functions from myDTMF
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -47,7 +48,7 @@ def main():
|
||||
# and continue looping.
|
||||
while (1):
|
||||
if (dtmf_obj.digitReady()):
|
||||
print "Got DTMF code:", dtmf_obj.decodeDigit()
|
||||
print("Got DTMF code:", dtmf_obj.decodeDigit())
|
||||
# now spin until digitReady() goes false again
|
||||
while (dtmf.digitReady()):
|
||||
pass
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_hwxpxx as sensorObj
|
||||
from upm import pyupm_hwxpxx as sensorObj
|
||||
|
||||
def main():
|
||||
## Exit handlers ##
|
||||
@ -32,7 +33,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print "Exiting..."
|
||||
print("Exiting...")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -45,21 +46,21 @@ def main():
|
||||
if (len(sys.argv) > 1):
|
||||
defaultDev = sys.argv[1]
|
||||
|
||||
print "Using device", defaultDev
|
||||
print "Initializing..."
|
||||
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()
|
||||
print("Slave ID:", sensor.getSlaveID())
|
||||
|
||||
# stored temperature and humidity offsets
|
||||
print "Temperature Offset:", sensor.getTemperatureOffset()
|
||||
print "Humidity Offset:", sensor.getHumidityOffset()
|
||||
print("Temperature Offset:", sensor.getTemperatureOffset())
|
||||
print("Humidity Offset:", sensor.getHumidityOffset())
|
||||
|
||||
print
|
||||
print()
|
||||
|
||||
# update and print available values every second
|
||||
while (1):
|
||||
@ -67,16 +68,16 @@ def main():
|
||||
sensor.update()
|
||||
|
||||
# we show both C and F for temperature
|
||||
print "Temperature:", sensor.getTemperature(), "C /",
|
||||
print sensor.getTemperature(True), "F"
|
||||
print("Temperature:", sensor.getTemperature(), "C /", end=' ')
|
||||
print(sensor.getTemperature(True), "F")
|
||||
|
||||
print "Humidity:", sensor.getHumidity(), "%"
|
||||
print("Humidity:", sensor.getHumidity(), "%")
|
||||
|
||||
print "Slider:", sensor.getSlider(), "%"
|
||||
print("Slider:", sensor.getSlider(), "%")
|
||||
|
||||
print "Override Switch Status:", sensor.getOverrideSwitchStatus()
|
||||
print("Override Switch Status:", sensor.getOverrideSwitchStatus())
|
||||
|
||||
print
|
||||
print()
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -22,7 +22,7 @@
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import time
|
||||
import pyupm_ili9341 as ili9341
|
||||
from upm import pyupm_ili9341 as ili9341
|
||||
|
||||
def main():
|
||||
# Pins (Edison)
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_ina132 as upmIna132
|
||||
from upm import pyupm_ina132 as upmIna132
|
||||
|
||||
def main():
|
||||
# Tested with the INA132 Differential Amplifier Sensor module.
|
||||
@ -37,7 +38,7 @@ def main():
|
||||
# This lets you run code on exit,
|
||||
# including functions from myDifferentialAmplifier
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -45,7 +46,7 @@ def main():
|
||||
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||
|
||||
while(1):
|
||||
print myDifferentialAmplifier.value()
|
||||
print(myDifferentialAmplifier.value())
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, atexit
|
||||
import pyupm_isd1820 as upmIsd1820
|
||||
from upm import pyupm_isd1820 as upmIsd1820
|
||||
|
||||
def main():
|
||||
# Instantiate a ISD1820 on digital pins 2 (play) and 3 (record)
|
||||
@ -42,7 +43,7 @@ def main():
|
||||
myRecorder.record(False)
|
||||
else:
|
||||
myRecorder.play(False)
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -51,10 +52,10 @@ def main():
|
||||
# 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"
|
||||
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):
|
||||
@ -64,7 +65,7 @@ def main():
|
||||
|
||||
# There are about 10 seconds of recording/playback time, so we will
|
||||
# sleep for a little extra time.
|
||||
print "Sleeping for 15 seconds..."
|
||||
print("Sleeping for 15 seconds...")
|
||||
time.sleep(15)
|
||||
|
||||
# exitHandler runs automatically
|
||||
|
@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
# Author: John Van Drasek <john.r.van.drasek@intel.com>
|
||||
# Copyright (c) 2015 Intel Corporation.
|
||||
#
|
||||
@ -21,7 +22,7 @@
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import time
|
||||
import pyupm_itg3200 as itg3200
|
||||
from upm import pyupm_itg3200 as itg3200
|
||||
|
||||
def main():
|
||||
# Create an I2C gyro object
|
||||
@ -31,12 +32,12 @@ def main():
|
||||
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 ' '
|
||||
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
|
||||
|
@ -21,7 +21,7 @@
|
||||
# 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
|
||||
from upm import pyupm_i2clcd as lcd
|
||||
|
||||
def main():
|
||||
# Initialize Jhd1313m1 at 0x3E (LCD_ADDRESS) and 0x62 (RGB_ADDRESS)
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_joystick12 as upmJoystick12
|
||||
from upm import pyupm_joystick12 as upmJoystick12
|
||||
|
||||
def main():
|
||||
# Instantiate a joystick on analog pins A0 and A1
|
||||
@ -35,7 +36,7 @@ def main():
|
||||
|
||||
# This function lets you run code on exit, including functions from myJoystick
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -46,7 +47,7 @@ def main():
|
||||
while(1):
|
||||
XString = "Driving X:" + str(myJoystick.getXInput())
|
||||
YString = ": and Y:" + str(myJoystick.getYInput())
|
||||
print XString + YString
|
||||
print(XString + YString)
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_l298 as upmL298
|
||||
from upm import pyupm_l298 as upmL298
|
||||
|
||||
def main():
|
||||
# Instantiate a Stepper motor on a L298 Dual H-Bridge.
|
||||
@ -37,7 +38,7 @@ def main():
|
||||
# This lets you run code on exit,
|
||||
# including functions from myHBridge
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
@ -48,14 +49,14 @@ def main():
|
||||
myHBridge.setDirection(upmL298.L298.DIR_CW)
|
||||
myHBridge.enable(True)
|
||||
|
||||
print "Rotating 1 full revolution at 10 RPM speed."
|
||||
print("Rotating 1 full revolution at 10 RPM speed.")
|
||||
# move 200 steps, a full rev
|
||||
myHBridge.stepperSteps(200)
|
||||
|
||||
print "Sleeping for 2 seconds..."
|
||||
print("Sleeping for 2 seconds...")
|
||||
time.sleep(2)
|
||||
|
||||
print "Rotating 1/2 revolution in opposite direction at 10 RPM speed."
|
||||
print("Rotating 1/2 revolution in opposite direction at 10 RPM speed.")
|
||||
myHBridge.setDirection(upmL298.L298.DIR_CCW)
|
||||
myHBridge.stepperSteps(100)
|
||||
|
||||
|
@ -21,8 +21,9 @@
|
||||
# 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
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_l298 as upmL298
|
||||
from upm import pyupm_l298 as upmL298
|
||||
|
||||
def main():
|
||||
# Instantiate one of the 2 possible DC motors on a L298 Dual
|
||||
@ -38,21 +39,21 @@ def main():
|
||||
# This lets you run code on exit,
|
||||
# including functions from myHBridge
|
||||
def exitHandler():
|
||||
print "Exiting"
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
atexit.register(exitHandler)
|
||||
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||
|
||||
print "Starting motor at 50% for 3 seconds..."
|
||||
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..."
|
||||
print("Reversing direction...")
|
||||
myHBridge.setDirection(upmL298.L298.DIR_NONE) # fast stop
|
||||
myHBridge.setDirection(upmL298.L298.DIR_CCW)
|
||||
time.sleep(3);
|
||||
|
@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
# Author: Sarah Knepper <sarah.knepper@intel.com>
|
||||
# Copyright (c) 2014 Intel Corporation.
|
||||
#
|
||||
@ -22,7 +23,7 @@
|
||||
|
||||
import time
|
||||
import array
|
||||
import pyupm_ldt0028 as ldt0028
|
||||
from upm import pyupm_ldt0028 as ldt0028
|
||||
|
||||
def main():
|
||||
NUMBER_OF_SECONDS = 10
|
||||
@ -33,8 +34,8 @@ def main():
|
||||
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'
|
||||
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())
|
||||
@ -45,15 +46,15 @@ def main():
|
||||
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(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.'
|
||||
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
|
||||
@ -61,7 +62,7 @@ def main():
|
||||
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
|
||||
print('(' + repr(int(round(average))).rjust(4) + ') |', '*' * stars_to_print)
|
||||
|
||||
# Delete the sensor object
|
||||
del sensor
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user