...changed some return types

This commit is contained in:
Wastl Kraus 2025-08-28 14:37:02 +02:00
parent 443d032d56
commit d7bcd523e0
5 changed files with 78 additions and 23 deletions

View File

@ -11,8 +11,8 @@ concurrency:
cancel-in-progress: true cancel-in-progress: true
env: env:
ARDUINO_CLI_VERSION: 'latest' ARDUINO_CLI_VERSION: '1.3.0'
ESP32_CORE_VERSION: 'latest' ESP32_CORE_VERSION: '3.3.0'
jobs: jobs:
# ============================================================================ # ============================================================================
@ -27,6 +27,25 @@ jobs:
- name: Checkout Repository - name: Checkout Repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup Arduino CLI
uses: arduino/setup-arduino-cli@v1
with:
version: ${{ env.ARDUINO_CLI_VERSION }}
- name: Cache Arduino data
uses: actions/cache@v4
with:
path: |
~/.arduino15
key: ${{ runner.os }}-arduino-${{ env.ESP32_CORE_VERSION }}-${{ hashFiles('**/libraries/**') }}
restore-keys: |
${{ runner.os }}-arduino-${{ env.ESP32_CORE_VERSION }}-
- name: Install ESP32 core
run: |
arduino-cli core update-index
arduino-cli core install esp32:esp32@${{ env.ESP32_CORE_VERSION }}
- name: Arduino Lint - name: Arduino Lint
uses: arduino/arduino-lint-action@v1 uses: arduino/arduino-lint-action@v1
with: with:
@ -55,12 +74,28 @@ jobs:
- name: Checkout Repository - name: Checkout Repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Compile Example (${{ matrix.build-flags.name }}) - name: Setup Arduino CLI
uses: arduino/compile-sketches@v1 uses: arduino/setup-arduino-cli@v1
with: with:
fqbn: esp32:esp32:esp32 version: ${{ env.ARDUINO_CLI_VERSION }}
libraries: |
- source-path: ${{ github.workspace }} - name: Cache Arduino data
uses: actions/cache@v4
with:
path: |
~/.arduino15
key: ${{ runner.os }}-arduino-${{ env.ESP32_CORE_VERSION }}-${{ hashFiles('**/libraries/**') }}
restore-keys: |
${{ runner.os }}-arduino-${{ env.ESP32_CORE_VERSION }}-
- name: Install ESP32 core
run: |
arduino-cli core update-index
arduino-cli core install esp32:esp32@${{ env.ESP32_CORE_VERSION }}
- name: Compile Example (${{ matrix.build-flags.name }})
run: |
arduino-cli compile --fqbn esp32:esp32:esp32 ${{ matrix.example }}
# ============================================================================ # ============================================================================
# Static Code Analysis # Static Code Analysis
@ -74,6 +109,25 @@ jobs:
- name: Checkout Repository - name: Checkout Repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup Arduino CLI
uses: arduino/setup-arduino-cli@v1
with:
version: ${{ env.ARDUINO_CLI_VERSION }}
- name: Cache Arduino data
uses: actions/cache@v4
with:
path: |
~/.arduino15
key: ${{ runner.os }}-arduino-${{ env.ESP32_CORE_VERSION }}-${{ hashFiles('**/libraries/**') }}
restore-keys: |
${{ runner.os }}-arduino-${{ env.ESP32_CORE_VERSION }}-
- name: Install ESP32 core
run: |
arduino-cli core update-index
arduino-cli core install esp32:esp32@${{ env.ESP32_CORE_VERSION }}
- name: Install Cppcheck - name: Install Cppcheck
run: sudo apt-get update && sudo apt-get install -y cppcheck run: sudo apt-get update && sudo apt-get install -y cppcheck

1
.gitignore vendored
View File

@ -21,3 +21,4 @@ examples/dshot300/esp32.svd
examples/dshot300/debug_custom.json examples/dshot300/debug_custom.json
examples/dshot300/debug.svd examples/dshot300/debug.svd
/build /build
/.github/chatmodes

View File

