Skip to content

Commit fecc587

Browse files
authored
Fix #21, documentation bug (#22)
- Fix #21, documentation bug
1 parent a17a0b1 commit fecc587

File tree

6 files changed

+22
-14
lines changed

6 files changed

+22
-14
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

88

9+
## [0.3.4] 2024-07-04
10+
- Fix #21, documentation bug
11+
912
## [0.3.3] 2024-05-25
1013
- add several interrupt functions (sync MCP23S17)
1114
- update **MCP23x08_registers.h** (reuse with MCP23008)

MCP23008.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// FILE: MCP23008.cpp
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.3.3
4+
// VERSION: 0.3.4
55
// PURPOSE: Arduino library for I2C MCP23008 8 channel port expander
66
// DATE: 2019-10-12
77
// URL: https://github.com/RobTillaart/MCP23008
@@ -63,6 +63,7 @@ uint8_t MCP23008::getAddress()
6363
//
6464
// pin = 0..7
6565
// mode = INPUT, OUTPUT, INPUT_PULLUP (= same as INPUT)
66+
// do NOT use 0 or 1 for mode
6667
bool MCP23008::pinMode1(uint8_t pin, uint8_t mode)
6768
{
6869
if (pin > 7)
@@ -269,10 +270,11 @@ bool MCP23008::getPullup(uint8_t pin, bool &pullup)
269270
// 8 pins interface
270271
//
271272
// whole register at once
272-
// value = 0..0xFF bit pattern
273-
bool MCP23008::pinMode8(uint8_t value)
273+
// mask = 0x00..0xFF bit pattern
274+
// bit 0 = output mode, bit 1 = input mode
275+
bool MCP23008::pinMode8(uint8_t mask)
274276
{
275-
writeReg(MCP23x08_DDR_A, value);
277+
writeReg(MCP23x08_DDR_A, mask);
276278
_error = MCP23008_OK;
277279
return true;
278280
}

MCP23008.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// FILE: MCP23008.h
44
// AUTHOR: Rob Tillaart
5-
// VERSION: 0.3.3
5+
// VERSION: 0.3.4
66
// PURPOSE: Arduino library for I2C MCP23008 8 channel port expander
77
// DATE: 2022-01-10
88
// URL: https://github.com/RobTillaart/MCP23008
@@ -13,7 +13,7 @@
1313
#include "MCP23x08_registers.h"
1414

1515

16-
#define MCP23008_LIB_VERSION (F("0.3.3"))
16+
#define MCP23008_LIB_VERSION (F("0.3.4"))
1717

1818
#define MCP23008_OK 0x00
1919
#define MCP23008_PIN_ERROR 0x81
@@ -35,7 +35,8 @@ class MCP23008
3535

3636

3737
// single pin interface
38-
// mode: 0 = OUTPUT, 1 = INPUT, 1 = INPUT_PULLUP (==INPUT)
38+
// mode = INPUT, OUTPUT, INPUT_PULLUP (= same as INPUT)
39+
// do not use 0, 1 for mode.
3940
bool pinMode1(uint8_t pin, uint8_t mode);
4041
bool write1(uint8_t pin, uint8_t value);
4142
uint8_t read1(uint8_t pin);
@@ -47,8 +48,10 @@ class MCP23008
4748

4849

4950
// 8 pins interface
50-
// value = bit pattern
51-
bool pinMode8(uint8_t value);
51+
// mask = 0x00..0xFF bit pattern,
52+
// bit 0 = output mode, bit 1 = input mode
53+
// value = bit pattern.
54+
bool pinMode8(uint8_t mask);
5255
bool write8(uint8_t value);
5356
int read8();
5457

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ Returns false if not connected or a register could not be set.
117117

118118
### Single pin interface
119119

120-
- **bool pinMode1(uint8_t pin, uint8_t mode)** pin = 0..7, mode = INPUT, OUTPUT.
121-
0xFF is all pins are input, 0x1F are 5 inputs and 3 outputs.
120+
- **bool pinMode1(uint8_t pin, uint8_t mode)** pin = 0..7, mode = INPUT, OUTPUT or INPUT_PULLUP.
121+
Do NOT use 0, 1 for mode as the 3 constants are (possibly) defined differently.
122122
Returns true if successful.
123123
- **bool write1(uint8_t pin, uint8_t value)** pin = 0..7, value = LOW(0) HIGH (!0). Returns true if successful.
124124
- **uint8_t read1(uint8_t pin)** pin = 0..7, returns LOW or HIGH, might set the lastError();
@@ -130,7 +130,7 @@ Returns true if successful.
130130

131131
### 8 pins interface
132132

133-
- **bool pinMode8(uint8_t value)** value = 0..255. Returns true if successful.
133+
- **bool pinMode8(uint8_t mask)** mask = 0..255. Returns true if successful.
134134
- **bool write8(uint8_t value)** value = 0..255. Returns true if successful.
135135
- **uint8_t read8()** reads 8 pins into one byte.
136136
- **bool setPolarity8(uint8_t mask)** sets polarity for 8 channels at once. Returns true if successful.

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"type": "git",
1616
"url": "https://github.com/RobTillaart/MCP23008.git"
1717
},
18-
"version": "0.3.3",
18+
"version": "0.3.4",
1919
"license": "MIT",
2020
"frameworks": "*",
2121
"platforms": "*",

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=MCP23008
2-
version=0.3.3
2+
version=0.3.4
33
author=Rob Tillaart <rob.tillaart@gmail.com>
44
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
55
sentence=Arduino library for I2C MCP23008 8 channel port expander 8 IO-lines

0 commit comments

Comments
 (0)