From b1c666bb7f8d1aae226813d0d1e87513c2d90e12 Mon Sep 17 00:00:00 2001 From: Joseph Coffland Date: Thu, 4 May 2017 00:06:00 -0700 Subject: [PATCH] Set motor current in amps, Fixed control view updates --- src/jade/templates/control-view.jade | 2 +- src/js/app.js | 4 +++- src/js/control-view.js | 4 +++- src/py/bbctrl/AVR.py | 11 +++++++++-- src/py/bbctrl/Web.py | 2 +- src/resources/config-template.json | 26 ++++++++++++-------------- 6 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/jade/templates/control-view.jade b/src/jade/templates/control-view.jade index 6844058..4da12cc 100644 --- a/src/jade/templates/control-view.jade +++ b/src/jade/templates/control-view.jade @@ -147,7 +147,7 @@ script#control-view-template(type="text/x-template") input(v-model="mdi", @keyup.enter="submit_mdi") .history(:class="{placeholder: !history}") - {{history || 'MDI history displays here.'}} + | {{history || 'MDI history displays here.'}} section#content3.tab-content .jog diff --git a/src/js/app.js b/src/js/app.js index ac701ec..a5092ef 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -84,7 +84,7 @@ module.exports = new Vue({ if (typeof msg == 'object') { for (var key in msg) - this.$set('state.' + key, msg[key]); + Vue.set(this.state, key, msg[key]); if ('msg' in msg) this.$broadcast('message', msg); } @@ -100,6 +100,8 @@ module.exports = new Vue({ this.status = 'disconnected'; this.$broadcast(this.status); }.bind(this); + + console.debug('Hello'); }, diff --git a/src/js/control-view.js b/src/js/control-view.js index 43ac7d8..0740e49 100644 --- a/src/js/control-view.js +++ b/src/js/control-view.js @@ -77,7 +77,9 @@ module.exports = { get_reason: function () { - return this.state.x == 'HOLDING' ? this.state.pr : ''; + if (this.state.x == 'ESTOPPED') return this.state.er; + if (this.state.x == 'HOLDING') return this.state.pr; + return ''; }, diff --git a/src/py/bbctrl/AVR.py b/src/py/bbctrl/AVR.py index d38d9d7..99af743 100644 --- a/src/py/bbctrl/AVR.py +++ b/src/py/bbctrl/AVR.py @@ -212,9 +212,16 @@ class AVR(): self._stop_sending_gcode() self.vars.update(update) - self.ctrl.lcd.update(update) - self.ctrl.web.broadcast(update) + try: + self.ctrl.lcd.update(update) + except Exception as e: + log.error('Updating LCD: %s', e) + + try: + self.ctrl.web.broadcast(update) + except Exception as e: + log.error('Updating Web: %s', e) def queue_command(self, cmd): self.queue.append(cmd) diff --git a/src/py/bbctrl/Web.py b/src/py/bbctrl/Web.py index 9fbf253..001509a 100644 --- a/src/py/bbctrl/Web.py +++ b/src/py/bbctrl/Web.py @@ -171,5 +171,5 @@ class Web(tornado.web.Application): def broadcast(self, msg): - if self.clients: + if len(self.clients): self.clients[0].broadcast(self.clients, msg) diff --git a/src/resources/config-template.json b/src/resources/config-template.json index bceb4c0..9c50a2f 100644 --- a/src/resources/config-template.json +++ b/src/resources/config-template.json @@ -16,22 +16,20 @@ "default": "when-moving", "code": "pm" }, - "max-current": { - "type": "percent", - "unit": "%", - "default": 80, - "code": "xc" - }, - "min-current": { - "type": "percent", - "unit": "%", - "default": 20, - "code": "lc" + "drive-current": { + "type": "float", + "min": 0, + "max": 8, + "unit": "A", + "default": 2, + "code": "dc" }, "idle-current": { - "type": "percent", - "unit": "%", - "default": 1, + "type": "float", + "min": 0, + "max": 8, + "unit": "A", + "default": 0, "code": "ic" } }, -- 2.27.0