예제 #1
0
    #
    # Also count the number of times it was touched.
    #
    old_touch_count = touch_count
    touch_count = psm.BAS1.numTouchesNXT()

    # print value only if it was changed.
    if (old_touch != touch) or (old_touch_count != touch_count):
        msg = "Sensor Touched:  " + str(touch)
        msg2 = "Touch Count: " + str(touch_count)

        psm.screen.termPrintAt(2, "")
        psm.screen.termPrintAt(3, msg)
        psm.screen.termPrintAt(4, msg2)

        psm.screen.termPrintAt(7, "Touch screen to reset Count")
        psm.screen.termPrintAt(8, "Press GO to stop program")

    if (psm.isKeyPressed() == True):  # if the GO button is pressed
        psm.screen.clearScreen()
        psm.screen.termPrintAt(8, "Exiting to menu")
        doExit = True

    #
    # check if screen touched.
    #
    if (psm.screen.isTouched()):
        # if scren was touched,
        # reset BAS1 touch count
        psm.BAS1.resetTouchesNXT()
예제 #2
0
    if ( ambientMode == True):
        colorValue = psm.BAS1.ambientLightSensorEV3()
        msg = "Color Seen:  " + str(colorValue) + " (ambient)"
    else:
        colorValue = psm.BAS1.colorSensorEV3()
        msg = "Color Seen:  " + str(colorValue) + " (reflected)"

    # print value only if it was changed.
    if (old_colorValue != colorValue):
        psm.screen.clearScreen()
        psm.screen.drawAutoText(msg, 15, 164, fill=(255, 255, 255), size = 18) 
        psm.screen.drawAutoText("Touch screen to change mode", 15, 182, fill=(255, 255, 255), size = 18) 
        psm.screen.drawAutoText("between ambient/reflected", 15, 200, fill=(255, 255, 255), size = 18) 
        psm.screen.drawAutoText("Press Go to stop program", 15, 218, fill=(255, 255, 255), size = 18) 
    
    if(psm.isKeyPressed() == True): # if the GO button is pressed
        psm.screen.clearScreen()
        psm.screen.termPrintln("")
        psm.screen.termPrintln("Exiting to menu")
        doExit = True 

    #
    # check if screen touched.
    #
    if(psm.screen.checkButton(0,0,320,320)):
        # if scren was touched, 
        # reset BAS1 touch count
        if ( ambientMode == False):
            ambientMode = True
        else:
            ambientMode = False
예제 #3
0
    psm.screen.drawAutoText("configurations backups",
                            35,
                            50,
                            fill=(255, 0, 0),
                            size=22,
                            display=False)
    psm.screen.drawButton(35,
                          170,
                          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, 170, 250, 40)
        if cont or psm.isKeyPressed(): sys.exit(0)


# Reload adapter to apply config changes
def reload_adapter():
    # Clear the screen and show the loading image
    show_loading(up=True)
    # Turn off and back on the wlan interface
    subprocess.call(["sudo", "ifdown", "wlan0"])
    subprocess.call(["sudo", "ifup", "wlan0"])


