Ejemplo n.º 1
0
# mindsensors.com invests time and resources providing this open source code,
# please support mindsensors.com  by purchasing products from mindsensors.com!
# Learn more product option visit us @  http://www.mindsensors.com/
#
# History:
# Date          Author          Comments
# March 2016    Roman Bohuk     Initial Authoring
# July 2017     Seth Tenembaum  Update for GRX

import os, inspect
currentdir = os.path.dirname(
    os.path.abspath(inspect.getfile(inspect.currentframe())))

import time, socket
from PiStorms_GRX import PiStorms_GRX
psm = PiStorms_GRX()


def checkInternet():
    try:
        socket.setdefaulttimeout(5)
        socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect(
            ("8.8.8.8", 53))
        return True
    except:
        return False


psm.screen.drawAutoText("Testing internet connection",
                        20,
                        30,
Ejemplo n.º 2
0
--BLOCKLY FILE--
--START BLOCKS--
PHhtbCB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94aHRtbCI+PGJsb2NrIHR5cGU9InNjcmVlbl9kcmF3dGl0bGUiIGlkPSI9N0NMM2U9TTBtOGRpYV9BXkB6KyIgeD0iMTgiIHk9Ii01Ij48ZmllbGQgbmFtZT0iRElTUExBWSI+VFJVRTwvZmllbGQ+PHZhbHVlIG5hbWU9IlRFWFQiPjxzaGFkb3cgdHlwZT0idGV4dCIgaWQ9IlgsbHZWYmRmMmRsRX45Vzs3cHI5Ij48ZmllbGQgbmFtZT0iVEVYVCI+U2Vuc29yIERlbW88L2ZpZWxkPjwvc2hhZG93PjwvdmFsdWU+PG5leHQ+PGJsb2NrIHR5cGU9InRlcm1pbmFsX3ByaW50bG4iIGlkPSJsQDN5OWB6LUZgK090U1FTXVAvLCI+PHZhbHVlIG5hbWU9InRleHQiPjxzaGFkb3cgdHlwZT0idGV4dCIgaWQ9IjZgbilPW0JJO09+UD1kI3BYQlR+Ij48ZmllbGQgbmFtZT0iVEVYVCI+QkFBMTogR3JvdmUgTGlnaHQgU2Vuc29yPC9maWVsZD48L3NoYWRvdz48L3ZhbHVlPjxuZXh0PjxibG9jayB0eXBlPSJ0ZX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tZT0icG9ydCI+QkFEMTwvZmllbGQ+PC9ibG9jaz48L3ZhbHVlPjwvYmxvY2s+PC92YWx1ZT48dmFsdWUgbmFtZT0ibGluZSI+PHNoYWRvdyB0eXBlPSJtYXRoX251bWJlciIgaWQ9IkI9aTBKNUFhSHU0Zjt3O09Re3hlIj48ZmllbGQgbmFtZT0iTlVNIj4zPC9maWVsZD48L3NoYWRvdz48L3ZhbHVlPjwvYmxvY2s+PC9uZXh0PjwvYmxvY2s+PC9uZXh0PjwvYmxvY2s+PC9uZXh0PjwvYmxvY2s+PC9zdGF0ZW1lbnQ+PC9ibG9jaz48L25leHQ+PC9ibG9jaz48L25leHQ+PC9ibG9jaz48L25leHQ+PC9ibG9jaz48L25leHQ+PC9ibG9jaz48L25leHQ+PC9ibG9jaz48L25leHQ+PC9ibG9jaz48L25leHQ+PC9ibG9jaz48L25leHQ+PC9ibG9jaz48L3htbD4=
9f2f08d3ed272ec88dda0204f1ff341ce248240f56a35cf02954692074f8930a
--END BLOCKS--
"""


from PiStorms import PiStorms
import time
from PiStorms_GRX import PiStorms_GRX
import GroveDevices

psm = PiStorms()

grx = PiStorms_GRX()

groveLightSensor_BAA1 = GroveDevices.Grove_Light_Sensor("BAA1")

groveMoistureSensor_BAA2 = GroveDevices.Grove_Moisture_Sensor("BAA2")

groveSoundSensor_BAA3 = GroveDevices.Grove_Sound_Sensor("BAA3")

groveFlameSensor_BAD1 = GroveDevices.Grove_Flame_Sensor("BAD1")


psm.screen.drawDisplay('Sensor Demo', True)
psm.screen.termPrintln('BAA1: Grove Light Sensor')
psm.screen.termPrintln('BAA2: Grove Moisture Sensor')
psm.screen.termPrintln('BAA3: Grove Sound Sensor')
# These sensors are available in the Grove Sensor Kit:
Ejemplo n.º 3
0
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#mindsensors.com invests time and resources providing this open source code, 
#please support mindsensors.com  by purchasing products from mindsensors.com!
#Learn more product option visit us @  http://www.mindsensors.com

"""
--BLOCK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RvdyB0eXBlPSJtYXRoX251bWJlciIgaWQ9ImFLYzJwUylnWkNoaDk4ZEVpYHsrIj48ZmllbGQgbmFtZT0iTlVNIj4xPC9maWVsZD48L3NoYWRvdz48L3ZhbHVlPjwvYmxvY2s+PC9uZXh0PjwvYmxvY2s+PC9uZXh0PjwvYmxvY2s+PC9uZXh0PjwvYmxvY2s+PC9zdGF0ZW1lbnQ+PC9ibG9jaz48L3htbD4=
c70aaded7b0b66cce0501c89245ba00e38e6f17d585cfc04570046128708434e
--END BLOCKS--
"""


from PiStorms_GRX import RCServo
import time
from PiStorms_GRX import PiStorms_GRX

servo_BBS1 = RCServo("BBS1")

grx = PiStorms_GRX()


def leCUI8hutHZI4480Dc():
  servo_BBS1.setSpeed(50)
  time.sleep(1)
  servo_BBS1.stop()
  time.sleep(1)
grx.untilKeyPress(leCUI8hutHZI4480Dc)
Ejemplo n.º 4
0
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#mindsensors.com invests time and resources providing this open source code,
#please support mindsensors.com  by purchasing products from mindsensors.com!
#Learn more product option visit us @  http://www.mindsensors.com/
#
# History:
# Date      Author          Comments
# 04/18/17  Seth Tenembaum  Initial development.
#

# This program introduces the process of continually updating a graph.

from PiStorms_GRX import PiStorms_GRX
psm = PiStorms_GRX()
psm.screen.termPrintln("Please wait a moment")
psm.screen.termPrintln("as matplotlib loads...")
psm.screen.termPrintAt(3, "Press GO to quit.")

import matplotlib
matplotlib.use("AGG")
import matplotlib.pyplot as plt
import numpy as np
import tempfile

plt.figure(figsize=(4,3), dpi=80)
plt.xlabel('time')
plt.ylabel('Voltage (V)')
plt.title('Battery Voltage')
plt.grid(True)
Ejemplo n.º 5
0
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.    See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#mindsensors.com invests time and resources providing this open source code,
#please support mindsensors.com  by purchasing products from mindsensors.com!
#Learn more product option visit us @  http://www.mindsensors.com/

from PiStorms_GRX import PiStorms_GRX
from GroveDevices import Grove_Light_Sensor

psm = PiStorms_GRX()
lightSensor = Grove_Light_Sensor("BAA1")

m = [
    "Grove Light Sensor Demo",
    "Please connect a Grove light sensor to port BAA1 (Bank A, Analog 1) and press OK (or GO) to continue."
]
psm.screen.showMessage(m, wrapText=True)

# title
psm.screen.drawDisplay("Light Sensor Demo")


def mainLoop():
    reading = lightSensor.lightLevel()
    message = "Light level: {}".format(reading)
Ejemplo n.º 6
0
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.    See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#mindsensors.com invests time and resources providing this open source code,
#please support mindsensors.com  by purchasing products from mindsensors.com!
#Learn more product option visit us @  http://www.mindsensors.com/
#
# History:
# Date      Author      Comments
# 06/22/16   Deepak     Initial development.
#

from PiStorms_GRX import PiStorms_GRX
import sys, subprocess

psm = PiStorms_GRX()
m = ["PiStorms", "Are you sure you want to shutdown?"]
res = psm.screen.askQuestion(m, ["OK", "Cancel"])

if (res == 0):
    cmd = "sudo psm_shutdown -h now"
    status = subprocess.call(cmd, shell=True)
Ejemplo n.º 7
0
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#mindsensors.com invests time and resources providing this open source code,
#please support mindsensors.com  by purchasing products from mindsensors.com!
#Learn more product option visit us @  http://www.mindsensors.com/
#
# History:
# Date      Author      Comments
# July 2015  Henry     Initial Authoring from SensorShield import SensorShield
# July 2017  Seth      Clean, update for GRX

import os, socket
import ConfigParser
from PiStorms_GRX import PiStorms_GRX

psm = PiStorms_GRX()

config = ConfigParser.RawConfigParser()
config.read("/usr/local/mindsensors/conf/msdev.cfg")
homefolder = config.get("msdev", "homefolder")
try:
    with open(os.path.join(homefolder, ".version"), "r") as f:
        version_no = f.readline().strip()
except IOError:
    version_no = "unknown"

psm.screen.drawDisplay("About Me")
psm.screen.termPrintln("Device: {}".format(psm.getDeviceModel()))
psm.screen.termPrintln("Feature: {}".format(psm.getDeviceFeatures()))
psm.screen.termPrintln("f/w version: {}".format(psm.getFirmwareVersion()))
psm.screen.termPrintln("s/w version: {}".format(version_no))
Ejemplo n.º 8
0
# Date      Author      Comments
# 01/01/16   Deepak     Initial development.
#
import json, time, os, sys, inspect, thread
import ConfigParser
from ws4py.client.threadedclient import WebSocketClient
from swarmclient import *
from PiStorms_GRX import PiStorms_GRX

#
# message sender
#
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0,parentdir)
psm = PiStorms_GRX()
doExit = False
bmpw = 60
old_x = 110
old_y = 80
config = ConfigParser.RawConfigParser()
config.read("/usr/local/mindsensors/conf/msdev.cfg")
homefolder = config.get("msdev", "homefolder")
currentdir = os.path.join(homefolder, "programs")

psm.screen.clearScreen()
if __name__ == '__main__':
    #
    # this callback handler handles the messages
    # received from the swarm server.
    #
Ejemplo n.º 9
0
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#mindsensors.com invests time and resources providing this open source code,
#please support mindsensors.com  by purchasing products from mindsensors.com!
#Learn more product option visit us @  http://www.mindsensors.com/

import time, sys
import ConfigParser
from PiStormsCom_GRX import GRXCom
from PiStorms_GRX import PiStorms_GRX, RCServo, GrovePort

psm = PiStorms_GRX()
config = ConfigParser.RawConfigParser()
config.read("/usr/local/mindsensors/conf/msdev.cfg")

# introduce program and intent
m = ["Find Neutral Point - Introduction",
     'Every servo is slightly different due to the manufacturing process. This could make a continuous rotation servo "drift" when you set the speed to "0".']
psm.screen.showMessage(m, wrapText=True)
m[1] = "This program can help you find what value *actually* makes your servo stop. This will be saved to a configuration file so you don't have to worry about it again. Would you like to continue?"
if not psm.screen.askYesOrNoQuestion(m, wrapText=True, goBtn=True):
    sys.exit(0)

bank = psm.screen.askQuestion(["Motor Bank", "Which bank is your servo connected to?"], [" <-- B", " "*13+"A -->"], wrapText=True)
bank = ["B", "A"][bank]
port = psm.screen.askQuestion(["Motor Port", "Which port number is your servo connected to?"],
                              [1,2,3] if bank!="A" else [3,2,1], wrapText=True)
Ejemplo n.º 10
0
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#mindsensors.com invests time and resources providing this open source code,
#please support mindsensors.com  by purchasing products from mindsensors.com!
#Learn more product option visit us @  http://www.mindsensors.com/
#
# History:
# Date      Author          Comments
# 05/02/17  Seth Tenembaum  Initial development.
#

# This program demonstrates displaying a smooth curve.

from PiStorms_GRX import PiStorms_GRX
psm = PiStorms_GRX()
psm.screen.termPrintln("Please wait a moment")
psm.screen.termPrintln("as matplotlib loads...")
psm.screen.termPrintAt(3, "Press GO to quit.")

import matplotlib
matplotlib.use("AGG")
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import spline
import tempfile

plt.figure(figsize=(4, 3), dpi=80)
plt.xlabel('time')
plt.ylabel('Voltage (V)')
plt.title('Battery Voltage')
Ejemplo n.º 11
0
--BLOCKLY FILE--
--START BLOCKS--
PHhtbCB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94aHRtbCI+PGJsb2NrIHR5cGU9InNjcmVlbl9kcmF3Y2lyY2xlIiBpZD0ibUlNa0FWKX17Yik6YjQ5My9pNDkiIHg9Ii03IiB5PSItMzgxIj48ZmllbGQgbmFtZT0iQ09MT1IiPiNmZmNjMDA8L2ZpZWxkPjxmaWVsZCBuYW1lPSJESVNQTEFZIj5UUlVFPC9maWV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QU5CYVd9d1dhOFhSOyI+PGZpZWxkIG5hbWU9Ik5VTSI+MTwvZmllbGQ+PC9zaGFkb3c+PGJsb2NrIHR5cGU9InZhcmlhYmxlc19nZXQiIGlkPSI0dXBGeno4THdJQyw7R2J4LG4uMyI+PGZpZWxkIG5hbWU9IlZBUiI+eDwvZmllbGQ+PC9ibG9jaz48L3ZhbHVlPjx2YWx1ZSBuYW1lPSJCIj48c2hhZG93IHR5cGU9Im1hdGhfbnVtYmVyIiBpZD0iQUtQYHgweWI5a3IzUTtsdn5aczUiPjxmaWVsZCBuYW1lPSJOVU0iPjE8L2ZpZWxkPjwvc2hhZG93PjwvdmFsdWU+PC9ibG9jaz48L3ZhbHVlPjwvYmxvY2s+PC92YWx1ZT48L2Jsb2NrPjwvdmFsdWU+PC9ibG9jaz48L3htbD4=
5df5a51910ea114a4edd737793179a6bb4e4a3a9e24aa1cf40da97e23a38e0d6
--END BLOCKS--
"""

from PiStorms import PiStorms
from PiStorms_GRX import PiStorms_GRX

x = None
i = None

psm = PiStorms()

grx = PiStorms_GRX()
"""Describe this function...
"""


def fibonacci(x):
    if x <= 1:
        return 1
    return fibonacci(x - 2) + fibonacci(x - 1)


psm.screen.fillCircle(40, 40, 25, (255, 204, 0), display=True)
for i in range(13):
    print(''.join([str(x2) for x2 in [i, ': ', fibonacci(i)]]))
    psm.screen.fillCircle((fibonacci(i)), (fibonacci(i)),
                          5, (255, 0, 0),
Ejemplo n.º 12
0
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.    See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#mindsensors.com invests time and resources providing this open source code,
#please support mindsensors.com  by purchasing products from mindsensors.com!
#Learn more product option visit us @  http://www.mindsensors.com/

from PiStorms_GRX import PiStorms_GRX
psm = PiStorms_GRX()

from PiStorms_GRX import RCServo
l = RCServo("BAS1", 1300)
r = RCServo("BAS2", 1690)

import pygame, sys
try:
    pygame.init()
    joystick = pygame.joystick.Joystick(0)
    joystick.init()
except:
    psm.screen.showMessage("Please connect a joystick and try again.")
    sys.exit(0)

import time
Ejemplo n.º 13
0
#
#mindsensors.com invests time and resources providing this open source code,
#please support mindsensors.com  by purchasing products from mindsensors.com!
#Learn more product option visit us @  http://www.mindsensors.com/
#
# History:
# Date      Author          Comments
# 04/18/17  Seth Tenembaum  Initial development.
#

# This program demonstrates how to create and display a basic, static graph
# on the PiStorms screen.
# It is heavily based on https://matplotlib.org/examples/pylab_examples/simple_plot.html

from PiStorms_GRX import PiStorms_GRX
psm = PiStorms_GRX()
psm.screen.termPrintln("Please wait a moment")
psm.screen.termPrintln("as matplotlib loads...")
psm.screen.termPrintAt(3, "Press GO to quit.")

import matplotlib
matplotlib.use("AGG")
import matplotlib.pyplot as plt
import numpy as np

# setup figure
plt.figure(figsize=(4, 3), dpi=80)
plt.xlabel('time (s)')
plt.ylabel('voltage (mV)')
plt.title('About as simple as it gets, folks')
plt.grid(True)
Ejemplo n.º 14
0
#mindsensors.com invests time and resources providing this open source code,
#please support mindsensors.com  by purchasing products from mindsensors.com!
#Learn more product option visit us @  http://www.mindsensors.com/
#
# History:
# Date      Author          Comments
# 04/18/17  Seth Tenembaum  Initial development.
#

# This program demonstrates how to create a live-updating graph, but only displaying
# the latest n values on screen. It also explicitly sets the y-axis range.
# Don't hold the button too long, or you'll turn off the PiStorms!
# Tap the touchscreen to exit.

from PiStorms_GRX import PiStorms_GRX
psm = PiStorms_GRX()
psm.screen.termPrintln("Please wait a moment")
psm.screen.termPrintln("as matplotlib loads...")
psm.screen.termPrintAt(3, "Tap and hold the screen to quit.")

import matplotlib
matplotlib.use("AGG")
import matplotlib.pyplot as plt
import numpy as np
import tempfile

plt.figure(figsize=(4,3), dpi=80)
plt.xlabel('time')
plt.ylabel('GO button state')
plt.title('GO Button')
plt.grid(True)
Ejemplo n.º 15
0
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#mindsensors.com invests time and resources providing this open source code,
#please support mindsensors.com  by purchasing products from mindsensors.com!
#Learn more product option visit us @  http://www.mindsensors.com/

import os,sys,inspect,time,thread,random
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)

from PiStorms_GRX import PiStorms_GRX
psm = PiStorms_GRX()

color = (255, 255, 255)

while True:
    if psm.isKeyPressed():
        break
    
    if psm.isF1Pressed():
        color = (255, 0, 0)
    if psm.isF2Pressed():
        color = (255, 255, 0)
    if psm.isF3Pressed():
        color = (0, 255, 0)
    if psm.isF4Pressed():
        color = (0, 0, 255)
Ejemplo n.º 16
0
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#mindsensors.com invests time and resources providing this open source code,
#please support mindsensors.com  by purchasing products from mindsensors.com!
#Learn more product option visit us @  http://www.mindsensors.com/
#
# History:
# Date      Author      Comments
# July 2015  Henry     Initial Authoring from SensorShield import SensorShield
# July 2017  Seth      Clean, update for GRX

import os, socket
import ConfigParser
from PiStorms_GRX import PiStorms_GRX
psm = PiStorms_GRX()

config = ConfigParser.RawConfigParser()
config.read("/usr/local/mindsensors/conf/msdev.cfg")
homefolder = config.get("msdev", "homefolder")
try:
    with open(os.path.join(homefolder, ".version"), "r") as f:
        version_no = f.readline().strip()
except IOError:
    version_no = "unknown"

psm.screen.drawDisplay("About Me")
psm.screen.termPrintln("Device: {}".format(psm.getDeviceModel()))
psm.screen.termPrintln("Feature: {}".format(psm.getDeviceFeatures()))
psm.screen.termPrintln("f/w version: {}".format(psm.getFirmwareVersion()))
psm.screen.termPrintln("s/w version: {}".format(version_no))
Ejemplo n.º 17
0
from PiStorms_GRX import PiStorms_GRX
from TouchScreenInput import TouchScreenInput
from wireless import Wireless
from wifi import Cell
import ConfigParser

config = ConfigParser.RawConfigParser()
config.read("/usr/local/mindsensors/conf/msdev.cfg")
homefolder = config.get("msdev", "homefolder")
currentdir = os.path.join(homefolder, "programs")

# Globals
config_file = "/etc/wpa_supplicant/wpa_supplicant.conf" # Config file for Wi-Fi
wifi = None
wlan_inteface = "wlan0"
psm = PiStorms_GRX()

# Check if a wifi adapter is available
try:
    wifi = Wireless()
    wlan_interface = wifi.interfaces()[0]
except Exception as e:
    psm.screen.fillRect(0, 0, 320, 240, fill = (0,0,0), display = False)
    psm.screen.drawAutoText("No Wi-Fi adapter", 35, 20, fill = (255,0,0), size = 25, display = False)
    psm.screen.drawAutoText("available!", 35, 50, fill = (255,0,0), size = 25, display = False)
    psm.screen.drawButton(35, 160, width = 250, height = 40, text="Continue", display=False)
    psm.screen.fillRect(0, 0, 1, 1, fill = (0,0,0), display = True)
    while True:
        cont = psm.screen.checkButton(35, 160, 250, 40)
        if cont: sys.exit(0)
Ejemplo n.º 18
0
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.    See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#mindsensors.com invests time and resources providing this open source code,
#please support mindsensors.com  by purchasing products from mindsensors.com!
#Learn more product option visit us @  http://www.mindsensors.com/

from PiStorms_GRX import PiStorms_GRX
psm = PiStorms_GRX()

from PiStorms_GRX import RCServo
l = RCServo("BAS1", 1300)
r = RCServo("BAS2", 1690)

import pygame, sys
try:
    pygame.init()
    joystick = pygame.joystick.Joystick(0)
    joystick.init()
except:
    psm.screen.showMessage("Please connect a joystick and try again.")
    sys.exit(0)

import time
Ejemplo n.º 19
0
#
# mindsensors.com invests time and resources providing this open source code,
# please support mindsensors.com  by purchasing products from mindsensors.com!
# Learn more product option visit us @  http://www.mindsensors.com/
#
# History:
# Date          Author          Comments
# March 2016    Roman Bohuk     Initial Authoring
# July 2017     Seth Tenembaum  Update for GRX

import os, inspect
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))

