From: Joseph Coffland Date: Sun, 24 Jun 2018 23:12:53 +0000 (-0700) Subject: Separate machine and settings units, settings units determinate default machine units X-Git-Url: https://git.buildbotics.com/?a=commitdiff_plain;h=5f21134dd2a22aa2eb6d58e26b7272924192c0d0;p=bbctrl-firmware Separate machine and settings units, settings units determinate default machine units --- diff --git a/src/jade/index.jade b/src/jade/index.jade index b7b1099..7b6cbf6 100644 --- a/src/jade/index.jade +++ b/src/jade/index.jade @@ -60,15 +60,14 @@ html(lang="en") button.save.pure-button.button-success(:disabled="!modified", @click="save") Save - select.units(v-model="config.settings.units", @change="modified = true") - option(value="METRIC") Metric - option(value="IMPERIAL") Imperial - .pure-menu ul.pure-menu-list li.pure-menu-heading a.pure-menu-link(href="#control") Control + li.pure-menu-heading + a.pure-menu-link(href="#settings") Settings + li.pure-menu-heading a.pure-menu-link(href="#motor:0") Motors @@ -81,9 +80,6 @@ html(lang="en") li.pure-menu-heading a.pure-menu-link(href="#io") I/O - li.pure-menu-heading - a.pure-menu-link(href="#gcode") Gcode - li.pure-menu-heading a.pure-menu-link(href="#admin-general") Admin diff --git a/src/jade/templates/control-view.jade b/src/jade/templates/control-view.jade index fd4a840..1318ffc 100644 --- a/src/jade/templates/control-view.jade +++ b/src/jade/templates/control-view.jade @@ -121,7 +121,10 @@ script#control-view-template(type="text/x-template") td tr(title="Currently active machine units") th Units - td {{state.imperial ? 'IMPERIAL' : 'METRIC'}} + td.mach_units + select(v-model="mach_units", :disabled="!can_mdi") + option(value="METRIC") METRIC + option(value="IMPERIAL") IMPERIAL td tr th Feed @@ -191,8 +194,8 @@ script#control-view-template(type="text/x-template") input#tab6(type="radio", name="tabs", @click="load_video") label(for="tab6") Video - section#content1.tab-content - .toolbar + section#content1.tab-content.pure-form + .toolbar.pure-control-group button.pure-button( title="{{is_running ? 'Pause' : 'Start'}} program.", @click="start_pause", :disabled="!state.selected") diff --git a/src/jade/templates/gcode-view.jade b/src/jade/templates/gcode-view.jade deleted file mode 100644 index 730922d..0000000 --- a/src/jade/templates/gcode-view.jade +++ /dev/null @@ -1,35 +0,0 @@ -//-///////////////////////////////////////////////////////////////////////////// -//- // -//- This file is part of the Buildbotics firmware. // -//- // -//- Copyright (c) 2015 - 2018, Buildbotics LLC // -//- All rights reserved. // -//- // -//- This file ("the software") is free software: you can redistribute it // -//- and/or modify it under the terms of the GNU General Public License, // -//- version 2 as published by the Free Software Foundation. You should // -//- have received a copy of the GNU General Public License, version 2 // -//- along with the software. If not, see . // -//- // -//- The software is distributed in the hope that it will be useful, but // -//- WITHOUT ANY WARRANTY; without even the implied warranty of // -//- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // -//- Lesser General Public License for more details. // -//- // -//- You should have received a copy of the GNU Lesser General Public // -//- License along with the software. If not, see // -//- . // -//- // -//- For information regarding this software email: // -//- "Joseph Coffland" // -//- // -//-///////////////////////////////////////////////////////////////////////////// - -script#gcode-view-template(type="text/x-template") - #gcode - h1 GCode Configuration - - form.pure-form.pure-form-aligned - fieldset - templated-input(v-for="templ in template.gcode", :name="$key", - :model.sync="config.gcode[$key]", :template="templ") diff --git a/src/jade/templates/io-view.jade b/src/jade/templates/io-view.jade index 980a973..f0c81a3 100644 --- a/src/jade/templates/io-view.jade +++ b/src/jade/templates/io-view.jade @@ -29,14 +29,13 @@ script#io-view-template(type="text/x-template") #io h1 I/O Configuration - h2 Switches - form.pure-form.pure-form-aligned + .pure-form.pure-form-aligned fieldset + h2 Switches templated-input(v-for="templ in template.switches", :name="$key", :model.sync="config.switches[$key]", :template="templ") - h2 Outputs - form.pure-form.pure-form-aligned fieldset + h2 Outputs templated-input(v-for="templ in template.outputs", :name="$key", :model.sync="config.outputs[$key]", :template="templ") diff --git a/src/jade/templates/motor-view.jade b/src/jade/templates/motor-view.jade index e1440b4..6171570 100644 --- a/src/jade/templates/motor-view.jade +++ b/src/jade/templates/motor-view.jade @@ -29,7 +29,7 @@ script#motor-view-template(type="text/x-template") .motor(:class="{slave: is_slave}") h1 Motor {{index}} Configuration - form.pure-form.pure-form-aligned + .pure-form.pure-form-aligned fieldset(v-for="category in template.motors.template", :class="$key") h2 {{$key}} diff --git a/src/jade/templates/settings-view.jade b/src/jade/templates/settings-view.jade new file mode 100644 index 0000000..cd3444b --- /dev/null +++ b/src/jade/templates/settings-view.jade @@ -0,0 +1,41 @@ +//- All rights reserved. // +//- // +//- This file ("the software") is free software: you can redistribute it // +//- and/or modify it under the terms of the GNU General Public License, // +//- version 2 as published by the Free Software Foundation. You should // +//- have received a copy of the GNU General Public License, version 2 // +//- along with the software. If not, see . // +//- // +//- The software is distributed in the hope that it will be useful, but // +//- WITHOUT ANY WARRANTY; without even the implied warranty of // +//- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // +//- Lesser General Public License for more details. // +//- // +//- You should have received a copy of the GNU Lesser General Public // +//- License along with the software. If not, see // +//- . // +//- // +//- For information regarding this software email: // +//- "Joseph Coffland" // +//- // +//-///////////////////////////////////////////////////////////////////////////// + +script#settings-view-template(type="text/x-template") + #settings + h1 Settings + + .pure-form.pure-form-aligned + fieldset + h2 Units + templated-input(name="units", :model.sync="config.settings.units", + :template="template.settings.units") + + p + | Note, units sets both the machine default units and the + | units used in motor configuration. GCode program-start, + | set below, may also change the default machine units. + + fieldset + h2 GCode + templated-input(v-for="templ in template.gcode", :name="$key", + :model.sync="config.gcode[$key]", :template="templ") diff --git a/src/jade/templates/tool-view.jade b/src/jade/templates/tool-view.jade index 6f33f1b..661ceef 100644 --- a/src/jade/templates/tool-view.jade +++ b/src/jade/templates/tool-view.jade @@ -29,31 +29,26 @@ script#tool-view-template(type="text/x-template") #tool h1 Tool Configuration - form.pure-form.pure-form-aligned + .pure-form.pure-form-aligned fieldset templated-input(v-for="templ in template.tool", :name="$key", :model.sync="config.tool[$key]", :template="templ", v-if="tool_type != 'DISABLED' || $key == 'tool-type'") - div(v-if="tool_type == 'PWM SPINDLE'") - h2 PWM Spindle - form.pure-form.pure-form-aligned - fieldset - templated-input(v-for="templ in template['pwm-spindle']", - :name="$key", :model.sync="config['pwm-spindle'][$key]", - :template="templ") + fieldset(v-if="tool_type == 'PWM SPINDLE'") + h2 PWM Spindle + templated-input(v-for="templ in template['pwm-spindle']", + :name="$key", :model.sync="config['pwm-spindle'][$key]", + :template="templ") - div(v-if="is_modbus") - h2 Modbus Configuration - form.pure-form.pure-form-aligned - fieldset - templated-input(v-for="templ in template['modbus-spindle']", - :name="$key", :model.sync="config['modbus-spindle'][$key]", - :template="templ", v-if="$key != 'regs'") + fieldset(v-if="is_modbus") + h2 Modbus Configuration + templated-input(v-for="templ in template['modbus-spindle']", + :name="$key", :model.sync="config['modbus-spindle'][$key]", + :template="templ", v-if="$key != 'regs'") - div(v-if="tool_type == 'VFD TEST'") - h2 Modbus Test - form.pure-form + fieldset(v-if="tool_type == 'VFD TEST'") + h2 Modbus Test table.modbus-regs tr th Address @@ -68,9 +63,9 @@ script#tool-view-template(type="text/x-template") button.pure-button(@click="write") Write td.modbus-status {{modbus_status}} - div.modbus-program(v-if="is_modbus && this.tool_type != 'HUANYANG VFD'") - h2 Active Modbus Program - form.pure-form + fieldset.modbus-program( + v-if="is_modbus && this.tool_type != 'HUANYANG VFD'") + h2 Active Modbus Program table.modbus-regs.fixed-regs tr th Index @@ -84,12 +79,11 @@ script#tool-view-template(type="text/x-template") td.reg-addr {{get_reg_addr(reg)}} td.reg-value {{get_reg_value(reg)}} - button.pure-button-secondary(@click="customize") Customize - button.pure-button-secondary(@click="clear") Clear + button.pure-button-secondary(@click="customize") Customize + button.pure-button-secondary(@click="clear") Clear - div(v-if="tool_type == 'CUSTOM MODBUS VFD'") - h2 Edit Modbus Program - form.pure-form + fieldset(v-if="tool_type == 'CUSTOM MODBUS VFD'") + h2 Edit Modbus Program table.modbus-regs tr th Index diff --git a/src/js/app.js b/src/js/app.js index 76f9f61..0ca5e61 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -114,10 +114,10 @@ module.exports = new Vue({ 'estop': {template: '#estop-template'}, 'loading-view': {template: '

