diff --git a/libraries/AS5600/AS5600.cpp b/libraries/AS5600/AS5600.cpp index 03ddeb69..13652e9d 100644 --- a/libraries/AS5600/AS5600.cpp +++ b/libraries/AS5600/AS5600.cpp @@ -1,7 +1,7 @@ // // FILE: AS56000.cpp // AUTHOR: Rob Tillaart -// VERSION: 0.4.0 +// VERSION: 0.4.1 // PURPOSE: Arduino library for AS5600 magnetic rotation meter // DATE: 2022-05-28 // URL: https://github.com/RobTillaart/AS5600 @@ -79,6 +79,32 @@ bool AS5600::begin(int dataPin, int clockPin, uint8_t directionPin) #endif +#if defined (ARDUINO_ARCH_STM32) + +bool AS5600::begin(int dataPin, int clockPin, uint8_t directionPin) +{ + _directionPin = directionPin; + if (_directionPin != AS5600_SW_DIRECTION_PIN) + { + pinMode(_directionPin, OUTPUT); + } + setDirection(AS5600_CLOCK_WISE); + + if ((dataPin < 255) && (clockPin < 255)) + { + _wire->setSDA(dataPin); + _wire->setSCL(clockPin); + _wire->begin(); + } else { + _wire->begin(); + } + if (! isConnected()) return false; + return true; +} + +#endif + + bool AS5600::begin(uint8_t directionPin) { _directionPin = directionPin; @@ -331,7 +357,7 @@ uint16_t AS5600::rawAngle() int16_t value = readReg2(AS5600_RAW_ANGLE) & 0x0FFF; if (_offset > 0) value = (value + _offset) & 0x0FFF; - if ((_directionPin == AS5600_SW_DIRECTION_PIN) && + if ((_directionPin == AS5600_SW_DIRECTION_PIN) && (_direction == AS5600_COUNTERCLOCK_WISE)) { value = (4096 - value) & 0x0FFF; @@ -345,7 +371,7 @@ uint16_t AS5600::readAngle() uint16_t value = readReg2(AS5600_ANGLE) & 0x0FFF; if (_offset > 0) value = (value + _offset) & 0x0FFF; - if ((_directionPin == AS5600_SW_DIRECTION_PIN) && + if ((_directionPin == AS5600_SW_DIRECTION_PIN) && (_direction == AS5600_COUNTERCLOCK_WISE)) { value = (4096 - value) & 0x0FFF; diff --git a/libraries/AS5600/AS5600.h b/libraries/AS5600/AS5600.h index 08c88bb3..411e49f3 100644 --- a/libraries/AS5600/AS5600.h +++ b/libraries/AS5600/AS5600.h @@ -2,7 +2,7 @@ // // FILE: AS5600.h // AUTHOR: Rob Tillaart -// VERSION: 0.4.0 +// VERSION: 0.4.1 // PURPOSE: Arduino library for AS5600 magnetic rotation meter // DATE: 2022-05-28 // URL: https://github.com/RobTillaart/AS5600 @@ -12,7 +12,7 @@ #include "Wire.h" -#define AS5600_LIB_VERSION (F("0.4.0")) +#define AS5600_LIB_VERSION (F("0.4.1")) // default addresses const uint8_t AS5600_DEFAULT_ADDRESS = 0x36; @@ -89,10 +89,11 @@ class AS5600 public: AS5600(TwoWire *wire = &Wire); -#if defined (ESP8266) || defined(ESP32) +#if defined (ESP8266) || defined(ESP32) || defined(ARDUINO_ARCH_STM32) // AS5600_SW_DIRECTION_PIN is software controlled direction pin bool begin(int dataPin, int clockPin, uint8_t directionPin = AS5600_SW_DIRECTION_PIN); #endif + bool begin(uint8_t directionPin = AS5600_SW_DIRECTION_PIN); bool isConnected(); diff --git a/libraries/AS5600/CHANGELOG.md b/libraries/AS5600/CHANGELOG.md index c661202c..11e0a1d6 100644 --- a/libraries/AS5600/CHANGELOG.md +++ b/libraries/AS5600/CHANGELOG.md @@ -5,6 +5,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [0.4.1] - 2023-09-16 +- fix #45 support STM32 set I2C pins ARDUINO_ARCH_STM32 +- update readme badges +- minor edits + + ## [0.4.0] - 2023-06-27 - fix #39 support for Wire2 on ESP32 - update readme.md diff --git a/libraries/AS5600/README.md b/libraries/AS5600/README.md index fdc240ec..0ada7051 100644 --- a/libraries/AS5600/README.md +++ b/libraries/AS5600/README.md @@ -2,8 +2,11 @@ [![Arduino CI](https://github.com/RobTillaart/AS5600/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci) [![Arduino-lint](https://github.com/RobTillaart/AS5600/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/AS5600/actions/workflows/arduino-lint.yml) [![JSON check](https://github.com/RobTillaart/AS5600/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/AS5600/actions/workflows/jsoncheck.yml) +[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/AS5600.svg)](https://github.com/RobTillaart/AS5600/issues) + [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/AS5600/blob/master/LICENSE) [![GitHub release](https://img.shields.io/github/release/RobTillaart/AS5600.svg?maxAge=3600)](https://github.com/RobTillaart/AS5600/releases) +[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/AS5600.svg)](https://registry.platformio.org/libraries/robtillaart/AS5600) # AS5600 @@ -683,3 +686,12 @@ priority is relative. - see getAngularSpeed() +## Support + +If you appreciate my libraries, you can support the development and maintenance. +Improve the quality of the libraries by providing issues and Pull Requests, or +donate through PayPal or GitHub sponsors. + +Thank you, + + diff --git a/libraries/AS5600/examples/AS5600_demo_radians/AS5600_demo_radians.ino b/libraries/AS5600/examples/AS5600_demo_radians/AS5600_demo_radians.ino index 7e8b2814..3c7d363c 100644 --- a/libraries/AS5600/examples/AS5600_demo_radians/AS5600_demo_radians.ino +++ b/libraries/AS5600/examples/AS5600_demo_radians/AS5600_demo_radians.ino @@ -19,6 +19,7 @@ void setup() Wire.begin(); + // as5600.begin(11, 12, 4); // test for STM32 or ESP32 as5600.begin(4); // set direction pin. as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. } diff --git a/libraries/AS5600/library.json b/libraries/AS5600/library.json index bfc897ed..77109221 100644 --- a/libraries/AS5600/library.json +++ b/libraries/AS5600/library.json @@ -15,9 +15,9 @@ "type": "git", "url": "https://github.com/RobTillaart/AS5600.git" }, - "version": "0.4.0", + "version": "0.4.1", "license": "MIT", - "frameworks": "arduino", + "frameworks": "*", "platforms": "*", "headers": "AS5600.h" } diff --git a/libraries/AS5600/library.properties b/libraries/AS5600/library.properties index 0cd7a0bb..4b88ad9e 100644 --- a/libraries/AS5600/library.properties +++ b/libraries/AS5600/library.properties @@ -1,5 +1,5 @@ name=AS5600 -version=0.4.0 +version=0.4.1 author=Rob Tillaart maintainer=Rob Tillaart sentence=Arduino library for AS5600 and AS5600L magnetic rotation meter.