1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-09-02 02:42:36 +02:00

Report attributes in pin names

This commit is contained in:
Mitch Bradley
2021-05-28 09:20:07 -10:00
parent c92ef9d9c1
commit f0d2feb901
10 changed files with 35 additions and 32 deletions

View File

@@ -57,7 +57,7 @@ namespace Pins {
void attachInterrupt(void (*callback)(void*), void* arg, int mode) override;
void detachInterrupt() override;
String toString() const override { return _implementation->toString(); }
String toString() override { return _implementation->toString(); }
~DebugPinDetail() override {}
};

View File

@@ -30,5 +30,5 @@ namespace Pins {
}
PinAttributes ErrorPinDetail::getAttr() const { return PinAttributes::None; }
String ErrorPinDetail::toString() const { return "ERROR_PIN"; }
String ErrorPinDetail::toString() { return "ERROR_PIN"; }
}

View File

@@ -34,7 +34,7 @@ namespace Pins {
void setAttr(PinAttributes value) override;
PinAttributes getAttr() const override;
String toString() const override;
String toString() override;
~ErrorPinDetail() override {}
};

View File

@@ -119,12 +119,8 @@ namespace Pins {
}
}
// Update the R/W mask for ActiveLow setting
if (_attributes.has(PinAttributes::ActiveLow)) {
_readWriteMask = HIGH;
} else {
_readWriteMask = LOW;
}
// readWriteMask is xor'ed with the value to invert it if active low
_readWriteMask = _attributes.has(PinAttributes::ActiveLow);
}
PinAttributes GPIOPinDetail::getAttr() const { return _attributes; }
@@ -172,11 +168,7 @@ namespace Pins {
// If the pin is ActiveLow, we should take that into account here:
if (value.has(PinAttributes::Output)) {
if (value.has(PinAttributes::InitialOn)) {
__digitalWrite(_index, HIGH ^ _readWriteMask);
} else {
__digitalWrite(_index, LOW ^ _readWriteMask);
}
__digitalWrite(_index, value.has(PinAttributes::InitialOn) ^ _readWriteMask);
}
__pinMode(_index, pinModeValue);
@@ -194,5 +186,18 @@ namespace Pins {
::detachInterrupt(_index);
}
String GPIOPinDetail::toString() const { return String("GPIO.") + int(_index); }
String GPIOPinDetail::toString() {
auto s = String("gpio.") + int(_index);
if (_attributes.has(PinAttributes::ActiveLow)) {
s += ":low";
}
if (_attributes.has(PinAttributes::PullUp)) {
s += ":pu";
}
if (_attributes.has(PinAttributes::PullDown)) {
s += ":pd";
}
return s;
}
}

View File

@@ -43,7 +43,7 @@ namespace Pins {
void attachInterrupt(void (*callback)(void*), void* arg, int mode) override;
void detachInterrupt() override;
String toString() const override;
String toString() override;
~GPIOPinDetail() override {}
};

View File

@@ -39,12 +39,8 @@ namespace Pins {
}
}
// Update the R/W mask for ActiveLow setting
if (_attributes.has(PinAttributes::ActiveLow)) {
_readWriteMask = HIGH;
} else {
_readWriteMask = LOW;
}
// readWriteMask is xor'ed with the value to invert it if active low
_readWriteMask = _attributes.has(PinAttributes::ActiveLow);
}
PinCapabilities I2SOPinDetail::capabilities() const { return PinCapabilities::Output | PinCapabilities::I2S; }
@@ -72,16 +68,18 @@ namespace Pins {
// just check for conflicts above...
// If the pin is ActiveLow, we should take that into account here:
if (value.has(PinAttributes::InitialOn)) {
i2s_out_write(_index, HIGH ^ _readWriteMask);
} else {
i2s_out_write(_index, LOW ^ _readWriteMask);
}
i2s_out_write(_index, value.has(PinAttributes::InitialOn) ^ _readWriteMask);
}
PinAttributes I2SOPinDetail::getAttr() const { return _attributes; }
String I2SOPinDetail::toString() const { return String("I2SO.") + int(_index); }
String I2SOPinDetail::toString() {
auto s = String("I2SO.") + int(_index);
if (_attributes.has(PinAttributes::ActiveLow)) {
s += ":low";
}
return s;
}
}
#endif

View File

@@ -38,7 +38,7 @@ namespace Pins {
void setAttr(PinAttributes value) override;
PinAttributes getAttr() const override;
String toString() const override;
String toString() override;
~I2SOPinDetail() override {}
};

View File

@@ -52,7 +52,7 @@ namespace Pins {
virtual void attachInterrupt(void (*callback)(void*), void* arg, int mode);
virtual void detachInterrupt();
virtual String toString() const = 0;
virtual String toString() = 0;
inline int number() const { return _index; }

View File

@@ -32,6 +32,6 @@ namespace Pins {
void VoidPinDetail::setAttr(PinAttributes value) {}
PinAttributes VoidPinDetail::getAttr() const { return PinAttributes::None; }
String VoidPinDetail::toString() const { return ""; }
String VoidPinDetail::toString() { return ""; }
}

View File

@@ -35,7 +35,7 @@ namespace Pins {
void setAttr(PinAttributes value) override;
PinAttributes getAttr() const override;
String toString() const override;
String toString() override;
~VoidPinDetail() override {}
};