0.1.3 MCP23008

This commit is contained in:
rob tillaart 2023-02-04 14:40:35 +01:00
parent 0c52a748b9
commit 4d40c33c0b
11 changed files with 50 additions and 22 deletions

View File

@ -6,7 +6,7 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: arduino/arduino-lint-action@v1
with:
library-manager: update

View File

@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6

View File

@ -10,7 +10,7 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: json-syntax-check
uses: limitusus/json-syntax-check@v1
with:

View File

@ -6,13 +6,19 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.1.3] - 2023-02-04
- update readme.md
- update GitHub actions
- update license 2023
- minor edits
## [0.1.2] - 2022-11-17
- add RP2040 in build-CI
- add changelog.md
- minor edit readme.md
- update datasheet page numbers of registers MCP23008.cpp
## [0.1.1] - 2022-09-28
- optimize digitalWrite() - as that is the most used one

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2022-2022 Rob Tillaart
Copyright (c) 2022-2023 Rob Tillaart
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,7 +1,7 @@
//
// FILE: MCP23008.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.1.2
// VERSION: 0.1.3
// PURPOSE: Arduino library for I2C MCP23008 8 channel port expander
// DATE: 2019-10-12
// URL: https://github.com/RobTillaart/MCP23008
@ -97,7 +97,7 @@ bool MCP23008::pinMode(uint8_t pin, uint8_t mode)
return false;
}
uint8_t mask = 1 << pin;
// only work with valid
// only work with valid
if ((mode == INPUT) || (mode == INPUT_PULLUP))
{
val |= mask;
@ -106,7 +106,7 @@ bool MCP23008::pinMode(uint8_t pin, uint8_t mode)
{
val &= ~mask;
}
// other values won't change val ....
// other values won't change val ....
writeReg(dataDirectionRegister, val);
if (_error != MCP23008_OK)
{
@ -362,8 +362,8 @@ int MCP23008::lastError()
////////////////////////////////////////////////////
//
// PRIVATE
//
// PRIVATE
//
bool MCP23008::writeReg(uint8_t reg, uint8_t value)
{
@ -403,5 +403,5 @@ uint8_t MCP23008::readReg(uint8_t reg)
}
// -- END OF FILE --
// -- END OF FILE --

View File

@ -2,8 +2,8 @@
//
// FILE: MCP23008.h
// AUTHOR: Rob Tillaart
// VERSION: 0.1.2
// PURPOSE: Arduino library for I2C MCP23008 16 channel port expander
// VERSION: 0.1.3
// PURPOSE: Arduino library for I2C MCP23008 8 channel port expander
// DATE: 2022-01-10
// URL: https://github.com/RobTillaart/MCP23008
@ -12,7 +12,7 @@
#include "Wire.h"
#define MCP23008_LIB_VERSION (F("0.1.2"))
#define MCP23008_LIB_VERSION (F("0.1.3"))
#define MCP23008_OK 0x00
#define MCP23008_PIN_ERROR 0x81
@ -72,5 +72,5 @@ private:
};
// -- END OF FILE --
// -- END OF FILE --

View File

@ -22,8 +22,28 @@ Since 0.1.1 the **digitalWrite(pin, value)** is optimized.
If a pin is not changed it will not be written again to save time.
#### Related
16 bit port expanders
- https://github.com/RobTillaart/MCP23017_RT
- https://github.com/RobTillaart/MCP23S17
- https://github.com/RobTillaart/PCF8575
8 bit port expanders
- https://github.com/RobTillaart/MCP23008
- https://github.com/RobTillaart/MCP23S08
- https://github.com/RobTillaart/PCF8574
## Interface
```cpp
#include "MCP23008.h"
```
### Constructor
- **MCP23008(uint8_t address, TwoWire \*wire = &Wire)** constructor, with default Wire interface.

View File

@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/MCP23008.git"
},
"version": "0.1.2",
"version": "0.1.3",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*",

View File

@ -1,5 +1,5 @@
name=MCP23008
version=0.1.2
version=0.1.3
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

View File

@ -58,7 +58,7 @@ unittest(test_constants)
}
// TODO more tests if godmode->wire works
// TODO more tests if godmode->wire works
unittest(test_constructor)
{
Wire.resetMocks();
@ -67,7 +67,7 @@ unittest(test_constructor)
assertFalse(Wire.didBegin());
MCP.begin();
// in fact invalid ...
// in fact invalid ...
assertTrue(Wire.didBegin());
assertTrue(MCP.isConnected());
}
@ -81,7 +81,7 @@ unittest(test_lastError)
MCP.begin();
assertEqual(MCP23008_OK, MCP.lastError());
// MCP23008_PIN_ERROR
// MCP23008_PIN_ERROR
MCP.pinMode(8, INPUT);
assertEqual(MCP23008_PIN_ERROR, MCP.lastError());
assertEqual(MCP23008_OK, MCP.lastError());
@ -95,7 +95,7 @@ unittest(test_lastError)
assertEqual(MCP23008_OK, MCP.lastError());
// MCP23008_VALUE_ERROR - 3 is not INPUT, INPUT_PULLUP, OUTPUT)
// MCP23008_VALUE_ERROR - 3 is not INPUT, INPUT_PULLUP, OUTPUT)
MCP.pinMode(0, 3);
assertEqual(MCP23008_VALUE_ERROR, MCP.lastError());
assertEqual(MCP23008_OK, MCP.lastError());
@ -104,4 +104,6 @@ unittest(test_lastError)
unittest_main()
// --------
// --END OF FILE --