mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-09-01 02:21:46 +02:00
YAML Spindles - a stab at it.
This commit is contained in:
@@ -35,11 +35,6 @@
|
||||
# define DEFAULT_STATUS_REPORT_MASK 1 // $10
|
||||
#endif
|
||||
|
||||
// ======== SPINDLE STUFF ====================
|
||||
#ifndef SPINDLE_TYPE
|
||||
# define SPINDLE_TYPE SpindleType::NONE
|
||||
#endif
|
||||
|
||||
#ifndef SERVO_TIMER_INTERVAL
|
||||
# define SERVO_TIMER_INTERVAL 75.0 // Hz This is the update inveral in milliseconds
|
||||
#endif
|
||||
|
@@ -481,7 +481,7 @@ Error gc_execute_line(char* line, uint8_t client) {
|
||||
case 3:
|
||||
gc_block.modal.spindle = SpindleState::Cw;
|
||||
break;
|
||||
case 4: // Supported if SPINDLE_DIR_PIN is defined or laser mode is on.
|
||||
case 4: // Supported if the spindle can be reversed or laser mode is on.
|
||||
if (spindle->is_reversable || config->_laserMode) {
|
||||
gc_block.modal.spindle = SpindleState::Ccw;
|
||||
} else {
|
||||
|
@@ -93,7 +93,6 @@ void grbl_init() {
|
||||
}
|
||||
#endif
|
||||
grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Initializing spindle...");
|
||||
Spindles::Spindle::select();
|
||||
|
||||
#ifdef ENABLE_WIFI
|
||||
grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Initializing WiFi-config...");
|
||||
|
@@ -379,6 +379,7 @@ void MachineConfig::handle(Configuration::HandlerBase& handler) {
|
||||
handler.handle("junction_deviation", _junctionDeviation);
|
||||
handler.handle("verbose_errors", _verboseErrors);
|
||||
handler.handle("report_inches", _reportInches);
|
||||
// Spindles::SpindleFactory::handle(handler, _spindle);
|
||||
}
|
||||
|
||||
void MachineConfig::afterParse() {
|
||||
@@ -402,7 +403,7 @@ void MachineConfig::afterParse() {
|
||||
}
|
||||
|
||||
if (_sdCard == nullptr) {
|
||||
_sdCard = new SDCard();
|
||||
_sdCard = new SDCardPin();
|
||||
}
|
||||
|
||||
if (_control == nullptr) {
|
||||
|
@@ -27,6 +27,7 @@
|
||||
#include "Control.h"
|
||||
#include "Probe.h"
|
||||
#include "SDCardPin.h"
|
||||
#include "Spindles/Spindle.h"
|
||||
|
||||
// TODO FIXME: Split this file up into several files, perhaps put it in some folder and namespace Machine?
|
||||
|
||||
@@ -365,15 +366,16 @@ class MachineConfig : public Configuration::Configurable {
|
||||
public:
|
||||
MachineConfig() = default;
|
||||
|
||||
Axes* _axes = nullptr;
|
||||
SPIBus* _spi = nullptr;
|
||||
I2SOBus* _i2so = nullptr;
|
||||
CoolantControl* _coolant = nullptr;
|
||||
Probe* _probe = nullptr;
|
||||
Communications* _comms = nullptr;
|
||||
Control* _control = nullptr;
|
||||
UserOutputs* _userOutputs = nullptr;
|
||||
Axes* _axes = nullptr;
|
||||
SPIBus* _spi = nullptr;
|
||||
I2SOBus* _i2so = nullptr;
|
||||
CoolantControl* _coolant = nullptr;
|
||||
Probe* _probe = nullptr;
|
||||
Communications* _comms = nullptr;
|
||||
Control* _control = nullptr;
|
||||
UserOutputs* _userOutputs = nullptr;
|
||||
SDCardPin* _sdCard = nullptr;
|
||||
Spindles::Spindle* _spindle = nullptr;
|
||||
|
||||
int _pulseMicroSeconds = 3;
|
||||
int _directionDelayMilliSeconds = 0;
|
||||
|
@@ -6,24 +6,8 @@ StringSetting* build_info;
|
||||
|
||||
IntSetting* status_mask;
|
||||
|
||||
EnumSetting* spindle_type;
|
||||
|
||||
EnumSetting* message_level;
|
||||
|
||||
enum_opt_t spindleTypes = {
|
||||
// clang-format off
|
||||
{ "NONE", int8_t(SpindleType::NONE) },
|
||||
{ "PWM", int8_t(SpindleType::PWM) },
|
||||
{ "RELAY", int8_t(SpindleType::RELAY) },
|
||||
{ "LASER", int8_t(SpindleType::LASER) },
|
||||
{ "DAC", int8_t(SpindleType::DAC) },
|
||||
{ "HUANYANG", int8_t(SpindleType::HUANYANG) },
|
||||
{ "BESC", int8_t(SpindleType::BESC) },
|
||||
{ "10V", int8_t(SpindleType::_10V) },
|
||||
{ "H2A", int8_t(SpindleType::H2A) },
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
enum_opt_t messageLevels = {
|
||||
// clang-format off
|
||||
{ "None", int8_t(MsgLevel::None) },
|
||||
@@ -59,15 +43,6 @@ static bool postMotorSetting(char* value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool checkSpindleChange(char* val) {
|
||||
if (!val) {
|
||||
gc_state.spindle_speed = 0; // Set S value to 0
|
||||
Spindles::Spindle::select(); // get new spindle
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void make_coordinate(CoordIndex index, const char* name) {
|
||||
float coord_data[MAX_N_AXIS] = { 0.0 };
|
||||
auto coord = new Coordinates(name);
|
||||
@@ -91,10 +66,6 @@ void make_settings() {
|
||||
make_coordinate(CoordIndex::G28, "G28");
|
||||
make_coordinate(CoordIndex::G30, "G30");
|
||||
|
||||
// Spindle Settings
|
||||
spindle_type =
|
||||
new EnumSetting(NULL, EXTENDED, WG, NULL, "Spindle/Type", static_cast<int8_t>(SPINDLE_TYPE), &spindleTypes, checkSpindleChange);
|
||||
|
||||
// GRBL Non-numbered settings
|
||||
startup_line_0 = new StringSetting(EXTENDED, WG, "N0", "GCode/Line0", "", checkStartupLine);
|
||||
startup_line_1 = new StringSetting(EXTENDED, WG, "N1", "GCode/Line1", "", checkStartupLine);
|
||||
|
@@ -6,8 +6,6 @@ extern StringSetting* build_info;
|
||||
|
||||
extern IntSetting* status_mask;
|
||||
|
||||
extern EnumSetting* spindle_type;
|
||||
|
||||
extern StringSetting* user_macro0;
|
||||
extern StringSetting* user_macro1;
|
||||
extern StringSetting* user_macro2;
|
||||
|
@@ -21,74 +21,10 @@
|
||||
TODO
|
||||
Add Spindle spin up/down delays
|
||||
|
||||
Get rid of dependance on machine definition #defines
|
||||
SPINDLE_OUTPUT_PIN
|
||||
SPINDLE_ENABLE_PIN
|
||||
SPINDLE_DIR_PIN
|
||||
|
||||
*/
|
||||
#include "Spindle.h"
|
||||
|
||||
#include "NullSpindle.h"
|
||||
#include "PWMSpindle.h"
|
||||
#include "RelaySpindle.h"
|
||||
#include "Laser.h"
|
||||
#include "DacSpindle.h"
|
||||
#include "HuanyangSpindle.h"
|
||||
#include "H2ASpindle.h"
|
||||
#include "BESCSpindle.h"
|
||||
#include "10vSpindle.h"
|
||||
|
||||
namespace Spindles {
|
||||
// An instance of each type of spindle is created here.
|
||||
// This allows the spindle to be dynamicly switched
|
||||
Null null;
|
||||
PWM pwm;
|
||||
Relay relay;
|
||||
Laser laser;
|
||||
Dac dac;
|
||||
Huanyang huanyang;
|
||||
H2A h2a;
|
||||
BESC besc;
|
||||
_10v _10v;
|
||||
|
||||
void Spindle::select() {
|
||||
// TODO FIXME: I don't think we need this anymore; the factory should take care of it...
|
||||
|
||||
switch (static_cast<SpindleType>(spindle_type->get())) {
|
||||
case SpindleType::PWM:
|
||||
spindle = &pwm;
|
||||
break;
|
||||
case SpindleType::RELAY:
|
||||
spindle = &relay;
|
||||
break;
|
||||
case SpindleType::LASER:
|
||||
spindle = &laser;
|
||||
break;
|
||||
case SpindleType::DAC:
|
||||
spindle = &dac;
|
||||
break;
|
||||
case SpindleType::HUANYANG:
|
||||
spindle = &huanyang;
|
||||
break;
|
||||
case SpindleType::BESC:
|
||||
spindle = &besc;
|
||||
break;
|
||||
case SpindleType::_10V:
|
||||
spindle = &_10v;
|
||||
break;
|
||||
case SpindleType::H2A:
|
||||
spindle = &h2a;
|
||||
break;
|
||||
case SpindleType::NONE:
|
||||
default:
|
||||
spindle = &null;
|
||||
break;
|
||||
}
|
||||
|
||||
spindle->init();
|
||||
}
|
||||
|
||||
// ========================= Spindle ==================================
|
||||
|
||||
bool Spindle::isRateAdjusted() {
|
||||
|
@@ -28,23 +28,12 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
enum class SpindleType : int8_t {
|
||||
NONE = 0,
|
||||
PWM,
|
||||
RELAY,
|
||||
LASER,
|
||||
DAC,
|
||||
HUANYANG,
|
||||
BESC,
|
||||
_10V,
|
||||
H2A,
|
||||
YL620,
|
||||
};
|
||||
#include "../GCode.h" // for SpindleState
|
||||
#include "../Report.h" // for MsgLevel
|
||||
#include "../Serial.h" // for CLIENT_ALL
|
||||
#include "../Protocol.h" // for protocol_buffer_synchronize
|
||||
|
||||
#include "../Grbl.h"
|
||||
#include "../Configuration/GenericFactory.h"
|
||||
#include <driver/dac.h>
|
||||
#include <driver/uart.h>
|
||||
|
||||
// =============== No floats! ===========================
|
||||
// ================ NO FLOATS! ==========================
|
||||
@@ -76,8 +65,6 @@ namespace Spindles {
|
||||
uint32_t _spinup_delay;
|
||||
uint32_t _spindown_delay;
|
||||
|
||||
static void select();
|
||||
|
||||
// Name is required for the configuration factory to work.
|
||||
virtual const char* name() const = 0;
|
||||
|
||||
@@ -94,7 +81,6 @@ namespace Spindles {
|
||||
// Virtual base classes require a virtual destructor.
|
||||
virtual ~Spindle() {}
|
||||
};
|
||||
|
||||
using SpindleFactory = Configuration::GenericFactory<Spindle>;
|
||||
}
|
||||
|
||||
|
@@ -34,6 +34,7 @@
|
||||
*/
|
||||
#include "VFDSpindle.h"
|
||||
#include "../MachineConfig.h"
|
||||
#include "../MotionControl.h" // for mc_reset
|
||||
#include <atomic>
|
||||
|
||||
const uart_port_t VFD_RS485_UART_PORT = UART_NUM_2; // hard coded for this port right now
|
||||
|
Reference in New Issue
Block a user