@ -53,7 +53,7 @@ DShotRMT::DShotRMT(uint16_t pin_nr, dshot_mode_t mode, bool is_bidirectional) :
} }
// Setup and configure DShotRMT // Setup and configure DShotRMT
bool DShotRMT::begin() uint16_t DShotRMT::begin()
{ {
// Inits TX Channel // Inits TX Channel
if (!_initTXChannel()) if (!_initTXChannel())
@ -320,7 +320,7 @@ uint16_t DShotRMT::_decodeDShotFrame(const rmt_symbol_word_t *symbols)
// Decodes each symbol to reconstruct the frame // Decodes each symbol to reconstruct the frame
for (size_t i = 0; i < DSHOT_BITS_PER_FRAME; ++i) for (size_t i = 0; i < DSHOT_BITS_PER_FRAME; ++i)
{ {
bool bit = symbols[i].duration0 < symbols[i].duration1; bool bit = symbols[i].duration0 > symbols[i].duration1;
received_frame = (received_frame << 1) | bit; received_frame = (received_frame << 1) | bit;
} }

View File

@ -15,20 +15,20 @@
#include <driver/rmt_rx.h> #include <driver/rmt_rx.h>
// --- DShot Protocol Constants --- // --- DShot Protocol Constants ---
static constexpr auto DSHOT_THROTTLE_FAILSAFE = 0; constexpr auto DSHOT_THROTTLE_FAILSAFE = 0;
static constexpr auto DSHOT_THROTTLE_MIN = 48; constexpr auto DSHOT_THROTTLE_MIN = 48;
static constexpr auto DSHOT_THROTTLE_MAX = 2047; constexpr auto DSHOT_THROTTLE_MAX = 2047;
static constexpr auto DSHOT_BITS_PER_FRAME = 16; constexpr auto DSHOT_BITS_PER_FRAME = 16;
static constexpr auto DSHOT_SWITCH_TIME = 30; // 30us constexpr auto DSHOT_SWITCH_TIME = 30; // 30us
static constexpr auto DSHOT_NULL_PACKET = 0b0000000000000000; constexpr auto DSHOT_NULL_PACKET = 0b0000000000000000;
// --- RMT Config Constants --- // --- RMT Config Constants ---
static constexpr auto DSHOT_CLOCK_SRC_DEFAULT = RMT_CLK_SRC_DEFAULT; constexpr auto DSHOT_CLOCK_SRC_DEFAULT = RMT_CLK_SRC_DEFAULT;
static constexpr auto DSHOT_RMT_RESOLUTION = 10 * 1000 * 1000; // 10 MHz constexpr auto DSHOT_RMT_RESOLUTION = 10 * 1000 * 1000; // 10 MHz
static constexpr auto TX_BUFFER_SIZE = DSHOT_BITS_PER_FRAME; constexpr auto TX_BUFFER_SIZE = DSHOT_BITS_PER_FRAME;
static constexpr auto RX_BUFFER_SIZE = 128; constexpr auto RX_BUFFER_SIZE = 128;
static constexpr auto DSHOT_SYMBOLS_SIZE = 64; constexpr auto DSHOT_SYMBOLS_SIZE = 64;
// --- DShot Mode Select --- // --- DShot Mode Select ---
typedef enum dshot_mode_e typedef enum dshot_mode_e
@ -71,7 +71,7 @@ public:
DShotRMT(uint16_t pin_nr, dshot_mode_t mode, bool is_bidirectional); DShotRMT(uint16_t pin_nr, dshot_mode_t mode, bool is_bidirectional);
// --- Init RMT Module --- // --- Init RMT Module ---
bool begin(); uint16_t begin();
// Sets the throttle value and transmits // Sets the throttle value and transmits
[[deprecated("Use sendThrottle() instead")]] [[deprecated("Use sendThrottle() instead")]]

View File

@ -42,7 +42,7 @@ void setup()
USB_SERIAL.printf("CPU Freq = %lu MHz\n", getCpuFrequencyMhz()); USB_SERIAL.printf("CPU Freq = %lu MHz\n", getCpuFrequencyMhz());
USB_SERIAL.printf("XTAL Freq = %lu MHz\n", getXtalFrequencyMhz()); USB_SERIAL.printf("XTAL Freq = %lu MHz\n", getXtalFrequencyMhz());
USB_SERIAL.printf("APB Freq = %lu Hz\n", getApbFrequency()); USB_SERIAL.printf("APB Freq = %lu Hz\n", getApbFrequency());
USB_SERIAL.println("***********************************"); USB_SERIAL.println("***********************************");
USB_SERIAL.println(" === DShotRMT Demo started. === "); USB_SERIAL.println(" === DShotRMT Demo started. === ");
USB_SERIAL.println("Enter a throttle value (48 2047):"); USB_SERIAL.println("Enter a throttle value (48 2047):");
@ -109,7 +109,7 @@ void print_RMT_packet()
USB_SERIAL.print("Current Frame: "); USB_SERIAL.print("Current Frame: ");
// Print bit by bit // Print bit by bit
for (auto i = 15; i >= 0; --i) for (int i = 15; i >= 0; --i)
{ {
if ((packet >> i) & 1) if ((packet >> i) & 1)
{ {