import time, socket
from PiStorms_GRX import PiStorms_GRX
psm = PiStorms_GRX()

def checkInternet():
    try:
        socket.setdefaulttimeout(5)
        socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect(("8.8.8.8", 53))
        return True
    except:
        return False

psm.screen.drawAutoText("Testing internet connection", 20, 30, fill=(255,255,255), size=23, display=False)
psm.screen.fillRect(20, 80, 320, 240, fill=(0,0,0), display=False)
psm.screen.fillBmp(110, 110, 100, 100, path=currentdir+'/'+'load.png', display=False)
psm.screen.disp.display()
#time.sleep(1)
Ejemplo n.º 20
0
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
import sys, rmap, threading, time, math, socket, scratch, subprocess, datetime
import rmapcfg
from PiStorms_GRX import PiStorms_GRX

debug = False
device_dict = rmap.dict
read_dict = rmap.read_dict
command_array = []
command_array1 = []
string_message = ""
psm = PiStorms_GRX()
lasttime = int(round(time.time() * 1000))
# Connect to Scratch
try:
    s = scratch.Scratch(host=rmapcfg.host, port=rmapcfg.port)
    if s.connected:
        rmap.rmap_print("Connected")
except scratch.ScratchError:
    rmap.rmap_print(
        "Scratch is either not opened or remote sensor connections aren't enabled"
    )

