Closed pspastushkov closed 5 years ago
Hi,
Sorry about the delay, your issue came at the same time I moved house and it's been a crazy week. Hopefully I'll be able to have a look a the it tomorrow.
Regards
Hi,
Again, sorry for the delay. I'm having trouble understand your issue. You're setting the IOPOLA
& IOPOLB
registers to 0xFF
to invert the reflected state on the pins. By the way, you could have used either of those two solutions for readability ;)
mcp23017_0x20.writeRegister(MCP23017_REGISTER::IOPOLA, 0xff)
mcp23017_0x20.writeRegister(MCP23017_REGISTER::IOPOLB, 0xff)
//or
mcp23017_0x20.writeRegister(MCP23017_REGISTER::IOPOLA, 0xff, 0xff)
What you're saying is in that case, digitalRead(x)
is true
when a signal is applied to the first pin of x
corresponding port. Am I getting this right ?
Since you set IOPOL
, we both agree that
pin2 = LOW 10000100 10000100
Means that pin 2, 7, 10 and 15 are actually low and everything else is high, right ?
GCC complains with: .pio/libdeps/nodemcuv2/MCP23017_ID6001/src/MCP23017.cpp:75:10: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses] if(gpio & _BV(pin) == _BV(pin)) return HIGH;
https://github.com/blemasle/arduino-mcp23017/blob/master/src/MCP23017.cpp#L75
I think it should be:
if((gpio & _BV(pin)) == _BV(pin)) return HIGH;
You (and GCC) are absolutely right. I'll change it as soon as possible !
Thank you !
Hi!
program code
COM port monitor
When inverted ports with any choice of pin (0-7 / 8-15), the condition is triggered when a signal is applied to 0 or 8, respectively. Help me!
Pavel