-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from jonas-merkle/develop
Fix for #41
- Loading branch information
Showing
15 changed files
with
51 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,8 @@ | |
* @author Jonas Merkle [JJM] ([email protected]) | ||
* @brief This is a basic example program to read the angle position from a AS5047 rotary encoder. | ||
* The angle postion gets updated and printed to the serial consol once a second. | ||
* @version 2.1.5 | ||
* @date 2021-04-10 | ||
* @version 2.2.0 | ||
* @date 2022-11-20 | ||
* | ||
* @copyright Copyright (c) 2021 Jonas Merkle. This project is released under the GPL-3.0 License License. | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,8 @@ | |
* @author Jonas Merkle [JJM] ([email protected]) | ||
* @brief This is a basic example program to read the angle position and debug information from a AS5047 rotary encoder. | ||
* The angle postion and debug information gets updated and printed to the serial consol once a second. | ||
* @version 2.1.5 | ||
* @date 2021-04-10 | ||
* @version 2.2.0 | ||
* @date 2022-11-20 | ||
* | ||
* @copyright Copyright (c) 2021 Jonas Merkle. This project is released under the GPL-3.0 License License. | ||
* | ||
|
@@ -50,16 +50,8 @@ void loop() { | |
digitalWrite(LED_PIN, HIGH); // activate the led. | ||
Serial.print("Angle: "); // print some text to the serial consol. | ||
Serial.println(as5047p.readAngleDegree()); // read the angle value from the AS5047P sensor an print it to the serial consol. | ||
#ifdef ARDUINO_ARCH_SAMD | ||
std::string s = as5047p.readStatusAsStdString(); // get the string containing the debug information. | ||
for(uint16_t i = 0; i < s.size(); i++) { // printing the string character by character | ||
Serial.print(s[i]); | ||
} | ||
Serial.println(""); | ||
#else | ||
Serial.println(as5047p.readStatusAsArduinoString()); // get the string containing the debug information and print it. | ||
Serial.println(""); | ||
#endif | ||
delay(500); // wait for 500 milli seconds. | ||
|
||
// wait | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
* @file PrintAllSettings.ino | ||
* @author Jonas Merkle [JJM] ([email protected]) | ||
* @brief This is a example prints out the settings of the AS5047P sensor. | ||
* @version 2.1.5 | ||
* @date 2021-04-10 | ||
* @version 2.2.0 | ||
* @date 2022-11-20 | ||
* | ||
* @copyright Copyright (c) 2021 Jonas Merkle. This project is released under the GPL-3.0 License License. | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name=AS5047P | ||
version=2.1.5 | ||
version=2.2.0 | ||
author=Jonas Merkle [JJM] <[email protected]> | ||
maintainer=Jonas Merkle [JJM] <[email protected]> | ||
sentence=An Arduino library for the AS5047P high-resolution rotary position sensor. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
* @file AS5047P.h | ||
* @author Jonas Merkle [JJM] ([email protected]) | ||
* @brief This is the main sourcefile of the AS5047P Library. | ||
* @version 2.1.5 | ||
* @date 2021-04-10 | ||
* @version 2.2.0 | ||
* @date 2022-11-20 | ||
* | ||
* @copyright Copyright (c) 2021 Jonas Merkle. This project is released under the GPL-3.0 License License. | ||
* | ||
|
@@ -128,7 +128,7 @@ bool AS5047P::verifyWittenRegF(uint16_t regAddress, uint16_t expectedData) { | |
return recData.data.raw == expectedData; | ||
} | ||
|
||
#if defined(ARDUINO_ARCH_SAMD) || defined(CORE_TEENSY) | ||
#if defined(AS5047P_STD_STRING_SUPPORT) | ||
|
||
std::string AS5047P::readStatusAsStdString() { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
* @file AS5047P.h | ||
* @author Jonas Merkle [JJM] ([email protected]) | ||
* @brief This is the main headerfile of the AS5047P Library. | ||
* @version 2.1.5 | ||
* @date 2021-04-10 | ||
* @version 2.2.0 | ||
* @date 2022-11-20 | ||
* | ||
* @copyright Copyright (c) 2021 Jonas Merkle. This project is released under the GPL-3.0 License License. | ||
* | ||
|
@@ -14,12 +14,14 @@ | |
|
||
#include <inttypes.h> | ||
|
||
#include "./util/AS5047P_Settings.h" | ||
|
||
//#ifdef Arduino_h | ||
#include <Arduino.h> | ||
#include "spi/AS5047P_SPI_Arduino.h" | ||
//#endif | ||
|
||
#if defined(ARDUINO_ARCH_SAMD) || defined(CORE_TEENSY) | ||
#if defined(AS5047P_STD_STRING_SUPPORT) | ||
#include <string> | ||
#endif | ||
|
||
|
@@ -88,7 +90,7 @@ class AS5047P { | |
bool verifyWittenRegF(uint16_t regAddress, uint16_t expectedData); | ||
|
||
|
||
#if defined(ARDUINO_ARCH_SAMD) || defined(CORE_TEENSY) | ||
#if defined(AS5047P_STD_STRING_SUPPORT) | ||
/** | ||
* Reads all status information from the AS5047P sensor and returns them as a string. | ||
* @return A std::string with all status information. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,8 @@ | |
* @file AS5047P_SPI_Arduino.cpp | ||
* @author Jonas Merkle [JJM] ([email protected]) | ||
* @brief This sourefile contains the implementation of the Arduino SPI bus handler for the AS5047P Library. | ||
* @version 2.1.5 | ||
* @date 2021-04-10 | ||
* @version 2.2.0 | ||
* @date 2022-11-20 | ||
* | ||
* @copyright Copyright (c) 2021 Jonas Merkle. This project is released under the GPL-3.0 License License. | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
* @file AS5047P_SPI_Arduino.h | ||
* @author Jonas Merkle [JJM] ([email protected]) | ||
* @brief This headerfile contains the Arduino SPI bus handler for the AS5047P Library. | ||
* @version 2.1.5 | ||
* @date 2021-04-10 | ||
* @version 2.2.0 | ||
* @date 2022-11-20 | ||
* | ||
* @copyright Copyright (c) 2021 Jonas Merkle. This project is released under the GPL-3.0 License License. | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
* @file AS5047P_Types.cpp | ||
* @author Jonas Merkle [JJM] ([email protected]) | ||
* @brief This sourcefile contains the implementation of the type definitions for the AS5047P Library. | ||
* @version 2.1.5 | ||
* @date 2021-04-10 | ||
* @version 2.2.0 | ||
* @date 2022-11-20 | ||
* | ||
* @copyright Copyright (c) 2021 Jonas Merkle. This project is released under the GPL-3.0 License License. | ||
* | ||
|
@@ -30,7 +30,7 @@ namespace AS5047P_Types { | |
); | ||
} | ||
|
||
#if defined(ARDUINO_ARCH_SAMD) || defined(CORE_TEENSY) | ||
#if defined(AS5047P_STD_STRING_SUPPORT) | ||
|
||
std::string ERROR_t::toStdString() { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
* @file AS5047P_Types.h | ||
* @author Jonas Merkle [JJM] ([email protected]) | ||
* @brief This headerfile contains type definitions for the AS5047P Library. | ||
* @version 2.1.5 | ||
* @date 2021-04-10 | ||
* @version 2.2.0 | ||
* @date 2022-11-20 | ||
* | ||
* @copyright Copyright (c) 2021 Jonas Merkle. This project is released under the GPL-3.0 License License. | ||
* | ||
|
@@ -14,7 +14,9 @@ | |
|
||
#include <inttypes.h> | ||
|
||
#if defined(ARDUINO_ARCH_SAMD) || defined(CORE_TEENSY) | ||
#include "./util/AS5047P_Settings.h" | ||
|
||
#if defined(AS5047P_STD_STRING_SUPPORT) | ||
#include <string> | ||
#endif | ||
|
||
|
@@ -131,7 +133,7 @@ namespace AS5047P_Types { | |
*/ | ||
bool noError(); | ||
|
||
#if defined(ARDUINO_ARCH_SAMD) || defined(CORE_TEENSY) | ||
#if defined(AS5047P_STD_STRING_SUPPORT) | ||
|
||
/** | ||
* Converts the error information into an human readable string. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
* @file AS5047P_Settings.h | ||
* @author Jonas Merkle [JJM] ([email protected]) | ||
* @brief This headerfile contains settings information for the AS5047P Library. | ||
* @version 2.1.5 | ||
* @date 2021-04-10 | ||
* @version 2.2.0 | ||
* @date 2022-11-20 | ||
* | ||
* @copyright Copyright (c) 2021 Jonas Merkle. This project is released under the GPL-3.0 License License. | ||
* | ||
|
@@ -32,4 +32,14 @@ | |
*/ | ||
//#define AS5047P_SPI_ARDUINO_INIT_ON_COM_ENAB | ||
|
||
/** | ||
* @brief Uncomment this to use std::string compatible text output. | ||
* | ||
* This way of string handling is currently not supported by the default Arduino IDE an will result in errors during compilation. | ||
* Pleas use an alternative IDE like PlatformIO + VSCode. | ||
* | ||
*/ | ||
//#define AS5047P_STD_STRING_SUPPORT | ||
|
||
|
||
#endif // AS5047P_Settings_h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
* @file AS5047P_Util.h | ||
* @author Jonas Merkle [JJM] ([email protected]) | ||
* @brief This headerfile contains util functions for the AS5047P Library. | ||
* @version 2.1.5 | ||
* @date 2021-04-10 | ||
* @version 2.2.0 | ||
* @date 2022-11-20 | ||
* | ||
* @copyright Copyright (c) 2021 Jonas Merkle. This project is released under the GPL-3.0 License License. | ||
* | ||
|
@@ -14,7 +14,9 @@ | |
|
||
#include <inttypes.h> | ||
|
||
#if defined(ARDUINO_ARCH_SAMD) || defined(CORE_TEENSY) | ||
#include "./util/AS5047P_Settings.h" | ||
|
||
#if defined(AS5047P_STD_STRING_SUPPORT) | ||
#include <string> | ||
#include <sstream> | ||
#endif | ||
|
@@ -51,7 +53,7 @@ namespace AS5047P_Util { | |
|
||
} | ||
|
||
#if defined(ARDUINO_ARCH_SAMD) || defined(CORE_TEENSY) | ||
#if defined(AS5047P_STD_STRING_SUPPORT) | ||
|
||
/** | ||
* @brief Convert a value to a string (see std::to_string) | ||
|