-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrivecontrol.py
41 lines (30 loc) · 1.08 KB
/
drivecontrol.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from Tkinter import *
class MotorDrive:
MIN_SPEED = 40
MAX_SPEED = 1400
def __init__(self, axis, step_increment=20):
self.axis = axis
self.speed = self.MIN_SPEED
self.jogspeeddisplay = StringVar()
self._update()
def get_state(self):
return {'speed':self.speed}
def set_state(self, state):
self.speed = state.get('speed', 100)
self._update()
def _update(self):
self.jogspeeddisplay.set(str(self.speed))
def inc_jog_speed(self, *args):
self.speed += int(self.speed*0.1)
if (self.speed > self.MAX_SPEED): self.speed = self.MAX_SPEED
self._update()
def dec_jog_speed(self, *args):
self.speed -= int(self.speed*0.1)
if (self.speed < self.MIN_SPEED): self.speed = self.MIN_SPEED
self._update()
def jogup(self, *args):
print "Jogup %s"%self.axis
def jogdn(self, *args):
print "Jogdn %s"%self.axis
xmotor = MotorDrive('X')
ymotor = MotorDrive('Y')