Example #1
0
def main():
    g = grove_gesture_sensor.gesture()
    g.init()
    while True:
        gest = g.return_gesture()
        #Match the gesture
        if gest == g.FORWARD:
            print("FORWARD")
            #           time.sleep(1)
            router()

        elif gest == g.RIGHT:
            print("RIGHT")
            #          time.sleep(1)
            router()
        elif gest == g.LEFT:

            print("LEFT")
            #         time.sleep(1)
            router()

        elif gest == g.UP:
            print("UP")
            #           time.sleep(1)
            router()

        elif gest == g.DOWN:
            print("DOWN")
            #           time.sleep(1)
            router()
def main():
    global routerFlag
    try:
        g = grove_gesture_sensor.gesture()
        g.init()
        print("Welcome to the Wi-Pi")

    except IOError:
        #なぜかラズパイ起動後には必ず1回IOErrorが出るためリスタートしている
        print("wake-up Error Resterting")
        main()
        pass

    try:
        while True:
            gest = g.return_gesture()

            #Match the gesture
            if gest == g.FORWARD:
                print("FORWARD")

                led("recog")
                routerFlag = True
                router()
                time.sleep(1)

            elif gest == g.DOWN:
                print("DOWN")

                led("recog")
                routerFlag = False
                router()
                time.sleep(1)

            else:
                time.sleep(.1)

    except IOError:  #意図しない強制終了の際に、プログラムを再起動させる
        print("__________________/ntry/n________________")
        subprocess.Popen([
            'python',
            '/home/pi/Desktop/Wi-Pi-System/test/Gesture/ges-reverse.py'
        ])

        #現状では必要のないもの、再起動のログなどを残す場合には使えそう (その時はjson ではなくcsvかなんかで出したい)
        '''
	with open('/home/pi/Desktop/Wi-Pi-System/test/Data/Wi-Pi.json','w') as f:
	    df['routerFlag']=routerFlag
	    json.dump(df, f)
	'''
    except KeyboardInterrupt:
        print("Ctrl +C ")
        digitalWrite(7, 0)
        #↓プログラム強制終了時にセキュア回線をOFFにするため落とす
        #subprocess.call(['sudo','ip','l','set','wlan1','down'])
        print("Turn off secure line")
        print("See you")
Example #3
0
def main():
    global routerFlag
    try:
        g = grove_gesture_sensor.gesture()
        g.init()
        print("Welcome to the Wi-Pi")
        subprocess.call(['sudo', 'ip', 'l', 'set', 'wlan0',
                         'up'])  #public line ON

    except IOError:
        #なぜかラズパイ起動後には必ず1回IOErrorが出るためリスタートしている g.init() 部分
        print("wake-up Error Resterting")
        main()
        pass

    try:
        while True:
            gest = g.return_gesture()

            #Match the gesture
            if gest == g.FORWARD:
                print("FORWARD")

                led("recog")
                routerFlag = True
                router()
                time.sleep(1)

            elif gest == g.DOWN:
                print("DOWN")

                led("recog")
                routerFlag = False
                router()
                time.sleep(1)

            else:
                time.sleep(.01)

    except IOError:  #意図しない強制終了の際に、プログラムを再起動させる
        print("__________________\n try \n________________")
        subprocess.Popen(
            ['python', '/home/pi/Desktop/Wi-Pi-System/main/Wi-Pi.py'])
        time.sleep(2)

    except KeyboardInterrupt:
        print("Ctrl +C ")
        digitalWrite(7, 0)
        #↓プログラム強制終了時に回線をOFFにするため落とす

        subprocess.call(['sudo', 'ip', 'l', 'set', 'wlan0',
                         'down'])  #public line off
        subprocess.call(['sudo', 'ip', 'l', 'set', 'wlan1',
                         'down'])  #secure line off
        print("Turn off secure line")
        print("See you")
        sys.exit()
Example #4
0
def main():
    try:
	print("いんすたんす?")
	g=grove_gesture_sensor.gesture()
	print("g init")
	g.init()
	print("initfin")
    
	#ledd = threading.Thread(target=led)
    except IOError:
	g.init()
	print("IOE 1nitmain")
	pass
    
    try:
	while True:
	    time.sleep(0.1)
	    gest=g.return_gesture()

	    #Match the gesture
	    if gest==g.FORWARD:
		print("FORWARD")
		time.sleep(1)
		router()


	    elif gest==g.DOWN:
		print("DOWN")
		time.sleep(1)
		router()
		    	
	    else :
		time.sleep(.1)
    

	#elif gest==0:
	#    led()
    except IOError:
	global routerFlag
	print("__________________/ntry/n________________")
	subprocess.call(['i2cdetect', '-y', '1'])
	subprocess.Popen(['python','/home/pi/Desktop/Wi-Pi-System/test/Gesture/ges-subprocess.py'])

	print("IOE  sub kill")
	sub.kill()
	
	with open('/home/pi/Desktop/Wi-Pi-System/test/Data/Wi-Pi.json','w') as f:
	    df['routerFlag']=routerFlag
	    json.dump(df, f)