# Broadcast 'READY' to Scratch
try:
    s.broadcast('READY')
    time.sleep(.5)
Ejemplo n.º 21
0
#mindsensors.com invests time and resources providing this open source code,
#please support mindsensors.com  by purchasing products from mindsensors.com!
#Learn more product option visit us @  http://www.mindsensors.com/
#
# History:
# Date      Author          Comments
# 07/10/17  Seth Tenembaum  Initial development.
#

# This program introduces the use of an external sensor.

from GroveDevices import Grove_Button
button = Grove_Button("BBD1")

from PiStorms_GRX import PiStorms_GRX
psm = PiStorms_GRX()
psm.screen.termPrintln("Please wait a moment")
psm.screen.termPrintln("as matplotlib loads...")
psm.screen.termPrintAt(3, "Press GO to quit.")

import matplotlib
matplotlib.use("AGG")
import matplotlib.pyplot as plt
import numpy as np
import tempfile

psm.screen.showMessage("Please connect a Grove button to BBD1", wrapText=True)

plt.figure(figsize=(4,3), dpi=80)
plt.xlabel('time')
plt.ylabel('state')
Ejemplo n.º 22
0
"""
--BLOCKLY FILE--
--START BLOCKS--
PHhtbCB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94aHRtbCI+PGJsb2NrIHR5cGU9InNjcmVlbl9kcmF3dGl0bGUiIGlkPSI9N0NMM2U9TTBtOGRpYV9BXkB6KyIgeD0iMTgiIHk9Ii01Ij48ZmllbGQgbmFtZT0iRElTUExBWSI+VFJVRTwvZmllbGQ+PHZhbHVlIG5hbWU9IlRFWFQiPjxzaGFkb3cgdHlwZT0idGV4dCIgaWQ9IlgsbHZWYmRmMmRsRX45Vzs3cHI5Ij48ZmllbGQgbmFtZT0iVEVYVCI+U2Vuc29yIERlbW88L2ZpZWxkPjwvc2hhZG93PjwvdmFsdWU+PG5leHQ+PGJsb2NrIHR5cGU9InRlcm1pbmFsX3ByaW50bG4iIGlkPSJsQDN5OWB6LUZgK090U1FTXVAvLCI+PHZhbHVlIG5hbWU9InRleHQiPjxzaGFkb3cgdHlwZT0idGV4dCIgaWQ9IjZgbilPW0JJO09+UD1kI3BYQlR+Ij48ZmllbGQgbmFtZT0iVEVYVCI+QkFBMTogR3JvdmUgTGlnaHQgU2Vuc29yPC9maWVsZD48L3NoYWRvdz48L3ZhbHVlPjxuZXh0PjxibG9jayB0eXBlPSJ0ZXJtaW5hbF9wcmludGxuIi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wvZmllbGQ+PC9ibG9jaz48L3ZhbHVlPjwvYmxvY2s+PC92YWx1ZT48dmFsdWUgbmFtZT0ibGluZSI+PHNoYWRvdyB0eXBlPSJtYXRoX251bWJlciIgaWQ9IkI9aTBKNUFhSHU0Zjt3O09Re3hlIj48ZmllbGQgbmFtZT0iTlVNIj4zPC9maWVsZD48L3NoYWRvdz48L3ZhbHVlPjwvYmxvY2s+PC9uZXh0PjwvYmxvY2s+PC9uZXh0PjwvYmxvY2s+PC9uZXh0PjwvYmxvY2s+PC9zdGF0ZW1lbnQ+PC9ibG9jaz48L25leHQ+PC9ibG9jaz48L25leHQ+PC9ibG9jaz48L25leHQ+PC9ibG9jaz48L25leHQ+PC9ibG9jaz48L25leHQ+PC9ibG9jaz48L25leHQ+PC9ibG9jaz48L25leHQ+PC9ibG9jaz48L25leHQ+PC9ibG9jaz48L3htbD4=
9f2f08d3ed272ec88dda0204f1ff341ce248240f56a35cf02954692074f8930a
--END BLOCKS--
"""