def draw_options():
    # Clear the screen
    psm.screen.fillRect(0, 0, 320, 240, (0, 0, 0))
    psm.screen.drawAutoText("Revert WiFi configuration",
예제 #4
0
                    print self.matrixF
                    print i
                    self.Grab(i)
                    self.turn = True

    def Grab(self, degrees):
        self.joint1.runDegs(degrees + 55)
        time.sleep(1)
        self.joint2.setSpeed(-10)
        time.sleep(1)
        self.joint2.setSpeed(-5)
        time.sleep(0.5)
        self.joint1.runDegs(-(degrees - 20))
        time.sleep(1)
        self.Stop()

    def Stop(self):
        self.joint1.setSpeed(0)
        self.joint2.setSpeed(0)


grabber = Grabber(psm.BAM2, psm.BAM1)
driver = Driver(psm.BBM2, psm.BBM1)
subsumptionPixy = SubsumptionPixy()
finder = Finder(subsumptionPixy, driver, grabber)

while psm.isKeyPressed() == False:
    finder.Step()

driver.Stop()
grabber.Stop()
예제 #5
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
"""
--BLOCKLY FILE--
--START BLOCKS--
PHhtbCB4bWxucz0iaHR0cDovL3d3dy53My5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LTh7NnV5bzEock5saHNlNSI+PGZpZWxkIG5hbWU9Ik5VTSI+MDwvZmllbGQ+PC9zaGFkb3c+PC92YWx1ZT48bmV4dD48YmxvY2sgdHlwZT0ic3lzdGVtX3NsZWVwIiBpZD0iY2BAP0ZjWHUre2xnbW8rX0p7enciPjx2YWx1ZSBuYW1lPSJUSU1FIj48c2hhZG93IHR5cGU9Im1hdGhfbnVtYmVyIiBpZD0iSC5Ed2UqYVleKUBCbzIlVXpUKVoiPjxmaWVsZCBuYW1lPSJOVU0iPjE8L2ZpZWxkPjwvc2hhZG93PjwvdmFsdWU+PC9ibG9jaz48L25leHQ+PC9ibG9jaz48L25leHQ+PC9ibG9jaz48L25leHQ+PC9ibG9jaz48L3N0YXRlbWVudD48L2Jsb2NrPjwveG1sPg==
184e880526960bd774d2be11aadd04c103d1c18b1cfb9bf66e80c527d4a8051e
--END BLOCKS--
"""

from PiStorms import PiStorms
import time

psm = PiStorms()

while not bool(psm.isKeyPressed()):
    psm.BAM1.setSpeed(50)
    time.sleep(1)
    psm.BAM1.setSpeed(0)
    time.sleep(1)
예제 #6
0
from PiStorms import PiStorms
psm = PiStorms()

import PID

def setSpeed(speed):
	if speed > 100:
		speed = 100
	elif speed < -100:
		speed = -100
	psm.BAM1.setSpeedSync(-speed)
	if speed == 0:
		psm.BAM1.brakeSync()

def getDistanceToGoal():
	return psm.BAS2.distanceUSEV3() - 400

controller = PID.PIDController(1,0,0.05, getDistanceToGoal, 0.1, 0.5)

while not psm.isKeyPressed():
	tm = time.time()

	setSpeed(controller.tick())

	sleept = 0.1 - (time.time() - tm)
	if sleept < 0:
		sleept = 0
	time.sleep(sleept)

setSpeed(0)
예제 #7
0
psm = PiStorms() # PiStorms object
exit = False    # break loop

while (not exit):
    light = psm.BBS1.lightSensorNXT(True)
    #       520
    error = 540 - light #if within 40 on edge, if negative on line, if positive in white 
    # psm.BBM1.setSpeedSync(30)
    # if (abs(error) < 20): #on edge
	# psm.BBM1.setSpeedSync(30)
	# psm.led(1,0,255,0) #green
    if (error < 0): #on line, turn to right, left wheel accelerate
  	psm.BBM1.setSpeed(25)
	psm.BBM2.setSpeed(-50)
	psm.led(1,0,0,255)#blue
    elif (error > 0): #on white, turn to left, right wheel accelerate
	psm.BBM2.setSpeed(25)
	psm.BBM1.setSpeed(-50)
	psm.led(1,255,0,0)#Red
    sleep(0.1)

    if (psm.isKeyPressed()): #exit
        psm.BBM1.brakeSync()
	psm.led(1,0,0,0)
	psm.screen.clearScreen()
	psm.screen.termPrintln("")
	psm.screen.termPrintln("Exiting to menu")
	sleep(0.5)
	exit = True
예제 #8
0
cam = MsDevices.NXTCam5(psm.BAS1)
func = doBlob

while(not doExit):

    drawButtons()
    id = cam.GetDeviceId()
    pos = id.find('\0')
    psm.screen.termPrintAt(6, "Device ID: " + id[:pos])

    #cam.command(79)  # object
    time.sleep(1)
    psm.screen.clearScreen()
    drawButtons()

    if( psm.isKeyPressed() == True) or ( psm.screen.checkButton(0,0,30,30)):
        psm.screen.clearScreen()
        psm.screen.termPrintAt(8, "Exiting to menu")
        doExit = True

    btn = checkButtonPress()
    if ( btn != "" ):
        psm.screen.clearScreen()
        if ( btn == 'blob'):
            psm.screen.termPrintAt(4, "blob pressed")
            doBlob(True)
        if ( btn == 'face'):
            psm.screen.termPrintAt(4, "face pressed")
            doFace(True)
        if ( btn == 'movie'):
            psm.screen.termPrintAt(4, "movie pressed")
예제 #9
0
            if (addr != 0x34 and addr != 0x35 and addr != 0x36 and addr != 0x37):
                i2c = ms_explorerlib.Explorer(addr)
                found = i2c.ping(0x00)
                print ">>01 found: " + str(found)
                if ( found > 0 ):
                    if ( (addr%2) == 0 ):
                        # print only the even addresses.
                        psm.screen.termPrintAt(line, "Device: " + i2c.GetDeviceId()[:6] +" " + (str(hex(addr))))
                        line = line + 1
            if (count > 2000):
                found = 5
        else:
            addr = 0x00
    return found

bye = False
while(not exit):
    explorer = psm.screen.checkButton(75, 95,width=85,height=40)
    if(psm.isKeyPressed()): bye = True
    if(explorer == True):
        psm.screen.termPrintAt(1, "Searching (Go to cancel) ...")        
        psm.BAS1.activateCustomSensorI2C()
        f = explore()
        if ( f == -1):
            psm.screen.termPrintAt(8, "Done, Explore again ")        
            
    if(bye == True):
        psm.screen.termPrintAt(5, "Exiting to menu")
        exit = True
    time.sleep(.1)
예제 #10
0
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)
plt.ylim(
    (-0.05, 1.05)
)  # set y-axis range, off by a bit so the line isn't right on the edge of the graph

