diff --git a/FluidNC/data/index.html.gz b/FluidNC/data/index.html.gz index 8bc5ae67c..c49cc5fa1 100644 Binary files a/FluidNC/data/index.html.gz and b/FluidNC/data/index.html.gz differ diff --git a/FluidNC/src/Machine/Axes.cpp b/FluidNC/src/Machine/Axes.cpp index dd47ddf2e..1b07a42ef 100644 --- a/FluidNC/src/Machine/Axes.cpp +++ b/FluidNC/src/Machine/Axes.cpp @@ -52,6 +52,10 @@ namespace Machine { log_info("Axis " << axisName(axis) << " (" << limitsMinPosition(axis) << "," << limitsMaxPosition(axis) << ")"); a->init(); } + auto homing = a->_homing; + if (homing && !homing->_positiveDirection) { + set_bitnum(Homing::direction_mask, axis); + } } config_motors(); diff --git a/FluidNC/src/Machine/Homing.cpp b/FluidNC/src/Machine/Homing.cpp index 577c6fe2e..2ce3668f0 100644 --- a/FluidNC/src/Machine/Homing.cpp +++ b/FluidNC/src/Machine/Homing.cpp @@ -32,10 +32,11 @@ namespace Machine { const uint32_t MOTOR0 = 0xffff; const uint32_t MOTOR1 = 0xffff0000; - Homing::Phase Homing::_phase = Phase::None; - AxisMask Homing::_cycleAxes = 0; - AxisMask Homing::_phaseAxes = 0; - MotorMask Homing::_cycleMotors = 0; + Homing::Phase Homing::_phase = Phase::None; + AxisMask Homing::_cycleAxes = 0; + AxisMask Homing::_phaseAxes = 0; + AxisMask Homing::direction_mask = 0; + MotorMask Homing::_cycleMotors = 0; MotorMask Homing::_phaseMotors; std::queue Homing::_remainingCycles; uint32_t Homing::_settling_ms; diff --git a/FluidNC/src/Machine/Homing.h b/FluidNC/src/Machine/Homing.h index cf869656a..2113be23c 100644 --- a/FluidNC/src/Machine/Homing.h +++ b/FluidNC/src/Machine/Homing.h @@ -27,6 +27,7 @@ namespace Machine { static uint32_t _runs; static AxisMask unhomed_axes(); + static AxisMask direction_mask; static void set_axis_homed(size_t axis); static void set_axis_unhomed(size_t axis); diff --git a/FluidNC/src/Motors/TMC2160Driver.cpp b/FluidNC/src/Motors/TMC2160Driver.cpp new file mode 100644 index 000000000..dd51a2b22 --- /dev/null +++ b/FluidNC/src/Motors/TMC2160Driver.cpp @@ -0,0 +1,12 @@ +// Copyright (c) 2020 - Bart Dring +// Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. + +#include "TMC2160Driver.h" +#include "../Machine/MachineConfig.h" + +namespace MotorDrivers { + // Configuration registration + namespace { + MotorFactory::InstanceBuilder registration("tmc_2160"); + } +} diff --git a/FluidNC/src/Motors/TMC2160Driver.h b/FluidNC/src/Motors/TMC2160Driver.h new file mode 100644 index 000000000..9d833851f --- /dev/null +++ b/FluidNC/src/Motors/TMC2160Driver.h @@ -0,0 +1,13 @@ +// Copyright (c) 2020 - Bart Dring +// Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. + +#pragma once + +#include "TMC5160Driver.h" + +namespace MotorDrivers { + class TMC2160Driver : public TMC5160Driver { + public: + TMC2160Driver(const char* name) : TMC5160Driver(name) {} + }; +} diff --git a/FluidNC/src/Parameters.cpp b/FluidNC/src/Parameters.cpp index 4b7e74610..ab616673b 100644 --- a/FluidNC/src/Parameters.cpp +++ b/FluidNC/src/Parameters.cpp @@ -467,7 +467,6 @@ bool get_param_ref(const char* line, size_t& pos, param_ref_t& param_ref) { return true; case '[': { // Expression evaluating to param number - ++pos; Error status = expression(line, pos, result); if (status != Error::Ok) { log_debug(errorString(status)); diff --git a/FluidNC/src/Settings.cpp b/FluidNC/src/Settings.cpp index ff2ad081b..ae4a3456b 100644 --- a/FluidNC/src/Settings.cpp +++ b/FluidNC/src/Settings.cpp @@ -45,7 +45,7 @@ bool notIdleOrJog() { return !state_is(State::Idle) && !state_is(State::Jog); } bool notIdleOrAlarm() { - return !state_is(State::Idle) && !state_is(State::Alarm) && !state_is(State::ConfigAlarm); + return !state_is(State::Idle) && !state_is(State::Alarm) && !state_is(State::ConfigAlarm) && !state_is(State::SafetyDoor); } bool cycleOrHold() { return state_is(State::Cycle) || state_is(State::Hold); diff --git a/FluidNC/src/SettingsDefinitions.cpp b/FluidNC/src/SettingsDefinitions.cpp index 262dca128..f17b0450a 100644 --- a/FluidNC/src/SettingsDefinitions.cpp +++ b/FluidNC/src/SettingsDefinitions.cpp @@ -1,6 +1,8 @@ #include "Machine/MachineConfig.h" #include "SettingsDefinitions.h" #include "Config.h" +#include "Stepping.h" +#include "Machine/Homing.h" #include #include @@ -109,7 +111,9 @@ void make_settings() { FLOAT_PROXY("101", "Grbl/Resolution/Y", config._axes->_axis[1]->_stepsPerMm) FLOAT_PROXY("102", "Grbl/Resolution/Z", config._axes->_axis[2]->_stepsPerMm) + INT_PROXY("3", "Grbl/InvertMask", Machine::Stepping::direction_mask) INT_PROXY("20", "Grbl/SoftLimitsEnable", config._axes->_axis[0]->_softLimits) INT_PROXY("21", "Grbl/HardLimitsEnable", config._axes->hasHardLimits()) INT_PROXY("22", "Grbl/HomingCycleEnable", (bool)Axes::homingMask) + INT_PROXY("23", "Grbl/HomingInvertMask", Homing::direction_mask) } diff --git a/FluidNC/src/Spindles/Spindle.cpp b/FluidNC/src/Spindles/Spindle.cpp index af0c78407..99cd877a7 100644 --- a/FluidNC/src/Spindles/Spindle.cpp +++ b/FluidNC/src/Spindles/Spindle.cpp @@ -18,10 +18,15 @@ namespace Spindles { ATCs::ATC* candidate = nullptr; auto atcs = ATCs::ATCFactory::objects(); for (auto a : atcs) { - if (strcmp(_atc_name.c_str(), a->name()) == 0) { - _atc = a; + if (_atc_name == a->name()) { + _atc = a; + _atc_info = " with " + _atc_name; + return; } } + if (!_m6_macro._gcode.empty()) { + _atc_info = " with m6_macro"; + } } void Spindle::switchSpindle(uint32_t new_tool, SpindleList spindles, Spindle*& spindle, bool& stop_spindle, bool& new_spindle) { @@ -121,21 +126,11 @@ namespace Spindles { _speeds.push_back({ max, 100.0f }); } - std::string Spindle::atc_info() { // this can be used in the startup response - std::string atc_info = ""; - if (_atc != NULL) { - atc_info = " ATC:" + _atc_name; - } else if (!_m6_macro._gcode.empty()) { - atc_info = " m6_macro:"; - } - return atc_info; - } - // pre_select is generally ignored except for machines that need to get a tool ready // set_tool is just used to tell the atc what is already installed. bool Spindle::tool_change(uint32_t tool_number, bool pre_select, bool set_tool) { if (_atc != NULL) { - log_info(_name << " spindle changed to tool:" << tool_number << " using ATC:" << _atc_name); + log_info(_name << " spindle changed to tool:" << tool_number << " using " << _atc_name); return _atc->tool_change(tool_number, pre_select, set_tool); } if (!_m6_macro.get().empty()) { diff --git a/FluidNC/src/Spindles/Spindle.h b/FluidNC/src/Spindles/Spindle.h index c85817311..cdbe2c32f 100644 --- a/FluidNC/src/Spindles/Spindle.h +++ b/FluidNC/src/Spindles/Spindle.h @@ -26,9 +26,10 @@ namespace Spindles { class Spindle : public Configuration::Configurable { private: const char* _name; + std::string _atc_info = ""; protected: - ATCs::ATC* _atc = NULL; + ATCs::ATC* _atc = nullptr; uint32_t _last_tool = 0; public: @@ -52,7 +53,7 @@ namespace Spindles { void spindleDelay(SpindleState state, SpindleSpeed speed); virtual void init() = 0; // not in constructor because this also gets called when $$ settings change virtual void init_atc(); - std::string atc_info(); + std::string atc_info() { return _atc_info; }; // Used by Protocol.cpp to restore the state during a restart virtual void setState(SpindleState state, uint32_t speed) = 0; diff --git a/FluidNC/src/Spindles/VFDSpindle.cpp b/FluidNC/src/Spindles/VFDSpindle.cpp index 31315e225..a71240cc1 100644 --- a/FluidNC/src/Spindles/VFDSpindle.cpp +++ b/FluidNC/src/Spindles/VFDSpindle.cpp @@ -31,11 +31,10 @@ #include #include -namespace Spindles -{ +namespace Spindles { // number of commands that can be queued up. - const int VFD_RS485_QUEUE_SIZE = 10; - + const int VFD_RS485_QUEUE_SIZE = 10; + // ================== Class methods ================================== void VFDSpindle::init() { @@ -85,8 +84,12 @@ namespace Spindles set_mode(SpindleState::Disable, true); } - void VFDSpindle::config_message() { _uart->config_message(name(), " Spindle "); } - + void VFDSpindle::config_message() { + std::string usage(" Spindle"); + usage += atc_info(); + _uart->config_message(name(), usage.c_str()); + } + void VFDSpindle::set_mode(SpindleState mode, bool critical) { _last_override_value = sys.spindle_speed_ovr; // sync these on mode changes if (VFD::VFDProtocol::vfd_cmd_queue) { diff --git a/FluidNC/src/Stepping.cpp b/FluidNC/src/Stepping.cpp index eb166668d..0dabd99fa 100644 --- a/FluidNC/src/Stepping.cpp +++ b/FluidNC/src/Stepping.cpp @@ -24,6 +24,8 @@ namespace Machine { int Stepping::_engine = RMT_ENGINE; + AxisMask Stepping::direction_mask = 0; + bool Stepping::_switchedStepper = false; size_t Stepping::_segments = 12; @@ -78,6 +80,10 @@ void Stepping::assignMotor(int axis, int motor, int step_pin, bool step_invert, m->dir_invert = dir_invert; m->blocked = false; m->limited = false; + + if (motor == 0 && dir_invert) { + set_bitnum(direction_mask, axis); + } } int Stepping::axis_steps[MAX_N_AXIS] = { 0 }; diff --git a/FluidNC/src/Stepping.h b/FluidNC/src/Stepping.h index fbf7a48ab..dcccf8da9 100644 --- a/FluidNC/src/Stepping.h +++ b/FluidNC/src/Stepping.h @@ -87,6 +87,8 @@ namespace Machine { static uint32_t maxPulsesPerSec(); + static AxisMask direction_mask; + // Timers static void setTimerPeriod(uint32_t timerTicks); static void startTimer();