Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encode + in WebUI commands so it doesn't get lost #1383

Merged
merged 9 commits into from
Dec 9, 2024
Binary file modified FluidNC/data/index.html.gz
Binary file not shown.
4 changes: 4 additions & 0 deletions FluidNC/src/Machine/Axes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
9 changes: 5 additions & 4 deletions FluidNC/src/Machine/Homing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> Homing::_remainingCycles;
uint32_t Homing::_settling_ms;
Expand Down
1 change: 1 addition & 0 deletions FluidNC/src/Machine/Homing.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 12 additions & 0 deletions FluidNC/src/Motors/TMC2160Driver.cpp
Original file line number Diff line number Diff line change
@@ -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<TMC2160Driver> registration("tmc_2160");
}
}
13 changes: 13 additions & 0 deletions FluidNC/src/Motors/TMC2160Driver.h
Original file line number Diff line number Diff line change
@@ -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) {}
};
}
1 change: 0 additions & 1 deletion FluidNC/src/Parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion FluidNC/src/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions FluidNC/src/SettingsDefinitions.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "Machine/MachineConfig.h"
#include "SettingsDefinitions.h"
#include "Config.h"
#include "Stepping.h"
#include "Machine/Homing.h"

#include <tuple>
#include <array>
Expand Down Expand Up @@ -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)
}
21 changes: 8 additions & 13 deletions FluidNC/src/Spindles/Spindle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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()) {
Expand Down
5 changes: 3 additions & 2 deletions FluidNC/src/Spindles/Spindle.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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;
Expand Down
15 changes: 9 additions & 6 deletions FluidNC/src/Spindles/VFDSpindle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@
#include <freertos/queue.h>
#include <atomic>

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() {
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions FluidNC/src/Stepping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 };
Expand Down
2 changes: 2 additions & 0 deletions FluidNC/src/Stepping.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ namespace Machine {

static uint32_t maxPulsesPerSec();

static AxisMask direction_mask;

// Timers
static void setTimerPeriod(uint32_t timerTicks);
static void startTimer();
Expand Down
Loading