mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-09-01 02:21:46 +02:00
Accept NO_PIN (case independent) as a pin name.
Also, the pin parser no longer requires a . , so you can have pin names without a numeric suffix, and it no longer limits the numeric suffix to 254.
This commit is contained in:
@@ -75,17 +75,10 @@ const char* Pin::parse(StringRange tmp, Pins::PinDetail*& pinImplementation) {
|
|||||||
|
|
||||||
int pinNumber = 0;
|
int pinNumber = 0;
|
||||||
if (prefix != "") {
|
if (prefix != "") {
|
||||||
if (idx == str.end()) {
|
if (idx != str.end()) {
|
||||||
// Incorrect pin definition.
|
for (int n = 0; idx != str.end() && n <= 4 && *idx >= '0' && *idx <= '9'; ++idx, ++n) {
|
||||||
return "Pin definition is missing.";
|
pinNumber = pinNumber * 10 + int(*idx - '0');
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int n = 0; idx != str.end() && n <= 4 && *idx >= '0' && *idx <= '9'; ++idx, ++n) {
|
|
||||||
pinNumber = pinNumber * 10 + int(*idx - '0');
|
|
||||||
}
|
|
||||||
if ((idx != str.end() && *idx >= '0' && *idx <= '9') || (pinNumber < 0 || pinNumber > 253)) {
|
|
||||||
// Pin number has to be between [0,253].
|
|
||||||
return "Pin number has to be between [0,253>";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +105,7 @@ const char* Pin::parse(StringRange tmp, Pins::PinDetail*& pinImplementation) {
|
|||||||
// Build an options parser:
|
// Build an options parser:
|
||||||
Pins::PinOptionsParser parser(options.begin(), options.end());
|
Pins::PinOptionsParser parser(options.begin(), options.end());
|
||||||
|
|
||||||
pin_debug("Attempting to set up pin: %s, index %d\r\n", prefix.c_str(), int(pinNumber));
|
pin_debug("Attempting to set up pin: %s, index %d", prefix.c_str(), int(pinNumber));
|
||||||
|
|
||||||
// Build this pin:
|
// Build this pin:
|
||||||
if (prefix == "gpio") {
|
if (prefix == "gpio") {
|
||||||
@@ -123,16 +116,20 @@ const char* Pin::parse(StringRange tmp, Pins::PinDetail*& pinImplementation) {
|
|||||||
pinImplementation = new Pins::I2SOPinDetail(uint8_t(pinNumber), parser);
|
pinImplementation = new Pins::I2SOPinDetail(uint8_t(pinNumber), parser);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if (prefix == "no_pin") {
|
||||||
|
pinImplementation = new Pins::VoidPinDetail();
|
||||||
|
}
|
||||||
|
|
||||||
if (prefix == "void") {
|
if (prefix == "void") {
|
||||||
// Note: having multiple void pins has its uses for debugging.
|
// Note: having multiple void pins has its uses for debugging.
|
||||||
pinImplementation = new Pins::VoidPinDetail();
|
pinImplementation = new Pins::VoidPinDetail();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pinImplementation == nullptr) {
|
if (pinImplementation == nullptr) {
|
||||||
pin_error("ERR: Unknown prefix: \"%s\"\r\n", prefix.c_str());
|
pin_error("ERR: Unknown prefix: \"%s\"", prefix.c_str());
|
||||||
return "Unknown pin prefix";
|
return "Unknown pin prefix";
|
||||||
} else {
|
} else {
|
||||||
#if DEBUG_PIN_DUMP
|
#ifdef DEBUG_PIN_DUMP
|
||||||
pinImplementation = new Pins::DebugPinDetail(pinImplementation);
|
pinImplementation = new Pins::DebugPinDetail(pinImplementation);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -147,7 +144,7 @@ Pin Pin::create(const String& str) {
|
|||||||
Pin Pin::create(const StringRange& str) {
|
Pin Pin::create(const StringRange& str) {
|
||||||
Pins::PinDetail* pinImplementation = nullptr;
|
Pins::PinDetail* pinImplementation = nullptr;
|
||||||
try {
|
try {
|
||||||
pin_debug("Setting up pin: [%s]\r\n", str.str().c_str());
|
pin_debug("Setting up pin: [%s]", str.str().c_str());
|
||||||
|
|
||||||
const char* err = parse(str, pinImplementation);
|
const char* err = parse(str, pinImplementation);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
Reference in New Issue
Block a user