diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 41be53a8..86711f05 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,10 @@ on: paths-ignore: - "**/*.md" +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: build-bhaptics: name: Build ${{ matrix.target }} ${{ matrix.coverage && 'with coverage' || 'without coverage' }}, -D ${{ matrix.battery_flag }} -D ${{ matrix.nimble_flag }} @@ -131,7 +135,7 @@ jobs: - name: Change memory segments if: matrix.coverage run: | - sed -i "s/len\s=\s0x2c200\s-\s0xdb5c/len = 2898880/" ~/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/ld/memory.ld + sed -i "s/len\s=\s0x2c200\s-\s0xdb5c/len = 2898880/" ~/.platformio/packages/framework-arduinoespressif32-libs/esp32/ld/memory.ld sed -i "/\[env\]/p; s/\[env\]/board_build.partitions = huge_app.csv/" platformio.ini - name: Build @@ -271,7 +275,7 @@ jobs: - name: Change memory segments if: matrix.coverage run: | - sed -i "s/len\s=\s0x2c200\s-\s0xdb5c/len = 2898880/" ~/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/ld/memory.ld + sed -i "s/len\s=\s0x2c200\s-\s0xdb5c/len = 2898880/" ~/.platformio/packages/framework-arduinoespressif32-libs/esp32/ld/memory.ld sed -i "/\[env\]/p; s/\[env\]/board_build.partitions = huge_app.csv/" platformio.ini - name: Build diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 93b31adf..9263ccb3 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -13,6 +13,10 @@ on: schedule: - cron: '0 16 * * 6' +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: analyze: name: Analyze diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 18755c7f..c2ef1716 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -14,6 +14,10 @@ on: paths-ignore: - '**/*.md' +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: clang-format: name: clang-format - `${{ matrix.path }}` diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 12fe53c4..8515cd38 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,6 +13,10 @@ on: paths: - '.github/workflows/release.yml' +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: build-bhaptics: runs-on: ubuntu-latest diff --git a/.wokwi/lucidgloves-prototype4+serial/test.yaml b/.wokwi/lucidgloves-prototype4+serial/test.yaml index d3a1f656..ed6807fb 100644 --- a/.wokwi/lucidgloves-prototype4+serial/test.yaml +++ b/.wokwi/lucidgloves-prototype4+serial/test.yaml @@ -3,7 +3,7 @@ version: 1 author: Leonid Meleshin steps: - - delay: 2000ms + - delay: 3000ms # Press calibration button - set-control: @@ -11,8 +11,9 @@ steps: control: pressed value: 1 - - delay: 250ms + - delay: 500ms + # Release calibration button - set-control: part-id: btn3 control: pressed diff --git a/ini/bhaptics.ini b/ini/bhaptics.ini index a9dc121b..7bcd9daf 100644 --- a/ini/bhaptics.ini +++ b/ini/bhaptics.ini @@ -1,7 +1,8 @@ [bhaptics] -platform = platformio/espressif32@^6.1.0 +platform = platformio/espressif32@^6.7.0 platform_packages = - platformio/framework-arduinoespressif32@^3.20014.231204 + framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.2 + framework-arduinoespressif32-libs @ https://github.com/espressif/arduino-esp32/releases/download/3.0.2/esp32-arduino-libs-3.0.2.zip framework = arduino board = esp32doit-devkit-v1 upload_speed = 921600 diff --git a/ini/opengloves.ini b/ini/opengloves.ini index 763fa00f..bd89da7e 100644 --- a/ini/opengloves.ini +++ b/ini/opengloves.ini @@ -1,7 +1,8 @@ [opengloves] -platform = platformio/espressif32@^6.1.0 +platform = platformio/espressif32@^6.7.0 platform_packages = - platformio/framework-arduinoespressif32@^3.20014.231204 + framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.2 + framework-arduinoespressif32-libs @ https://github.com/espressif/arduino-esp32/releases/download/3.0.2/esp32-arduino-libs-3.0.2.zip framework = arduino board = esp32doit-devkit-v1 upload_speed = 921600 diff --git a/lib/arduino/library.json b/lib/arduino/library.json index b906817b..844417f9 100644 --- a/lib/arduino/library.json +++ b/lib/arduino/library.json @@ -8,6 +8,6 @@ "adafruit/Adafruit PWM Servo Driver Library": "^2.4.0", "adafruit/Adafruit INA219": "^1.2.1", "sparkfun/SparkFun MAX1704x Fuel Gauge Arduino Library": "^1.0.4", - "madhephaestus/ESP32Servo": "^1.1.2" + "madhephaestus/ESP32Servo": "^3.0.0" } } diff --git a/lib/arduino_esp32/senseshift/arduino/output/ledc.hpp b/lib/arduino_esp32/senseshift/arduino/output/ledc.hpp index 6c29efed..064890ba 100644 --- a/lib/arduino_esp32/senseshift/arduino/output/ledc.hpp +++ b/lib/arduino_esp32/senseshift/arduino/output/ledc.hpp @@ -20,13 +20,14 @@ namespace SenseShift::Arduino::Output { { } + ~LedcOutput() override { ledcDetach(this->pin_); } + void init() override { pinMode(this->pin_, OUTPUT); - this->channel_ = findChannel(this->pin_); LOG_D(TAG, "GPIO %d - Setting up Channel %d", this->pin_, this->channel_); - if (ledcSetup(this->channel_, this->analog_frequency_, this->analog_resolution_) == 0) { + if (!ledcAttach(this->pin_, this->analog_frequency_, this->analog_resolution_)) { LOG_E( TAG, "setup failed (freq = %u, resolution = %u). Try setting different resolution or frequency", @@ -35,26 +36,19 @@ namespace SenseShift::Arduino::Output { ); return; } - ledcAttachPin(this->pin_, this->channel_); } - [[nodiscard]] auto getMaxValue() const -> std::uint32_t { return (1 << analog_resolution_) - 1; } + [[nodiscard]] inline auto getMaxValue() const -> std::uint32_t { return (1 << this->analog_resolution_) - 1; } void writeState(const float value) override { const auto duty = static_cast(value * this->getMaxValue()); LOG_V(TAG, "GPIO %d - Writing %d to Channel %d", this->pin_, duty, this->channel_); - ledcWrite(this->channel_, duty); + ledcWrite(this->pin_, duty); }; - protected: - static auto findChannel(std::uint8_t /*pin*/) -> std::int8_t { return CHANNELS++; } - private: - static inline std::uint8_t CHANNELS = 0; - std::uint8_t pin_; - std::int8_t channel_ = -1; std::uint8_t analog_resolution_; std::uint32_t analog_frequency_; }; diff --git a/lib/bhaptics_ble/senseshift/bh/ble/connection.cpp b/lib/bhaptics_ble/senseshift/bh/ble/connection.cpp index 0fd40054..f926a314 100644 --- a/lib/bhaptics_ble/senseshift/bh/ble/connection.cpp +++ b/lib/bhaptics_ble/senseshift/bh/ble/connection.cpp @@ -103,9 +103,10 @@ namespace SenseShift::BH::BLE { void onWrite(BLECharacteristic* pCharacteristic) override { - std::string value = pCharacteristic->getValue(); + auto value = pCharacteristic->getValue(); + std::string valueStr(value.begin(), value.end()); - this->motorTransformer(value); + this->motorTransformer(valueStr); }; }; diff --git a/lib/bhaptics_ble/senseshift/bh/ble/connection.hpp b/lib/bhaptics_ble/senseshift/bh/ble/connection.hpp index c35810b4..ebba352b 100644 --- a/lib/bhaptics_ble/senseshift/bh/ble/connection.hpp +++ b/lib/bhaptics_ble/senseshift/bh/ble/connection.hpp @@ -20,7 +20,11 @@ namespace SenseShift::BH::BLE { struct ConnectionConfig { static constexpr size_t SN_LENGTH = 10; +#if defined(SS_BLE_USE_NIMBLE) && SS_BLE_USE_NIMBLE == true std::string deviceName; +#else + String deviceName; +#endif uint16_t appearance; uint8_t serialNumber[SN_LENGTH]; }; diff --git a/lib/ble_serial/BLESerial.hpp b/lib/ble_serial/BLESerial.hpp index 090ecb75..de7c1d7b 100644 --- a/lib/ble_serial/BLESerial.hpp +++ b/lib/ble_serial/BLESerial.hpp @@ -237,7 +237,7 @@ class BLESerialCharacteristicCallbacks : public BLECharacteristicCallbacks { return; } - std::string rxValue = pCharacteristic->getValue(); + auto rxValue = pCharacteristic->getValue(); for (int i = 0; i < rxValue.length(); i++) { bleSerial->m_receiveBuffer.push(rxValue[i]); } diff --git a/platformio.ini b/platformio.ini index fb8423bb..cd54ac00 100644 --- a/platformio.ini +++ b/platformio.ini @@ -30,6 +30,7 @@ build_flags = ; -D DEBUG_ESP_PORT=Serial ; -D SS_BATTERY_ENABLED=true ; -D SS_BLE_USE_NIMBLE=true + -D SOC_WIFI_SUPPORTED=1 build_src_filter = +<*>