def main():
    print("いんすたんす?")
    g = grove_gesture_sensor.gesture()
    print("g init")
    g.init()

    ledd = threading.Thread(target=led)

    while True:
        time.sleep(0.01)
        gest = g.return_gesture()
        #Match the gesture
        if gest == g.FORWARD:
            print("FORWARD")
            time.sleep(1)
            router()

        elif gest == g.RIGHT:
            print("RIGHT")
            time.sleep(1)
            router()
        elif gest == g.LEFT:

            print("LEFT")
            time.sleep(1)
            router()

        elif gest == g.UP:
            print("UP")
            time.sleep(1)
            print("router")
            flag1 = 1
            router()

        elif gest == g.DOWN:
            print("DOWN")
            time.sleep(1)
            flag1 = 0
            router()

        elif gest == 0:
            led("flash")
Example #6
0
def main():
    print("いんすたんす?")
    g=grove_gesture_sensor.gesture()
    print("g init")
    g.init()
    print("test=test1")
    test = Test1()
    print("while start↓")
    while True:
	time.sleep(0.01)
        gest=g.return_gesture()
        #Match the gesture
        if gest==g.FORWARD:
            print("FORWARD")
            time.sleep(1)
            router()
            

        elif gest==g.RIGHT:
            print("RIGHT")
            time.sleep(1)
            router()
        elif gest==g.LEFT:
            
            print("LEFT")
            time.sleep(1)
            router()
            
        elif gest==g.UP:
            print("UP")
            time.sleep(1)
	    print("router")
            router()
	    print("testbegin")
	    test.begin()
            
        elif gest==g.DOWN:
            print("DOWN")
            time.sleep(1)
            router()
	    test.end()
Example #7
0
 def func(self):
   i = 0
   led =7
   self.started.wait()
   
   print("thgいんすたんす")
   g=grove_gesture_sensor.gesture()
   print("th g init")
   g.init()
   while self.alive:
     i += 1
     #print ("{}\r".format(i),end="")
     print "{}\r".format(i),
     
     digitalWrite(led,1)# Send HIGH to switch on LED
     print ("Thread-LED ON!")
     time.sleep(2)
     digitalWrite(led,0)# Send LOW to switch off LED
     print ("Thread-LED OFF!")
     time.sleep(2)
     self.started.wait()
def main():
    print("いんすたんす?")
    g = grove_gesture_sensor.gesture()
    print("g init")
    g.init()

    #ledd = threading.Thread(target=led)

    while True:
        time.sleep(0.01)
        gest = g.return_gesture()
        #Match the gesture
        if gest == g.FORWARD:
            print("FORWARD")
            time.sleep(1)
            router()

        elif gest == g.DOWN:
            print("DOWN")
            time.sleep(1)
            router()
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 grove_gesture_sensor
import time

g=grove_gesture_sensor.gesture()
g.init()
while True:
	gest=g.return_gesture()
	#Match the gesture
	if gest==g.FORWARD:
		print"FORWARD"
	elif gest==g.BACKWARD:
		print "BACKWARD"
	elif gest==g.RIGHT:
		print "RIGHT"
	elif gest==g.LEFT:
		print "LEFT"
	elif gest==g.UP:
		print "UP"
	elif gest==g.DOWN:
Example #10
0
def main():
    try:
        print("いんすたんす?")
        g = grove_gesture_sensor.gesture()
        print("g init")
        g.init()
        print("initfin")

        #ledd = threading.Thread(target=led)
    except IOError:
        g.init()
        print("IOE 1nitmain")
        pass

    try:
        while True:
            time.sleep(0.1)
            gest = g.return_gesture()

            #Match the gesture
            if gest == g.FORWARD:
                print("FORWARD")
                time.sleep(1)
                router()

            elif gest == g.DOWN:
                print("DOWN")
                time.sleep(1)
                #router()

            elif gest == g.RIGHT:
                print("RIGHT")
                time.sleep(1)
                #router()

            elif gest == g.LEFT:

                print("LEFT")
                time.sleep(1)
                #router()

            elif gest == g.UP:
                print("UP")
                time.sleep(1)
                print("router")
                #router()

            else:
                time.sleep(.1)

        #elif gest==0:
        #    led()
    except IOError:

        #print("__________________/ntry/n________________")
        subprocess.call(['i2cdetect', '-y', '1'])
        subprocess.Popen([
            'python',
            '/home/pi/Desktop/Wi-Pi-System/test/Gesture/ges-subprocess.py'
        ])

        print("IOE  sub kill")
        sub.kill()
Example #11
0
The MIT License (MIT)

GrovePi for the Raspberry Pi: an open source platform for connecting Grove Sensors to the Raspberry Pi.
Copyright (C) 2015  Dexter Industries

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 grove_gesture_sensor
import time

g = grove_gesture_sensor.gesture()
g.init()
while True:
    g.print_gesture()
    time.sleep(.1)