mirror of
https://github.com/eclipse/upm.git
synced 2025-07-01 09:21:12 +03:00
grove: remove deprecated classes and examples
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
@ -23,11 +23,11 @@ from __future__ import print_function
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import time
|
||||
from upm import pyupm_grove as grove
|
||||
from upm import pyupm_button as upmbutton
|
||||
|
||||
def main():
|
||||
# Create the button object using GPIO pin 0
|
||||
button = grove.Button(0)
|
||||
button = upmbutton.Button(0)
|
||||
|
||||
# Read the input and print, waiting one second between readings
|
||||
while 1:
|
||||
|
@ -1,41 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
# Author: Sarah Knepper <sarah.knepper@intel.com>
|
||||
# Copyright (c) 2014 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import time
|
||||
from upm import pyupm_grove as grove
|
||||
|
||||
def main():
|
||||
# Create the button object using GPIO pin 0
|
||||
button = grove.GroveButton(0)
|
||||
|
||||
# Read the input and print, waiting one second between readings
|
||||
while 1:
|
||||
print(button.name(), ' value is ', button.value())
|
||||
time.sleep(1)
|
||||
|
||||
# Delete the button object
|
||||
del button
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,60 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# Author: Zion Orent <zorent@ics.com>
|
||||
# Copyright (c) 2015 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from __future__ import print_function
|
||||
import time, sys, signal, atexit
|
||||
from upm import pyupm_grovecollision as upmGrovecollision
|
||||
|
||||
def main():
|
||||
# The was tested with the Grove Collision Sensor
|
||||
# Instantiate a Grove Collision on digital pin D2
|
||||
myGrovecollision = upmGrovecollision.GroveCollision(2)
|
||||
|
||||
## Exit handlers ##
|
||||
# This stops python from printing a stacktrace when you hit control-C
|
||||
def SIGINTHandler(signum, frame):
|
||||
raise SystemExit
|
||||
|
||||
# This lets you run code on exit,
|
||||
# including functions from myGrovecollision
|
||||
def exitHandler():
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
atexit.register(exitHandler)
|
||||
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||
|
||||
collisionState = False
|
||||
print("No collision")
|
||||
|
||||
while(1):
|
||||
if (myGrovecollision.isColliding() and not collisionState):
|
||||
print("Collision!")
|
||||
collisionState = True
|
||||
elif (not myGrovecollision.isColliding() and collisionState):
|
||||
print("No collision")
|
||||
collisionState = False
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,70 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# Author: Zion Orent <zorent@ics.com>
|
||||
# Copyright (c) 2015 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from __future__ import print_function
|
||||
import time, sys, signal, atexit
|
||||
from upm import pyupm_groveehr as upmGroveehr
|
||||
|
||||
def main():
|
||||
# Instantiate a Grove Ear-clip Heart Rate sensor on digital pin D2
|
||||
myHeartRateSensor = upmGroveehr.GroveEHR(2)
|
||||
|
||||
## Exit handlers ##
|
||||
# This stops python from printing a stacktrace when you hit control-C
|
||||
def SIGINTHandler(signum, frame):
|
||||
raise SystemExit
|
||||
|
||||
# This lets you run code on exit,
|
||||
# including functions from myHeartRateSensor
|
||||
def exitHandler():
|
||||
myHeartRateSensor.stopBeatCounter()
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
atexit.register(exitHandler)
|
||||
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||
|
||||
# set the beat counter to 0, init the clock and start counting beats
|
||||
myHeartRateSensor.clearBeatCounter()
|
||||
myHeartRateSensor.initClock()
|
||||
myHeartRateSensor.startBeatCounter()
|
||||
|
||||
while(1):
|
||||
# we grab these (millis and flowCount) just for display
|
||||
# purposes in this example
|
||||
millis = myHeartRateSensor.getMillis()
|
||||
beats = myHeartRateSensor.beatCounter()
|
||||
|
||||
# heartRate() requires that at least 5 seconds pass before
|
||||
# returning anything other than 0
|
||||
fr = myHeartRateSensor.heartRate()
|
||||
|
||||
# output milliseconds passed, beat count, and computed heart rate
|
||||
outputStr = "Millis: {0} Beats: {1} Heart Rate: {2}".format(
|
||||
millis, beats, fr)
|
||||
print(outputStr)
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,60 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# Author: Zion Orent <zorent@ics.com>
|
||||
# Copyright (c) 2015 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from __future__ import print_function
|
||||
import time, sys, signal, atexit
|
||||
from upm import pyupm_groveeldriver as upmGroveeldriver
|
||||
|
||||
def main():
|
||||
# The was tested with the Grove El Driver Module
|
||||
# Instantiate a Grove El Driver on digital pin D2
|
||||
myEldriver = upmGroveeldriver.GroveElDriver(2)
|
||||
|
||||
## Exit handlers ##
|
||||
# This function stops python from printing a stacktrace when you hit control-C
|
||||
def SIGINTHandler(signum, frame):
|
||||
raise SystemExit
|
||||
|
||||
# This function lets you run code on exit, including functions from myEldriver
|
||||
def exitHandler():
|
||||
print("Exiting")
|
||||
myEldriver.off()
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
atexit.register(exitHandler)
|
||||
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||
|
||||
lightState = True
|
||||
|
||||
while(1):
|
||||
if (lightState):
|
||||
myEldriver.on()
|
||||
else:
|
||||
myEldriver.off()
|
||||
lightState = not lightState
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,63 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# Author: Zion Orent <zorent@ics.com>
|
||||
# Copyright (c) 2015 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from __future__ import print_function
|
||||
import time, sys, signal, atexit
|
||||
from upm import pyupm_groveelectromagnet as upmGroveelectromagnet
|
||||
|
||||
def main():
|
||||
# This was tested with the Grove Electromagnetic Module
|
||||
# Instantiate a Grove Electromagnet on digital pin D2
|
||||
myElectromagnet = upmGroveelectromagnet.GroveElectromagnet(2)
|
||||
|
||||
## Exit handlers ##
|
||||
# This stops python from printing a stacktrace when you hit control-C
|
||||
def SIGINTHandler(signum, frame):
|
||||
raise SystemExit
|
||||
|
||||
# This lets you run code on exit,
|
||||
# including functions from myElectromagnet
|
||||
def exitHandler():
|
||||
print("Exiting")
|
||||
myElectromagnet.off()
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
atexit.register(exitHandler)
|
||||
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||
|
||||
magnetState = False
|
||||
|
||||
# Turn magnet on and off every 5 seconds
|
||||
while(1):
|
||||
magnetState = not magnetState
|
||||
if (magnetState):
|
||||
myElectromagnet.on()
|
||||
else:
|
||||
myElectromagnet.off()
|
||||
print("Turning magnet", ("on" if magnetState else "off"))
|
||||
|
||||
time.sleep(5)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,55 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# Author: Zion Orent <zorent@ics.com>
|
||||
# Copyright (c) 2015 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from __future__ import print_function
|
||||
import time, sys, signal, atexit
|
||||
from upm import pyupm_groveemg as upmGroveemg
|
||||
|
||||
def main():
|
||||
# Tested with the GroveEMG Muscle Signal Reader Sensor Module
|
||||
# Instantiate a GroveEMG on analog pin A0
|
||||
myEMG = upmGroveemg.GroveEMG(0)
|
||||
|
||||
## Exit handlers ##
|
||||
# This stops python from printing a stacktrace when you hit control-C
|
||||
def SIGINTHandler(signum, frame):
|
||||
raise SystemExit
|
||||
|
||||
# This lets you run code on exit, including functions from myEMG
|
||||
def exitHandler():
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
atexit.register(exitHandler)
|
||||
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||
|
||||
print("Calibrating....")
|
||||
myEMG.calibrate()
|
||||
|
||||
while (1):
|
||||
print(myEMG.value())
|
||||
time.sleep(.1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,89 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# Author: Jon Trulson <jtrulson@ics.com>
|
||||
# Copyright (c) 2015 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from __future__ import print_function
|
||||
import time, sys, signal, atexit
|
||||
from upm import pyupm_grovegprs as sensorObj
|
||||
|
||||
def main():
|
||||
# Instantiate a GroveGPRS Module on UART 0
|
||||
sensor = sensorObj.GroveGPRS(0)
|
||||
|
||||
## Exit handlers ##
|
||||
# This stops python from printing a stacktrace when you hit control-C
|
||||
def SIGINTHandler(signum, frame):
|
||||
raise SystemExit
|
||||
|
||||
# This function lets you run code on exit
|
||||
def exitHandler():
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
atexit.register(exitHandler)
|
||||
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||
|
||||
# Set the baud rate, 19200 baud is the default.
|
||||
if (sensor.setBaudRate(19200)):
|
||||
print("Failed to set baud rate")
|
||||
sys.exit(0)
|
||||
|
||||
usageStr = ("Usage:\n"
|
||||
"If an argument is supplied on the command line, that argument is\n"
|
||||
"sent to the module and the response is printed out.\n\n"
|
||||
"If no argument is used, then the manufacturer and the current\n"
|
||||
"saved profiles are queried and the results printed out.\n\n")
|
||||
print(usageStr)
|
||||
|
||||
# simple helper function to send a command and wait for a response
|
||||
def sendCommand(sensor, cmd):
|
||||
# commands need to be terminated with a carriage return
|
||||
cmd += "\r";
|
||||
sensor.writeDataStr(cmd)
|
||||
|
||||
# wait up to 1 second
|
||||
if (sensor.dataAvailable(1000)):
|
||||
print("Returned: ", end=' ')
|
||||
print(sensor.readDataStr(1024))
|
||||
else:
|
||||
print("Timed out waiting for response")
|
||||
|
||||
if (len(sys.argv) > 1):
|
||||
print("Sending command line argument (" + sys.argv[1] + ")...")
|
||||
sendCommand(sensor, sys.argv[1])
|
||||
else:
|
||||
# query the module manufacturer
|
||||
print("Querying module manufacturer (AT+CGMI)...")
|
||||
sendCommand(sensor, "AT+CGMI");
|
||||
|
||||
time.sleep(1);
|
||||
|
||||
# query the saved profiles
|
||||
print("Querying the saved profiles (AT&V)...")
|
||||
sendCommand(sensor, "AT&V");
|
||||
|
||||
# A comprehensive list is available from the datasheet at:
|
||||
# http://www.seeedstudio.com/wiki/images/7/72/AT_Commands_v1.11.pdf
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,56 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# Author: Zion Orent <zorent@ics.com>
|
||||
# Copyright (c) 2015 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from __future__ import print_function
|
||||
import time, sys, signal, atexit
|
||||
from upm import pyupm_grovegsr as upmGrovegsr
|
||||
|
||||
def main():
|
||||
# Tested with the GroveGSR Galvanic Skin Response Sensor module.
|
||||
|
||||
# Instantiate a GroveGSR on analog pin A0
|
||||
myGSR = upmGrovegsr.GroveGSR(0)
|
||||
|
||||
## Exit handlers ##
|
||||
# This stops python from printing a stacktrace when you hit control-C
|
||||
def SIGINTHandler(signum, frame):
|
||||
raise SystemExit
|
||||
|
||||
# This lets you run code on exit, including functions from myGSR
|
||||
def exitHandler():
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
atexit.register(exitHandler)
|
||||
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||
|
||||
print("Calibrating....")
|
||||
myGSR.calibrate()
|
||||
|
||||
while (1):
|
||||
print(myGSR.value())
|
||||
time.sleep(.5)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,47 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
# Author: Sarah Knepper <sarah.knepper@intel.com>
|
||||
# Copyright (c) 2015 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import time
|
||||
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())
|
||||
|
||||
# Turn the LED on and off 10 times, pausing one second
|
||||
# between transitions
|
||||
for i in range (0,10):
|
||||
led.on()
|
||||
time.sleep(1)
|
||||
led.off()
|
||||
time.sleep(1)
|
||||
|
||||
# Delete the Grove LED object
|
||||
del led
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,43 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
# Author: Sarah Knepper <sarah.knepper@intel.com>
|
||||
# Copyright (c) 2014 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import time
|
||||
from upm import pyupm_grove as grove
|
||||
|
||||
def main():
|
||||
# Create the light sensor object using AIO pin 0
|
||||
light = grove.GroveLight(0)
|
||||
|
||||
# Read the input and print both the raw value and a rough lux value,
|
||||
# waiting one second between readings
|
||||
while 1:
|
||||
print(light.name() + " raw value is %d" % light.raw_value() + \
|
||||
", which is roughly %d" % light.value() + " lux");
|
||||
time.sleep(1)
|
||||
|
||||
# Delete the light sensor object
|
||||
del light
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,54 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# Author: Zion Orent <zorent@ics.com>
|
||||
# Copyright (c) 2015 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from __future__ import print_function
|
||||
import time, sys, signal, atexit
|
||||
from upm import pyupm_grovelinefinder as upmGrovelinefinder
|
||||
|
||||
def main():
|
||||
# Instantiate a Grove line finder sensor on digital pin D2
|
||||
myLineFinder = upmGrovelinefinder.GroveLineFinder(2)
|
||||
|
||||
## Exit handlers ##
|
||||
# This function stops python from printing a stacktrace when you hit control-C
|
||||
def SIGINTHandler(signum, frame):
|
||||
raise SystemExit
|
||||
|
||||
# This function lets you run code on exit, including functions from myLineFinder
|
||||
def exitHandler():
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
atexit.register(exitHandler)
|
||||
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||
|
||||
while(1):
|
||||
if (myLineFinder.whiteDetected()):
|
||||
print("White detected.")
|
||||
else:
|
||||
print("Black detected.")
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,55 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# Author: Jon Trulson <jtrulson@ics.com>
|
||||
# Copyright (c) 2015 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import time
|
||||
from upm import pyupm_grovemd as upmGrovemd
|
||||
|
||||
def main():
|
||||
I2C_BUS = upmGrovemd.GROVEMD_I2C_BUS
|
||||
I2C_ADDR = upmGrovemd.GROVEMD_DEFAULT_I2C_ADDR
|
||||
|
||||
# Instantiate an I2C Grove Motor Driver on I2C bus 0
|
||||
myMotorDriver = upmGrovemd.GroveMD(I2C_BUS, I2C_ADDR)
|
||||
|
||||
# This example demonstrates using the GroveMD to drive a stepper motor
|
||||
|
||||
# configure it, for this example, we'll assume 200 steps per rev
|
||||
myMotorDriver.configStepper(200)
|
||||
|
||||
# set for half a rotation
|
||||
myMotorDriver.setStepperSteps(100)
|
||||
|
||||
# let it go - clockwise rotation, 10 RPM speed
|
||||
myMotorDriver.enableStepper(upmGrovemd.GroveMD.STEP_DIR_CW, 10)
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
# Now do it backwards...
|
||||
myMotorDriver.setStepperSteps(100)
|
||||
myMotorDriver.enableStepper(upmGrovemd.GroveMD.STEP_DIR_CCW, 10)
|
||||
|
||||
# now disable
|
||||
myMotorDriver.disableStepper()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,51 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# Author: Zion Orent <zorent@ics.com>
|
||||
# Copyright (c) 2015 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from __future__ import print_function
|
||||
import time
|
||||
from upm import pyupm_grovemd as upmGrovemd
|
||||
|
||||
def main():
|
||||
I2C_BUS = upmGrovemd.GROVEMD_I2C_BUS
|
||||
I2C_ADDR = upmGrovemd.GROVEMD_DEFAULT_I2C_ADDR
|
||||
|
||||
# Instantiate an I2C Grove Motor Driver on I2C bus 0
|
||||
myMotorDriver = upmGrovemd.GroveMD(I2C_BUS, I2C_ADDR)
|
||||
|
||||
# set direction to CW and set speed to 50%
|
||||
print("Spin M1 and M2 at half speed for 3 seconds")
|
||||
myMotorDriver.setMotorDirections(upmGrovemd.GroveMD.DIR_CW, upmGrovemd.GroveMD.DIR_CW)
|
||||
myMotorDriver.setMotorSpeeds(127, 127)
|
||||
|
||||
time.sleep(3)
|
||||
# counter clockwise
|
||||
print("Reversing M1 and M2 for 3 seconds")
|
||||
myMotorDriver.setMotorDirections(upmGrovemd.GroveMD.DIR_CCW,
|
||||
upmGrovemd.GroveMD.DIR_CCW)
|
||||
time.sleep(3)
|
||||
|
||||
print("Stopping motors")
|
||||
myMotorDriver.setMotorSpeeds(0, 0)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,64 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# Author: Zion Orent <zorent@ics.com>
|
||||
# Copyright (c) 2015 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from __future__ import print_function
|
||||
import time, sys, signal, atexit
|
||||
from upm import pyupm_grovemoisture as upmMoisture
|
||||
|
||||
def main():
|
||||
# Instantiate a Grove Moisture sensor on analog pin A0
|
||||
myMoisture = upmMoisture.GroveMoisture(0)
|
||||
|
||||
## Exit handlers ##
|
||||
# This function stops python from printing a stacktrace when you hit control-C
|
||||
def SIGINTHandler(signum, frame):
|
||||
raise SystemExit
|
||||
|
||||
# This function lets you run code on exit, including functions from myMoisture
|
||||
def exitHandler():
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
atexit.register(exitHandler)
|
||||
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||
|
||||
# Values (approximate):
|
||||
# 0-300, sensor in air or dry soil
|
||||
# 300-600, sensor in humid soil
|
||||
# 600+, sensor in wet soil or submerged in water
|
||||
|
||||
# Read the value every second and print the corresponding moisture level
|
||||
while(1):
|
||||
moisture_val = myMoisture.value()
|
||||
if (moisture_val >= 0 and moisture_val < 300):
|
||||
result = "Dry"
|
||||
elif (moisture_val >= 300 and moisture_val < 600):
|
||||
result = "Moist"
|
||||
else:
|
||||
result = "Wet"
|
||||
print("Moisture value: {0}, {1}".format(moisture_val, result))
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,54 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# Author: Zion Orent <zorent@ics.com>
|
||||
# Copyright (c) 2015 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from __future__ import print_function
|
||||
import time, sys, signal, atexit
|
||||
from upm import pyupm_groveo2 as upmGroveo2
|
||||
|
||||
def main():
|
||||
# This was tested with the O2 Oxygen Concentration Sensor Module
|
||||
# Instantiate a GroveO2 on analog pin A0
|
||||
myGroveO2 = upmGroveo2.GroveO2(0)
|
||||
|
||||
## Exit handlers ##
|
||||
# This stops python from printing a stacktrace when you hit control-C
|
||||
def SIGINTHandler(signum, frame):
|
||||
raise SystemExit
|
||||
|
||||
# This lets you run code on exit, including functions from myGroveO2
|
||||
def exitHandler():
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
atexit.register(exitHandler)
|
||||
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||
|
||||
while(1):
|
||||
print("The output voltage is: {0}mV".format(
|
||||
myGroveO2.voltageValue()))
|
||||
|
||||
time.sleep(.1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,50 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
# Author: Sarah Knepper <sarah.knepper@intel.com>
|
||||
# Copyright (c) 2015 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import time
|
||||
from upm import pyupm_grove as grove
|
||||
|
||||
def main():
|
||||
# Create the relay switch object using GPIO pin 0
|
||||
relay = grove.GroveRelay(0)
|
||||
|
||||
# Close and then open the relay switch 3 times,
|
||||
# waiting one second each time. The LED on the relay switch
|
||||
# will light up when the switch is on (closed).
|
||||
# The switch will also make a noise between transitions.
|
||||
for i in range (0,3):
|
||||
relay.on()
|
||||
if relay.isOn():
|
||||
print(relay.name(), 'is on')
|
||||
time.sleep(1)
|
||||
relay.off()
|
||||
if relay.isOff():
|
||||
print(relay.name(), 'is off')
|
||||
time.sleep(1)
|
||||
|
||||
# Delete the relay switch object
|
||||
del relay
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,50 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
# Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
|
||||
# Copyright (c) 2014 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from time import sleep
|
||||
from upm import pyupm_grove as grove
|
||||
|
||||
def main():
|
||||
# New knob on AIO pin 0
|
||||
knob = grove.GroveRotary(0)
|
||||
|
||||
# Loop indefinitely
|
||||
while True:
|
||||
# Read values
|
||||
abs = knob.abs_value()
|
||||
absdeg = knob.abs_deg()
|
||||
absrad = knob.abs_rad()
|
||||
|
||||
rel = knob.rel_value()
|
||||
reldeg = knob.rel_deg()
|
||||
relrad = knob.rel_rad()
|
||||
|
||||
print("Abs values: %4d" % int(abs) , " raw %4d" % int(absdeg), "deg = %5.2f" % absrad , " rad ", end=' ')
|
||||
print("Rel values: %4d" % int(rel) , " raw %4d" % int(reldeg), "deg = %5.2f" % relrad , " rad")
|
||||
|
||||
# Sleep for 2.5 s
|
||||
sleep(2.5)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,66 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Author: Jon Trulson <jtrulson@ics.com>
|
||||
# Copyright (c) 2015 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
from upm import pyupm_grovescam as upmGrovescam
|
||||
|
||||
def main():
|
||||
# Instantiate a Grove Serial Camera on UART 0
|
||||
camera = upmGrovescam.GROVESCAM(0)
|
||||
|
||||
# make sure port is initialized properly. 115200 baud is the default.
|
||||
if (not camera.setupTty()):
|
||||
print("Failed to setup tty port parameters")
|
||||
sys.exit(1)
|
||||
|
||||
if (camera.init()):
|
||||
print("Initialized...")
|
||||
else:
|
||||
print("init() failed")
|
||||
|
||||
if (camera.preCapture()):
|
||||
print("preCapture succeeded...")
|
||||
else:
|
||||
print("preCapture failed.")
|
||||
|
||||
if (camera.doCapture()):
|
||||
print("doCapture succeeded...")
|
||||
else:
|
||||
print("doCapture failed.")
|
||||
|
||||
print("Image size is", camera.getImageSize(), "bytes")
|
||||
|
||||
if (camera.getImageSize() > 0):
|
||||
print("Storing image.jpg...")
|
||||
if (camera.storeImage("image.jpg")):
|
||||
print("storeImage succeeded...")
|
||||
else:
|
||||
print("storeImage failed.")
|
||||
|
||||
print("Exiting.")
|
||||
sys.exit(0)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,44 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
# Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
|
||||
# Copyright (c) 2014 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from time import sleep
|
||||
from upm import pyupm_grove as grove
|
||||
|
||||
def main():
|
||||
# New Grove Slider on AIO pin 0
|
||||
slider = grove.GroveSlide(0)
|
||||
|
||||
# Loop indefinitely
|
||||
while True:
|
||||
# Read values
|
||||
raw = slider.raw_value()
|
||||
volts = slider.voltage_value()
|
||||
|
||||
print("Slider value: ", raw , " = %.2f" % volts , " V")
|
||||
|
||||
# Sleep for 2.5 s
|
||||
sleep(2.5)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# Author: Zion Orent <zorent@ics.com>
|
||||
# Copyright (c) 2015 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import time, sys, signal, atexit
|
||||
from upm import pyupm_grovespeaker as upmGrovespeaker
|
||||
|
||||
def main():
|
||||
# Instantiate a Grove Speaker on digital pin D2
|
||||
mySpeaker = upmGrovespeaker.GroveSpeaker(2)
|
||||
|
||||
# Play all 7 of the lowest notes
|
||||
mySpeaker.playAll()
|
||||
|
||||
# Play a medium C-sharp
|
||||
mySpeaker.playSound('c', True, "med")
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,47 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
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.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import time
|
||||
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())
|
||||
|
||||
# Read the temperature ten times, printing both the Celsius and
|
||||
# equivalent Fahrenheit temperature, waiting one second between readings
|
||||
for i in range(0, 10):
|
||||
celsius = temp.value()
|
||||
fahrenheit = celsius * 9.0/5.0 + 32.0;
|
||||
print("%d degrees Celsius, or %d degrees Fahrenheit" \
|
||||
% (celsius, fahrenheit))
|
||||
time.sleep(1)
|
||||
|
||||
# Delete the temperature sensor object
|
||||
del temp
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,57 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# Author: Zion Orent <zorent@ics.com>
|
||||
# Copyright (c) 2015 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from __future__ import print_function
|
||||
import time, sys, signal, atexit
|
||||
from upm import pyupm_grovevdiv as upmGrovevdiv
|
||||
|
||||
def main():
|
||||
# Instantiate a Grove Voltage Divider sensor on analog pin A0
|
||||
myVoltageDivider = upmGrovevdiv.GroveVDiv(0)
|
||||
|
||||
## Exit handlers ##
|
||||
# This stops python from printing a stacktrace when you hit control-C
|
||||
def SIGINTHandler(signum, frame):
|
||||
raise SystemExit
|
||||
|
||||
# This function lets you run code on exit,
|
||||
# including functions from myVoltageDivider
|
||||
def exitHandler():
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
atexit.register(exitHandler)
|
||||
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||
|
||||
while(1):
|
||||
val = myVoltageDivider.value(100)
|
||||
gain3val = myVoltageDivider.computedValue(3, val)
|
||||
gain10val = myVoltageDivider.computedValue(10, val)
|
||||
print("ADC value: {0} Gain 3: {1}v Gain 10: {2}v".format(
|
||||
val, gain3val, gain10val))
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,54 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# Author: Zion Orent <zorent@ics.com>
|
||||
# Copyright (c) 2015 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from __future__ import print_function
|
||||
import time, sys, signal, atexit
|
||||
from upm import pyupm_grovewater as upmGrovewater
|
||||
|
||||
def main():
|
||||
# Instantiate a Grove Water sensor on digital pin D2
|
||||
myWaterSensor = upmGrovewater.GroveWater(2)
|
||||
|
||||
## Exit handlers ##
|
||||
# This function stops python from printing a stacktrace when you hit control-C
|
||||
def SIGINTHandler(signum, frame):
|
||||
raise SystemExit
|
||||
|
||||
# This function lets you run code on exit, including functions from myWaterSensor
|
||||
def exitHandler():
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
atexit.register(exitHandler)
|
||||
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||
|
||||
while(1):
|
||||
if (myWaterSensor.isWet()):
|
||||
print("Sensor is wet")
|
||||
else:
|
||||
print("Sensor is dry")
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,67 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# Author: Zion Orent <zorent@ics.com>
|
||||
# Copyright (c) 2015 Intel Corporation.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from __future__ import print_function
|
||||
import time, sys, signal, atexit
|
||||
from upm import pyupm_grovewfs as upmGrovewfs
|
||||
|
||||
def main():
|
||||
# Instantiate a Grove Water Flow Sensor on digital pin D2
|
||||
myWaterFlow = upmGrovewfs.GroveWFS(2)
|
||||
|
||||
## Exit handlers ##
|
||||
# This stops python from printing a stacktrace when you hit control-C
|
||||
def SIGINTHandler(signum, frame):
|
||||
raise SystemExit
|
||||
|
||||
# This function lets you run code on exit,
|
||||
# including functions from myWaterFlow
|
||||
def exitHandler():
|
||||
myWaterFlow.stopFlowCounter()
|
||||
print("Exiting")
|
||||
sys.exit(0)
|
||||
|
||||
# Register exit handlers
|
||||
atexit.register(exitHandler)
|
||||
signal.signal(signal.SIGINT, SIGINTHandler)
|
||||
|
||||
# set the flow counter to 0 and start counting
|
||||
myWaterFlow.clearFlowCounter()
|
||||
myWaterFlow.startFlowCounter()
|
||||
|
||||
while (1):
|
||||
# we grab these (millis and flowCount) just for display
|
||||
# purposes in this example
|
||||
millis = myWaterFlow.getMillis()
|
||||
flowCount = myWaterFlow.flowCounter()
|
||||
|
||||
fr = myWaterFlow.flowRate()
|
||||
|
||||
# output milliseconds passed, flow count, and computed flow rate
|
||||
outputStr = "Millis: {0} Flow Count: {1} Flow Rate: {2} LPM".format(
|
||||
millis, flowCount, fr)
|
||||
print(outputStr)
|
||||
time.sleep(2)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -23,11 +23,11 @@ from __future__ import print_function
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import time
|
||||
from upm import pyupm_grove as grove
|
||||
from upm import pyupm_relay as upmrelay
|
||||
|
||||
def main():
|
||||
# Create the relay switch object using GPIO pin 0
|
||||
relay = grove.Relay(0)
|
||||
relay = upmrelay.Relay(0)
|
||||
|
||||
# Close and then open the relay switch 3 times,
|
||||
# waiting one second each time. The LED on the relay switch
|
||||
|
@ -23,11 +23,11 @@ from __future__ import print_function
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from time import sleep
|
||||
from upm import pyupm_grove as grove
|
||||
from upm import pyupm_rotary as upmrotary
|
||||
|
||||
def main():
|
||||
# New knob on AIO pin 0
|
||||
knob = grove.Rotary(0)
|
||||
knob = upmrotary.Rotary(0)
|
||||
|
||||
# Loop indefinitely
|
||||
while True:
|
||||
|
Reference in New Issue
Block a user