axis = plt.gca()  # get current axis
data = np.empty(0)
image = tempfile.NamedTemporaryFile()  # we will be overwriting this same file

while not psm.screen.isTouched():
    data = np.append(data, psm.isKeyPressed()
                     )  # add a data point with the current GO button state
    if axis.lines:
        axis.lines.pop(
        )  # if there's already a line on the graph (old), remove it
    lines = plt.plot(
        data[-20:],
        color="blue")  # plot the last 20 data points on the graph (new line)
    plt.tight_layout()  # make sure the entire plot fits on screen
    plt.savefig(image.name, format="png")
    psm.screen.fillBmp(0, 0, 320, 240, image.name)
예제 #11
0
from PiStorms import PiStorms
psm = PiStorms()
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)
plt.ylim((-0.05, 1.05)) # set y-axis range, off by a bit so the line isn't right on the edge of the graph

axis = plt.gca() # get current axis
data = np.empty(0)
image = tempfile.NamedTemporaryFile() # we will be overwriting this same file

while not psm.screen.isTouched():
    data = np.append(data, psm.isKeyPressed()) # add a data point with the current GO button state
    if axis.lines: axis.lines.pop() # if there's already a line on the graph (old), remove it
    lines = plt.plot(data[-20:], color="blue") # plot the last 20 data points on the graph (new line)
    plt.tight_layout() # make sure the entire plot fits on screen
    plt.savefig(image.name, format="png")
    psm.screen.fillBmp(0,0, 320,240, image.name)
예제 #12
0
        answer = disconnect_question()
        if answer: disconnect()
        # Redraw
        draw_options()
        draw_connections(ssids, page)

    # Change the page
    if next: page += 1
    elif prev:
        page -= 1
        if page < 0: page = (len(ssids)-1) / 4
    elif refresh:
        show_loading()
        available = Cell.all(wlan_interface)
        ssids = get_available()
    # Redraw connections if changed
    if next or prev or refresh: shown = draw_connections(ssids, page)
    
    # Connect to a chosen network
    if label1 and len(shown) > 0: connect(shown[0][0],shown[0][1],shown[0][2])
    if label2 and len(shown) > 1: connect(shown[1][0],shown[1][1],shown[1][2])
    if label3 and len(shown) > 2: connect(shown[2][0],shown[2][1],shown[2][2])
    if label4 and len(shown) > 3: connect(shown[3][0],shown[3][1],shown[3][2])
    # Redraws options and available connections
    if (label1 and len(shown) > 0) or (label2 and len(shown) > 1) or (label3 and len(shown) > 2) or (label4 and len(shown) > 3):
        draw_options()
        shown = draw_connections(ssids, page)
    
    # Exit
    if(psm.isKeyPressed()): exit = True