from PiStorms import PiStorms
import time
from PiStorms_GRX import PiStorms_GRX
import GroveDevices

psm = PiStorms()

grx = PiStorms_GRX()

groveLightSensor_BAA1 = GroveDevices.Grove_Light_Sensor("BAA1")

groveMoistureSensor_BAA2 = GroveDevices.Grove_Moisture_Sensor("BAA2")

groveSoundSensor_BAA3 = GroveDevices.Grove_Sound_Sensor("BAA3")

groveFlameSensor_BAD1 = GroveDevices.Grove_Flame_Sensor("BAD1")

psm.screen.drawDisplay('Sensor Demo', True)
psm.screen.termPrintln('BAA1: Grove Light Sensor')
psm.screen.termPrintln('BAA2: Grove Moisture Sensor')
psm.screen.termPrintln('BAA3: Grove Sound Sensor')
# These sensors are available in the Grove Sensor Kit:
# http://www.mindsensors.com/grove-sensors-with-ev3/189-grove-sensor-kit
Ejemplo n.º 23
0
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.    See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#mindsensors.com invests time and resources providing this open source code,
#please support mindsensors.com  by purchasing products from mindsensors.com!
#Learn more product option visit us @  http://www.mindsensors.com/

from PiStorms_GRX import PiStorms_GRX
from GroveDevices import Grove_PIR_Motion_Sensor

