Example #1
0
def robot_init():
    print("I/O Initialization")
    print("PWM Starting")
    pwmExp.driverInit()
    pwmExp.setupDriver(pins.ALL, 0, 0)
    pwmExp.setVerbosity(-1)

    print("Setting I/O")
    ain2.setOutputDirection(LOW)
    ain1.setOutputDirection(LOW)
    bin2.setOutputDirection(LOW)
    bin1.setOutputDirection(LOW)
    print("Ready!")
Example #2
0
    def __init__(self, channel, frequency=50):
        self.channel = channel
        self.frequency = frequency

        # check that pwm-exp has been initialized
        bInit = pwmExp.checkInit()

        if (bInit == 0):
            # initialize the Expansion
            ret = pwmExp.driverInit()
            if (ret != 0):
                print 'ERROR: pwm-exp init not successful!'

            # set to default frequency
            self._setFrequency(self.frequency)
Example #3
0
	def __init__(self, channel):
		self.channel 	= channel
		self.frequency 	= SERVO_FREQUENCY

		# check that pwm-exp has been initialized
		bInit 	= pwmExp.checkInit()

		if (bInit == 0):
			# initialize the expansion
			ret 	= pwmExp.driverInit()
			if (ret != 0):
				print 'ERROR: pwm-exp init not successful!'

			# set to default frequency
			self._setFrequency(self.frequency)
Example #4
0
def Initialize():
  pwmExp.driverInit()
  Stop()
  return

def ws_on_close(ws):
    print("### Disconnected from SignalR Server ###")


def ws_on_open(ws):
    print("### Connected to SignalR Server via WebSocket ###")

    # Do a handshake request
    print("### Performing handshake request ###")
    ws.send(encode_json({"protocol": "json", "version": 1}))

    # Handshake completed
    print("### Handshake request completed ###")


if __name__ == "__main__":
    pwmExp.driverInit()
    pwmExp.setFrequency(freq)
    websocket.enableTrace(True)

    ## Use wss as protocol for your url. for example, wss://localshot:44321/messagehub

    ws = websocket.WebSocketApp("[YOUR SIGNALR URL HERE]",
                                on_message=ws_on_message,
                                on_error=ws_on_error,
                                on_close=ws_on_close)
    ws.on_open = ws_on_open
    ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE})
Example #6
0
import OmegaExpansion.pwmExp as pwm
import sys

status = pwm.driverInit()

if pwm.checkInit() == 0:
    print("PWM Init failed")
    exit

lr = float(sys.argv[1])
ud = float(sys.argv[2])

pwm.setFrequency(50)
pwm.setupDriver( 0, lr, 0)
pwm.setupDriver(15, ud, 0)
Example #7
0
# check the arguments
channel = 0
if len(sys.argv) == 2:
    channel = int(sys.argv[1])

print '>> Using channel ', channel

pwmExp.setVerbosity(0)

# check initialization
#	should return 0 if the PWM Expansion has just been plugged in
ret = pwmExp.checkInit()
print "checking if initialized: ", ret

# initialize the pwm-exp
ret = pwmExp.driverInit()
print "driverInit return: ", ret
if (ret != 0):
    exit()
ret = pwmExp.setFrequency(50)
print "setFrequency return: ", ret
if (ret != 0):
    exit()

# check initialization
#	should return 1 since the Expansion was initialized above
ret = pwmExp.checkInit()
print "checking if initialized: ", ret
time.sleep(1)

# set channel 0
Example #8
0
# check the arguments
channel = 0
if len(sys.argv) == 2:
	channel = int(sys.argv[1])

print '>> Using channel ', channel

pwmExp.setVerbosity(0)

# check initialization
#	should return 0 if the PWM Expansion has just been plugged in
ret 	= pwmExp.checkInit()
print "checking if initialized: ", ret

# initialize the pwm-exp
ret 	= pwmExp.driverInit()
print "driverInit return: ", ret
if (ret != 0):
	exit()
ret 	= pwmExp.setFrequency(50)	
print "setFrequency return: ", ret
if (ret != 0):
	exit()

# check initialization
#	should return 1 since the Expansion was initialized above
ret 	= pwmExp.checkInit()
print "checking if initialized: ", ret
time.sleep(1)