0.4.0 PCA9553

This commit is contained in:
Rob Tillaart 2023-12-27 19:18:13 +01:00
parent 00b27bd80a
commit eb2c780787
12 changed files with 63 additions and 34 deletions

View File

@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.4.0] - 2023-12-27
- Fix #6, support for Arduino ESP32 S3 - breaking change
- update readme.md
- update examples.
----
## [0.3.0] - 2023-12-11
- refactor API, begin();
- update readme.md;

View File

@ -2,7 +2,7 @@
// FILE: PCA9553.cpp
// AUTHOR: Rob Tillaart
// DATE: 2023-07-16
// VERSION: 0.3.0
// VERSION: 0.4.0
// PURPOSE: Arduino library for for I2C PCA9553 4 channel PWM
// URL: https://github.com/RobTillaart/PCA9553
@ -75,20 +75,20 @@ uint8_t PCA9553::getInput()
}
void PCA9553::pinMode(uint8_t pin, uint8_t mode)
void PCA9553::pinMode1(uint8_t pin, uint8_t mode)
{
if (mode != OUTPUT) setOutputMode(pin, PCA9553_MODE_HIGH);
}
void PCA9553::digitalWrite(uint8_t pin, uint8_t val)
void PCA9553::write1(uint8_t pin, uint8_t val)
{
if (val == LOW) setOutputMode(pin, PCA9553_MODE_LOW);
else setOutputMode(pin, PCA9553_MODE_HIGH);
}
uint8_t PCA9553::digitalRead(uint8_t pin)
uint8_t PCA9553::read1(uint8_t pin)
{
uint8_t value = readReg(PCA9553_INPUT);
if ((value >> pin) & 0x01) return HIGH;

View File

@ -3,7 +3,7 @@
// FILE: PCA9553.h
// AUTHOR: Rob Tillaart
// DATE: 2023-07-16
// VERSION: 0.3.0
// VERSION: 0.4.0
// PUPROSE: Arduino library for for I2C PCA9553 4 channel PWM
// URL: https://github.com/RobTillaart/PCA9553
@ -12,7 +12,7 @@
#include "Wire.h"
#define PCA9553_LIB_VERSION (F("0.3.0"))
#define PCA9553_LIB_VERSION (F("0.4.0"))
// REGISTERS
@ -59,9 +59,9 @@ public:
// GPIO
uint8_t getInput();
void pinMode(uint8_t pin, uint8_t mode);
void digitalWrite(uint8_t pin, uint8_t value);
uint8_t digitalRead(uint8_t pin);
void pinMode1(uint8_t pin, uint8_t mode);
void write1(uint8_t pin, uint8_t value);
uint8_t read1(uint8_t pin);
// PRESCALERS
void setPrescaler(uint8_t generator, uint8_t prescaler = 0);

View File

@ -40,6 +40,28 @@ Power-On Reset (POR) initializes the registers to their default state,
all zeroes, causing the bits to be set HIGH (LED off).
#### 0.4.0 Breaking change
The version 0.4.0 has breaking changes in the interface.
The rationale is that the programming environment of the **Arduino ESP32 S3**
board uses a remapping by means of the include file **io_pin_remap.h**.
This file remaps the pins of several core Arduino functions.
The remapping is implemented by #define macros and these implement "hard" text
replacements without considering context.
The effect is that methods from this class (and several others) which have the same
name as those Arduino core functions will be remapped into something not working.
The following library functions have been renamed:
| old name | new name | notes |
|:-----------------|:-------------|:--------|
| analogRead() | read() |
| analogWrite() | write() |
| pinMode() | pinMode1() |
| digitalRead() | read1() |
| digitalWrite() | write1() |
#### 0.3.0 Breaking change
Version 0.3.0 introduced a breaking change.
@ -93,9 +115,9 @@ Returns true if device address is available on I2C bus.
#### GPIO
- **uint8_t getInput()** read all current output levels.
- **void pinMode(uint8_t pin, uint8_t mode)** set output pin to INPUT or OUTPUT.
- **void digitalWrite(uint8_t pin, uint8_t value)** set output pin HIGH or LOW.
- **uint8_t digitalRead(uint8_t pin)** read current state of output pin.
- **void pinMode1(uint8_t pin, uint8_t mode)** set output pin to INPUT or OUTPUT.
- **void write1(uint8_t pin, uint8_t value)** set output pin HIGH or LOW.
- **uint8_t read1(uint8_t pin)** read current state of output pin.
#### Prescaler Frequency

View File

@ -35,20 +35,20 @@ void setup()
// GPIO
// not mandatory, just to make it explicit
leds.pinMode(0, OUTPUT);
leds.pinMode(1, OUTPUT);
leds.pinMode1(0, OUTPUT);
leds.pinMode1(1, OUTPUT);
}
void loop()
{
leds.digitalWrite(0, LOW);
leds.write1(0, LOW);
delay(500);
leds.digitalWrite(1, LOW);
leds.write1(1, LOW);
delay(500);
leds.digitalWrite(0,HIGH);
leds.write1(0,HIGH);
delay(500);
leds.digitalWrite(1,HIGH);
leds.write1(1,HIGH);
delay(500);
}

View File

@ -35,7 +35,7 @@ void setup()
for (int pin = 0; pin < leds.outputCount(); pin++)
{
leds.pinMode(pin, INPUT);
leds.pinMode1(pin, INPUT);
}
}
@ -44,7 +44,7 @@ void loop()
{
for (int pin = 0; pin < leds.outputCount(); pin++)
{
int x = leds.digitalRead(pin);
int x = leds.read1(pin);
Serial.print(x);
Serial.print('\t');
}

View File

@ -53,4 +53,4 @@ void loop()
}
// -- END OF FILE --
// -- END OF FILE --

View File

@ -36,14 +36,14 @@ void setup()
void loop()
{
// random blink
leds.digitalWrite(0, random(2));
leds.write1(0, random(2));
// steady blink
leds.digitalWrite(1, !leds.digitalRead(1));
leds.write1(1, !leds.read1(1));
// output 2 follows 3
leds.digitalWrite(2, leds.digitalRead(3));
leds.digitalWrite(3, random(2));
leds.write1(2, leds.read1(3));
leds.write1(3, random(2));
delay(1000);
}

View File

@ -18,13 +18,13 @@ void test_GPIO()
Serial.println(__FUNCTION__);
for (int i = 0; i < leds.outputCount(); i++)
{
leds.digitalWrite(i, LOW);
leds.write1(i, LOW);
Serial.print(i);
Serial.print("\t");
Serial.print(leds.digitalRead(i));
Serial.print(leds.read1(i));
Serial.print("\t");
leds.digitalWrite(i, HIGH);
Serial.print(leds.digitalRead(i));
leds.write1(i, HIGH);
Serial.print(leds.read1(i));
Serial.print("\n");
}
Serial.println();

View File

@ -14,9 +14,9 @@ outputCount KEYWORD2
reset KEYWORD2
getInput KEYWORD2
pinMode KEYWORD2
digitalWrite KEYWORD2
digitalRead KEYWORD2
pinMode1 KEYWORD2
write1 KEYWORD2
read1 KEYWORD2
setPrescaler KEYWORD2
getPrescaler KEYWORD2

View File

@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/PCA9553.git"
},
"version": "0.3.0",
"version": "0.4.0",
"license": "MIT",
"frameworks": "*",
"platforms": "*",

View File

@ -1,5 +1,5 @@
name=PCA9553
version=0.3.0
version=0.4.0
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for PCA9553 I2C LED driver 4 channel