diff --git a/.github/ISSUE_TEMPLATE/Issue-report.yml b/.github/ISSUE_TEMPLATE/Issue-report.yml index 3efe4537204..1dc31c32872 100644 --- a/.github/ISSUE_TEMPLATE/Issue-report.yml +++ b/.github/ISSUE_TEMPLATE/Issue-report.yml @@ -41,6 +41,7 @@ body: options: - latest master (checkout manually) - latest development Release Candidate (RC-X) + - v2.0.8 - v2.0.7 - v2.0.6 - v2.0.5 diff --git a/.github/scripts/find_all_boards.sh b/.github/scripts/find_all_boards.sh new file mode 100755 index 00000000000..a2c53c212c5 --- /dev/null +++ b/.github/scripts/find_all_boards.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Get all boards +boards_array=() + +for line in `grep '.tarch=' boards.txt`; do + board_name=$(echo "$line" | cut -d '.' -f1 | cut -d '#' -f1) + boards_array+=("espressif:esp32:$board_name") + echo "Added 'espressif:esp32:$board_name' to array" +done + +# Create JSON like string with all boards found and pass it to env variable +board_count=${#boards_array[@]} +echo "Boards found: $board_count" +echo "BOARD-COUNT=$board_count" >> $GITHUB_ENV + +if [ $board_count -gt 0 ] +then + json_matrix='[' + for board in ${boards_array[@]} + do + json_matrix+='"'$board'"' + if [ $board_count -gt 1 ] + then + json_matrix+="," + fi + board_count=$(($board_count - 1)) + done + json_matrix+=']' + + echo $json_matrix + echo "FQBNS=${json_matrix}" >> $GITHUB_ENV +else + echo "FQBNS=" >> $GITHUB_ENV +fi diff --git a/.github/workflows/allboards.yml b/.github/workflows/allboards.yml new file mode 100644 index 00000000000..ddd631b1bf8 --- /dev/null +++ b/.github/workflows/allboards.yml @@ -0,0 +1,86 @@ +name: Boards Test - Remote trigger + +# The workflow will run on remote dispath with event-type set to "test-boards" +on: + repository_dispatch: + types: [test-boards] + +jobs: + find-boards: + runs-on: ubuntu-latest + + outputs: + fqbns: ${{ env.FQBNS }} + board-count: ${{ env.BOARD-COUNT }} + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + ref: ${{ github.event.client_payload.branch }} + + - name: Get boards fqbns + run: + bash .github/scripts/find_all_boards.sh + + setup-chunks: + needs: find-boards + runs-on: ubuntu-latest + if: needs.find-boards.outputs.fqbns != '' + + outputs: + test-chunks: ${{ steps['set-test-chunks'].outputs['test-chunks'] }} + + steps: + - uses: actions/checkout@v3 + - run: npm install + - name: Setup jq + uses: dcarbone/install-jq-action@v1.0.1 + + - id: set-test-chunks + name: Set Chunks + run: + echo "test-chunks<> $GITHUB_OUTPUT + + echo "$( jq -nc '${{ needs.find-boards.outputs.fqbns }} | [_nwise( ${{ needs.find-boards.outputs.board-count }}/15 | ceil)]')" >> $GITHUB_OUTPUT + + echo "EOF" >> $GITHUB_OUTPUT + + test-boards: + needs: setup-chunks + runs-on: ubuntu-latest + + env: + REPOSITORY: | + - source-path: '.' + name: "espressif:esp32" + + strategy: + fail-fast: false + matrix: + chunk: ${{ fromJSON(needs.setup-chunks.outputs['test-chunks']) }} + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Echo FQBNS to file + run: + echo "$FQBN" > fqbns.json + env: + FQBN: ${{ toJSON(matrix.chunk) }} + + - name: Compile sketch + uses: P-R-O-C-H-Y/compile-sketches@main + with: + platforms: | + ${{ env.REPOSITORY }} + multiple-fqbn: true + multiple-fqbn-path: "fqbns.json" + use-json-file: false + enable-deltas-report: false + enable-warnings-report: false + cli-compile-flags: | + - --warnings="all" + sketch-paths: + "- ./libraries/ESP32/examples/CI/CIBoardsTest/CIBoardsTest.ino" diff --git a/.github/workflows/lib.json b/.github/workflows/lib.json index c237537bd38..453267a2d2d 100644 --- a/.github/workflows/lib.json +++ b/.github/workflows/lib.json @@ -19,9 +19,6 @@ "name": "ESP32Servo", "exclude_targets": [], "sketch_path": [ - "~/Arduino/libraries/ESP32Servo/examples/Knob/Knob.ino", - "~/Arduino/libraries/ESP32Servo/examples/Sweep/Sweep.ino", - "~/Arduino/libraries/ESP32Servo/examples/PWMExample/PWMExample.ino", "~/Arduino/libraries/ESP32Servo/examples/Multiple-Servo-Example-Arduino/Multiple-Servo-Example-Arduino.ino" ] }, @@ -51,5 +48,19 @@ "sketch_path": [ "~/Arduino/libraries/IRremote/examples/SendDemo/SendDemo.ino" ] + }, + { + "name": "MFRC522", + "exclude_targets": [], + "sketch_path": [ + "~/Arduino/libraries/MFRC522/examples/ReadUidMultiReader/ReadUidMultiReader.ino" + ] + }, + { + "name": "WS2812FX", + "exclude_targets": [], + "sketch_path": [ + "~/Arduino/libraries/WS2812FX/examples/ws2812fx_spi/ws2812fx_spi.ino" + ] } ] \ No newline at end of file diff --git a/boards.txt b/boards.txt index 7fef6d89647..f3ea5e1cc5b 100644 --- a/boards.txt +++ b/boards.txt @@ -7314,6 +7314,7 @@ dfrobot_beetle_esp32c3.menu.EraseFlash.all.upload.erase_cmd=-e dfrobot_firebeetle2_esp32e.name=FireBeetle 2 ESP32-E dfrobot_firebeetle2_esp32e.upload.tool=esptool_py +dfrobot_firebeetle2_esp32e.upload.tool.default=esptool_py dfrobot_firebeetle2_esp32e.upload.maximum_size=1310720 dfrobot_firebeetle2_esp32e.upload.maximum_data_size=327680 dfrobot_firebeetle2_esp32e.upload.flags= @@ -22259,6 +22260,7 @@ esp32c3m1IKit.menu.EraseFlash.all.upload.erase_cmd=-e roboheart_hercules.name=RoboHeart Hercules roboheart_hercules.upload.tool=esptool_py +roboheart_hercules.upload.tool.default=esptool_py roboheart_hercules.upload.maximum_size=1310720 roboheart_hercules.upload.maximum_data_size=327680 roboheart_hercules.upload.wait_for_upload_port=true diff --git a/cores/esp32/WString.h b/cores/esp32/WString.h index 261868bc9aa..6517109f29b 100644 --- a/cores/esp32/WString.h +++ b/cores/esp32/WString.h @@ -34,8 +34,8 @@ // A pure abstract class forward used as a means to proide a unique pointer type // but really is never defined. class __FlashStringHelper; -#define FPSTR(pstr_pointer) (pstr_pointer) -#define F(string_literal) (string_literal) +#define FPSTR(str_pointer) (reinterpret_cast(str_pointer)) +#define F(string_literal) (FPSTR(PSTR(string_literal))) // An inherited class for holding the result of a concatenation. These // result objects are assumed to be writable by subsequent concatenations. diff --git a/cores/esp32/esp32-hal-ledc.c b/cores/esp32/esp32-hal-ledc.c index a02431b58fb..08dba67104c 100644 --- a/cores/esp32/esp32-hal-ledc.c +++ b/cores/esp32/esp32-hal-ledc.c @@ -215,26 +215,32 @@ static int cnt_channel = LEDC_CHANNELS; static uint8_t analog_resolution = 8; static int analog_frequency = 1000; void analogWrite(uint8_t pin, int value) { - // Use ledc hardware for internal pins - if (pin < SOC_GPIO_PIN_COUNT) { - if (pin_to_channel[pin] == 0) { - if (!cnt_channel) { - log_e("No more analogWrite channels available! You can have maximum %u", LEDC_CHANNELS); - return; - } - if(ledcSetup(cnt_channel - 1, analog_frequency, analog_resolution) == 0){ - log_e("analogWrite setup failed (freq = %u, resolution = %u). Try setting different resolution or frequency"); - return; - } - ledcAttachPin(pin, cnt_channel - 1); - pin_to_channel[pin] = cnt_channel--; + // Use ledc hardware for internal pins + if (pin < SOC_GPIO_PIN_COUNT) { + int8_t channel = -1; + if (pin_to_channel[pin] == 0) { + if (!cnt_channel) { + log_e("No more analogWrite channels available! You can have maximum %u", LEDC_CHANNELS); + return; + } + cnt_channel--; + channel = cnt_channel; + } else { + channel = analogGetChannel(pin); + } + log_v("GPIO %d - Using Channel %d, Value = %d", pin, channel, value); + if(ledcSetup(channel, analog_frequency, analog_resolution) == 0){ + log_e("analogWrite setup failed (freq = %u, resolution = %u). Try setting different resolution or frequency"); + return; + } + ledcAttachPin(pin, channel); + pin_to_channel[pin] = channel; + ledcWrite(channel, value); } - ledcWrite(pin_to_channel[pin] - 1, value); - } } int8_t analogGetChannel(uint8_t pin) { - return pin_to_channel[pin] - 1; + return pin_to_channel[pin]; } void analogWriteFrequency(uint32_t freq) { diff --git a/cores/esp32/esp_arduino_version.h b/cores/esp32/esp_arduino_version.h index beeb4976a26..a16dc6f8eaf 100644 --- a/cores/esp32/esp_arduino_version.h +++ b/cores/esp32/esp_arduino_version.h @@ -23,7 +23,7 @@ extern "C" { /** Minor version number (x.X.x) */ #define ESP_ARDUINO_VERSION_MINOR 0 /** Patch version number (x.x.X) */ -#define ESP_ARDUINO_VERSION_PATCH 8 +#define ESP_ARDUINO_VERSION_PATCH 9 /** * Macro to convert ARDUINO version number into an integer diff --git a/docs/source/api/timer.rst b/docs/source/api/timer.rst index d253b6794f9..7a97feaabce 100644 --- a/docs/source/api/timer.rst +++ b/docs/source/api/timer.rst @@ -48,10 +48,10 @@ This function is used to end timer. * ``timer`` timer struct. -timerSetConfig +timerGetConfig ************** -This function is used to configure initialized timer (timerBegin() called). +This function is used to get configuration of initialized timer (timerBegin() called). .. code-block:: arduino @@ -62,6 +62,18 @@ This function is used to configure initialized timer (timerBegin() called). This function will return ``configuration`` as uint32_t number. This can be translated by inserting it to struct ``timer_cfg_t.val``. +timerSetConfig +************** + +This function is used to configure initialized timer (timerBegin() called). + +.. code-block:: arduino + + void timerSetConfig(hw_timer_t *timer, uint32_t config); + +* ``timer`` timer struct. +* ``config`` configuration as uint32_t number. Use configuration struct ``timer_cfg_t`` and pass ``timer_cfg_t.val`` as ``config`` paramater. + timerAttachInterrupt ******************** @@ -372,4 +384,4 @@ Repeat timer example: Watchdog timer example: .. literalinclude:: ../../../libraries/ESP32/examples/Timer/WatchdogTimer/WatchdogTimer.ino - :language: arduino \ No newline at end of file + :language: arduino diff --git a/docs/source/getting_started.rst b/docs/source/getting_started.rst index 0b4280d4b91..4093b415c07 100644 --- a/docs/source/getting_started.rst +++ b/docs/source/getting_started.rst @@ -133,6 +133,7 @@ in the examples menu or inside each library folder. https://github.com/espressif/arduino-esp32/tree/master/libraries +There is also a `list of examples `_ managed outside of Espressif, so check them out. .. include:: common/datasheet.inc diff --git a/libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino b/libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino index 009de6e1e52..17491588d86 100644 --- a/libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino +++ b/libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino @@ -60,8 +60,8 @@ void setup() { config.pin_pclk = PCLK_GPIO_NUM; config.pin_vsync = VSYNC_GPIO_NUM; config.pin_href = HREF_GPIO_NUM; - config.pin_sscb_sda = SIOD_GPIO_NUM; - config.pin_sscb_scl = SIOC_GPIO_NUM; + config.pin_sccb_sda = SIOD_GPIO_NUM; + config.pin_sccb_scl = SIOC_GPIO_NUM; config.pin_pwdn = PWDN_GPIO_NUM; config.pin_reset = RESET_GPIO_NUM; config.xclk_freq_hz = 20000000; diff --git a/libraries/ESPmDNS/src/ESPmDNS.cpp b/libraries/ESPmDNS/src/ESPmDNS.cpp index 77ab313a08f..cb2828716b1 100644 --- a/libraries/ESPmDNS/src/ESPmDNS.cpp +++ b/libraries/ESPmDNS/src/ESPmDNS.cpp @@ -60,7 +60,7 @@ MDNSResponder::~MDNSResponder() { end(); } -bool MDNSResponder::begin(const char* hostName){ +bool MDNSResponder::begin(const String& hostName){ if(mdns_init()){ log_e("Failed starting MDNS"); return false; @@ -68,7 +68,7 @@ bool MDNSResponder::begin(const char* hostName){ //WiFi.onEvent(_on_sys_event); _hostname = hostName; _hostname.toLowerCase(); - if(mdns_hostname_set(hostName)) { + if(mdns_hostname_set(hostName.c_str())) { log_e("Failed setting MDNS hostname"); return false; } diff --git a/libraries/ESPmDNS/src/ESPmDNS.h b/libraries/ESPmDNS/src/ESPmDNS.h index 16c590d4a87..9a5e5c14184 100644 --- a/libraries/ESPmDNS/src/ESPmDNS.h +++ b/libraries/ESPmDNS/src/ESPmDNS.h @@ -54,7 +54,10 @@ class MDNSResponder { public: MDNSResponder(); ~MDNSResponder(); - bool begin(const char* hostName); + bool begin(const String& hostName); + bool begin(const char* hostName){ + return begin(String(hostName)); + } void end(); void setInstanceName(String name); diff --git a/libraries/WiFi/src/WiFiSTA.cpp b/libraries/WiFi/src/WiFiSTA.cpp index 7bcafea1d3e..185aaa84503 100644 --- a/libraries/WiFi/src/WiFiSTA.cpp +++ b/libraries/WiFi/src/WiFiSTA.cpp @@ -366,6 +366,22 @@ bool WiFiSTAClass::disconnect(bool wifioff, bool eraseap) return false; } +/** + * @brief Reset WiFi settings in NVS to default values. + * @return true if erase succeeded + * @note: Resets SSID, password, protocol, mode, etc. + * These settings are maintained by WiFi driver in IDF. + * WiFi driver must be initialized. + */ +bool WiFiSTAClass::eraseAP(void) { + if(WiFi.getMode()==WIFI_MODE_NULL) { + if(!WiFi.enableSTA(true)) + return false; + } + + return esp_wifi_restore()==ESP_OK; +} + /** * Change IP configuration settings disabling the dhcp client * @param local_ip Static ip configuration diff --git a/libraries/WiFi/src/WiFiSTA.h b/libraries/WiFi/src/WiFiSTA.h index b8bb855c198..0b8f9daf053 100644 --- a/libraries/WiFi/src/WiFiSTA.h +++ b/libraries/WiFi/src/WiFiSTA.h @@ -45,7 +45,13 @@ class WiFiSTAClass public: wl_status_t begin(const char* wpa2_ssid, wpa2_auth_method_t method, const char* wpa2_identity=NULL, const char* wpa2_username=NULL, const char *wpa2_password=NULL, const char* ca_pem=NULL, const char* client_crt=NULL, const char* client_key=NULL, int32_t channel=0, const uint8_t* bssid=0, bool connect=true); + wl_status_t begin(const String& wpa2_ssid, wpa2_auth_method_t method, const String& wpa2_identity = (const char*)NULL, const String& wpa2_username = (const char*)NULL, const String& wpa2_password = (const char*)NULL, const String& ca_pem = (const char*)NULL, const String& client_crt = (const char*)NULL, const String& client_key = (const char*)NULL, int32_t channel=0, const uint8_t* bssid=0, bool connect=true) { + return begin(wpa2_ssid.c_str(), method, wpa2_identity.c_str(), wpa2_username.c_str(), wpa2_password.c_str(), ca_pem.c_str(), client_crt.c_str(), client_key.c_str(), channel, bssid, connect); + } wl_status_t begin(const char* ssid, const char *passphrase = NULL, int32_t channel = 0, const uint8_t* bssid = NULL, bool connect = true); + wl_status_t begin(const String& ssid, const String& passphrase = (const char*)NULL, int32_t channel = 0, const uint8_t* bssid = NULL, bool connect = true) { + return begin(ssid.c_str(), passphrase.c_str(), channel, bssid, connect); + } wl_status_t begin(char* ssid, char *passphrase = NULL, int32_t channel = 0, const uint8_t* bssid = NULL, bool connect = true); wl_status_t begin(); @@ -53,6 +59,7 @@ class WiFiSTAClass bool reconnect(); bool disconnect(bool wifioff = false, bool eraseap = false); + bool eraseAP(void); bool isConnected(); diff --git a/package.json b/package.json index 973add3b31f..057c2e1e3f6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "framework-arduinoespressif32", - "version": "2.0.8", + "version": "2.0.9", "description": "Arduino Wiring-based Framework for the Espressif ESP32, ESP32-S and ESP32-C series of SoCs", "keywords": [ "framework", diff --git a/platform.txt b/platform.txt index 7aefee20c93..8bb67884e71 100644 --- a/platform.txt +++ b/platform.txt @@ -1,5 +1,5 @@ name=ESP32 Arduino -version=2.0.8 +version=2.0.9 tools.xtensa-esp32-elf-gcc.path={runtime.platform.path}/tools/xtensa-esp32-elf tools.xtensa-esp32s2-elf-gcc.path={runtime.platform.path}/tools/xtensa-esp32s2-elf