psm = PiStorms_GRX()
motionSensor = Grove_PIR_Motion_Sensor("BAA1")

m = ["Grove PIR Motion Sensor Demo",
     "Please connect a Grove PIR motion sensor to port BAA1 (Bank A, Analog 1) and press OK (or GO) to continue."]
psm.screen.showMessage(m, wrapText=True)

def mainLoop():
    if motionSensor.motionDetected():
        psm.screen.termPrintAt(0, "Motion detected")
    else:
        psm.screen.termPrintAt(0, "No motion detected")

psm.untilKeyPress(mainLoop)
Ejemplo n.º 24
0
#mindsensors.com invests time and resources providing this open source code,
#please support mindsensors.com  by purchasing products from mindsensors.com!
#Learn more product option visit us @  http://www.mindsensors.com/
#
# History:
# Date      Author          Comments
# 07/10/17  Seth Tenembaum  Initial development.
#

# This program introduces the use of an external sensor.

from GroveDevices import Grove_Light_Sensor
lightSensor = Grove_Light_Sensor("BAA1")

from PiStorms_GRX import PiStorms_GRX
psm = PiStorms_GRX()
psm.screen.termPrintln("Please wait a moment")
psm.screen.termPrintln("as matplotlib loads...")
psm.screen.termPrintAt(3, "Press GO to quit.")

