コード例 #1
0
ファイル: easygopigo.py プロジェクト: karan259/GoPiGo
 def get_remote_code(self):
     '''
     Returns the keycode from the remote control
     No preprocessing
     You have to check that length > 0
         before handling the code value
     if the IR Receiver is not enabled, this will return -1
     '''
     if IR_RECEIVER_ENABLED:
         return ir_receiver.nextcode()
     else:
         print("Error with the Remote Controller")
         print("Please enable the IR Receiver in the Advanced Comms tool")
         return -1
コード例 #2
0
ファイル: easygopigo.py プロジェクト: johnisanerd/GoPiGo
    def get_remote_code(self):
        '''
        Returns the keycode from the remote control
        No preprocessing
        You have to check that length > 0
            before handling the code value
        '''
        if IR_RECEIVER_ENABLED:
            import ir_receiver
            key = ir_receiver.nextcode(consume=False)
        else:
            key = ""

        return key
コード例 #3
0
 def get_remote_code(self):
     '''
     Returns the keycode from the remote control
     No preprocessing
     You have to check that length > 0
         before handling the code value
     if the IR Receiver is not enabled, this will return -1
     '''
     if IR_RECEIVER_ENABLED:
         return ir_receiver.nextcode()
     else:
         print("Error with the Remote Controller")
         print("Please enable the IR Receiver in the Advanced Comms tool")
         return -1
コード例 #4
0
ファイル: easygopigo.py プロジェクト: KingCraftNub/GoPiGo
    def get_remote_code(self):
        '''
        Returns the keycode from the remote control
        No preprocessing
        You have to check that length > 0
            before handling the code value
        '''

        if IR_RECEIVER_ENABLED:
            import ir_receiver
            key = ir_receiver.nextcode(consume=False)
        else:
            key = ""

        return key
コード例 #5
0
    def get_remote_code(self):
        '''
        Returns the keycode from the remote control
        No preprocessing
        You have to check that length > 0
            before handling the code value
        '''

        if IR_RECEIVER_ENABLED:
            import ir_receiver
            key = ir_receiver.nextcode(consume=False)
        else:
            key = ""
        try:
            # in python3, key will come in as a byte
            key = key.decode("utf-8")
        except AttributeError:
            # in python2, key will be a string, so no need to do anything
            pass

        return key
コード例 #6
0
ファイル: easygopigo.py プロジェクト: CleoQc/GoPiGo
    def get_remote_code(self):
        '''
        Returns the keycode from the remote control
        No preprocessing
        You have to check that length > 0
            before handling the code value
        '''

        if IR_RECEIVER_ENABLED:
            import ir_receiver
            key = ir_receiver.nextcode(consume=False)
        else:
            key = ""
        try:
            # in python3, key will come in as a byte
            key = key.decode("utf-8") 
        except AttributeError:
            # in python2, key will be a string, so no need to do anything
            pass

        return key
コード例 #7
0
ファイル: GoPiGoScratch.py プロジェクト: nuttythings/GoPiGo-1
					e = sys.exc_info()[1]
					print "Error reading motion sensor: " + str(e)
			if en_debug:
				print "Motion Reading: " + str(motion)
			if en_gpg:
				s.sensorupdate({'motion':motion})
				
		# Get the value from the IR remote when a button is pressed
		# IR Sensor goes on Serial Port.
		elif msg.lower()=="IR".lower():
			print "IR!"
			if en_ir_sensor==0:
				import ir_receiver
				en_ir_sensor=1
			try:
				a= ir_receiver.nextcode()  # press a button on the remote 
				if len(a) !=0: 
					print a
				else:
					a=[0]	#eturn 0 if no keypress found 
			except:
				if en_debug:
					e = sys.exc_info()[1]
					print "Error reading IR sensor: " + str(a)
			if en_debug:
				print "IR Reading: " + str(a)
			if en_gpg: 
				s.sensorupdate({'ir':a})
				
		# Get the value from the Dexter Industries line sensor
		elif msg.lower()=="LINE".lower():
コード例 #8
0
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 ir_receiver
import time

while True:
	#Wait for the next IR code to arrive. The codes are queued in a buffer before printing
	a= ir_receiver.nextcode()
	if not isinstance(a, str):
		a = a.decode('utf-8')
	if len(a) !=0:
		print (a)
	time.sleep(.1)
コード例 #9
0
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.
'''
##################################################
# Connect the IR receiver to the Serial port on the GoPiGo
# Run the install script before you start

import gopigo
import time, sys
import ir_receiver

print "Press any button on the remote to control the GoPiGo"
while True:
    sig = inp = ir_receiver.nextcode()
    if len(sig) != 0:
        print sig
        if sig == "KEY_UP":  #Assign the button with 82 and 83 in position 9 and 10 in the signal to forward command
            print "fwd"
            gopigo.fwd()
        elif sig == "KEY_LEFT":
            print "left"
            gopigo.left()
        elif sig == "KEY_RIGHT":
            print "right"
            gopigo.right()
        elif sig == "KEY_DOWN":
            print "back"
            gopigo.bwd()
        elif sig == "KEY_OK":
コード例 #10
0
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.
'''
##################################################
# Connect the IR receiver to the Serial port on the GoPiGo
# Run the install script before you start
 
import gopigo
import time,sys
import ir_receiver


print "Press any button on the remote to control the GoPiGo"
while True:
	sig= inp= ir_receiver.nextcode() 
	if len(sig) !=0:
		print sig
		if sig=="KEY_UP":		#Assign the button with 82 and 83 in position 9 and 10 in the signal to forward command
			print "fwd"
			gopigo.fwd()
		elif sig=="KEY_LEFT":
			print "left"
			gopigo.left()
		elif sig=="KEY_RIGHT":
			print "right"
			gopigo.right()
		elif sig=="KEY_DOWN":
			print "back"
			gopigo.bwd()
		elif sig=="KEY_OK":