}
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));
+}
// 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")
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'])")
| ∅
- 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
td
tr
th Reason
- td {{get_reason()}}
+ td.reason {{get_reason()}}
td
tr
th Feed
.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
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);
+ }
},
# - 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():
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']
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)
.info
empty-cells show
+ max-width 50%
th, td
padding 3px
text-align right
+ white-space normal
th
width 5.25em