예제 #13
0
                elif self.turnState == 1:
                    self.manager.turnRight(self.turnSpeed,
                                           self.turnDuration * 2)
                else:
                    self.manager.turnLeft(self.turnSpeed, self.turnDuration)
                    self.turnDuration += self.turnAdd
                self.turnState = (self.turnState + 1) % 3
        else:
            if lastSensorReading > self.searchDistance:
                self.moveState = 1
                self.turnDuration = 1
                self.turnState = 0
                self.manager.stopAll()
                return
            self.manager.driveStraight(
                self.controller.step(lastSensorReading - self.followDistance),
                1)


PSM = PiStorms()
RECKONER = Reckoner(PSM.BBS1, PSM.BAM1, PSM.BAM2)
MANAGER = MotorManager(PSM.BAM1, PSM.BAM2, True)
PID = PIDController()
F = Follower(MANAGER, PSM.BAS2, PID, RECKONER)

while not PSM.isKeyPressed():
    F.step()
    sleep(0.02)
F.manager.stopAll()
F.reckoner.plot()
예제 #14
0
#exit variable will be used later to exit the program and return to PiStorms 
exit = False

#clears the screen of any unwanted text by displaying a white rectangle
#psm.screen.fillRect(0, 0, 320, 240)
psm.screen.clearScreen()
#displays Sam's greeting of "Hello, I am Sam"
#psm.screen.drawAutoText("Test 1", 80, 30, fill=(255, 0, 0), size = 70)
#psm.screen.drawAutoText("Lets see what this can do", 70, 140, fill=(255, 0, 0), size = 45)
psm.screen.termPrintln("")
psm.screen.termPrintln("Lets Drive")

#psm.BBM2.runSecs(1,20,True);
#psm.BAM2.runSecs(1,20,True);

count = 0
#main loop
while(not exit and count < 3):
#	psm.BBM1.runSecs(1,20,True);
#	psm.BAM2.runSecs(1,20,True);
    count+= 1
    time.sleep(5)
        
    if psm.isKeyPressed(): # if the GO button is pressed
        psm.screen.clearScreen()
        psm.screen.termPrintln("") 
        psm.screen.termPrintln("Exiting to menu")
        time.sleep(0.5) 
        exit = True 
예제 #15
0
# Date      Author      Comments
#  July 2015  Henry     Initial Authoring from SensorShield import SensorShield


import os,sys,inspect,time
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0,parentdir)
from PiStorms import PiStorms

psm = PiStorms()
psm.screen.termPrintAt(2, "PiStorms ")
psm.screen.termPrintAt(3, "GO button test:")

exit = False
print "Running Button Test"
print "press anywhere in PiStorms Screen to exit"
psm.screen.termPrintAt(8, "Touch Display to Exit")
psm.screen.termPrintln(" ")
while(not exit):

    pass

    psm.screen.termPrintAt(5, "GO Button is = " +str(psm.isKeyPressed()))
    psm.screen.termPrintAt(6, "Press Count = " +str(psm.getKeyPressCount()))
    if (psm.screen.isTouched()):
        psm.screen.termPrintln(" ")
        psm.screen.termPrintln("Exiting .....")
        exit = True

예제 #16
0
psm = PiStorms()
exit = False

psm.screen.clearScreen()
psm.screen.termPrintln("")
psm.screen.termPrintln("Photo Test x3")

count = 0

while not exit and count < 3:

    psm.screen.clearScreen()
    psm.screen.termPrintln("Taking Photo " + str(count + 1))

    cameraModule.take_photo('/home/pi/PiStormsprograms/images/', 'image01.png')
    psm.screen.clearScreen()
    psm.screen.fillBmp(30,
                       0,
                       240,
                       240,
                       path='/home/pi/PiStormsprograms/images/image01.png')
    count += 1
    time.sleep(5)
    if psm.isKeyPressed():
        psm.screen.clearScreen()
        psm.screen.termPrintln("")
        psm.screen.termPrintln("Exiting to menu")
        time.sleep(0.5)
        exit = True
