Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import mod_utils
- import hardware.motor_hat
- # Example for adding custom code to the controller
- from subprocess import Popen
- module = None
- def setup(robot_config):
- global module
- # Your custom setup code goes here
- # Call the setup handler for max7219 LEDs
- hardware.motor_hat.setup(robot_config)
- # This code calls the default setup function for your hardware.
- # global module
- # module = __import__("hardware."+robot_config.get('robot', 'type'), fromlist=[robot_config.get('robot', 'type')])
- module = mod_utils.import_module('hardware', robot_config.get('robot', 'type'))
- module.setup(robot_config)
- def move(args):
- # Your custom command interpreter code goes here
- command = args['command']
- print "command recieved"
- print command
- if args['key_position'] == 'up':
- if command == 'spaghetti':
- playSound('spaghetti.mp3')
- return
- elif command == 'directive':
- playSound('directive.mp3')
- return
- elif command == 'gasp':
- playSound('gasp.mp3')
- return
- elif command == 'adios':
- playSound('adios.mp3')
- return
- elif command == 'basghetti':
- playSound('basghetti.mp3')
- return
- elif command == 'does not compute':
- playSound('doesnotcompute.mp3')
- return
- elif command == 'yum':
- playSound('yum.mp3')
- return
- elif command == 'baby':
- playSound('baby.mp3')
- return
- elif command == 'response':
- playSound('response.mp3')
- return
- elif command == 'mom':
- playSound('mom.mp3')
- return
- elif command == 'neutralized':
- playSound('neutralized.mp3')
- return
- # Call the command handler for max7219 LEDs
- #hardware.motor_hat.move(args)
- # This code calls the default command interpreter function for your hardware.
- module.move(args)
- def playSound ( fileName):
- Popen('/usr/bin/mpg123-alsa /home/pi/'+ fileName, shell=True, stdin=None, stdout=None, stderr=None, close_fds=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement