th State
td {{get_state()}}
td
+ tr
+ th Reason
+ td {{state.pr}}
+ td
tr
th Feed
td {{state.f || 0}}
th Velocity
td {{state.v || 0 | fixed 0}}
td mm/min
+ tr
+ th Line
+ td {{state.ln || ''}}
+ td
tr
th Tool
td {{state.t || 0}}
option(v-for="file in files", :value="file") {{file}}
.gcode(:class="{placeholder: !gcode}")
- {{gcode || 'GCode displays here.'}}
+ {{{gcode || 'GCode displays here.'}}}
section#content2.tab-content
.mdi.pure-form
},
+ watch: {
+ 'state.ln': function () {this.update_gcode_line();}
+ },
+
+
events: {
// TODO These should all be implemented via the API
jog: function (axis, move) {this.send('g91 g0' + axis + move)}
},
+ update_gcode_line: function () {
+ if (typeof this.last_line != 'undefined') {
+ $('#gcode-line-' + this.last_line).removeClass('highlight');
+ this.last_line = undefined;
+ }
+
+ if (0 <= this.state.ln) {
+ var line = this.state.ln - 1;
+ $('#gcode-line-' + line)
+ .addClass('highlight')[0]
+ .scrollIntoView({behavior: 'smooth'});
+
+ this.last_line = line;
+ }
+ },
+
+
update: function () {
api.get('file')
.done(function (files) {
api.get('file/' + file)
.done(function (data) {
- this.gcode = data;
+ var lines = data.split(/\r?\n/);
+ var html = '<ul>';
+
+ for (var i = 0; i < lines.length; i++)
+ // TODO escape HTML chars in lines
+ html += '<li id="gcode-line-' + i + '">' +
+ '<span>' + (i + 1) + '</span>' + lines[i] + '</li>';
+
+ html += '</ul>';
+
+ this.gcode = html;
this.last_file = file;
+
+ Vue.nextTick(this.update_gcode_line);
}.bind(this));
},
self.i2c_bus = smbus.SMBus(self.ctrl.args.avr_port)
continue
- else: raise e
+ else:
+ log.error('I2C communication failed: %s' % e)
+ return
def report(self): self._i2c_command(I2C_REPORT)
except Exception as e:
log.warning('%s: %s', e, data)
+ update = {}
+
# Parse incoming serial data into lines
while True:
i = self.in_buf.find('\n')
except Exception as e:
log.error('%s, data: %s', e, line)
- return
+ continue
- if 'firmware' in msg:
- log.error('AVR rebooted')
- self.stop();
- self.report()
+ update.update(msg)
+ log.debug(line)
- if 'x' in msg and msg['x'] == 'ESTOPPED':
- self._stop_sending_gcode()
+ if 'msg' in update: break
- self.vars.update(msg)
- self.ctrl.lcd.update(msg)
- self.ctrl.web.broadcast(msg)
+ if update:
+ if 'firmware' in msg:
+ log.error('AVR rebooted')
+ self.stop();
+ self.report()
- log.debug(line)
+ if 'x' in msg and msg['x'] == 'ESTOPPED':
+ self._stop_sending_gcode()
+ self.vars.update(update)
+ self.ctrl.lcd.update(update)
+ self.ctrl.web.broadcast(update)
def queue_command(self, cmd):
&.placeholder
color #aaa
+ .gcode ul
+ margin 0
+ padding 0
+ list-style none
+
+ li
+ span
+ display inline-block
+ min-width 3em
+ margin-right 1em
+ padding 0 0.25em
+ font-family courier
+ color #e5aa3d
+
+ &.highlight
+ background-color #eaeaea
+
.mdi
clear both
white-space nowrap