Skip to content

Commit

Permalink
update arduino esp32 branches (espressif#312)
Browse files Browse the repository at this point in the history
* update arduino esp32 branches

* add note to readme, mv repository url to config
  • Loading branch information
brianignacio5 authored Feb 18, 2021
1 parent f430066 commit c01c51f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ Click <kbd>F1</kbd> to show Visual studio code actions, then type **ESP-IDF** to

The **Add Arduino-ESP32 as ESP-IDF Component** command will add [Arduino-ESP32](https://github.com/espressif/arduino-esp32) as a ESP-IDF component in your current directory (`${CURRENT_DIRECTORY}/components/arduino`). You can also use the **Create ESP-IDF project** command with `arduino-as-component` template to create a new project directory that includes Arduino-esp32 as an ESP-IDF component.

> **NOTE** Not all versions of ESP-IDF are supported. Make sure to check [Arduino-ESP32](https://github.com/espressif/arduino-esp32) to see if your ESP-IDF version is compatible.
The **Show Examples Projects** command allows you create a new project using one of the examples in ESP-IDF, ESP-ADF or ESP-MDF directory if related configuration settings are set.
The **Install ESP-ADF** will clone ESP-ADF to a selected directory and set `idf.espAdfPath` (`idf.espAdfPathWin` in Windows) configuration setting.
The **Install ESP-MDF** will clone ESP-MDF to a selected directory and set `idf.espMdfPath` (`idf.espMdfPathWin` in Windows) configuration setting.
Expand Down
6 changes: 6 additions & 0 deletions docs/FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ This extension provides many features to ease development of ESP-IDF Projects.
- [CMake Editor](#CMake-Editor)
- [Support for WSL 2](./WSL.md)

## Arduino as ESP-IDF component

The **Add Arduino-ESP32 as ESP-IDF Component** command will add [Arduino-ESP32](https://github.com/espressif/arduino-esp32) as a ESP-IDF component in your current directory (`${CURRENT_DIRECTORY}/components/arduino`). You can also use the **Create ESP-IDF project** command with `arduino-as-component` template to create a new project directory that includes Arduino-esp32 as an ESP-IDF component.

> **NOTE** Not all versions of ESP-IDF are supported. Make sure to check [Arduino-ESP32](https://github.com/espressif/arduino-esp32) to see if your ESP-IDF version is compatible.
## Build

**ESP-IDF: Build your project** is provided by this extension to build your project using `CMake` and `Ninja-build` as explained in [ESP-IDF Build system using Cmake directly](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#using-cmake-directly).
Expand Down
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export namespace ESP {
export namespace URL {
export const GithubRepository =
"https://github.com/espressif/vscode-esp-idf-extension";
export const ARDUINO_ESP32_URL =
"https://github.com/espressif/arduino-esp32.git";
export namespace Docs {
export const BASE_URL = "https://docs.espressif.com/projects/esp-idf";
export let IDF_INDEX;
Expand Down
23 changes: 10 additions & 13 deletions src/espIdf/arduino/addArduinoComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ import { join } from "path";
import { ensureDir } from "fs-extra";
import { OutputChannel } from "../../logger/outputChannel";
import { Logger } from "../../logger/logger";
import { Progress } from "vscode";
import { ESP } from "../../config";

export class ArduinoComponentInstaller {
private readonly ARDUINO_ESP32_URL =
"https://github.com/espressif/arduino-esp32.git";
private readonly projectDir: string;
private cloneProcess: ChildProcess;
constructor(projectDir: string) {
Expand Down Expand Up @@ -58,7 +56,7 @@ export class ArduinoComponentInstaller {
"--progress",
"-b",
branchToUse,
this.ARDUINO_ESP32_URL,
ESP.URL.ARDUINO_ESP32_URL,
"arduino",
],
{ cwd: componentsDir }
Expand Down Expand Up @@ -88,21 +86,20 @@ export class ArduinoComponentInstaller {
idfConf.readParameter("idf.espIdfPath") || process.env.IDF_PATH;
}
const idfVersion = await getEspIdfVersion(espIdfPath);
const results = {
const majorMinorMatches = idfVersion.match(/([0-9]+\.[0-9]+).*/);
const espIdfVersion =
majorMinorMatches && majorMinorMatches.length > 0
? majorMinorMatches[1]
: "x.x";
const results: { [key: string]: string } = {
"4.0": "idf-release/v4.0",
"3.3": "idf-release/v3.3",
"4.2": "idf-release/v4.2",
};
return results[idfVersion] || undefined;
return results[espIdfVersion] || "master";
}

public async addArduinoAsComponent(espIdfPath?: string) {
const branchToUse = await this.checkIdfVersion(espIdfPath);
if (!branchToUse) {
Logger.infoNotify(
"ESP-IDF version 4.0 or 3.3 is required for Arduino ESP32"
);
return;
}
await ensureDir(this.projectDir);
await this.cloneArduinoInComponentsFolder(branchToUse);
}
Expand Down

0 comments on commit c01c51f

Please sign in to comment.