Skip to content

Commit

Permalink
Fix #17, add parameter to begin(pullup)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobTillaart committed Mar 2, 2024
1 parent e897960 commit 68bbf8b
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/arduino-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: arduino/arduino-lint-action@v1
with:
library-manager: update
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/arduino_test_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/jsoncheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: json-syntax-check
uses: limitusus/json-syntax-check@v1
with:
Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [0.3.2] 2024-03-02
- Fix #17, add parameter to **begin(bool pullup)**
- remove DATE field from examples as it adds no value.
- update GitHub/actions to version v4 in workflows.


## [0.3.1] - 2024-01-05
- add URL to examples
- minor edits


## [0.3.0] - 2023-12-24
- Fix #14, support for Arduino ESP32 S3 - breaking change
- update readme.md
Expand Down
11 changes: 7 additions & 4 deletions MCP23008.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// FILE: MCP23008.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.3.1
// VERSION: 0.3.2
// PURPOSE: Arduino library for I2C MCP23008 8 channel port expander
// DATE: 2019-10-12
// URL: https://github.com/RobTillaart/MCP23008
Expand Down Expand Up @@ -32,14 +32,17 @@ MCP23008::MCP23008(uint8_t address, TwoWire *wire)
}


bool MCP23008::begin()
bool MCP23008::begin(bool pullup)
{
// check connected
if (! isConnected()) return false;
// disable address increment (datasheet)
if (! writeReg(MCP23008_IOCR, 0b00100000)) return false;
// Force INPUT_PULLUP
if (! writeReg(MCP23008_PUR_A, 0xFF)) return false;
if (pullup)
{
// Force INPUT_PULLUP
if (! writeReg(MCP23008_PUR_A, 0xFF)) return false;
}
return true;
}

Expand Down
6 changes: 3 additions & 3 deletions MCP23008.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// FILE: MCP23008.h
// AUTHOR: Rob Tillaart
// VERSION: 0.3.1
// VERSION: 0.3.2
// PURPOSE: Arduino library for I2C MCP23008 8 channel port expander
// DATE: 2022-01-10
// URL: https://github.com/RobTillaart/MCP23008
Expand All @@ -12,7 +12,7 @@
#include "Wire.h"


#define MCP23008_LIB_VERSION (F("0.3.1"))
#define MCP23008_LIB_VERSION (F("0.3.2"))

#define MCP23008_OK 0x00
#define MCP23008_PIN_ERROR 0x81
Expand All @@ -29,7 +29,7 @@ class MCP23008
public:
MCP23008(uint8_t address, TwoWire *wire = &Wire);

bool begin();
bool begin(bool pullup = true);
bool isConnected();
uint8_t getAddress();

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ before calling **begin()**.

- **MCP23008(uint8_t address, TwoWire \*wire = &Wire)** constructor, with default Wire interface.
Can be overruled with Wire0..WireN.
- **bool begin()** initializes library. Returns true upon success.
- **bool begin(bool pullup = true)** initializes library, returns true if successful.
Default sets the pins to INPUT PULLUP.
Returns false if not connected or a register could not be set.
- **bool isConnected()** returns true if connected, false otherwise.
- **uint8_t getAddress()** returns address set in the constructor.

Expand Down
1 change: 0 additions & 1 deletion examples/MCP23008_digitalRead/MCP23008_digitalRead.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//
// FILE: MCP23008_digitalRead.ino
// AUTHOR: Rob Tillaart
// DATE: 2019-10-14
// PURPOSE: test MCP23008 library
// URL: https://github.com/RobTillaart/MCP23008

Expand Down
1 change: 0 additions & 1 deletion examples/MCP23008_digitalWrite/MCP23008_digitalWrite.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//
// FILE: MCP23008_digitalWrite.ino
// AUTHOR: Rob Tillaart
// DATE: 2019-10-14
// PURPOSE: test MCP23008 library
// URL: https://github.com/RobTillaart/MCP23008

Expand Down
1 change: 0 additions & 1 deletion examples/MCP23008_performance/MCP23008_performance.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//
// FILE: MCP23008_performance.ino
// AUTHOR: Rob Tillaart
// DATE: 2022-01-09
// PURPOSE: test MCP23008 library
// URL: https://github.com/RobTillaart/MCP23008

Expand Down
1 change: 0 additions & 1 deletion examples/MCP23008_test/MCP23008_test.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//
// FILE: MCP23008_test.ino
// AUTHOR: Rob Tillaart
// DATE: 2023-06-20
// PURPOSE: test MCP23008 library
// URL: https://github.com/RobTillaart/MCP23008

Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/MCP23008.git"
},
"version": "0.3.1",
"version": "0.3.2",
"license": "MIT",
"frameworks": "*",
"platforms": "*",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=MCP23008
version=0.3.1
version=0.3.2
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for I2C MCP23008 8 channel port expander 8 IO-lines
Expand Down

0 comments on commit 68bbf8b

Please sign in to comment.