예제 #17
0
            value = IR.readChannelProximity(1)
            mode = "Proximity"
        elif (count == 2):
            psm.screen.termPrintAt(1, "Keep remote on channel 1 and ")
            psm.screen.termPrintAt(2, "press joystick(s).")
            value = IR.readRemote(1)
            #Output is in array (L, R), where L is the left stick and R is the right stick
            #1 is up, 0 is nothing, and -1 is down

        msg = mode+":  " + str(value)


    if (oldValue != value):
        psm.screen.termPrintAt(3, msg0)
        psm.screen.termPrintAt(4, msg)
    if(psm.isKeyPressed() == True):
        psm.screen.clearScreen()
        IR = EV3InfraredSensor("BAS1", 9) #Turn off detecting
        psm.screen.termPrintln("")
        psm.screen.termPrintln("Exiting to menu")
        doExit = True
    change = 0
    if(psm.screen.isTouched()): #Change mode if screen is tapped
        count = count + 1
        if ( count > 2):
            count = 0
        psm.screen.clearScreen()
        psm.screen.termPrintAt(4, "Switching...")
        psm.screen.termPrintAt(7, "Touch screen to change mode")
        psm.screen.termPrintAt(8, "Press Go to stop program")
        change = 1
예제 #18
0
def getDistanceToGoal():
	return psm.BAS2.distanceUSEV3() - FOLLOW_DIST

def waitForSensor(dist,timeout):
	t = time.time()

	while psm.BAS2.distanceUSEV3() > dist and (not psm.isKeyPressed()):
		if time.time() - t > timeout:
			return False
	return True



curError = getDistanceToGoal()

while not psm.isKeyPressed():
	tm = time.time()


	while psm.BAS2.distanceUSEV3() > OUTOFRANGE and (not psm.isKeyPressed()):
		spinTime = SPINTIME
		#move left
		psm.BAM1.setSpeed(SPINSPEED)
		psm.BAM2.setSpeed(-SPINSPEED)
		if waitForSensor(OUTOFRANGE, spinTime):
			break

		setSpeed(0)
		if waitForSensor(OUTOFRANGE, 0.5):
			break
예제 #19
0
# History:
# Date      Author      Comments
#  July 2015  Henry     Initial Authoring from SensorShield import SensorShield


import os,sys,inspect,time
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0,parentdir) 
from PiStorms import PiStorms

psm = PiStorms()
psm.screen.termPrintln("PiStorms ")
psm.screen.termPrintln("GO button test:")
psm.screen.termPrintln(" ")

exit = False
print "Running Button Test"
print "press anywhere in PiStorms Screen to exit"
psm.screen.termPrintln("Touch Display to Exit")
psm.screen.termPrintln(" ")
while(not exit):
 
    pass
    
    psm.screen.termReplaceLastLine("Go Button is = " +str(psm.isKeyPressed()))
    if (psm.screen.checkButton(0,0,320,320)):
        psm.screen.termPrintln(" ")
        psm.screen.termPrintln("Exiting .....")
        exit = True
        
