Skip to content

Commit 678d608

Browse files
committed
Merge branch 'feature-2.0'
2 parents 3bb35ca + 1337485 commit 678d608

File tree

8 files changed

+172
-151
lines changed

8 files changed

+172
-151
lines changed

.travis.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
language: c
22
env:
33
global:
4-
- ARDUINO_IDE_VERSION="1.8.5"
4+
- ARDUINO_IDE_VERSION="1.8.12"
5+
- ARDUINO_SAMD_VERSION="1.8.6"
6+
- STM32_STM32_VERSION="1.8.0"
57
- LIBRARY_NAME="MCP23017"
8+
matrix:
9+
- BOARD="arduino:avr:uno" CORE="" CORE_URL=""
10+
- BOARD="arduino:samd:nano_33_iot" CORE="arduino:samd:$ARDUINO_SAMD_VERSION" CORE_URL=""
11+
- BOARD="STM32:stm32:Nucleo_64" CORE="STM32:stm32:$STM32_STM32_VERSION" CORE_URL="https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json"
612
before_install:
713
- "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16"
814
- sleep 3
@@ -11,11 +17,14 @@ before_install:
1117
- tar xf arduino-$ARDUINO_IDE_VERSION-linux64.tar.xz
1218
- sudo mv arduino-$ARDUINO_IDE_VERSION /usr/local/share/arduino
1319
- sudo ln -s /usr/local/share/arduino/arduino /usr/local/bin/arduino
20+
- if [ $CORE_URL ]; then arduino --pref boardsmanager.additional.urls=$CORE_URL --save-prefs; fi
21+
- if [ $CORE ]; then arduino --install-boards $CORE; fi
1422
install:
1523
- ln -s $PWD /usr/local/share/arduino/libraries/$LIBRARY_NAME
1624
script:
17-
- arduino --verify --board arduino:avr:uno $PWD/examples/PortCopyOnInterrupt/PortCopyOnInterrupt.ino
18-
- arduino --verify --board arduino:avr:uno $PWD/examples/RegistersDumper/RegistersDumper.ino
25+
- arduino --verify --board $BOARD $PWD/examples/RegistersDumper/PortCopy.ino
26+
- arduino --verify --board $BOARD $PWD/examples/PortCopyOnInterrupt/PortCopyOnInterrupt.ino
27+
- arduino --verify --board $BOARD $PWD/examples/RegistersDumper/RegistersDumper.ino
1928
notifications:
2029
email:
2130
on_success: change

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,14 @@ MCP23017 mcp = MCP23017(0x24);
2222

2323
Additionaly, you can specify the `Wire` instance to use as a second argument. For instance `MCP23017(0x24, Wire1)`.
2424
See included examples for further usage.
25+
26+
## Remarks
27+
Major renames have been performed in v2.0.0 to improve compatibility with a variety of platforms. Existing code *will* break when you update from version v1.x.
28+
29+
| Name in v1.x | Name in v2.x |
30+
|-----------------------|---------------------------|
31+
| `MCP23017_PORT` | `MCP23017Port` |
32+
| `MCP23017_REGISTER` | `MCP23017Register` |
33+
| `MCP23017_INTMODE` | `MCP23017InterruptMode` |
34+
35+
In addition to this, every member of the `MCP23017Register` enum were renamed to avoid possible conflicts with macro definitions. `GPIOA` was renamed to `GPIO_A`, `INTCAPA` to `INTCAP_A` and so on...

examples/PortCopy/PortCopy.ino

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,21 @@ void setup() {
1818
Serial.begin(115200);
1919

2020
mcp.init();
21-
mcp.portMode(MCP23017_PORT::A, 0); //Port A as output
22-
mcp.portMode(MCP23017_PORT::B, 0b11111111); //Port B as input
21+
mcp.portMode(MCP23017Port::A, 0); //Port A as output
22+
mcp.portMode(MCP23017Port::B, 0b11111111); //Port B as input
2323

24-
mcp.writeRegister(MCP23017_REGISTER::GPIOA, 0x00); //Reset port A
25-
mcp.writeRegister(MCP23017_REGISTER::GPIOB, 0x00); //Reset port B
24+
mcp.writeRegister(MCP23017Register::GPIO_A, 0x00); //Reset port A
25+
mcp.writeRegister(MCP23017Register::GPIO_B, 0x00); //Reset port B
2626

27-
// GPIOB reflects the same logic as the input pins state
28-
mcp.writeRegister(MCP23017_REGISTER::IPOLB, 0x00);
27+
// GPIO_B reflects the same logic as the input pins state
28+
mcp.writeRegister(MCP23017Register::IPOL_B, 0x00);
2929
// Uncomment this line to invert inputs (press a button to lit a led)
30-
//mcp.writeRegister(MCP23017_REGISTER::IPOLB, 0xFF);
30+
//mcp.writeRegister(MCP23017Register::IPOL_B, 0xFF);
3131
}
3232

3333
void loop() {
3434
uint8_t currentB;
3535

36-
currentB = mcp.readPort(MCP23017_PORT::B);
37-
mcp.writePort(MCP23017_PORT::A, currentB);
36+
currentB = mcp.readPort(MCP23017Port::B);
37+
mcp.writePort(MCP23017Port::A, currentB);
3838
}

