1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-09-01 18:32:37 +02:00

Rename coolant variables

This commit is contained in:
Mitch Bradley
2021-05-24 06:24:44 -10:00
parent 92532e8622
commit 11f436ddda
3 changed files with 24 additions and 31 deletions

View File

@@ -28,17 +28,17 @@ void CoolantControl::init() {
static bool init_message = true; // used to show messages only once. static bool init_message = true; // used to show messages only once.
if (init_message) { if (init_message) {
if (flood_.defined()) { if (_flood.defined()) {
grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Flood coolant on pin %s", flood_.name().c_str()); grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Flood coolant on pin %s", _flood.name().c_str());
} }
if (mist_.defined()) { if (_mist.defined()) {
grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Mist coolant on pin %s", mist_.name().c_str()); grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Mist coolant on pin %s", _mist.name().c_str());
} }
init_message = false; init_message = false;
} }
flood_.setAttr(Pin::Attr::Output); _flood.setAttr(Pin::Attr::Output);
mist_.setAttr(Pin::Attr::Output); _mist.setAttr(Pin::Attr::Output);
stop(); stop();
} }
@@ -48,16 +48,16 @@ CoolantState CoolantControl::get_state() {
CoolantState cl_state = {}; CoolantState cl_state = {};
bool pinState; bool pinState;
if (flood_.defined()) { if (_flood.defined()) {
auto pinState = flood_.read(); auto pinState = _flood.read();
if (pinState) { if (pinState) {
cl_state.Flood = 1; cl_state.Flood = 1;
} }
} }
if (mist_.defined()) { if (_mist.defined()) {
auto pinState = mist_.read(); auto pinState = _mist.read();
if (pinState) { if (pinState) {
cl_state.Mist = 1; cl_state.Mist = 1;
@@ -68,20 +68,14 @@ CoolantState CoolantControl::get_state() {
} }
void CoolantControl::write(CoolantState state) { void CoolantControl::write(CoolantState state) {
if (flood_.defined()) { if (_flood.defined()) {
bool pinState = state.Flood; bool pinState = state.Flood;
#ifdef INVERT_COOLANT_FLOOD_PIN _flood.write(pinState);
pinState = !pinState;
#endif
flood_.write(pinState);
} }
if (mist_.defined()) { if (_mist.defined()) {
bool pinState = state.Mist; bool pinState = state.Mist;
#ifdef INVERT_COOLANT_MIST_PIN _mist.write(pinState);
pinState = !pinState;
#endif
mist_.write(pinState);
} }
} }
@@ -123,7 +117,7 @@ void CoolantControl::sync(CoolantState state) {
void CoolantControl::validate() const {} void CoolantControl::validate() const {}
void CoolantControl::handle(Configuration::HandlerBase& handler) { void CoolantControl::handle(Configuration::HandlerBase& handler) {
handler.handle("flood", flood_); handler.handle("flood", _flood);
handler.handle("mist", mist_); handler.handle("mist", _mist);
handler.handle("delay", delay_); handler.handle("delay", _delay);
} }

View File

@@ -28,18 +28,18 @@
#include "GCode.h" #include "GCode.h"
class CoolantControl : public Configuration::Configurable { class CoolantControl : public Configuration::Configurable {
Pin mist_; Pin _mist;
Pin flood_; Pin _flood;
float delay_ = 0.0; float _delay = 0.0;
void write(CoolantState state); void write(CoolantState state);
public: public:
CoolantControl() = default; CoolantControl() = default;
bool hasMist() const { return mist_.defined(); } bool hasMist() const { return _mist.defined(); }
bool hasFlood() const { return flood_.defined(); } bool hasFlood() const { return _flood.defined(); }
// Initializes coolant control pins. // Initializes coolant control pins.
void init(); void init();
@@ -54,8 +54,6 @@ public:
void off(); void off();
void set_state(CoolantState state); void set_state(CoolantState state);
float delay() { return delay_; }
// G-code parser entry-point for setting coolant states. Checks for and executes additional conditions. // G-code parser entry-point for setting coolant states. Checks for and executes additional conditions.
void sync(CoolantState state); void sync(CoolantState state);

View File

@@ -684,7 +684,8 @@ static void protocol_exec_rt_suspend() {
if (!sys.suspend.bit.restartRetract) { if (!sys.suspend.bit.restartRetract) {
// NOTE: Laser mode will honor this delay. An exhaust system is often controlled by this pin. // NOTE: Laser mode will honor this delay. An exhaust system is often controlled by this pin.
config->_coolant->set_state(restore_coolant); config->_coolant->set_state(restore_coolant);
delay_msec(int32_t(1000.0 * config->_coolant->delay()), DwellMode::SysSuspend); // TODO: Should this be buried in _coolant->set_state() ?
delay_msec(int32_t(1000.0 * config->_coolant->_delay), DwellMode::SysSuspend);
} }
} }
#ifdef PARKING_ENABLE #ifdef PARKING_ENABLE