From d5494703ef1158a185d3f3830b8a7fa3d863a205 Mon Sep 17 00:00:00 2001 From: Rob Tillaart Date: Thu, 7 Dec 2023 12:17:08 +0100 Subject: [PATCH] refactor API, begin() --- AS5600.cpp | 53 +------------------ AS5600.h | 9 +--- CHANGELOG.md | 9 +++- README.md | 9 ++++ .../AS5600L_set_address.ino | 5 +- .../AS5600_I2C_frequency.ino | 9 ++-- .../AS5600_angular_speed.ino | 11 ++-- .../AS5600_angular_speed_RPM.ino | 9 ++-- .../AS5600_burn_conf_mang.ino | 10 ++-- .../AS5600_burn_zpos/AS5600_burn_zpos.ino | 10 ++-- examples/AS5600_demo/AS5600_demo.ino | 12 ++--- examples/AS5600_demo_ESP32/.arduino-ci.yml | 28 ++++++++++ .../AS5600_demo_ESP32/AS5600_demo_ESP32.ino | 44 +++++++++++++++ examples/AS5600_demo_RP2040/.arduino-ci.yml | 28 ++++++++++ .../AS5600_demo_RP2040/AS5600_demo_RP2040.ino | 46 ++++++++++++++++ examples/AS5600_demo_STM32/.arduino-ci.yml | 28 ++++++++++ .../AS5600_demo_STM32/AS5600_demo_STM32.ino | 46 ++++++++++++++++ .../AS5600_demo_offset/AS5600_demo_offset.ino | 4 +- .../AS5600_demo_radians.ino | 5 +- .../AS5600_demo_software_direction.ino | 6 +-- .../AS5600_demo_status/AS5600_demo_status.ino | 5 +- .../AS5600_demo_two_I2C.ino | 7 ++- .../AS5600_outmode_analog_100.ino | 4 +- .../AS5600_outmode_analog_90.ino | 4 +- .../AS5600_outmode_analog_pwm.ino | 4 +- .../AS5600_outmode_pwm_interrupt.ino | 2 +- examples/AS5600_position/AS5600_position.ino | 12 ++--- .../AS5600_resetCumulativeCounter.ino | 8 ++- library.json | 2 +- library.properties | 4 +- 30 files changed, 303 insertions(+), 130 deletions(-) create mode 100644 examples/AS5600_demo_ESP32/.arduino-ci.yml create mode 100644 examples/AS5600_demo_ESP32/AS5600_demo_ESP32.ino create mode 100644 examples/AS5600_demo_RP2040/.arduino-ci.yml create mode 100644 examples/AS5600_demo_RP2040/AS5600_demo_RP2040.ino create mode 100644 examples/AS5600_demo_STM32/.arduino-ci.yml create mode 100644 examples/AS5600_demo_STM32/AS5600_demo_STM32.ino diff --git a/AS5600.cpp b/AS5600.cpp index 13652e9..77efd7f 100644 --- a/AS5600.cpp +++ b/AS5600.cpp @@ -1,7 +1,7 @@ // // FILE: AS56000.cpp // AUTHOR: Rob Tillaart -// VERSION: 0.4.1 +// VERSION: 0.5.0 // PURPOSE: Arduino library for AS5600 magnetic rotation meter // DATE: 2022-05-28 // URL: https://github.com/RobTillaart/AS5600 @@ -55,56 +55,6 @@ AS5600::AS5600(TwoWire *wire) } -#if defined (ESP8266) || defined(ESP32) - -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->begin(dataPin, clockPin); - } else { - _wire->begin(); - } - if (! isConnected()) return false; - return true; -} - -#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; @@ -114,7 +64,6 @@ bool AS5600::begin(uint8_t directionPin) } setDirection(AS5600_CLOCK_WISE); - _wire->begin(); if (! isConnected()) return false; return true; } diff --git a/AS5600.h b/AS5600.h index 411e49f..7800e65 100644 --- a/AS5600.h +++ b/AS5600.h @@ -2,7 +2,7 @@ // // FILE: AS5600.h // AUTHOR: Rob Tillaart -// VERSION: 0.4.1 +// VERSION: 0.5.0 // 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.1")) +#define AS5600_LIB_VERSION (F("0.5.0")) // default addresses const uint8_t AS5600_DEFAULT_ADDRESS = 0x36; @@ -89,11 +89,6 @@ class AS5600 public: AS5600(TwoWire *wire = &Wire); -#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/CHANGELOG.md b/CHANGELOG.md index 11e0a1d..fd95278 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,12 +5,19 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [0.5.0] - 2023-12-07 +- refactor API, begin() +- update readme.md +- update examples +- patch library.properties => category=Sensors + +---- + ## [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/README.md b/README.md index 0ada705..df47876 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,15 @@ or fluctuating power supply. Please share your experiences. +#### 0.5.0 Breaking change + +Version 0.5.0 introduced a breaking change. +You cannot set the pins in **begin()** any more. +This reduces the dependency of processor dependent Wire implementations. +The user has to call **Wire.begin()** and can optionally set the Wire pins +before calling **begin()**. + + #### Related libraries - https://github.com/RobTillaart/Angle diff --git a/examples/AS5600L_set_address/AS5600L_set_address.ino b/examples/AS5600L_set_address/AS5600L_set_address.ino index c9a0e5e..54057b5 100644 --- a/examples/AS5600L_set_address/AS5600L_set_address.ino +++ b/examples/AS5600L_set_address/AS5600L_set_address.ino @@ -2,7 +2,6 @@ // FILE: AS5600L_set_address.ino // AUTHOR: Rob Tillaart // PURPOSE: demo -// DATE: 2022-08-30 #include "AS5600.h" @@ -21,7 +20,7 @@ void setup() Wire.begin(); ASL.begin(4); // set direction pin. - ASL.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. + ASL.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. int b = ASL.isConnected(); Serial.print("Connect: "); Serial.println(b); @@ -48,4 +47,4 @@ void loop() } -// -- END OF FILE -- +// -- END OF FILE -- diff --git a/examples/AS5600_I2C_frequency/AS5600_I2C_frequency.ino b/examples/AS5600_I2C_frequency/AS5600_I2C_frequency.ino index df84b3b..0510a51 100644 --- a/examples/AS5600_I2C_frequency/AS5600_I2C_frequency.ino +++ b/examples/AS5600_I2C_frequency/AS5600_I2C_frequency.ino @@ -2,18 +2,18 @@ // FILE: AS5600_I2C_frequency.ino // AUTHOR: Rob Tillaart // PURPOSE: demo -// DATE: 2022-05-28 #include "AS5600.h" #include "Wire.h" -AS5600 as5600; // use default Wire +AS5600L as5600; // use default Wire uint32_t clk = 0; uint32_t start, stop; + void setup() { Serial.begin(115200); @@ -23,13 +23,10 @@ void setup() Wire.begin(); - // UNO as5600.begin(4); // set direction pin. - // ESP32 - // as5600.begin(14, 15); // no direction pin. // as5600.setAddress(0x40); // AS5600L only - as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. + as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. int b = as5600.isConnected(); Serial.print("Connect: "); Serial.println(b); diff --git a/examples/AS5600_angular_speed/AS5600_angular_speed.ino b/examples/AS5600_angular_speed/AS5600_angular_speed.ino index da1f273..bdcde29 100644 --- a/examples/AS5600_angular_speed/AS5600_angular_speed.ino +++ b/examples/AS5600_angular_speed/AS5600_angular_speed.ino @@ -2,13 +2,12 @@ // FILE: AS5600_angular_speed.ino // AUTHOR: Rob Tillaart // PURPOSE: demo -// DATE: 2022-06-02 #include "AS5600.h" #include "Wire.h" -AS5600 as5600; // use default Wire +AS5600L as5600; // use default Wire void setup() @@ -21,7 +20,7 @@ void setup() Wire.begin(); as5600.begin(4); // set direction pin. - as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. + as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. Serial.println(as5600.getAddress()); @@ -39,10 +38,10 @@ void loop() { // Serial.print("\ta = "); // Serial.print(as5600.readAngle()); - Serial.print("\tω = "); + // Serial.print("\tω = "); Serial.println(as5600.getAngularSpeed()); - delay(100); + delay(25); } -// -- END OF FILE -- +// -- END OF FILE -- diff --git a/examples/AS5600_angular_speed_RPM/AS5600_angular_speed_RPM.ino b/examples/AS5600_angular_speed_RPM/AS5600_angular_speed_RPM.ino index d927b42..d733eb0 100644 --- a/examples/AS5600_angular_speed_RPM/AS5600_angular_speed_RPM.ino +++ b/examples/AS5600_angular_speed_RPM/AS5600_angular_speed_RPM.ino @@ -2,7 +2,6 @@ // FILE: AS5600_angular_speed_RPM.ino // AUTHOR: Rob Tillaart // PURPOSE: demo -// DATE: 2022-06-02 #include "AS5600.h" @@ -19,13 +18,13 @@ void setup() Serial.println(AS5600_LIB_VERSION); Wire.begin(); - // as5600.begin(14,15); + as5600.begin(4); // set direction pin. - as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. + as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. Serial.println(as5600.getAddress()); - // as5600.setAddress(0x40); // AS5600L only + // as5600.setAddress(0x40); // AS5600L only int b = as5600.isConnected(); Serial.print("Connect: "); @@ -45,4 +44,4 @@ void loop() } -// -- END OF FILE -- +// -- END OF FILE -- diff --git a/examples/AS5600_burn_conf_mang/AS5600_burn_conf_mang.ino b/examples/AS5600_burn_conf_mang/AS5600_burn_conf_mang.ino index f814181..13ba3c7 100644 --- a/examples/AS5600_burn_conf_mang/AS5600_burn_conf_mang.ino +++ b/examples/AS5600_burn_conf_mang/AS5600_burn_conf_mang.ino @@ -2,7 +2,6 @@ // FILE: AS5600_burn_conf_mang.ino // AUTHOR: Rob Tillaart // PURPOSE: demo (not tested yet - see issue #38) -// DATE: 2023-06-18 // WARNING @@ -31,11 +30,10 @@ void setup() Serial.print("AS5600_LIB_VERSION: "); Serial.println(AS5600_LIB_VERSION); - // ESP32 - // as5600.begin(14, 15); - // AVR + Wire.begin(); + as5600.begin(4); // set direction pin. - as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. + as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. if (as5600.isConnected()) { @@ -172,4 +170,4 @@ void burn_mang() } -// -- END OF FILE -- +// -- END OF FILE -- diff --git a/examples/AS5600_burn_zpos/AS5600_burn_zpos.ino b/examples/AS5600_burn_zpos/AS5600_burn_zpos.ino index 8a3a0d9..0360442 100644 --- a/examples/AS5600_burn_zpos/AS5600_burn_zpos.ino +++ b/examples/AS5600_burn_zpos/AS5600_burn_zpos.ino @@ -2,7 +2,6 @@ // FILE: AS5600_burn_zpos.ino // AUTHOR: Rob Tillaart // PURPOSE: demo (not tested yet - see issue #38) -// DATE: 2023-06-18 // WARNING @@ -31,11 +30,10 @@ void setup() Serial.print("AS5600_LIB_VERSION: "); Serial.println(AS5600_LIB_VERSION); - // ESP32 - // as5600.begin(14, 15); - // AVR + Wire.begin(); + as5600.begin(4); // set direction pin. - as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. + as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. if (as5600.isConnected()) { @@ -111,4 +109,4 @@ void burn_zpos() -// -- END OF FILE -- +// -- END OF FILE -- diff --git a/examples/AS5600_demo/AS5600_demo.ino b/examples/AS5600_demo/AS5600_demo.ino index d41377b..78f10fb 100644 --- a/examples/AS5600_demo/AS5600_demo.ino +++ b/examples/AS5600_demo/AS5600_demo.ino @@ -2,13 +2,12 @@ // FILE: AS5600_demo.ino // AUTHOR: Rob Tillaart // PURPOSE: demo -// DATE: 2022-05-28 #include "AS5600.h" #include "Wire.h" -AS5600 as5600; // use default Wire +AS5600L as5600; // use default Wire void setup() @@ -17,12 +16,11 @@ void setup() Serial.println(__FILE__); Serial.print("AS5600_LIB_VERSION: "); Serial.println(AS5600_LIB_VERSION); + + Wire.begin(); - // ESP32 - // as5600.begin(14,15); - // AVR as5600.begin(4); // set direction pin. - as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. + as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. int b = as5600.isConnected(); Serial.print("Connect: "); Serial.println(b); @@ -43,4 +41,4 @@ void loop() } -// -- END OF FILE -- +// -- END OF FILE -- diff --git a/examples/AS5600_demo_ESP32/.arduino-ci.yml b/examples/AS5600_demo_ESP32/.arduino-ci.yml new file mode 100644 index 0000000..e1c447b --- /dev/null +++ b/examples/AS5600_demo_ESP32/.arduino-ci.yml @@ -0,0 +1,28 @@ +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: + # - uno + # - due + # - zero + # - leonardo + # - m4 + - esp32 + # - esp8266 + # - mega2560 + # - rpipico + diff --git a/examples/AS5600_demo_ESP32/AS5600_demo_ESP32.ino b/examples/AS5600_demo_ESP32/AS5600_demo_ESP32.ino new file mode 100644 index 0000000..a3ba5c2 --- /dev/null +++ b/examples/AS5600_demo_ESP32/AS5600_demo_ESP32.ino @@ -0,0 +1,44 @@ +// +// FILE: AS5600_demo.ino +// AUTHOR: Rob Tillaart +// PURPOSE: demo + + +#include "AS5600.h" +#include "Wire.h" + +AS5600L as5600; // use default Wire + + +void setup() +{ + Serial.begin(115200); + Serial.println(__FILE__); + Serial.print("AS5600_LIB_VERSION: "); + Serial.println(AS5600_LIB_VERSION); + + Wire.begin(14, 15); + + as5600.begin(4); // set direction pin. + as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. + int b = as5600.isConnected(); + Serial.print("Connect: "); + Serial.println(b); + delay(1000); +} + + +void loop() +{ + // Serial.print(millis()); + // Serial.print("\t"); + Serial.print(as5600.readAngle()); + Serial.print("\t"); + Serial.println(as5600.rawAngle()); + // Serial.println(as5600.rawAngle() * AS5600_RAW_TO_DEGREES); + + delay(1000); +} + + +// -- END OF FILE -- diff --git a/examples/AS5600_demo_RP2040/.arduino-ci.yml b/examples/AS5600_demo_RP2040/.arduino-ci.yml new file mode 100644 index 0000000..534b5e3 --- /dev/null +++ b/examples/AS5600_demo_RP2040/.arduino-ci.yml @@ -0,0 +1,28 @@ +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: + # - uno + # - due + # - zero + # - leonardo + # - m4 + # - esp32 + # - esp8266 + # - mega2560 + - rpipico + diff --git a/examples/AS5600_demo_RP2040/AS5600_demo_RP2040.ino b/examples/AS5600_demo_RP2040/AS5600_demo_RP2040.ino new file mode 100644 index 0000000..bc13a94 --- /dev/null +++ b/examples/AS5600_demo_RP2040/AS5600_demo_RP2040.ino @@ -0,0 +1,46 @@ +// +// FILE: AS5600_demo.ino +// AUTHOR: Rob Tillaart +// PURPOSE: demo + + +#include "AS5600.h" +#include "Wire.h" + +AS5600L as5600; // use default Wire + + +void setup() +{ + Serial.begin(115200); + Serial.println(__FILE__); + Serial.print("AS5600_LIB_VERSION: "); + Serial.println(AS5600_LIB_VERSION); + + Wire.setSDA(14); + Wire.setSCL(15); + Wire.begin() + + as5600.begin(4); // set direction pin. + as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. + int b = as5600.isConnected(); + Serial.print("Connect: "); + Serial.println(b); + delay(1000); +} + + +void loop() +{ + // Serial.print(millis()); + // Serial.print("\t"); + Serial.print(as5600.readAngle()); + Serial.print("\t"); + Serial.println(as5600.rawAngle()); + // Serial.println(as5600.rawAngle() * AS5600_RAW_TO_DEGREES); + + delay(1000); +} + + +// -- END OF FILE -- diff --git a/examples/AS5600_demo_STM32/.arduino-ci.yml b/examples/AS5600_demo_STM32/.arduino-ci.yml new file mode 100644 index 0000000..783ab31 --- /dev/null +++ b/examples/AS5600_demo_STM32/.arduino-ci.yml @@ -0,0 +1,28 @@ +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: + # - uno + # - due + # - zero + # - leonardo + # - m4 + # - esp32 + # - esp8266 + # - mega2560 + # - rpipico + diff --git a/examples/AS5600_demo_STM32/AS5600_demo_STM32.ino b/examples/AS5600_demo_STM32/AS5600_demo_STM32.ino new file mode 100644 index 0000000..bc13a94 --- /dev/null +++ b/examples/AS5600_demo_STM32/AS5600_demo_STM32.ino @@ -0,0 +1,46 @@ +// +// FILE: AS5600_demo.ino +// AUTHOR: Rob Tillaart +// PURPOSE: demo + + +#include "AS5600.h" +#include "Wire.h" + +AS5600L as5600; // use default Wire + + +void setup() +{ + Serial.begin(115200); + Serial.println(__FILE__); + Serial.print("AS5600_LIB_VERSION: "); + Serial.println(AS5600_LIB_VERSION); + + Wire.setSDA(14); + Wire.setSCL(15); + Wire.begin() + + as5600.begin(4); // set direction pin. + as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. + int b = as5600.isConnected(); + Serial.print("Connect: "); + Serial.println(b); + delay(1000); +} + + +void loop() +{ + // Serial.print(millis()); + // Serial.print("\t"); + Serial.print(as5600.readAngle()); + Serial.print("\t"); + Serial.println(as5600.rawAngle()); + // Serial.println(as5600.rawAngle() * AS5600_RAW_TO_DEGREES); + + delay(1000); +} + + +// -- END OF FILE -- diff --git a/examples/AS5600_demo_offset/AS5600_demo_offset.ino b/examples/AS5600_demo_offset/AS5600_demo_offset.ino index 158d646..c6c7c1a 100644 --- a/examples/AS5600_demo_offset/AS5600_demo_offset.ino +++ b/examples/AS5600_demo_offset/AS5600_demo_offset.ino @@ -20,7 +20,7 @@ void setup() Wire.begin(); as5600.begin(4); // set direction pin. - as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. + as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. } @@ -45,4 +45,4 @@ void loop() } -// -- END OF FILE -- +// -- END OF FILE -- diff --git a/examples/AS5600_demo_radians/AS5600_demo_radians.ino b/examples/AS5600_demo_radians/AS5600_demo_radians.ino index 3c7d363..6f75716 100644 --- a/examples/AS5600_demo_radians/AS5600_demo_radians.ino +++ b/examples/AS5600_demo_radians/AS5600_demo_radians.ino @@ -19,9 +19,8 @@ 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. + as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. } @@ -37,4 +36,4 @@ void loop() } -// -- END OF FILE -- +// -- END OF FILE -- diff --git a/examples/AS5600_demo_software_direction/AS5600_demo_software_direction.ino b/examples/AS5600_demo_software_direction/AS5600_demo_software_direction.ino index 25bab2b..fe23b1f 100644 --- a/examples/AS5600_demo_software_direction/AS5600_demo_software_direction.ino +++ b/examples/AS5600_demo_software_direction/AS5600_demo_software_direction.ino @@ -4,7 +4,7 @@ // PURPOSE: demo software direction control -// connect the DIR pin of teh AS5600 to GND +// connect the DIR pin of the AS5600 to GND #include "AS5600.h" @@ -24,7 +24,7 @@ void setup() Wire.begin(); as5600.begin(); // set software direction control. default param = 255 - as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. + as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. } @@ -48,4 +48,4 @@ void loop() } -// -- END OF FILE -- +// -- END OF FILE -- diff --git a/examples/AS5600_demo_status/AS5600_demo_status.ino b/examples/AS5600_demo_status/AS5600_demo_status.ino index 096caa7..2430b49 100644 --- a/examples/AS5600_demo_status/AS5600_demo_status.ino +++ b/examples/AS5600_demo_status/AS5600_demo_status.ino @@ -2,7 +2,6 @@ // FILE: AS5600_demo_status.ino // AUTHOR: Rob Tillaart // PURPOSE: demo -// DATE: 2022-05-28 #include "AS5600.h" @@ -21,7 +20,7 @@ void setup() Wire.begin(); as5600.begin(4); // set direction pin. - as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. + as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. } @@ -47,4 +46,4 @@ void loop() } -// -- END OF FILE -- +// -- END OF FILE -- diff --git a/examples/AS5600_demo_two_I2C/AS5600_demo_two_I2C.ino b/examples/AS5600_demo_two_I2C/AS5600_demo_two_I2C.ino index 444f808..4103bea 100644 --- a/examples/AS5600_demo_two_I2C/AS5600_demo_two_I2C.ino +++ b/examples/AS5600_demo_two_I2C/AS5600_demo_two_I2C.ino @@ -2,11 +2,11 @@ // FILE: AS5600_demo_two_I2C.ino // AUTHOR: Rob Tillaart // PURPOSE: demo two I2C busses -// DATE: 2023-03-07 // -// Works only if Wire1 bus is present +// Works only if Wire1 bus is present e.g. // - nano33 ble // - teensy 4.1 +// - RP2040 #include "AS5600.h" @@ -23,6 +23,9 @@ void setup() Serial.print("AS5600_LIB_VERSION: "); Serial.println(AS5600_LIB_VERSION); + Wire.begin(); + Wire1.begin(); + as5600_0.begin(4); // set direction pin. as5600_0.setDirection(AS5600_CLOCK_WISE); Serial.print("Connect device 0: "); diff --git a/examples/AS5600_outmode_analog_100/AS5600_outmode_analog_100.ino b/examples/AS5600_outmode_analog_100/AS5600_outmode_analog_100.ino index 4570d27..e6ec10b 100644 --- a/examples/AS5600_outmode_analog_100/AS5600_outmode_analog_100.ino +++ b/examples/AS5600_outmode_analog_100/AS5600_outmode_analog_100.ino @@ -22,7 +22,7 @@ void setup() Wire.begin(); as5600.begin(4); // set direction pin. - as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. + as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. as5600.setOutputMode(AS5600_OUTMODE_ANALOG_100); } @@ -39,4 +39,4 @@ void loop() } -// -- END OF FILE -- +// -- END OF FILE -- diff --git a/examples/AS5600_outmode_analog_90/AS5600_outmode_analog_90.ino b/examples/AS5600_outmode_analog_90/AS5600_outmode_analog_90.ino index eb5438c..f1662b3 100644 --- a/examples/AS5600_outmode_analog_90/AS5600_outmode_analog_90.ino +++ b/examples/AS5600_outmode_analog_90/AS5600_outmode_analog_90.ino @@ -22,7 +22,7 @@ void setup() Wire.begin(); as5600.begin(4); // set direction pin. - as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. + as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. as5600.setOutputMode(AS5600_OUTMODE_ANALOG_90); } @@ -39,4 +39,4 @@ void loop() } -// -- END OF FILE -- +// -- END OF FILE -- diff --git a/examples/AS5600_outmode_analog_pwm/AS5600_outmode_analog_pwm.ino b/examples/AS5600_outmode_analog_pwm/AS5600_outmode_analog_pwm.ino index 2e92776..f68b199 100644 --- a/examples/AS5600_outmode_analog_pwm/AS5600_outmode_analog_pwm.ino +++ b/examples/AS5600_outmode_analog_pwm/AS5600_outmode_analog_pwm.ino @@ -28,7 +28,7 @@ void setup() Wire.begin(); as5600.begin(4); // set direction pin. - as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. + as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. as5600.setOutputMode(AS5600_OUTMODE_PWM); as5600.setPWMFrequency(AS5600_PWM_920); } @@ -46,4 +46,4 @@ void loop() } -// -- END OF FILE -- +// -- END OF FILE -- diff --git a/examples/AS5600_outmode_pwm_interrupt/AS5600_outmode_pwm_interrupt.ino b/examples/AS5600_outmode_pwm_interrupt/AS5600_outmode_pwm_interrupt.ino index 34cd132..7838ab3 100644 --- a/examples/AS5600_outmode_pwm_interrupt/AS5600_outmode_pwm_interrupt.ino +++ b/examples/AS5600_outmode_pwm_interrupt/AS5600_outmode_pwm_interrupt.ino @@ -57,4 +57,4 @@ void loop() } -// -- END OF FILE -- +// -- END OF FILE -- diff --git a/examples/AS5600_position/AS5600_position.ino b/examples/AS5600_position/AS5600_position.ino index 345a1c7..6c9e740 100644 --- a/examples/AS5600_position/AS5600_position.ino +++ b/examples/AS5600_position/AS5600_position.ino @@ -2,7 +2,6 @@ // FILE: AS5600_position.ino // AUTHOR: Rob Tillaart // PURPOSE: demo -// DATE: 2022-12-20 #include "AS5600.h" @@ -18,15 +17,14 @@ void setup() Serial.print("AS5600_LIB_VERSION: "); Serial.println(AS5600_LIB_VERSION); - // ESP32 - // as5600.begin(14, 15); - // AVR + Wire.begin(); + as5600.begin(4); // set direction pin. - as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. + as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. Serial.println(as5600.getAddress()); - // as5600.setAddress(0x40); // AS5600L only + // as5600.setAddress(0x40); // AS5600L only int b = as5600.isConnected(); Serial.print("Connect: "); @@ -61,4 +59,4 @@ void loop() } -// -- END OF FILE -- +// -- END OF FILE -- diff --git a/examples/AS5600_resetCumulativeCounter/AS5600_resetCumulativeCounter.ino b/examples/AS5600_resetCumulativeCounter/AS5600_resetCumulativeCounter.ino index b5f2543..eeb2f6e 100644 --- a/examples/AS5600_resetCumulativeCounter/AS5600_resetCumulativeCounter.ino +++ b/examples/AS5600_resetCumulativeCounter/AS5600_resetCumulativeCounter.ino @@ -13,7 +13,13 @@ AS5600L as5600; // use default Wire void setup() { Serial.begin(115200); - as5600.begin(14, 15); // ESP32 + Serial.println(__FILE__); + Serial.print("AS5600_LIB_VERSION: "); + Serial.println(AS5600_LIB_VERSION); + + Wire.begin(14, 15); // ESP32 + + as5600.begin(): as5600.setAddress(0x40); // AS5600L has address as5600.setDirection(AS5600_CLOCK_WISE); // default, just be explicit. diff --git a/library.json b/library.json index 7710922..8adefd4 100644 --- a/library.json +++ b/library.json @@ -15,7 +15,7 @@ "type": "git", "url": "https://github.com/RobTillaart/AS5600.git" }, - "version": "0.4.1", + "version": "0.5.0", "license": "MIT", "frameworks": "*", "platforms": "*", diff --git a/library.properties b/library.properties index 4b88ad9..7328f24 100644 --- a/library.properties +++ b/library.properties @@ -1,10 +1,10 @@ name=AS5600 -version=0.4.1 +version=0.5.0 author=Rob Tillaart maintainer=Rob Tillaart sentence=Arduino library for AS5600 and AS5600L magnetic rotation meter. paragraph= -category=Data Processing +category=Sensors url=https://github.com/RobTillaart/AS5600 architectures=* includes=AS5600.h