examples/PortCopyOnInterrupt/PortCopyOnInterrupt.ino

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ void setup() {
2424
Serial.begin(115200);
2525

2626
mcp.init();
27-
mcp.portMode(MCP23017_PORT::A, 0); //Port A as output
28-
mcp.portMode(MCP23017_PORT::B, 0b11111111); //Port B as input
27+
mcp.portMode(MCP23017Port::A, 0); //Port A as output
28+
mcp.portMode(MCP23017Port::B, 0b11111111); //Port B as input
2929

30-
mcp.interruptMode(MCP23017_INTMODE::SEPARATED);
31-
mcp.interrupt(MCP23017_PORT::B, FALLING);
30+
mcp.interruptMode(MCP23017InterruptMode::Separated);
31+
mcp.interrupt(MCP23017Port::B, FALLING);
3232

33-
mcp.writeRegister(MCP23017_REGISTER::IPOLA, 0x00);
34-
mcp.writeRegister(MCP23017_REGISTER::IPOLB, 0x00);
33+
mcp.writeRegister(MCP23017Register::IPOL_A, 0x00);
34+
mcp.writeRegister(MCP23017Register::IPOL_B, 0x00);
3535

36-
mcp.writeRegister(MCP23017_REGISTER::GPIOA, 0x00);
37-
mcp.writeRegister(MCP23017_REGISTER::GPIOB, 0x00);
36+
mcp.writeRegister(MCP23017Register::GPIO_A, 0x00);
37+
mcp.writeRegister(MCP23017Register::GPIO_B, 0x00);
3838

3939
mcp.clearInterrupts();
4040

@@ -63,11 +63,11 @@ void loop() {
6363
// this is the state of the port the moment the interrupt was triggered
6464
mcp.clearInterrupts(captureA, captureB);
6565
// this is the state of the B port right now, after the delay to act as debouncing
66-
currentB = mcp.readPort(MCP23017_PORT::B);
66+
currentB = mcp.readPort(MCP23017Port::B);
6767

6868
if((b & ~currentB) == (b & ~captureB)) {
6969
// the pin that triggered the interrupt is still in the same state after the deboucing delay
70-
currentA = mcp.readPort(MCP23017_PORT::A);
71-
mcp.writeRegister(MCP23017_REGISTER::GPIOA, currentA ^ b);
70+
currentA = mcp.readPort(MCP23017Port::A);
71+
mcp.writeRegister(MCP23017Register::GPIO_A, currentA ^ b);
7272
}
7373
}

examples/RegistersDumper/RegistersDumper.ino

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -9,57 +9,57 @@ void setup() {
99

1010
Serial.begin(115200);
1111

12-
uint8_t conf = mcp.readRegister(MCP23017_REGISTER::IODIRA);
13-
Serial.print("IODIRA : ");
12+
uint8_t conf = mcp.readRegister(MCP23017Register::IODIR_A);
13+
Serial.print("IODIR_A : ");
1414
Serial.print(conf, BIN);
1515
Serial.println();
1616

17-
conf = mcp.readRegister(MCP23017_REGISTER::IODIRB);
18-
Serial.print("IODIRB : ");
17+
conf = mcp.readRegister(MCP23017Register::IODIR_B);
18+
Serial.print("IODIR_B : ");
1919
Serial.print(conf, BIN);
2020
Serial.println();
2121

22-
conf = mcp.readRegister(MCP23017_REGISTER::IPOLA);
23-
Serial.print("IPOLA : ");
22+
conf = mcp.readRegister(MCP23017Register::IPOL_A);
23+
Serial.print("IPOL_A : ");
2424
Serial.print(conf, BIN);
2525
Serial.println();
2626

27-
conf = mcp.readRegister(MCP23017_REGISTER::IPOLB);
28-
Serial.print("IPOLB : ");
27+
conf = mcp.readRegister(MCP23017Register::IPOL_B);
28+
Serial.print("IPOL_B : ");
2929
Serial.print(conf, BIN);
3030
Serial.println();
3131

32-
conf = mcp.readRegister(MCP23017_REGISTER::GPINTENA);
33-
Serial.print("GPINTENA : ");
32+
conf = mcp.readRegister(MCP23017Register::GPINTEN_A);
33+
Serial.print("GPINTEN_A : ");
3434
Serial.print(conf, BIN);
3535
Serial.println();
3636

37-
conf = mcp.readRegister(MCP23017_REGISTER::GPINTENB);
38-
Serial.print("GPINTENB : ");
37+
conf = mcp.readRegister(MCP23017Register::GPINTEN_B);
38+
Serial.print("GPINTEN_B : ");
3939
Serial.print(conf, BIN);
4040
Serial.println();
4141

42-
conf = mcp.readRegister(MCP23017_REGISTER::DEFVALA);
43-
Serial.print("DEFVALA : ");
42+
conf = mcp.readRegister(MCP23017Register::DEFVAL_A);
43+
Serial.print("DEFVAL_A : ");
4444
Serial.print(conf, BIN);
4545
Serial.println();
4646

47-
conf = mcp.readRegister(MCP23017_REGISTER::DEFVALB);
48-
Serial.print("DEFVALB : ");
47+
conf = mcp.readRegister(MCP23017Register::DEFVAL_B);
48+
Serial.print("DEFVAL_B : ");
4949
Serial.print(conf, BIN);
5050
Serial.println();
5151

52-
conf = mcp.readRegister(MCP23017_REGISTER::INTCONA);
53-
Serial.print("INTCONA : ");
52+
conf = mcp.readRegister(MCP23017Register::INTCON_A);
53+
Serial.print("INTCON_A : ");
5454
Serial.print(conf, BIN);
5555
Serial.println();
5656

57-
conf = mcp.readRegister(MCP23017_REGISTER::INTCONB);
58-
Serial.print("INTCONB : ");
57+
conf = mcp.readRegister(MCP23017Register::INTCON_B);
58+
Serial.print("INTCON_B : ");
5959
Serial.print(conf, BIN);
6060
Serial.println();
6161

62-
conf = mcp.readRegister(MCP23017_REGISTER::IOCON);
62+
conf = mcp.readRegister(MCP23017Register::IOCON);
6363
Serial.print("IOCON : ");
6464
Serial.print(conf, BIN);
6565
Serial.println();
@@ -69,55 +69,56 @@ void setup() {
6969
//Serial.print(conf, BIN);
7070
//Serial.println();
7171

72-
conf = mcp.readRegister(MCP23017_REGISTER::GPPUA);
73-
Serial.print("GPPUA : ");
72+
conf = mcp.readRegister(MCP23017Register::GPPU_A);
73+
Serial.print("GPPU_A : ");
7474
Serial.print(conf, BIN);
7575
Serial.println();
7676

77-
conf = mcp.readRegister(MCP23017_REGISTER::GPPUB);
78-
Serial.print("GPPUB : ");
77+
conf = mcp.readRegister(MCP23017Register::GPPU_B);
78+
Serial.print("GPPU_B : ");
7979
Serial.print(conf, BIN);
8080
Serial.println();
8181

82-
conf = mcp.readRegister(MCP23017_REGISTER::INTFA);
83-
Serial.print("INTFA : ");
82+
conf = mcp.readRegister(MCP23017Register::INTF_A);
83+
Serial.print("INTF_A : ");
8484
Serial.print(conf, BIN);
8585
Serial.println();
8686

87-
conf = mcp.readRegister(MCP23017_REGISTER::INTFB);
88-
Serial.print("INTFB : ");
87+
conf = mcp.readRegister(MCP23017Register::INTF_B);
88+
Serial.print("INTF_B : ");
8989
Serial.print(conf, BIN);
9090
Serial.println();
9191

92-
conf = mcp.readRegister(MCP23017_REGISTER::INTCAPA);
93-
Serial.print("INTCAPA : ");
92+
conf = mcp.readRegister(MCP23017Register::INTCAP_A);
93+
Serial.print("INTCAP_A : ");
9494
Serial.print(conf, BIN);
9595
Serial.println();
9696

97-
conf = mcp.readRegister(MCP23017_REGISTER::INTCAPB);
98-
Serial.print("INTCAPB : ");
97+
conf = mcp.readRegister(MCP23017Register::INTCAP_B);
98+
Serial.print("INTCAP_B : ");
9999
Serial.print(conf, BIN);
100100
Serial.println();
101101

102-
conf = mcp.readRegister(MCP23017_REGISTER::GPIOA);
103-
Serial.print("GPIOA : ");
102+
conf = mcp.readRegister(MCP23017Register::GPIO_A);
103+
Serial.print("GPIO_A : ");
104104
Serial.print(conf, BIN);
105105
Serial.println();
106106

107-
conf = mcp.readRegister(MCP23017_REGISTER::GPIOB);
108-
Serial.print("GPIOB : ");
107+
conf = mcp.readRegister(MCP23017Register::GPIO_B);
108+
Serial.print("GPIO_B : ");
109109
Serial.print(conf, BIN);
110110
Serial.println();
111111

112-
conf = mcp.readRegister(MCP23017_REGISTER::OLATA);
113-
Serial.print("OLATA : ");
112+
conf = mcp.readRegister(MCP23017Register::OLAT_A);
113+
Serial.print("OLAT_A : ");
114114
Serial.print(conf, BIN);
115115
Serial.println();
116116

117-
conf = mcp.readRegister(MCP23017_REGISTER::OLATB);
118-
Serial.print("OLATB : ");
117+
conf = mcp.readRegister(MCP23017Register::OLAT_B);
118+
Serial.print("OLAT_B : ");
119119
Serial.print(conf, BIN);
120120
Serial.println();
121+
121122
Serial.end();
122123
}
123124

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=MCP23017
2-
version=1.2.0
2+
version=2.0.0
33
author=Bertrand Lemasle
44
maintainer=Bertrand Lemasle
55
sentence=MCP23017 I2C Port expander library.

0 commit comments

Comments
 (0)