Skip to content

Commit

Permalink
add RP2040 to build-CI (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobTillaart authored Nov 21, 2022
1 parent 62937d6 commit 7c663cc
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 94 deletions.
19 changes: 18 additions & 1 deletion .arduino-ci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
platforms:
rpipico:
board: rp2040:rp2040:rpipico
package: rp2040:rp2040
gcc:
features:
defines:
- ARDUINO_ARCH_RP2040
warnings:
flags:

packages:
rp2040:rp2040:
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json

compile:
# Choosing to run compilation tests on 2 different Arduino platforms
platforms:
Expand All @@ -8,4 +23,6 @@ compile:
- m4
- esp32
# - esp8266
# - mega2560
# - mega2560
- rpipico

6 changes: 1 addition & 5 deletions .github/workflows/arduino_test_runner.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
---
name: Arduino CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
on: [push, pull_request]

jobs:
runTest:
Expand Down
63 changes: 20 additions & 43 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,75 +6,52 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [0.1.6] - 2022-06-18
## [0.1.6] - 2022-11-21
- add RP2040 to build-CI
- simplified changelog.md
- add interrupt section to readme.md
- update GitHub actions from v2 -> v3 (kudos to Thijs Triemstra)


### Added
## [0.1.6] - 2022-06-18
- add select(), selectN(), selectAll(), selectNone()
- update documentation


## [0.1.5] - 2022-04-11

### Added
- add CHANGELOG.md

### Changed

### Fixed
- **begin(int sda, int scl)** int parameters for ESP alike.
to keep in sync with PCF8574 library.

to keep this library in sync with PCF8574 library.

## [0.1.4] - 2021-12-23

### Changed
- update library.json, license, readme, minor edits

- update library.json
- update license
- update readme.md
- minor edits

## [0.1.3] - 2021-12-01

## Added
- add getButtonMask()

### Changed
- update build-CI, readme

- update build-CI
- update readme.md

## [0.1.2] - 2021-07-09

### Fixed
- fix #10 add set/getAddress() function

- fix #10 add set/getAddress()

## [0.1.1] - 2021-04-23

### Fixed
- fix for platformIO compatibility


## [0.1.0] - 2021-01-03

### Added
- add Arduino-CI + unit tests


----

## [0.0.3] - 2020-07-29

### Fixed
- fix #5 reverse() + refactor.
- fix #5 reverse()
- refactor.

## [0.0.2] - 2020-07-21

### Fixed
- fix reverse(); refactor;
- fix reverse()
- refactor;

## [0.0.1] - 2020-07-20

### Added
- initial version





95 changes: 71 additions & 24 deletions PCF8575.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,6 @@ uint16_t PCF8575::read16()
}


void PCF8575::write16(const uint16_t value)
{
_dataOut = value;
_wire->beginTransmission(_address);
_wire->write(_dataOut & 0xFF); // low 8 bits
_wire->write(_dataOut >> 8); // high 8 bits
_error = _wire->endTransmission();
}


uint8_t PCF8575::read(const uint8_t pin)
{
if (pin > 15)
Expand All @@ -105,6 +95,22 @@ uint8_t PCF8575::read(const uint8_t pin)
}


uint16_t PCF8575::value()
{
return _dataIn;
};


void PCF8575::write16(const uint16_t value)
{
_dataOut = value;
_wire->beginTransmission(_address);
_wire->write(_dataOut & 0xFF); // low 8 bits
_wire->write(_dataOut >> 8); // high 8 bits
_error = _wire->endTransmission();
}


void PCF8575::write(const uint8_t pin, const uint8_t value)
{
if (pin > 15)
Expand All @@ -124,6 +130,12 @@ void PCF8575::write(const uint8_t pin, const uint8_t value)
}


uint16_t PCF8575::valueOut()
{
return _dataOut;
}


void PCF8575::toggle(const uint8_t pin)
{
if (pin > 15)
Expand Down Expand Up @@ -160,14 +172,6 @@ void PCF8575::shiftLeft(const uint8_t n)
}


int PCF8575::lastError()
{
int e = _error;
_error = PCF8575_OK; // reset error after read, is this wise?
return e;
}


void PCF8575::rotateRight(const uint8_t n)
{
uint8_t r = n & 15;
Expand All @@ -183,9 +187,9 @@ void PCF8575::rotateLeft(const uint8_t n)
}


void PCF8575::reverse() // quite fast
void PCF8575::reverse() // quite fast
{ // 1 char === 1 bit
uint16_t x = _dataOut; // x = 0123456789ABCDEF
uint16_t x = _dataOut; // x = 0123456789ABCDEF
x = (((x & 0xAAAA) >> 1) | ((x & 0x5555) << 1)); // x = 1032547698BADCFE
x = (((x & 0xCCCC) >> 2) | ((x & 0x3333) << 2)); // x = 32107654BA98FEDC
x = (((x & 0xF0F0) >> 4) | ((x & 0x0F0F) << 4)); // x = 76543210FEDCBA98
Expand All @@ -194,7 +198,10 @@ void PCF8575::reverse() // quite fast
}


