From 102a60e3272c43952160f3b8e47517f7c96a0fec Mon Sep 17 00:00:00 2001 From: Wastl Kraus Date: Mon, 25 Aug 2025 13:46:46 +0200 Subject: [PATCH] ...some tiny fixes from dev * ...update workflow * Update esp32.yml * ...testing new workflow config * ...testing new Github Actions * Update ci.yml --- .github/workflows/ci.yml | 138 ++++++++++++++++++++++++++++++++++++ .github/workflows/esp32.yml | 30 -------- DShotRMT.cpp | 4 +- DShotRMT.h | 8 ++- library.properties | 2 +- 5 files changed, 146 insertions(+), 36 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/esp32.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..499d2e7 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,138 @@ +name: ESP32 Build & Quality Check + +on: + push: + branches: [ '*' ] + release: + types: [ published ] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + ARDUINO_CLI_VERSION: 'latest' + ESP32_CORE_VERSION: 'latest' + +jobs: + # ============================================================================ + # Code Quality & Linting + # ============================================================================ + quality-check: + name: 'Code Quality' + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Arduino Lint + uses: arduino/arduino-lint-action@v1 + with: + path: ${{ github.workspace }} + compliance: strict + library-manager: update + verbose: true + + # ============================================================================ + # Compilation Test + # ============================================================================ + compile-test: + name: 'Compile Example Sketch' + runs-on: ubuntu-latest + timeout-minutes: 15 + strategy: + fail-fast: false + matrix: + example: + - "examples/dshot300/dshot300.ino" + build-flags: + - name: "Release" + flags: "Automated Build" + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Compile Example (${{ matrix.build-flags.name }}) + uses: arduino/compile-sketches@v1 + with: + fqbn: esp32:esp32:esp32 + libraries: | + - source-path: ${{ github.workspace }} + + # ============================================================================ + # Static Code Analysis + # ============================================================================ + static-analysis: + name: 'Static Analysis' + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Install Cppcheck + run: sudo apt-get update && sudo apt-get install -y cppcheck + + - name: Run Cppcheck + run: | + cppcheck --enable=warning,performance \ + --std=c++17 \ + --language=c++ \ + --platform=unix32 \ + --inline-suppr \ + ./DShotRMT.cpp ./DShotRMT.h + + # ============================================================================ + # Build Status Report + # ============================================================================ + build-summary: + name: 'Build Summary' + runs-on: ubuntu-latest + if: always() + needs: [quality-check, compile-test, static-analysis] + + steps: + - name: Create Build Summary + run: | + echo "# 🔧 DShotRMT Build Report" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "| Check | Status | Details |" >> $GITHUB_STEP_SUMMARY + echo "|-------|--------|---------|" >> $GITHUB_STEP_SUMMARY + + # Quality Check Status + if [[ "${{ needs.quality-check.result }}" == "success" ]]; then + echo "| 📋 Quality Check | ✅ Passed | Arduino Lint completed successfully |" >> $GITHUB_STEP_SUMMARY + else + echo "| 📋 Quality Check | ❌ Failed | Check Arduino Lint report |" >> $GITHUB_STEP_SUMMARY + fi + + # Compile Test Status + if [[ "${{ needs.compile-test.result }}" == "success" ]]; then + echo "| 🔨 Compilation | ✅ Passed | All examples compiled successfully |" >> $GITHUB_STEP_SUMMARY + else + echo "| 🔨 Compilation | ❌ Failed | Compilation errors detected |" >> $GITHUB_STEP_SUMMARY + fi + + # Static Analysis Status + if [[ "${{ needs.static-analysis.result }}" == "success" ]]; then + echo "| 🔍 Static Analysis | ✅ Passed | No critical issues found |" >> $GITHUB_STEP_SUMMARY + else + echo "| 🔍 Static Analysis | ❌ Failed | Issues detected by CPPCheck |" >> $GITHUB_STEP_SUMMARY + fi + + echo "" >> $GITHUB_STEP_SUMMARY + + # Overall Status + if [[ "${{ needs.quality-check.result }}" == "success" && + "${{ needs.compile-test.result }}" == "success" && + "${{ needs.static-analysis.result }}" == "success" ]]; then + echo "## 🎉 All Checks Passed!" >> $GITHUB_STEP_SUMMARY + echo "Your DShotRMT library is ready for deployment." >> $GITHUB_STEP_SUMMARY + else + echo "## ⚠️ Action Required" >> $GITHUB_STEP_SUMMARY + echo "Please review the failed checks and address any issues." + fi diff --git a/.github/workflows/esp32.yml b/.github/workflows/esp32.yml deleted file mode 100644 index e165bd0..0000000 --- a/.github/workflows/esp32.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Build DShotRMT Example Sketch - -on: - push: - branches: - - '*' - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Arduino CLI - run: | - curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=/usr/local/bin sh - arduino-cli core update-index - arduino-cli core install esp32:esp32 - - - name: Install DShotRMT as library - run: | - mkdir -p $HOME/Arduino/libraries - ln -s $PWD $HOME/Arduino/libraries/DShotRMT - - - name: Compile dshot300.ino example - run: | - arduino-cli compile --fqbn esp32:esp32:esp32 examples/dshot300/dshot300.ino - \ No newline at end of file diff --git a/DShotRMT.cpp b/DShotRMT.cpp index afcc34c..73dca3f 100644 --- a/DShotRMT.cpp +++ b/DShotRMT.cpp @@ -274,7 +274,7 @@ dshot_packet_t DShotRMT::_buildDShotPacket(const uint16_t value) } // Encodes DShot packet into RMT buffer and places code into IRAM instead of flash -bool IRAM_ATTR DShotRMT::_encodeDShotFrame(const dshot_packet_t &packet, rmt_symbol_word_t *symbols) +bool DShotRMT::_encodeDShotFrame(const dshot_packet_t &packet, rmt_symbol_word_t *symbols) { // Parse actual packet into buffer _current_packet = _parseDShotPacket(packet); @@ -337,7 +337,7 @@ uint16_t DShotRMT::_decodeDShotFrame(const rmt_symbol_word_t *symbols) } // Timer triggered -bool IRAM_ATTR DShotRMT::_timer_signal() +bool DShotRMT::_timer_signal() { // trying new tricks return __builtin_expect((micros() - _last_transmission_time >= _frame_timer_us), 1); diff --git a/DShotRMT.h b/DShotRMT.h index 065dee7..6e364c0 100644 --- a/DShotRMT.h +++ b/DShotRMT.h @@ -67,14 +67,16 @@ class DShotRMT { public: // --- DShot Config --- - DShotRMT(gpio_num_t gpio, dshot_mode_t mode = DSHOT300, bool is_bidirectional = false); + explicit DShotRMT(gpio_num_t gpio = GPIO_NUM_16, dshot_mode_t mode = DSHOT300, bool is_bidirectional = false); DShotRMT(uint16_t pin_nr, dshot_mode_t mode, bool is_bidirectional); // --- Init RMT Module --- bool begin(); // Sets the throttle value and transmits - bool setThrottle(uint16_t throttle); // deprecated + [[deprecated("Use sendThrottle() instead")]] + bool setThrottle(uint16_t throttle); + bool sendThrottle(uint16_t throttle); // Sends a DShot Command @@ -145,7 +147,7 @@ private: static constexpr auto DSHOT_OK = 0; static constexpr auto DSHOT_ERROR = 1; static constexpr auto *DSHOT_MSG_01 = "Failed to initialize TX channel!"; - static constexpr auto *DSHOT_MSG_02 = "Failed to initialize RX channe!l"; + static constexpr auto *DSHOT_MSG_02 = "Failed to initialize RX channel!"; static constexpr auto *DSHOT_MSG_03 = "Failed to initialize DShot encoder!"; static constexpr auto *DSHOT_MSG_04 = "RX CRC Check failed!"; static constexpr auto *DSHOT_MSG_05 = "Throttle value not in range (48 - 2047)!"; diff --git a/library.properties b/library.properties index e526f8f..158df30 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=DShotRMT -version=0.6.0 +version=0.6.1 author=derdoktor667 maintainer=derdoktor667 sentence=DShotRMT Library supporting all DShot Types and speeds. Tested with BlHeli_S.