예제 #20
0
--START BLOCKS--
PHhtbCB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94aHRtbCI+PGJsb2NrIHR5cGU9InZhcmlhYmxlc19zZXQiIGlkPSJhQW0lfkhpZ1MqdWNrKHR4X11JRyIgeD0iMCIgeT0iMCI+PGZpZWxkIG5hbWU9IlZBUiI+c3Vtb3NlbnNvcjwvZmllbGQ+PGNvbW1lbnQgcGlubmVkPSJ0cnVlIiBoPSI4NSIgdz0iMzQzIj5BdHRhY2ggYSBOWFRTdW1vRXllcyB0byBQb3J0IEJBUzEgb2YgUGlTdG9ybXMuClN0YXJ0IHRoZSBwcm9ncmFtIGZyb20gUGlTdG9ybXMgb24gU2NyZWVuIEJyb3dzZXIgYW5kIHByZXNzIEdPIGJ1dHRvbiB0byB0ZXJtaW5hdGUuPC9jb21tZW50Pjx2YWx1ZSBuYW1lPSJWQUxVRSI+PGJsb2NrIHR5cGU9InNlbnNvcnNfc3Vtb2V5ZXMiIGlkPSJSXz9UMCN+eV80OlBWZE5lSS9BJSI+PGZpZWxkIG5hbWU9InNlbnNvcl9zZWxlY3RvciI+Q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efa27c0a1d36f2f2a11d44da1aff62bfbcb2e1712fed
--END BLOCKS--
"""


from PiStorms import PiStorms
import MsDevices

sumosensor = None
old_zone = None
str1 = None

psm = PiStorms()

sumoeyes_BAS1 = MsDevices.SumoEyes(psm.BAS1)


# Attach a NXTSumoEyes to Port BAS1 of PiStorms.
# Start the program from PiStorms on Screen
# Browser and press GO button to terminate.
sumosensor = sumoeyes_BAS1
sumosensor.setRange(sumosensor.LONG_RANGE)
while not bool(psm.isKeyPressed()):
  old_zone = str1
  str1 = sumosensor.detectObstactleZone(True)
  if str1 != old_zone:
    psm.screen.clearScreen(True)
    psm.screen.drawAutoText(str1, 40, 40, fill = (255, 0, 0), size = 50, display = True)
예제 #21
0
                              y + h,
                              int(-2 + (w + h) / 3),
                              fill=(0, 0, 0),
                              display=False)
        psm.screen.fillCircle(imw - (x + w) + w / 4,
                              y + h - h / 4,
                              4,
                              fill=(255, 255, 255),
                              display=False)
        psm.screen.fillCircle(imw - (x + w) - w / 4,
                              y + h - h / 4,
                              4,
                              fill=(255, 255, 255),
                              display=True)

    # show the frame use this if you are setup for Display export on your pc or VNC
    #you may use Xming server for this

    #cv2.imshow("Frame", image)
    key = cv2.waitKey(1) & 0xFF
    lastfaces = faces

    # clear the stream in preparation for the next frame
    rawCapture.truncate(0)

    # if the `q` key was pressed, break from the loop
    if (psm.isKeyPressed() == True):
        break
    #if key == ord("q"):
    #    break
예제 #22
0
            opt.append([tim,i.split("\n",1)[1],int(i.split("\n")[0])])
            lt = tim
    opt = opt[::-1]
except Exception as e:
    error = True
    with open(config_file, "w+") as f:
        f.write("")
        
if error or len(opt) == 0:
    psm.screen.drawAutoText("You have no Wi-Fi", 35, 20, fill = (255,0,0), size = 22, display = False)
    psm.screen.drawAutoText("configurations backups", 35, 50, fill = (255,0,0), size = 22, display = False)    
    psm.screen.drawButton(35, 170, 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, 170, 250, 40)
        if cont or psm.isKeyPressed(): sys.exit(0)

# Reload adapter to apply config changes
def reload_adapter():
    # Clear the screen and show the loading image
    show_loading(up=True)
    # Turn off and back on the wlan interface
    subprocess.call(["sudo","ifdown","wlan0"])
    subprocess.call(["sudo","ifup","wlan0"])

def draw_options():
    # Clear the screen
    psm.screen.fillRect(0, 0, 320, 240, (0,0,0))
    psm.screen.drawAutoText("Revert WiFi configuration", 20, 10, fill = (255,0,0), size = 24, display = False)
    psm.screen.drawButton(20, 45, width = 150, height = 35, text="        <", display=False)
    psm.screen.drawButton(170, 45, width = 150, height = 35, text="        >", display=False)
예제 #23
0
# History:
# Date      Author      Comments
#  July 2015  Henry     Initial Authoring from SensorShield import SensorShield

import os, sys, inspect, time
currentdir = os.path.dirname(
    os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0, parentdir)
from PiStorms import PiStorms

psm = PiStorms()
psm.screen.termPrintln("PiStorms ")
psm.screen.termPrintln("GO button test:")
psm.screen.termPrintln(" ")

exit = False
print "Running Button Test"
print "press anywhere in PiStorms Screen to exit"
psm.screen.termPrintln("Touch Display to Exit")
psm.screen.termPrintln(" ")
while (not exit):

    pass

    psm.screen.termReplaceLastLine("Go Button is = " + str(psm.isKeyPressed()))
    if (psm.screen.checkButton(0, 0, 320, 320)):
        psm.screen.termPrintln(" ")
        psm.screen.termPrintln("Exiting .....")
        exit = True
예제 #24
0
            psm.BBM1.setSpeedSync(SPEED)

        sleep(0.1)

    psm.BAM1.float()
    psm.BAM2.float()
    psm.BBM1.float()
    psm.BBM2.float()


if __name__ == '__main__':

    psm.BAM1.resetPos()
    ramp(RAMP_UP)

    while not psm.isKeyPressed():
        psm.screen.termPrintln('waiting')

    psm.screen.clearScreen()
    psm.screen.termPrintln('starting!')

    for i in xrange(5):
        psm.led(1, 255, 0, 0)
        sleep(0.8)
        psm.led(1, 0, 0, 0)
        sleep(0.2)

    psm.screen.clearScreen()
    ramp(RAMP_MID)
    sleep(0.5)
예제 #25
0
    picam = PiCamera()
except:
    m = [
        "PopHeads", "Camera not enabled.", "Run raspi-config and enable camera"
    ]
    psm.screen.askQuestion(m, ["OK"])
    exit()
exitNow = 0
time.sleep(.2)
haar_path = currentdir + "/haarcascade_frontalface_default.xml"
faceCascade = cv2.CascadeClassifier(haar_path)
#psm.screen.fillRect(95, 145, 110, 160)
#psm.screen.fillRect(100, 150, 100, 150, fill=(0,0,0))
while not exitNow:
    psm.screen.termPrintAt(9, "Click Go to take a picture")
    if (psm.isKeyPressed()):
        # call("raspistill -o /tmp/cam.jpg", shell=True)
        # time.sleep(2)
        # psm.screen.fillBmp(0,0,100,100,path = "/tmp/cam.jpg")
        # time.sleep(2)
        picam.capture('/tmp/pic.jpg')
        psm.screen.fillBmp(0, 0, 320, 240, path="/tmp/pic.jpg")
        psm.screen.termPrintAt(8, "Captured!")
        time.sleep(1)
        psm.screen.termPrintAt(8, "Detecting faces...")
        img = cv2.imread('/tmp/pic.jpg')
        (imh, imw) = img.shape[:2]
        grayimg = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
        faces = faceCascade.detectMultiScale(grayimg,
                                             scaleFactor=1.1,
                                             minNeighbors=5,
예제 #26
0
# Date      Author      Comments
#  July 2015  Henry     Initial Authoring from SensorShield import SensorShield


import os,sys,inspect,time
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0,parentdir) 
from PiStorms import PiStorms

psm = PiStorms()
psm.screen.termPrintAt(2, "PiStorms ")
psm.screen.termPrintAt(3, "GO button test:")

exit = False
print "Running Button Test"
print "press anywhere in PiStorms Screen to exit"
psm.screen.termPrintAt(8, "Touch Display to Exit")
psm.screen.termPrintln(" ")
while(not exit):
 
    pass
    
    psm.screen.termPrintAt(5, "GO Button is = " +str(psm.isKeyPressed()))
    psm.screen.termPrintAt(6, "Press Count = " +str(psm.getKeyPressCount()))
    if (psm.screen.checkButton(0,0,320,320)):
        psm.screen.termPrintln(" ")
        psm.screen.termPrintln("Exiting .....")
        exit = True
        
예제 #27
0
    for (x, y, w, h) in faces:
        # for displaying on exported display
        cv2.circle(image, (x+w/2, y+h/2), int((w+h)/3), (255, 255, 255), 1)

        # for showing on PiStorms screen
        psm.screen.fillCircle((x+w)-w/2, y+h-h/2, int((w+h)/3), fill = (255,255,255),display = False)
        psm.screen.fillCircle((x+w)-w/2, y+h-h/2, int(-2+(w+h)/3), fill = (0,0,0),display = False)
        psm.screen.fillCircle((x+w)-w/2+w/4, y+h-h/4-h/2, 4, fill = (255,255,255),display = False)
        psm.screen.fillCircle((x+w)-w/2-w/4, y+h-h/4-h/2, 4, fill = (255,255,255),display = True)


    # show the frame use this if you are setup for Display export on your pc or VNC
    #you may use Xming server for this

    #cv2.imshow("Frame", image)
    key = cv2.waitKey(1) & 0xFF
    lastfaces = faces

	# clear the stream in preparation for the next frame
    rawCapture.truncate(0)

	# if the `q` key was pressed, break from the loop
    if((psm.isKeyPressed() == True) and psm.screen.isTouched()):
        break
    #if key == ord("q"):
    #    break




예제 #28
0
        socket.setdefaulttimeout(5)
        socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect(("8.8.8.8", 53))
        return True
    except Exception as e: pass
    return False

psm.screen.fillRect(0, 0, 320, 240, fill = (0,0,0), display = 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.fillRect(0, 0, 1, 1, fill = (0,0,0), display = True)

    
test = available()
psm.screen.fillRect(0, 0, 320, 240, fill = (0,0,0), display = False)
if test:
    psm.screen.drawAutoText("You are connected", 35, 20, fill = (0,255,0), size = 25, display = False)
    psm.screen.drawAutoText("to the internet!", 35, 50, fill = (0,255,0), size = 25, display = False)
    psm.screen.fillBmp(120, 85, 80, 80, path = currentdir+'/'+'wifi_green.png', display = False)
else:
    psm.screen.drawAutoText("You are not connected", 35, 20, fill = (255,0,0), size = 25, display = False)
    psm.screen.drawAutoText("to the internet!", 35, 50, fill = (255,0,0), size = 25, display = False)
    psm.screen.fillBmp(130, 95, 60, 60, path = currentdir+'/'+'x_red.png', display = False)
    
psm.screen.drawButton(35, 170, width = 250, height = 40, text="Continue", display=False)
psm.screen.fillRect(0, 0, 1, 1, fill = (0,0,0), display = True)
exit = False
while not exit:
    cont = psm.screen.checkButton(35, 170, 250, 40)
    if cont or psm.isKeyPressed(): exit = True
예제 #29
0
파일: minion.py 프로젝트: newsboytko/robots
        if resp and resp.status_code == 200:
            registered = True
    except:
        pass

    if registered:
        psm.screen.termPrintln('registered successfully')
    else:
        psm.screen.termPrintln('failed to register')

switchboard_register()


print 'starting event loop'

event_loop = bot.EventLoop(processors=(
    #locator,
    FrontBumperProcessor(driver),
    remote,
    path_follower,
))

while True:
    if psm.isKeyPressed():
        break
    event_loop.step()
    time.sleep(0.001)

driver.float()

psm.screen.termPrintln("Exiting ...")
예제 #30
0
    psm.screen.drawAutoText("You are not connected",
                            35,
                            20,
                            fill=(255, 0, 0),
                            size=25,
                            display=False)
    psm.screen.drawAutoText("to the internet!",
                            35,
                            50,
                            fill=(255, 0, 0),
                            size=25,
                            display=False)
    psm.screen.fillBmp(130,
                       95,
                       60,
                       60,
                       path=currentdir + '/' + 'x_red.png',
                       display=False)

psm.screen.drawButton(35,
                      170,
                      width=250,
                      height=40,
                      text="Continue",
                      display=False)
psm.screen.fillRect(0, 0, 1, 1, fill=(0, 0, 0), display=True)
exit = False
while not exit:
    cont = psm.screen.checkButton(35, 170, 250, 40)
    if cont or psm.isKeyPressed(): exit = True
예제 #31
0
                print 'f.set()'
        sleep(0.1)
    psm.led(1, 0, 0, 0)


if __name__ == "__main__":

    entered_house = Event()
    found_bomb = Event()
    got_victim = Event()

    f_thread = Thread(target=follow, args=(entered_house, found_bomb, got_victim))
    f_thread.start()
    s_thread = Thread(target=search, args=(entered_house, found_bomb, got_victim))
    s_thread.start()

    while not exit:

        sleep(0.05)

        if psm.isKeyPressed(): # if the GO button is pressed
            psm.screen.clearScreen()
            psm.screen.termPrintln("Exiting to menu")
            psm.led(1,0,0,0)    
            psm.BAM1.float()
            psm.BAM2.float()
            psm.BBM1.float()
            psm.BBM2.float() 
            sleep(0.1)
            exit = True
예제 #32
0

from PiStorms import PiStorms
import random, time

psm = PiStorms()

#
# To exit this program, press & hold GO button and touch the screen
#

psm.screen.termPrintAt(1, "To Exit: press & hold GO button")
psm.screen.termPrintAt(2, "and touch the screen.")
time.sleep(4)

while not (bool(psm.isKeyPressed()) and psm.screen.isTouched()):
  if ( psm.screen.isTouched() ):
    x = psm.screen.TS_X()
    y = psm.screen.TS_Y()
    tsx = psm.screen.TS_To_ImageCoords_X(x,y)
    tsy = psm.screen.TS_To_ImageCoords_Y(x,y)

    isTouched = True
    tFactor = 2
  else:
    isTouched = False
    tFactor = 0

  if (isTouched):
    x = tsx
    y = tsy