//added 0.1.07/08 Septillion
//////////////////////////////////////////////////
//
// added 0.1.07/08 Septillion
//
uint16_t PCF8575::readButton16(const uint16_t mask)
{
uint16_t temp = _dataOut;
Expand All @@ -205,7 +212,12 @@ uint16_t PCF8575::readButton16(const uint16_t mask)
}


//added 0.1.07 Septillion
uint16_t PCF8575::readButton16()
{
return readButton16(_buttonMask);
}


uint8_t PCF8575::readButton(const uint8_t pin)
{
if (pin > 15)
Expand All @@ -221,6 +233,22 @@ uint8_t PCF8575::readButton(const uint8_t pin)
}


void PCF8575::setButtonMask(uint16_t mask)
{
_buttonMask = mask;
};


uint16_t PCF8575::getButtonMask()
{
return _buttonMask;
};


//////////////////////////////////////////////////
//
// SELECT
//
void PCF8575::select(const uint8_t pin)
{
uint16_t n = 0x0000;
Expand All @@ -229,14 +257,33 @@ void PCF8575::select(const uint8_t pin)
};


void PCF8575::selectN(const uint8_t pin)
void PCF8575::selectN(const uint8_t pin)
{
uint16_t n = 0xFFFF;
if (pin < 16) n = (2L << pin) - 1;
write16(n);
};


void PCF8575::selectNone()
{
write16(0x0000);
};


void PCF8575::selectAll()
{
write16(0xFFFF);
};


int PCF8575::lastError()
{
int e = _error;
_error = PCF8575_OK; // reset error after read, is this wise?
return e;
}


// -- END OF FILE --
// -- END OF FILE --

35 changes: 17 additions & 18 deletions PCF8575.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
// FILE: PCF8575.h
// AUTHOR: Rob Tillaart
// DATE: 2020-07-20
// VERSION: 0.1.6
// VERSION: 0.1.7
// PURPOSE: Arduino library for PCF8575 - 16 channel I2C IO expander
// URL: https://github.com/RobTillaart/PCF8575
//


#include "Arduino.h"
#include "Wire.h"


#define PCF8575_LIB_VERSION (F("0.1.6"))
#define PCF8575_LIB_VERSION (F("0.1.7"))


#ifndef PCF8575_INITIAL_VALUE
Expand All @@ -28,7 +27,7 @@
class PCF8575
{
public:
// deviceAddress base = 0x20 + depends on address bits
// deviceAddress base = 0x20 + depends on address bits
explicit PCF8575(const uint8_t deviceAddress = 0x20, TwoWire *wire = &Wire);

#if defined (ESP8266) || defined(ESP32)
Expand All @@ -38,44 +37,44 @@ class PCF8575
bool isConnected();


// note: setting the address corrupt internal buffer values
// a read8() / write8() call updates them.
// note: setting the address may corrupt internal buffer values
// a read16() / write16() call updates them.
bool setAddress(const uint8_t deviceAddress);
uint8_t getAddress();
uint8_t getAddress();


uint16_t read16();
uint8_t read(uint8_t pin);
uint16_t value() const { return _dataIn; };
uint16_t value();


void write16(const uint16_t value);
void write(const uint8_t pin, const uint8_t value);
uint16_t valueOut() const { return _dataOut; }
uint16_t valueOut();


// added 0.1.07/08 Septillion
uint16_t readButton16() { return readButton16(_buttonMask); }
uint16_t readButton16();
uint16_t readButton16(const uint16_t mask);
uint8_t readButton(const uint8_t pin);
void setButtonMask(uint16_t mask) { _buttonMask = mask; };
uint16_t getButtonMask() { return _buttonMask; };
void setButtonMask(uint16_t mask);
uint16_t getButtonMask();


// rotate, shift, toggle, reverse expect all lines are output
// rotate, shift, toggle, reverse expect all lines are output
void toggle(const uint8_t pin);
void toggleMask(const uint16_t mask = 0xFFFF); // default invertAll()
void toggleMask(const uint16_t mask = 0xFFFF); // 0xFFFF == invertAll()
void shiftRight(const uint8_t n = 1);
void shiftLeft(const uint8_t n = 1);
void rotateRight(const uint8_t n = 1);
void rotateLeft(const uint8_t n = 1);
void reverse();


void select(const uint8_t pin);
void selectN(const uint8_t pin);
void selectNone() { write16(0x0000); };
void selectAll() { write16(0xFFFF); };
void select(const uint8_t pin);
void selectN(const uint8_t pin);
void selectNone();
void selectAll();


int lastError();
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/PCF8575.git"
},
"version": "0.1.6",
"version": "0.1.7",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*",
Expand Down
Loading

0 comments on commit 7c663cc

Please sign in to comment.