mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-09-02 19:02:35 +02:00
Changed ISR registration in ControlPin to class member registration.
This commit is contained in:
@@ -8,15 +8,12 @@
|
||||
void IRAM_ATTR ControlPin::handleISR() {
|
||||
bool pinState = _pin.read();
|
||||
_value = pinState;
|
||||
|
||||
if (_rtVariable) {
|
||||
*_rtVariable = pinState;
|
||||
}
|
||||
}
|
||||
|
||||
void /* IRAM_ATTR */ ControlPin::handle_control_pin(void* arg) {
|
||||
((ControlPin*)arg)->handleISR();
|
||||
}
|
||||
|
||||
void ControlPin::init() {
|
||||
if (_pin.defined()) {
|
||||
grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "%s switch on pin %s", _legend, _pin.name());
|
||||
@@ -25,6 +22,6 @@ void ControlPin::init() {
|
||||
attr = attr | Pin::Attr::PullUp;
|
||||
}
|
||||
_pin.setAttr(attr);
|
||||
_pin.attachInterrupt(ControlPin::handle_control_pin, CHANGE, (void*)this);
|
||||
_pin.attachInterrupt<ControlPin, &ControlPin::handleISR>(this, CHANGE);
|
||||
}
|
||||
}
|
||||
|
@@ -6,19 +6,20 @@ class ControlPin {
|
||||
private:
|
||||
// invertBitNum refers to a bit in INVERT_CONTROL_PIN_MASK. It is a
|
||||
// short-term hack to reduce the extent of the patch.
|
||||
bool _invertBitNum;
|
||||
bool _value;
|
||||
const char _letter;
|
||||
volatile bool* _rtVariable;
|
||||
const char* _legend;
|
||||
void IRAM_ATTR handleISR();
|
||||
static void /* IRAM_ATTR */ handle_control_pin(void* arg);
|
||||
bool _invertBitNum;
|
||||
bool _value;
|
||||
const char _letter;
|
||||
volatile bool* _rtVariable;
|
||||
const char* _legend;
|
||||
|
||||
void IRAM_ATTR handleISR();
|
||||
|
||||
public:
|
||||
ControlPin(uint8_t bitNum, volatile bool* rtVariable, const char* legend, char letter) :
|
||||
_invertBitNum(bitNum), _value(false), _letter(letter), _rtVariable(rtVariable), _legend(legend) {}
|
||||
|
||||
Pin _pin;
|
||||
Pin _pin;
|
||||
|
||||
bool get() { return _value; }
|
||||
const char* legend() { return _legend; }
|
||||
// char invertBitNum() { return _invertBitNum; }
|
||||
|
Reference in New Issue
Block a user