methods: {
jog: function (axis, move) {
this.$dispatch('jog', this.axes[axis], move)
- },
-
-
- home: function (axis) {
- this.$dispatch('home', this.axes[axis])
- },
-
-
- zero: function (axis) {
- this.$dispatch('zero', this.axes[axis])
}
}
}
events: {
// TODO These should all be implemented via the API
- jog: function (axis, move) {this.send('g91 g0' + axis + move)},
- home: function (axis) {this.send('$home ' + axis)},
- zero: function (axis) {this.send('$zero ' + axis)}
+ jog: function (axis, move) {this.send('g91 g0' + axis + move)}
},
home: function () {api.put('home')},
+ zero: function (axis) {
+ api.put('zero' + (typeof axis == 'undefined' ? '' : '/' + axis));
+ },
+
+
start_pause: function () {
if (this.state.x == 'RUNNING') this.pause();
I2C_REPORT = 8
I2C_HOME = 9
I2C_REBOOT = 10
+I2C_ZERO = 11
class AVR():
self.i2c_bus = None
log.warning('Failed to open device: %s', e)
+ # Reset AVR communication
+ self.stop();
self.report()
self.stream = None
- def _i2c_command(self, cmd, word = None):
+ def _i2c_command(self, cmd, byte = None, word = None):
if self.i2c_bus is None: return
log.info('I2C: %d' % cmd)
while True:
try:
- if word is not None:
+ if byte is not None:
+ self.i2c_bus.write_byte_data(self.i2c_addr, cmd, byte)
+
+ elif word is not None:
self.i2c_bus.write_word_data(self.i2c_addr, cmd, word)
- self.i2c_bus.write_byte(self.i2c_addr, cmd)
+
+ else: self.i2c_bus.write_byte(self.i2c_addr, cmd)
break
except IOError as e:
if 'firmware' in msg:
log.error('AVR rebooted')
- self._stop_sending_gcode()
+ self.stop();
self.report()
if 'x' in msg and msg['x'] == 'ESTOPPED':
def unpause(self): self._i2c_command(I2C_RUN)
def optional_pause(self): self._i2c_command(I2C_OPTIONAL_PAUSE)
def step(self): self._i2c_command(I2C_STEP)
+ def zero(self, axis = None): self._i2c_command(I2C_ZERO, byte = axis)
def next(self):
line = self.f.readline()
- if line is None: return
+ if line is None or line == '': return
# Remove comments
line = self.comment1RE.sub('', line)
def put_ok(self): self.ctrl.avr.step()
+class ZeroHandler(bbctrl.APIHandler):
+ def put_ok(self, axis):
+ if axis is not None: axis = ord(axis[1:].lower())
+ self.ctrl.avr.zero(axis)
+
+
class OverrideFeedHandler(bbctrl.APIHandler):
def put_ok(self, value): self.ctrl.avr.override_feed(float(value))
(r'/api/unpause', UnpauseHandler),
(r'/api/pause/optional', OptionalPauseHandler),
(r'/api/step', StepHandler),
+ (r'/api/zero(/[xyzabcXYZABC])?', ZeroHandler),
(r'/api/override/feed/([\d.]+)', OverrideFeedHandler),
(r'/api/override/speed/([\d.]+)', OverrideSpeedHandler),
(r'/(.*)', tornado.web.StaticFileHandler,