Пример #1
0
def Robot():
    """Use this to ensure robot stops if inner code 
        crashes"""
    try:
        yield _robot()
    finally:
        pz.stop()
        pz.cleanup()
Пример #2
0
def ws_disconnect(message):
    try:
        label = message.channel_session['room']
        room = Room.objects.get(label=label)
        if room.label=="remotecarcontrol":
            pz.cleanup()
            Group('control-'+label, channel_layer=message.channel_layer).discard(message.reply_channel)
        else:
            Group('chat-'+label, channel_layer=message.channel_layer).discard(message.reply_channel)
    except (KeyError, Room.DoesNotExist):
        pass
Пример #3
0
def Robot():
    """Use this to ensure robot stops if inner code 
        crashes"""
    r = None
    try:
        r = _robot()
        yield r
    finally:
        pz.stop()
        pz.cleanup()
        if r:
            r.cleanup()
Пример #4
0
        print "object " + str(distance - gripDistance) + " too far"

        tiltVal = max(tiltMin, tiltVal -
                      5)  # moves closer, but within the operational limit

        time.sleep(.5)  # gives you time to evacuate, can have zero
        pz.setOutput(rot, rotVal)
        pz.setOutput(tilt, tiltVal)
        pz.setOutput(lift, liftVal)

except KeyboardInterrupt:
    print()

finally:
    if (distance > gripDistance):
        print("object unreachable")
    else:  # grab and move if the object is withing grabbing distance
        print("EXTERMINATE")
        pz.setOutput(grip, gripMax)
        time.sleep(.5)
        print("EXTERMINATE")
        pz.setOutput(rot, 40)
        time.sleep(.5)
        pz.setOutput(tilt, tiltVal - 10)
        time.sleep(.5)
        pz.setOutput(lift, liftMax)
        time.sleep(.5)
        print("EXTERMINATE!")
    hcsr04.cleanup()
    pz.cleanup()
Пример #5
0
#! /usr/bin/env python

#testLedNumbers.py
# Testing McRoboFace led positions.
# requires picon zero hardware plus software library

import piconzero as pz, time

pz.init()
pz.setOutputConfig(5, 3)  # set output 5 to WS2812 (code 3)

try:
    while True:
        for i in xrange(0, 17):
            pz.setPixel(i, 0, 0, 255)
            time.sleep(0.5)
        pz.setAllPixels(0, 0, 0)
        time.sleep(0.5)
except KeyboardInterrupt:
    print
finally:
    pz.cleanup()  #reset picon zero board
Пример #6
0
 def cleanup(self):
     pz.stop()
     pz.cleanup()
Пример #7
0
#! /usr/bin/env python

# GNU GPL V3
# Test code for 4tronix Picon Zero

import piconzero as pz, time

pz.init()
pz.setInputConfig(0, 2)     # set input 0 to DS18B20
pz.setInputConfig(2, 2)     # set input 2 to DS18B20

try:
    while True:
        ana0 = pz.readInput(0)
        if (ana0>32767):
            ana0 -= 65536
        ana2 = pz.readInput(2)
        if (ana2>32767):
            ana2 -= 65536
        print ana0*0.0625, ana2*0.0625
        time.sleep(1)
except KeyboardInterrupt:
    print
finally:
    pz.cleanup()

Пример #8
0
 def cleanup():
     pz.stop()
     pz.cleanup()
     GPIO.cleanup()
     print('=======App cleaned up======')
Пример #9
0
def cleanupPZ():
    pz.cleanup()
    hcsr04.cleanup()
Пример #10
0
def on_exit(sig, func=None):
    print "Exiting DragonDetector"
    pz.cleanup()
    sys.exit(1)
 def ensure_piconzero_is_closed(self):
     if self.piconzero_initialized:
         pz.cleanup()
         self.piconzero_initialized = False