Skip to content

Commit

Permalink
Merge pull request #43 from jonas-merkle/develop
Browse files Browse the repository at this point in the history
Fix for #41
  • Loading branch information
jonas-merkle authored Nov 20, 2022
2 parents 194614f + f8cdd71 commit 54dc68f
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 43 deletions.
2 changes: 1 addition & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "AS5047P - Arduino Library"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 2.1.5
PROJECT_NUMBER = 2.2.0

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
4 changes: 2 additions & 2 deletions examples/BasicReadAngle/BasicReadAngle.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
12 changes: 2 additions & 10 deletions examples/BasicReadAngleAndDebugInfo/BasicReadAngleAndDebugInfo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* @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.
* In addition to the angle value the error information gets displayed.
* @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.
*
Expand Down
4 changes: 2 additions & 2 deletions examples/PrintAllSettings/PrintAllSettings.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "AS5047P",
"version": "2.1.5",
"version": "2.2.0",
"description": "An Arduino library for the AS5047P high-resolution rotary position sensor. Supporting also the following sensor types: AS5047D, AS5147, AS5147P, AS5247",
"keywords": "arduino-library, as5047p, spi, sensor, rotary-encoder, high-resolution, rotary-position-sensor, as5x47, as5047d, as5147, as5147p, as5247, encoder, rotaty, angle, uvw, abi",
"repository":
Expand Down
2 changes: 1 addition & 1 deletion library.properties
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.
Expand Down
6 changes: 3 additions & 3 deletions src/AS5047P.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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() {

Expand Down
10 changes: 6 additions & 4 deletions src/AS5047P.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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

Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/spi/AS5047P_SPI_Arduino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
4 changes: 2 additions & 2 deletions src/spi/AS5047P_SPI_Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
6 changes: 3 additions & 3 deletions src/types/AS5047P_Types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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() {

Expand Down
10 changes: 6 additions & 4 deletions src/types/AS5047P_Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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

Expand Down Expand Up @@ -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.
Expand Down
14 changes: 12 additions & 2 deletions src/util/AS5047P_Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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
10 changes: 6 additions & 4 deletions src/util/AS5047P_Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 54dc68f

Please sign in to comment.