diff --git a/Grbl_Esp32/src/Machines/test_drive.h b/Grbl_Esp32/src/Machines/test_drive.h index 95d57d22..41a6324a 100644 --- a/Grbl_Esp32/src/Machines/test_drive.h +++ b/Grbl_Esp32/src/Machines/test_drive.h @@ -46,32 +46,60 @@ #undef DEFAULT_HOMING_CYCLE_1 #endif -#define SPINDLE_TYPE SpindleType::NONE #ifdef USE_RMT_STEPS #undef USE_RMT_STEPS // Suppress unused variable warning #endif -// Output devices : +// Output devices: // - I2S -// x CoolantControl -// - StandardStepper -#define X_STEP_PIN "gpio.2" -#define X_DIRECTION_PIN "gpio.4" -#define X_DISABLE_PIN "gpio.16" -// - Unipolar -// - 10V +// x CoolantControl + +// #define COOLANT_MIST_PIN "gpio.2" // labeled Mist +// #define COOLANT_FLOOD_PIN "gpio.4" // labeled Flood + +// x StandardStepper + +// #define X_STEP_PIN "gpio.2" +// #define X_DIRECTION_PIN "gpio.4" +// #define X_DISABLE_PIN "gpio.16" + +// x Unipolar + +// #define X_UNIPOLAR +// #define X_PIN_PHASE_0 "gpio.2" +// #define X_PIN_PHASE_1 "gpio.4" +// #define X_PIN_PHASE_2 "gpio.16" +// #define X_PIN_PHASE_3 "gpio.15" + +// Spindles: + +#define SPINDLE_TYPE SpindleType::NONE + +// #define SPINDLE_OUTPUT_PIN "gpio.15" +// #define SPINDLE_ENABLE_PIN "gpio.2" +// #define SPINDLE_DIRECTION_PIN "gpio.4" +// #define SPINDLE_FORWARD_PIN "gpio.16" +// #define SPINDLE_REVERSE_PIN "gpio.17" + +// x 10V +// #define SPINDLE_TYPE SpindleType::_10V + +// x PWM +// #define SPINDLE_TYPE SpindleType::PWM + +// x Relay +// #define SPINDLE_TYPE SpindleType::RELAY + // - BESC // - DAC -// - Laser -// - PWM -// - Relay -// - Stepper // // Input devices : -// -Probe +// x Probe +// #define PROBE_PIN "gpio.18:pu" // labeled Probe + // - User Analog / Digital pins // - Limits // - System : ControlSafetyDoor diff --git a/Grbl_Esp32/src/Pins/DebugPinDetail.cpp b/Grbl_Esp32/src/Pins/DebugPinDetail.cpp index 5446f2ff..c0741336 100644 --- a/Grbl_Esp32/src/Pins/DebugPinDetail.cpp +++ b/Grbl_Esp32/src/Pins/DebugPinDetail.cpp @@ -1,15 +1,31 @@ #include "DebugPinDetail.h" -#include "../Grbl.h" // for printf -#include // for timer +#include "../Grbl.h" // for printf +#include // for timer +#include // HW serial +#include // vsnprintf namespace Pins { + inline void WriteSerial(const char* format, ...) { + char buf[50]; + va_list arg; + va_list copy; + va_start(arg, format); + va_copy(copy, arg); + size_t len = vsnprintf(buf, 50, format, arg); + va_end(copy); + Serial.print("[MSG: "); + Serial.print(buf); + Serial.println(" ]"); + va_end(arg); + } + // I/O: void DebugPinDetail::write(int high) { if (high != _isHigh) { _isHigh = high; if (shouldEvent()) { - grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Writing pin %s = %d", toString().c_str(), high); + WriteSerial( "Write %s < %d", toString().c_str(), high); } } _implementation->write(high); @@ -18,7 +34,7 @@ namespace Pins { int DebugPinDetail::read() { auto result = _implementation->read(); if (shouldEvent()) { - grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Reading pin %s = %d", toString().c_str(), result); + WriteSerial("Read %s > %d", toString().c_str(), result); } return result; } @@ -49,7 +65,7 @@ namespace Pins { buf[n++] = 0; if (shouldEvent()) { - grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Setting pin attr %s = %s", toString().c_str(), buf); + WriteSerial("Set pin attr %s = %s", toString().c_str(), buf); } _implementation->setAttr(value); } @@ -57,7 +73,7 @@ namespace Pins { void DebugPinDetail::CallbackHandler::handle(void* arg) { auto handler = static_cast(arg); if (handler->_myPin->shouldEvent()) { - grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Received ISR on pin %s", handler->_myPin->toString().c_str()); + WriteSerial("Received ISR on pin %s", handler->_myPin->toString().c_str()); } handler->callback(handler->argument); } @@ -69,7 +85,7 @@ namespace Pins { _isrHandler.callback = callback; if (shouldEvent()) { - grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Attaching interrupt to pin %s, mode %d", toString().c_str(), mode); + WriteSerial("Attaching interrupt to pin %s, mode %d", toString().c_str(), mode); } _implementation->attachInterrupt(_isrHandler.handle, &_isrHandler, mode); } @@ -90,7 +106,7 @@ namespace Pins { } else if (_eventCount == 10) { _lastEvent = time; ++_eventCount; - grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Suppressing events..."); + WriteSerial("Suppressing events..."); return false; } else { _lastEvent = time; diff --git a/Grbl_Esp32/src/Pins/GPIOPinDetail.cpp b/Grbl_Esp32/src/Pins/GPIOPinDetail.cpp index e7563e41..bac52684 100644 --- a/Grbl_Esp32/src/Pins/GPIOPinDetail.cpp +++ b/Grbl_Esp32/src/Pins/GPIOPinDetail.cpp @@ -143,12 +143,6 @@ namespace Pins { pinModeValue |= OUTPUT; } - // TODO FIXME: For now, I added PU capabilities to 'value' as well. This *should* be removed once the - // code that uses #define's to decide this is gone. - if (value.has(PinAttributes::PullUp)) { - pinModeValue |= PULLUP; - } - // PU/PD should be specified by the user. Code has nothing to do with them: if (_attributes.has(PinAttributes::PullUp)) { pinModeValue |= PULLUP;