spaced the tabs

master
Marek Baczynski 6 years ago
parent 1db35c90c8
commit eafbee72ce

@ -198,58 +198,58 @@ isRunning = False
def adjustSpeed(motor, adjustment): def adjustSpeed(motor, adjustment):
global nowTime, stopTime, currentMotor, speed, motorcfg, movement_time, max_speed, max_movement_time global nowTime, stopTime, currentMotor, speed, motorcfg, movement_time, max_speed, max_movement_time
if currentMotor==motor: if currentMotor==motor:
speed += adjustment * (abs(speed)/max_speed) speed += adjustment * (abs(speed)/max_speed)
stopTime += movement_time/2 * max_movement_time/(stopTime - nowTime) stopTime += movement_time/2 * max_movement_time/(stopTime - nowTime)
else: else:
currentMotor = motor currentMotor = motor
speed = adjustment speed = adjustment
stopTime = nowTime + movement_time stopTime = nowTime + movement_time
if(speed>0): if(speed>0):
candy.setJOGcmd(motorcfg[currentMotor]['positive']) candy.setJOGcmd(motorcfg[currentMotor]['positive'])
#print("JOG command {}".format(motorcfg[currentMotor]['positive'])) #print("JOG command {}".format(motorcfg[currentMotor]['positive']))
else: else:
candy.setJOGcmd(motorcfg[currentMotor]['negative']) candy.setJOGcmd(motorcfg[currentMotor]['negative'])
# print("JOG command {}".format(motorcfg[currentMotor]['negative'])) # print("JOG command {}".format(motorcfg[currentMotor]['negative']))
def stopMotorFunctions(): def stopMotorFunctions():
global currentMotor, speed global currentMotor, speed
currentMotor = 0 currentMotor = 0
speed = 0 speed = 0
candy.stop() candy.stop()
def updateLoop(): def updateLoop():
global nowTime, stopTime, currentMotor, speed, friction, min_speed, motorcfg global nowTime, stopTime, currentMotor, speed, friction, min_speed, motorcfg
nowTime = (time.time() - startTime) nowTime = (time.time() - startTime)
threading.Timer(0.2, updateLoop).start() threading.Timer(0.2, updateLoop).start()
if currentMotor != 0: if currentMotor != 0:
if nowTime > stopTime: if nowTime > stopTime:
stopMotorFunctions() stopMotorFunctions()
return return
else: else:
speed *= friction speed *= friction
if abs(speed) < min_speed: if abs(speed) < min_speed:
stopMotorFunctions() stopMotorFunctions()
return return
candy.setparams(motorcfg[currentMotor]['name'], abs(speed))) candy.setparams(motorcfg[currentMotor]['name'], abs(speed)))
#print("JOG parameter {} to {}".format( motorcfg[currentMotor]['speedslot'], abs(speed)) ) #print("JOG parameter {} to {}".format( motorcfg[currentMotor]['speedslot'], abs(speed)) )
def rt(): def rt():
adjustSpeed(1, 5) adjustSpeed(1, 5)
def lt(): def lt():
adjustSpeed(1, -5) adjustSpeed(1, -5)
def up(): def up():
adjustSpeed(2, 5) adjustSpeed(2, 5)
def dn(): def dn():
adjustSpeed(2, -5) adjustSpeed(2, -5)
updateLoop() updateLoop()

Loading…
Cancel
Save