Loading...

'}, 'control-view': require('./control-view'), + 'settings-view': require('./settings-view'), 'motor-view': require('./motor-view'), 'tool-view': require('./tool-view'), 'io-view': require('./io-view'), - 'gcode-view': require('./gcode-view'), 'admin-general-view': require('./admin-general-view'), 'admin-network-view': require('./admin-network-view'), 'help-view': {template: '#help-view-template'}, diff --git a/src/js/control-view.js b/src/js/control-view.js index 6ff21a3..ec4c5e7 100644 --- a/src/js/control-view.js +++ b/src/js/control-view.js @@ -48,6 +48,7 @@ module.exports = { data: function () { return { + mach_units: 'METRIC', mdi: '', files: [], axes: 'xyzabc', @@ -71,6 +72,17 @@ module.exports = { watch: { + 'state.imperial': function (imperial) { + this.mach_units = imperial ? 'IMPERIAL' : 'METRIC'; + }, + + + mach_units: function (units) { + if ((units == 'METRIC') != this.metric) + this.send(units == 'METRIC' ? 'G21' : 'G20'); + }, + + 'state.line': function () { if (this.mach_state != 'HOMING') this.$broadcast('gcode-line', this.state.line); @@ -82,7 +94,7 @@ module.exports = { computed: { - metric: function () {return this.$root.metric()}, + metric: function () {return !this.state.imperial}, mach_state: function () { diff --git a/src/js/gcode-view.js b/src/js/gcode-view.js deleted file mode 100644 index 9042c07..0000000 --- a/src/js/gcode-view.js +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************\ - - This file is part of the Buildbotics firmware. - - Copyright (c) 2015 - 2018, Buildbotics LLC - All rights reserved. - - This file ("the software") is free software: you can redistribute it - and/or modify it under the terms of the GNU General Public License, - version 2 as published by the Free Software Foundation. You should - have received a copy of the GNU General Public License, version 2 - along with the software. If not, see . - - The software is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the software. If not, see - . - - For information regarding this software email: - "Joseph Coffland" - -\******************************************************************************/ - -'use strict' - - -module.exports = { - template: '#gcode-view-template', - props: ['config', 'template'], - - - events: { - 'input-changed': function() { - this.$dispatch('config-changed'); - return false; - } - } -} diff --git a/src/js/settings-view.js b/src/js/settings-view.js new file mode 100644 index 0000000..599aea8 --- /dev/null +++ b/src/js/settings-view.js @@ -0,0 +1,42 @@ +/******************************************************************************\ + + This file is part of the Buildbotics firmware. + + Copyright (c) 2015 - 2018, Buildbotics LLC + All rights reserved. + + This file ("the software") is free software: you can redistribute it + and/or modify it under the terms of the GNU General Public License, + version 2 as published by the Free Software Foundation. You should + have received a copy of the GNU General Public License, version 2 + along with the software. If not, see . + + The software is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the software. If not, see + . + + For information regarding this software email: + "Joseph Coffland" + +\******************************************************************************/ + +'use strict' + + +module.exports = { + template: '#settings-view-template', + props: ['config', 'template'], + + + events: { + 'input-changed': function() { + this.$dispatch('config-changed'); + return false; + } + } +} diff --git a/src/js/unit-value.js b/src/js/unit-value.js index a84a61c..d4d6ee0 100644 --- a/src/js/unit-value.js +++ b/src/js/unit-value.js @@ -35,7 +35,7 @@ module.exports = { computed: { - metric: function () {return this.$root.metric()}, + metric: function () {return !this.$root.state.imperial}, text: function () { diff --git a/src/py/bbctrl/MainLCDPage.py b/src/py/bbctrl/MainLCDPage.py index 1b14d53..b55f921 100644 --- a/src/py/bbctrl/MainLCDPage.py +++ b/src/py/bbctrl/MainLCDPage.py @@ -48,12 +48,16 @@ class MainLCDPage(bbctrl.LCDPage): self.text('%-9s' % state.get('xx', ''), 0, 0) + metric = not state.get('imperial', False) + scale = 1 if metric else 25.4 + # Show enabled axes row = 0 for axis in 'xyzabc': if state.is_axis_enabled(axis): position = state.get(axis + 'p', 0) position += state.get('offset_' + axis, 0) + position /= scale self.text('% 10.3f%s' % (position, axis.upper()), 9, row) row += 1 @@ -62,8 +66,7 @@ class MainLCDPage(bbctrl.LCDPage): row += 1 # Show tool, units, feed and speed - units = 'INCH' if state.get('imperial', False) else 'MM' - self.text('%2uT' % state.get('tool', 0), 6, 1) - self.text('%-6s' % units, 0, 1) - self.text('%8uF' % state.get('feed', 0), 0, 2) - self.text('%8dS' % state.get('speed',0), 0, 3) + self.text('%2uT' % state.get('tool', 0), 6, 1) + self.text('%-6s' % 'MM' if metric else 'INCH', 0, 1) + self.text('%8uF' % (state.get('feed', 0) / scale), 0, 2) + self.text('%8dS' % state.get('speed', 0), 0, 3) diff --git a/src/py/bbctrl/Planner.py b/src/py/bbctrl/Planner.py index fd9f01c..fd82409 100644 --- a/src/py/bbctrl/Planner.py +++ b/src/py/bbctrl/Planner.py @@ -92,7 +92,9 @@ class Planner(): def _get_config(self, mdi, with_limits): + metric = self.ctrl.state.get('metric', True) config = { + 'default-units': 'METRIC' if metric else 'IMPERIAL', 'max-vel': self._get_config_vector('vm', 1000), 'max-accel': self._get_config_vector('am', 1000000), 'max-jerk': self._get_config_vector('jm', 1000000), diff --git a/src/py/bbctrl/State.py b/src/py/bbctrl/State.py index 2bee646..dcbd4a3 100644 --- a/src/py/bbctrl/State.py +++ b/src/py/bbctrl/State.py @@ -46,7 +46,6 @@ class State(object): self.vars = { 'line': -1, 'tool': 0, - 'units': 'METRIC', 'feed': 0, 'speed': 0, } @@ -153,6 +152,11 @@ class State(object): # Indirectly configure mach via calls to config() self.ctrl.config.reload() + # Configure units + metric = self.ctrl.config.get('units') == 'METRIC' + self.set('metric', 1 if metric else 0) + self.set('imperial', 0 if metric else 1) + def find_motor(self, axis): for motor in range(6): diff --git a/src/resources/config-template.json b/src/resources/config-template.json index 93eabf5..923d517 100644 --- a/src/resources/config-template.json +++ b/src/resources/config-template.json @@ -358,7 +358,7 @@ "gcode": { "program-start": { "type": "text", - "default": "(Runs at program start)\nG21 (Metric units)\nG90 (Absolute distance mode)\nG17 (Select XY plane)\n" + "default": "(Runs at program start)\nG90 (Absolute distance mode)\nG17 (Select XY plane)\n" }, "tool-change": { "type": "text", diff --git a/src/stylus/style.styl b/src/stylus/style.styl index 41495dc..7d0ac76 100644 --- a/src/stylus/style.styl +++ b/src/stylus/style.styl @@ -4,6 +4,11 @@ body [v-cloak] display none +tt + color #000 + background #eee + padding 2px + .button-success:not([disabled]) background-color #1cb841 @@ -114,7 +119,7 @@ span.unit top 50% #menu - .save, .units + .save display block margin 0.25em 0.6em @@ -283,6 +288,17 @@ span.unit td:nth-child(3) text-align left + .mach_units + padding 0 + + select + width 100% + height 1.9em + background-color transparent + border 0 + padding 3px + text-align right + .info:nth-of-type(2) float left clear left