-
Notifications
You must be signed in to change notification settings - Fork 623
Migrating to vs Code #238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
evilnick
wants to merge
6
commits into
wokwi:main
Choose a base branch
from
evilnick:migrating-to-vs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Migrating to vs Code #238
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2d67e59
initial-page
evilnick 43cf758
initial draft of migration
evilnick 1b47ca3
add converting .ino to .cpp as a tip
evilnick 4285ec5
updates to migration
evilnick b1be839
add micropython link
evilnick cf331dd
add micropython
evilnick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
--- | ||
title: Migrating Wokwi projects to VS Code | ||
sidebar_label: Migrating to VS Code | ||
description: Migrate your online Wokwi simulator projects to a local VS Code environment | ||
keywords: [Visual Studio Code, VS Code, embedded simulation, IoT simulation, PlatformIO, ESP-IDF, Arduino, MicroPython, Rust, Zephyr] | ||
--- | ||
import Tabs from '@theme/Tabs'; | ||
import TabItem from '@theme/TabItem'; | ||
|
||
The web-based Wokwi simulator is a powerful and well-integrated way to try out your project designs: there are many capabilities which "just work" in the online simulator which will require some additional steps or workarounds to build and run locally. | ||
|
||
This checklist of steps should help you overcome the most common issues. It is assumed that you have already installed the VS Code extension for Wokwi (see the [Getting started guide](./getting-started)). | ||
|
||
## Download the project source | ||
|
||
To start, the first step is to save your online project. From the same menu, under the save button, you can then select to download a `.zip` archive of the project. This will contain useful files such as any source code and the `diagram.json` file used by Wokwi. | ||
Once downloaded you can extract the files from the archive and use them in your local project. | ||
|
||
## Create an empty project in VS Code | ||
|
||
If you are using an extension such as ESP-IDF or PlatformIO in VS Code, it is far easier to create an empty template project first before adding your Wokwi code. Use the provided templates for your chosen platform to create a new empty project. This will include specifying the hardware to be targeted and will create the required source structure and build files. | ||
|
||
This step will create a boilerplate project in a working state, ready to add your own code. | ||
|
||
## Add the source | ||
|
||
Depending on the complexity of your project, adding the source should be quite straightforward. For a new PlatformIO Arduino project, the directory tree should look like this: | ||
|
||
```text | ||
├── .gitignore | ||
├── include | ||
│ └── README | ||
├── lib | ||
│ └── README | ||
├── .pio | ||
│ └── build | ||
│ ├── project.checksum | ||
│ └── uno | ||
│ └── idedata.json | ||
├── platformio.ini | ||
├── src | ||
│ └── main.cpp | ||
├── test | ||
│ └── README | ||
|
||
``` | ||
|
||
In this case you would replace the contents of `/src/main.cpp` with the contents of the '.ino' file from the project you downloaded (it's often easier to delete the `main.cpp` file, copy in your `.ino` file and then rename it to `main.cpp`). | ||
|
||
|
||
## Verify/add libraries | ||
|
||
If your project has used any additional libraries you may need to resolve them for your local build environment. The Wokwi online simulator includes access to a whole range of built-in and third party libraries which you may have added to your project - now your local build environment will also need them. It is usually better to use the library manager included with your build tools to ensure that you get an up to date and known working version of the library. | ||
|
||
<Tabs> | ||
<TabItem value="pio" label="PlatformIO" default> | ||
If you are using PlatformIO in VS Code, many libraries are available in the Library Manager. Use the `libraries.txt` file downloaded with your project as a guide to the names of the libraries you need. | ||
|
||
The PlatformIO Library Manager has a search facility which will make this easier - just copy in the name of the library and hit search. Clicking on the 'Add' button will add the library to the `platformio.ini` file for each of the build targets you have configured. | ||
|
||
 | ||
|
||
Note that many libraries have similar or sometimes even the same name. | ||
|
||
</TabItem> | ||
<TabItem value="ESP-IDF" label="ESP-IDF"> | ||
If you are using the ESP-IDF extension for VS Code, libraries are managed as 'components'. A component is any modular code object compiled as a static library. The component library for ESP-IDF, much like the Library Manager in PlatformIO, contains many useful libraries maintained by Espressif, and tested third-party contributions. | ||
|
||
 | ||
|
||
</TabItem> | ||
<TabItem value="Manual" label="Custom libraries"> | ||
If the library you wish to use isn't available in the supported available libraries, you can add it manually. | ||
|
||
For PlatformIO, the [library documentation](https://docs.platformio.org/en/latest/librarymanager/creating.html) will give further guidance. | ||
|
||
For ESP-IDF projects, custom libraries can be added as a component. Check out the [ESP-IDF project structure documentation](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#example-project) for more details. | ||
</TabItem> | ||
</Tabs> | ||
|
||
## Test the build tools | ||
|
||
The Wokwi simulator requires a built firmware file to run, so the next step should be to check that you can generate one. Use the relevant build command from your chosen framework to build the files. | ||
|
||
Check the terminal window output for any errors or warnings which you may want or need to correct. | ||
|
||
 | ||
|
||
## Add configuration | ||
|
||
The online simulator controls its own build environment. To work locally in VS Code, you will need to provide an extra configuration file, `wokwi.toml`. This will not be part of the downloaded archive because Wokwi doesn't know what build tools or framework you will use for local VS Code development. | ||
|
||
The structure and contents of the `wokwi.toml` file are covered in the [VS Code project configuration page](/vscode/project-config). In the previous step you already built the firmware files needed. | ||
evilnick marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
At this point you should also add the `diagram.json` file from your downloaded project. This must be in the same directory as the `wokwi.toml` file. | ||
|
||
## Test the simulator | ||
|
||
When you select the `diagram.json` file in the VS Code editor, it will automatically open an embedded window with a graphical display showing the Wokwi circuit layout. | ||
|
||
 | ||
|
||
Use the start button in this window to start the simulation. The simulation should run exactly as it did in the online Wokwi simulator. | ||
|
||
Note: You will need a license to edit the diagram in this view ([see the Wokwi pricing page](https://wokwi.com/pricing?ref=docs_migrating)). | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.