Homing should be working
authorJoseph Coffland <joseph@cauldrondevelopment.com>
Sun, 9 Jul 2017 01:49:44 +0000 (18:49 -0700)
committerJoseph Coffland <joseph@cauldrondevelopment.com>
Sun, 9 Jul 2017 01:49:44 +0000 (18:49 -0700)
avr/src/axis.c
avr/src/vars.def
src/jade/templates/control-view.jade
src/js/control-view.js
src/py/bbctrl/AVR.py
src/stylus/style.styl

index 5a48b78360befe67f452b542d7f9758561eeeb39..6b8f63ab3d6dd2a2fc13d79054765ac67fcd144a 100644 (file)
@@ -176,3 +176,36 @@ float get_home(int axis) {
   }
   return NAN;
 }
+
+
+static int _get_homing_switch(int axis) {
+  switch (axes[axis].homing_mode) {
+  case HOMING_MANUAL: break;
+
+  case HOMING_STALL_MIN: case HOMING_SWITCH_MIN:
+    switch (axis) {
+    case AXIS_X: return SW_MIN_X;
+    case AXIS_Y: return SW_MIN_Y;
+    case AXIS_Z: return SW_MIN_Z;
+    case AXIS_A: return SW_MIN_A;
+    }
+    break;
+
+  case HOMING_STALL_MAX: case HOMING_SWITCH_MAX:
+    switch (axis) {
+    case AXIS_X: return SW_MAX_X;
+    case AXIS_Y: return SW_MAX_Y;
+    case AXIS_Z: return SW_MAX_Z;
+    case AXIS_A: return SW_MAX_A;
+    }
+    break;
+  }
+
+  return -1;
+}
+
+
+bool get_axis_can_home(int axis) {
+  return axis_is_enabled(axis) && axes[axis].homing_mode != HOMING_MANUAL &&
+    switch_is_enabled(_get_homing_switch(axis));
+}
index 70fb49a03e36160a1d29062d0099ed9a9ec6d59c..2351e01a54b4d66262d6d6972430eb0804e4bf3d 100644 (file)
@@ -78,6 +78,7 @@ VAR(zero_backoff,   zb, float,    MOTORS, 1, 1, "Homing zero backoff")
 // Axis
 VAR(axis_mach_coord, p, float,    AXES,   1, 1, "Axis machine coordinate")
 VAR(axis_work_coord, w, float,    AXES,   0, 1, "Axis work coordinate")
+VAR(axis_can_home,  ch, bool,     AXES,   0, 1, "Is axis configured for homing")
 
 // Spindle
 VAR(spindle_type,   st, uint8_t,  0,      1, 1, "PWM=0 or HUANYANG=1")
