diff --git a/AS5600.cpp b/AS5600.cpp index 95bd277..d94f91b 100644 --- a/AS5600.cpp +++ b/AS5600.cpp @@ -426,14 +426,8 @@ bool AS5600::magnetTooWeak() // } -float AS5600::getAngularSpeed(uint8_t mode, bool update) +float AS5600::getAngularSpeed(uint8_t mode) { - static float speed = 0; - - if (update == false) - { - return speed; - } // default behaviour uint32_t now = micros(); int angle = readAngle(); @@ -445,7 +439,7 @@ float AS5600::getAngularSpeed(uint8_t mode, bool update) // => at least two measurements per rotation (preferred 4). if (deltaA > 2048) deltaA -= 4096; else if (deltaA < -2048) deltaA += 4096; - speed = (deltaA * 1e6) / deltaT; + float speed = (deltaA * 1e6) / deltaT; // remember last time & angle _lastMeasurement = now; @@ -469,12 +463,8 @@ float AS5600::getAngularSpeed(uint8_t mode, bool update) // // POSITION cumulative // -int32_t AS5600::getCumulativePosition(bool update) +int32_t AS5600::getCumulativePosition() { - if (update == false) - { - return _position; - } int16_t value = readAngle(); if (_error != AS5600_OK) { diff --git a/AS5600.h b/AS5600.h index d074a6e..1339957 100644 --- a/AS5600.h +++ b/AS5600.h @@ -219,11 +219,11 @@ class AS5600 // approximation of the angular speed in rotations per second. // mode == 1: radians /second // mode == 0: degrees /second (default) - float getAngularSpeed(uint8_t mode = AS5600_MODE_DEGREES, bool update = true); + float getAngularSpeed(uint8_t mode = AS5600_MODE_DEGREES); // EXPERIMENTAL CUMULATIVE POSITION // reads sensor and updates cumulative position - int32_t getCumulativePosition(bool update = true); + int32_t getCumulativePosition(); // converts last position to whole revolutions. int32_t getRevolutions(); // resets position only (not the i) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6b369f..ed64957 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [0.6.3] - 2024-10-04 -- fix #67, add update flag for speed and cumulative position - fix #69, **resetCumulativePosition()** - minor edits diff --git a/README.md b/README.md index c10c786..2938e64 100644 --- a/README.md +++ b/README.md @@ -385,10 +385,9 @@ as.increaseOffset(-30); ### Angular Speed -- **float getAngularSpeed(uint8_t mode = AS5600_MODE_DEGREES, bool update = true)** +- **float getAngularSpeed(uint8_t mode = AS5600_MODE_DEGREES)** is an experimental function that returns an approximation of the angular speed in rotations per second. -If the update flag is set to false, it returns the last calculated speed. The function needs to be called at least **four** times per rotation or once per second to get a reasonably precision. @@ -421,7 +420,7 @@ should be within 180° = half a rotation. Since 0.3.3 an experimental cumulative position can be requested from the library. The sensor does not provide interrupts to indicate a movement or revolution Therefore one has to poll the sensor at a frequency at least **three** times -per revolution with **getCumulativePosition(bool update = true)** +per revolution with **getCumulativePosition()** The cumulative position (32 bits) consists of 3 parts @@ -434,9 +433,8 @@ The cumulative position (32 bits) consists of 3 parts Functions are: -- **int32_t getCumulativePosition(bool update = true)** reads sensor and updates cumulative position. +- **int32_t getCumulativePosition()** reads sensor and updates cumulative position. Updated in 0.6.2 to follow the setting of the **directionPin**. -If update == false, it returns the last calculated position. - **int32_t getRevolutions()** converts last position to whole revolutions. Convenience function. Updated in 0.6.2 to return **zero** for the first negative revolution as this