import matplotlib
matplotlib.use("AGG")
import matplotlib.pyplot as plt
import numpy as np
import tempfile

psm.screen.showMessage("Please connect a Grove light sensor to BAA1",
                       wrapText=True)

plt.figure(figsize=(4, 3), dpi=80)
plt.xlabel('time')
Ejemplo n.º 25
0
--START BLOCKS--
PHhtbCB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94aHRtbCI+PGJsb2NrIHR5cGU9InNjcmVlbl9kcmF3Y2lyY2xlIiBpZD0ibUlNa0FWKX17Yik6YjQ5My9pNDkiIHg9Ii03IiB5PSItMzgxIj48ZmllbGQgbm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llbGQ+PHZhbHVlIG5hbWU9IkEiPjxzaGFkb3cgdHlwZT0ibWF0aF9udW1iZXIiIGlkPSJTalQqNWYvQU5CYVd9d1dhOFhSOyI+PGZpZWxkIG5hbWU9Ik5VTSI+MTwvZmllbGQ+PC9zaGFkb3c+PGJsb2NrIHR5cGU9InZhcmlhYmxlc19nZXQiIGlkPSI0dXBGeno4THdJQyw7R2J4LG4uMyI+PGZpZWxkIG5hbWU9IlZBUiI+eDwvZmllbGQ+PC9ibG9jaz48L3ZhbHVlPjx2YWx1ZSBuYW1lPSJCIj48c2hhZG93IHR5cGU9Im1hdGhfbnVtYmVyIiBpZD0iQUtQYHgweWI5a3IzUTtsdn5aczUiPjxmaWVsZCBuYW1lPSJOVU0iPjE8L2ZpZWxkPjwvc2hhZG93PjwvdmFsdWU+PC9ibG9jaz48L3ZhbHVlPjwvYmxvY2s+PC92YWx1ZT48L2Jsb2NrPjwvdmFsdWU+PC9ibG9jaz48L3htbD4=
5df5a51910ea114a4edd737793179a6bb4e4a3a9e24aa1cf40da97e23a38e0d6
--END BLOCKS--
"""


from PiStorms import PiStorms
from PiStorms_GRX import PiStorms_GRX

x = None
i = None

psm = PiStorms()

grx = PiStorms_GRX()

"""Describe this function...
"""
def fibonacci(x):
  if x <= 1:
    return 1
  return fibonacci(x - 2) + fibonacci(x - 1)


psm.screen.fillCircle(40, 40, 25, (255, 204, 0), display = True)
for i in range(13):
  print(''.join([str(x2) for x2 in [i, ': ', fibonacci(i)]]))
  psm.screen.fillCircle((fibonacci(i)), (fibonacci(i)), 5, (255, 0, 0), display = True)
grx.waitForKeyPress()
Ejemplo n.º 26
0
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#mindsensors.com invests time and resources providing this open source code,
#please support mindsensors.com  by purchasing products from mindsensors.com!
#Learn more product option visit us @  http://www.mindsensors.com/

import time, sys
import ConfigParser
from PiStormsCom_GRX import GRXCom
from PiStorms_GRX import PiStorms_GRX, RCServo, GrovePort

psm = PiStorms_GRX()
config = ConfigParser.RawConfigParser()
config.read("/usr/local/mindsensors/conf/msdev.cfg")

# introduce program and intent
m = [
    "Find Neutral Point - Introduction",
    'Every servo is slightly different due to the manufacturing process. This could make a continuous rotation servo "drift" when you set the speed to "0".'
]
psm.screen.showMessage(m, wrapText=True)
m[1] = "This program can help you find what value *actually* makes your servo stop. This will be saved to a configuration file so you don't have to worry about it again. Would you like to continue?"
if not psm.screen.askYesOrNoQuestion(m, wrapText=True, goBtn=True):
    sys.exit(0)

bank = psm.screen.askQuestion(
    ["Motor Bank", "Which bank is your servo connected to?"],