index f7faa883e76a85b024914969acddd8bdeda33d2c..9b324f4cf75ce504920a9cd11b0a38df11d8b572 100644 (file)
@@ -16,17 +16,18 @@ script#control-view-template(type="text/x-template")
           td.absolute {{state.#{axis}p || 0 | fixed 3}}
           td.offset {{(state.#{axis}w - state.#{axis}p) || 0 | fixed 3}}
           th.actions
-            button.pure-button(
+            button.pure-button(:disabled="state.x != 'READY'",
               title="Set {{'#{axis}' | upper}} axis position.",
               @click="show_set_position('#{axis}')")
               .fa.fa-cog
 
-            button.pure-button(
+            button.pure-button(:disabled="state.x != 'READY'",
               title="Zero {{'#{axis}' | upper}} axis offset.",
               @click="set_position('#{axis}', state['#{axis}p'])")
               | &empty;
 
-            button.pure-button(title="Home {{'#{axis}' | upper}} axis.",
+            button.pure-button(:disabled="state.x != 'READY'",
+              title="Home {{'#{axis}' | upper}} axis.",
               @click="home('#{axis}')")
               .fa.fa-home
 
@@ -77,7 +78,7 @@ script#control-view-template(type="text/x-template")
         td
       tr
         th Reason
-        td {{get_reason()}}
+        td.reason {{get_reason()}}
         td
       tr
         th Feed
@@ -128,7 +129,7 @@ script#control-view-template(type="text/x-template")
 
 
     .toolbar
-      button.pure-button(title="Home the machine.", @click="home",
+      button.pure-button(title="Home the machine.", @click="home()",
         :disabled="state.x != 'READY'")
         .fa.fa-home
 
index 2ac67ec7e1584040ec7ee60c44358f48fae452d7..46d894775abcaff37fc550f622e5e3819b66895b 100644 (file)
@@ -221,12 +221,17 @@ module.exports = {
 
 
     home: function (axis) {
-      var motor = this.get_axis_motor(axis);
-      if (motor['homing-mode'] == 'manual') {
-        this.axis_position = this.state[axis + 'w'];
-        this.manual_home[axis] = true;
+      if (typeof axis == 'undefined') api.put('home');
+
+      else {
+        var motor = this.get_axis_motor(axis);
 
-      } else api.put('home' + (typeof axis == 'undefined' ? '' : ('/' + axis)));
+        if (motor['homing-mode'] == 'manual') {
+          this.axis_position = this.state[axis + 'w'];
+          this.manual_home[axis] = true;
+
+        } else api.put('home/' + axis);
+      }
     },
 
 
index 8a67423988ecc0b052deeb765937342db527924d..aacf75a96da4b901a7987b763fc935d30ad2c37d 100644 (file)
@@ -35,12 +35,12 @@ machine_state_vars = '''
 #   - Backoff to machine zero
 #   - Set axis home position
 axis_homing_procedure = '''
-  G28.2 %(axis)c0 F[#<%(axis)c.sv>]
-  G38.6 %(axis)c[#<%(axis)c.hd> * [#<%(axis)c.tm> - #<%(axis)c.tn>]]
-  G38.8 %(axis)c[#<%(axis)c.hd> * -#<%(axis)c.lb>] F[#<%(axis)c.lv>]
-  G38.6 %(axis)c[#<%(axis)c.hd> * #<%(axis)c.lb> * 1.5]
-  G0 %(axis)c[#<%(axis)c.hd> * -#<%(axis)c.zb> + #<%(axis)cp>]
-  G28.3 %(axis)c[#<%(axis)c.hp>]
+  G28.2 %(axis)s0 F[#<%(axis)s.sv>]
+  G38.6 %(axis)s[#<%(axis)s.hd> * [#<%(axis)s.tm> - #<%(axis)s.tn>]]
+  G38.8 %(axis)s[#<%(axis)s.hd> * -#<%(axis)s.lb>] F[#<%(axis)s.lv>]
+  G38.6 %(axis)s[#<%(axis)s.hd> * #<%(axis)s.lb> * 1.5]
+  G0 %(axis)s[#<%(axis)s.hd> * -#<%(axis)s.zb> + #<%(axis)sp>]
+  G28.3 %(axis)s[#<%(axis)s.hp>]
 '''
 
 class AVR():
@@ -240,7 +240,7 @@ class AVR():
 
     def _update_lcd(self, msg):
         if 'x' in msg or 'c' in msg:
-            v = self.ctrl.avr.vars
+            v = self.vars
             state = v.get('x', 'INIT')
             if 'c' in v and state == 'RUNNING': state = v['c']
 
@@ -288,9 +288,15 @@ class AVR():
             self.queue_command('G28.3 %c%f' % (axis, position))
 
         else:
-            gcode = axis_homing_procedure % {'axis': axis}
-            for line in gcode.splitlines():
-                self.queue_command(line.strip())
+            if axis is None: axes = 'zxyabc' # TODO This should be configurable
+            else: axes = '%c' % axis
+
+            for axis in axes:
+                if not self.vars.get('%sch' % axis, 0): continue
+
+                gcode = axis_homing_procedure % {'axis': axis}
+                for line in gcode.splitlines():
+                    self.queue_command(line.strip())
 
 
     def estop(self): self._i2c_command(I2C_ESTOP)
index 7cc3302d68a4159dfb06a498f114464a5ce5e9f3..d9a2554038e9df4a5b5289b664d9c540679fbbb4 100644 (file)
@@ -234,10 +234,12 @@ body
 
   .info
     empty-cells show
+    max-width 50%
 
     th, td
       padding 3px
       text-align right
+      white-space normal
 
     th
       width 5.25em