File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -150,6 +150,25 @@ uint16_t Adafruit_MCP23017::readGPIOAB() {
150150 return ba;
151151}
152152
153+ /* *
154+ * Read a single port, A or B, and return its current 8 bit value.
155+ * Parameter b should be 0 for GPIOA, and 1 for GPIOB.
156+ */
157+ uint8_t Adafruit_MCP23017::readGPIO (uint8_t b) {
158+
159+ // read the current GPIO output latches
160+ Wire.beginTransmission (MCP23017_ADDRESS | i2caddr);
161+ if (b == 0 )
162+ wiresend (MCP23017_GPIOA);
163+ else {
164+ wiresend (MCP23017_GPIOB);
165+ }
166+ Wire.endTransmission ();
167+
168+ Wire.requestFrom (MCP23017_ADDRESS | i2caddr, 1 );
169+ return wirerecv ();
170+ }
171+
153172/* *
154173 * Writes all the pins in one go. This method is very useful if you are implementing a multiplexed matrix and want to get a decent refresh rate.
155174 */
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ class Adafruit_MCP23017 {
2727
2828 void writeGPIOAB (uint16_t );
2929 uint16_t readGPIOAB ();
30+ uint8_t readGPIO (uint8_t b);
3031
3132 void setupInterrupts (uint8_t mirroring, uint8_t open, uint8_t polarity);
3233 void setupInterruptPin (uint8_t p, uint8_t mode);
You can’t perform that action at this time.
0 commit comments