From d3692342e687f06053a261de7a502b7971d2ecc0 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Thu, 17 Nov 2022 12:15:54 +0100 Subject: [PATCH 01/11] Adding CI build action --- .github/workflows/compile-examples.yml | 99 ++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 .github/workflows/compile-examples.yml diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml new file mode 100644 index 0000000..5b15f3a --- /dev/null +++ b/.github/workflows/compile-examples.yml @@ -0,0 +1,99 @@ +name: Compile Examples + +on: + pull_request: + paths: + - ".github/workflows/compile-examples.yml" + - "examples/**" + - "src/**" + push: + paths: + - ".github/workflows/compile-examples.yml" + - "examples/**" + - "src/**" + +jobs: + build: + runs-on: ubuntu-latest + + env: + SKETCHES_REPORTS_PATH: sketches-reports + + strategy: + fail-fast: false + + matrix: + board: + - fqbn: arduino:samd:mkr1000 + platforms: | + - name: arduino:samd + - fqbn: arduino:samd:mkrzero + platforms: | + - name: arduino:samd + - fqbn: arduino:samd:mkrwifi1010 + platforms: | + - name: arduino:samd + - fqbn: arduino:samd:mkrfox1200 + platforms: | + - name: arduino:samd + - fqbn: arduino:samd:mkrwan1300 + platforms: | + - name: arduino:samd + - fqbn: arduino:samd:mkrwan1310 + platforms: | + - name: arduino:samd + - fqbn: arduino:samd:mkrgsm1400 + platforms: | + - name: arduino:samd + - fqbn: arduino:samd:mkrnb1500 + platforms: | + - name: arduino:samd + - fqbn: arduino:samd:mkrvidor4000 + platforms: | + - name: arduino:samd + - fqbn: arduino:mbed_portenta:envie_m7 + platforms: | + - name: arduino:mbed_portenta + - fqbn: arduino:mbed_portenta:envie_m4 + platforms: | + - name: arduino:mbed_portenta + - fqbn: arduino:mbed_nano:nano33ble + platforms: | + - name: arduino:mbed_nano + - fqbn: arduino:mbed_nano:nanorp2040connect + platforms: | + - name: arduino:mbed_nano + - fqbn: arduino:mbed_edge:edge_control + platforms: | + - name: arduino:mbed_edge + - fqbn: esp32:esp32:esp32 + platforms: | + - name: esp32:esp32 + source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json + - fqbn: rp2040:rp2040:rpipico + platforms: | + - name: rp2040:rp2040 + source-url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install ESP32 platform dependencies + if: startsWith(matrix.board.fqbn, 'esp32:esp32') + run: pip3 install pyserial + + - name: Compile examples + uses: arduino/compile-sketches@main + with: + fqbn: ${{ matrix.board.fqbn }} + platforms: ${{ matrix.board.platforms }} + enable-deltas-report: true + sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }} + + - name: Save memory usage change report as artifact + if: github.event_name == 'pull_request' + uses: actions/upload-artifact@v3 + with: + name: ${{ env.SKETCHES_REPORTS_PATH }} + path: ${{ env.SKETCHES_REPORTS_PATH }} From 82d962bbdce2da27e51132a2ac2ddeb783945719 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Fri, 18 Nov 2022 07:04:32 +0100 Subject: [PATCH 02/11] Add Arduino AVR to checked platforms. --- .github/workflows/compile-examples.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 5b15f3a..8e1e4cb 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -24,6 +24,9 @@ jobs: matrix: board: + - fqbn: arduino:avr:uno + platforms: | + - name: arduino:avr - fqbn: arduino:samd:mkr1000 platforms: | - name: arduino:samd From efed48085bc08ac1b6e0b8ba6e7e6c0e5f773fb8 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Fri, 18 Nov 2022 07:04:48 +0100 Subject: [PATCH 03/11] Pin workflow version to v1. --- .github/workflows/compile-examples.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 8e1e4cb..5791382 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -87,7 +87,7 @@ jobs: run: pip3 install pyserial - name: Compile examples - uses: arduino/compile-sketches@main + uses: arduino/compile-sketches@v1 with: fqbn: ${{ matrix.board.fqbn }} platforms: ${{ matrix.board.platforms }} From 24e96aa261b3941f5210fc0f83c31baeeeae5725 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Fri, 18 Nov 2022 07:05:26 +0100 Subject: [PATCH 04/11] Add CI compile badge. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index df03d53..986d168 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ # MagAlpha library +[![Compile Examples](https://github.com/monolithicpower/MagAlpha-Arduino-Library/workflows/Compile%20Examples/badge.svg)](https://github.com/monolithicpower/MagAlpha-Arduino-Library/actions?workflow=Compile+Examples) + Arduino library for the MPS MagAlpha magnetic angle sensor. ## About From 653a5a4f2345b877d385e7eb7578e930ae90ec6d Mon Sep 17 00:00:00 2001 From: Mathieu Kaelin Date: Wed, 15 Feb 2023 23:08:47 +0100 Subject: [PATCH 05/11] Add Rasperry Pi Pico test --- .github/workflows/compile-examples.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 5791382..09b32ad 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -54,6 +54,9 @@ jobs: - fqbn: arduino:samd:mkrvidor4000 platforms: | - name: arduino:samd + - fqbn: arduino:mbed_rp2040:pico + platforms: | + - name: arduino:mbed_rp2040 - fqbn: arduino:mbed_portenta:envie_m7 platforms: | - name: arduino:mbed_portenta From 9e694fc2988c98d69e398213ec338003a1dc4258 Mon Sep 17 00:00:00 2001 From: Mathieu Kaelin Date: Wed, 15 Feb 2023 23:57:04 +0100 Subject: [PATCH 06/11] Add gitignore --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8111780 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +# IDE related files +.vscode/ +.idea/ + +# Build related folders +build/ \ No newline at end of file From 9aa70f4b767cccc43aecf1142e0c71e0b9a4a471 Mon Sep 17 00:00:00 2001 From: Mathieu Kaelin Date: Wed, 15 Feb 2023 23:57:31 +0100 Subject: [PATCH 07/11] fix typos --- examples/edit-magalpha-config/edit-magalpha-config.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/edit-magalpha-config/edit-magalpha-config.ino b/examples/edit-magalpha-config/edit-magalpha-config.ino index 1273744..3d29f7b 100644 --- a/examples/edit-magalpha-config/edit-magalpha-config.ino +++ b/examples/edit-magalpha-config/edit-magalpha-config.ino @@ -25,7 +25,7 @@ void loop() { uint16_t angleRaw16; uint8_t angleRaw8; - Serial.println("Read Angle using differents methods:"); + Serial.println("Read Angle using different methods:"); //Read the angle in degree (Read 16-bit raw angle value and then convert it to the 0-360 degree range) angle = magAlpha.readAngle(); @@ -49,7 +49,7 @@ void loop() { //Read the angle (16-bit raw angle value) and check the parity bit to detect possible communication error bool error; - angleRaw16 = magAlpha.readAngleRaw16(&error); + angleRaw16 = magAlpha.readAngleRaw(&error); Serial.print(" magAlpha.readAngleRaw16(&error) = "); Serial.print(angleRaw16, DEC); if (error == true){ From ab9a835cdab4bcadbbf1879c1de5361aafa0c24e Mon Sep 17 00:00:00 2001 From: Mathieu Kaelin Date: Thu, 16 Feb 2023 00:30:14 +0100 Subject: [PATCH 08/11] remove SPI setDataMode function and replace it by SPISettings. This will improve the compatibility of the code across different platforms. For instance setDataMode is not supported on mbed based platforms like the Raspberry Pi Pico --- src/MagAlpha.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/MagAlpha.cpp b/src/MagAlpha.cpp index b35a7b3..793eaee 100644 --- a/src/MagAlpha.cpp +++ b/src/MagAlpha.cpp @@ -36,6 +36,7 @@ void MagAlpha::begin(int32_t spiSclkFrequency, uint8_t spiMode, uint8_t spiChip } void MagAlpha::end(){ + SPI.endTransaction(); SPI.end(); } @@ -132,12 +133,14 @@ uint8_t MagAlpha::writeRegister(uint8_t address, uint8_t value){ void MagAlpha::setSpiClockFrequency(uint32_t speedMaximum){ _speedMaximum = speedMaximum; + SPI.endTransaction(); SPI.beginTransaction(SPISettings(_speedMaximum, MSBFIRST, _spiMode)); } void MagAlpha::setSpiDataMode(uint8_t spiMode){ _spiMode = spiMode; - SPI.setDataMode(_spiMode); + SPI.endTransaction(); + SPI.beginTransaction(SPISettings(_speedMaximum, MSBFIRST, _spiMode)); } void MagAlpha::setSpiChipSelectPin(uint8_t spiChipSelectPin){ @@ -167,6 +170,7 @@ void MagAlphaSSI::begin(int32_t ssiSsckFrequency){ } void MagAlphaSSI::end(){ + SPI.endTransaction(); SPI.end(); } @@ -234,6 +238,7 @@ uint16_t MagAlphaSSI::readAngleRaw(bool* error){ void MagAlphaSSI::setSsiClockFrequency(uint32_t speedMaximum){ _speedMaximum = speedMaximum; + SPI.endTransaction(); SPI.beginTransaction(SPISettings(_speedMaximum, MSBFIRST, SSI_MODE)); } From 39f4b07371c0d846bf41884edc3e66e492905945 Mon Sep 17 00:00:00 2001 From: Mathieu Kaelin Date: Thu, 16 Feb 2023 00:31:12 +0100 Subject: [PATCH 09/11] increase version number to 1.0.2 --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 7ef9ac5..33a6805 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=MagAlpha Angle Sensor Library -version=1.0.1 +version=1.0.2 author=Mathieu Kaelin, Monolithic Power Systems maintainer=Mathieu Kaelin sentence=Arduino library for the MPS MagAlpha magnetic angle sensor. From 0fa9f614838ed9aa6895ca1d4663baa312dadff3 Mon Sep 17 00:00:00 2001 From: Mathieu Kaelin Date: Thu, 16 Feb 2023 00:44:25 +0100 Subject: [PATCH 10/11] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 986d168..e422626 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # MagAlpha library -[![Compile Examples](https://github.com/monolithicpower/MagAlpha-Arduino-Library/workflows/Compile%20Examples/badge.svg)](https://github.com/monolithicpower/MagAlpha-Arduino-Library/actions?workflow=Compile+Examples) +[![Compile Examples](https://github.com/monolithicpower/MagAlpha-Arduino-Library/actions/workflows/compile-examples.yml/badge.svg)](https://github.com/monolithicpower/MagAlpha-Arduino-Library/actions/workflows/compile-examples.yml) Arduino library for the MPS MagAlpha magnetic angle sensor. From f74adba793993bf948ffcde582c3536fbb8def6f Mon Sep 17 00:00:00 2001 From: Mathieu Kaelin Date: Thu, 16 Feb 2023 00:53:18 +0100 Subject: [PATCH 11/11] Update compile-examples.yml --- .github/workflows/compile-examples.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 09b32ad..06d5ccb 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -96,6 +96,7 @@ jobs: platforms: ${{ matrix.board.platforms }} enable-deltas-report: true sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }} + github-token: ${{ secrets.GITHUB_TOKEN }} - name: Save memory usage change report as artifact if: github.event_name == 'pull_request'