0.4.1 AS5600

This commit is contained in:
Rob Tillaart 2023-09-20 12:24:31 +02:00
parent 63d71837b3
commit 5aa81e80b9
7 changed files with 55 additions and 9 deletions

View File

@ -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;

View File

@ -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();

View File

@ -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

View File

@ -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,

View File

@ -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.
}

View File

@ -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"
}

View File

@ -1,5 +1,5 @@
name=AS5600
version=0.4.0
version=0.4.1
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for AS5600 and AS5600L magnetic rotation meter.