Exemplo n.º 1
0
def ZeroBorgInit():
    global ZB
    # Re-direct our output to standard error, we need to ignore standard out to hide some nasty print statements from pygame
    sys.stdout = sys.stderr

    # Setup the ZeroBorg
    ZB = ZeroBorg.ZeroBorg()
    #ZB.i2cAddress = 0x44                  # Uncomment and change the value if you have changed the board address
    ZB.Init()
    if not ZB.foundChip:
        boards = ZeroBorg.ScanForZeroBorg()
        if len(boards) == 0:
            print 'No ZeroBorg found, check you are attached :)'
        else:
            print 'No ZeroBorg at address %02X, but we did find boards:' % (
                ZB.i2cAddress)
            for board in boards:
                print '    %02X (%d)' % (board, board)
            print 'If you need to change the I�C address change the setup line so it is correct, e.g.'
            print 'ZB.i2cAddress = 0x%02X' % (boards[0])
        sys.exit()
    #ZB.SetEpoIgnore(True)                 # Uncomment to disable EPO latch, needed if you do not have a switch / jumper
    # Ensure the communications failsafe has been enabled!
    failsafe = False
    for i in range(5):
        ZB.SetCommsFailsafe(True)
        failsafe = ZB.GetCommsFailsafe()
        if failsafe:
            break
    if not failsafe:

        print 'Board %02X failed to report in failsafe mode!' % (ZB.i2cAddress)
        sys.exit()
    ZB.ResetEpo()
Exemplo n.º 2
0
# Load library functions we want
import time
import os
import sys
import pygame
import ZeroBorg

# Re-direct our output to standard error, we need to ignore standard out to hide some nasty print statements from pygame
sys.stdout = sys.stderr

# Setup the ZeroBorg
ZB = ZeroBorg.ZeroBorg()
#ZB.i2cAddress = 0x44                  # Uncomment and change the value if you have changed the board address
ZB.Init()
if not ZB.foundChip:
    boards = ZeroBorg.ScanForZeroBorg()
    if len(boards) == 0:
        print 'No ZeroBorg found, check you are attached :)'
    else:
        print 'No ZeroBorg at address %02X, but we did find boards:' % (ZB.i2cAddress)
        for board in boards:
            print '    %02X (%d)' % (board, board)
        print 'If you need to change the I²C address change the setup line so it is correct, e.g.'
        print 'ZB.i2cAddress = 0x%02X' % (boards[0])
    sys.exit()
#ZB.SetEpoIgnore(True)                 # Uncomment to disable EPO latch, needed if you do not have a switch / jumper
# Ensure the communications failsafe has been enabled!
failsafe = False
for i in range(5):
    ZB.SetCommsFailsafe(True)
    failsafe = ZB.GetCommsFailsafe()