Skip to content

Commit 9514e19

Browse files
committed
Merge branch 'develop' into programmer_population
2 parents 194232c + 8bb1130 commit 9514e19

31 files changed

+2274
-821
lines changed

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ before_install:
4646
# https://github.com/arduino/Arduino/issues/8034
4747
# Arduino 1.8.8 has fixed issue 8034.
4848
- if [ $TRAVIS_OS_NAME == "osx" ]; then
49-
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)";
50-
brew cask install arduino;
49+
/usr/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)";
50+
brew install --cask arduino;
5151
fi
5252
- npm install -g node-gyp
5353
- npm install -g vsce

BRANCHNOTES.md

+456
Large diffs are not rendered by default.

README.md

+70-4
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ This extension provides several commands in the Command Palette (<kbd>F1</kbd> o
5050
- **Arduino: Upload**: Build sketch and upload to Arduino board.
5151
- **Arduino: Upload Using Programmer**: Upload using an external programmer.
5252
- **Arduino: Verify**: Build sketch.
53+
- **Arduino: Rebuild IntelliSense Configuration**: Forced/manual rebuild of the IntelliSense configuration. The extension analyzes Arduino's build output and sets the Intellisense include paths, defines, compiler arguments accordingly.
5354

5455
## Keybindings
5556
- **Arduino: Upload** <kbd>Alt</kbd> + <kbd>Cmd</kbd> + <kbd>U</kbd> *or* <kbd>Alt</kbd> + <kbd>Ctrl</kbd> + <kbd>U</kbd>
5657
- **Arduino: Verify** <kbd>Alt</kbd> + <kbd>Cmd</kbd> + <kbd>R</kbd> *or* <kbd>Alt</kbd> + <kbd>Ctrl</kbd> + <kbd>R</kbd>
58+
- **Arduino: Rebuild IntelliSense Configuration** <kbd>Alt</kbd> + <kbd>Cmd</kbd> + <kbd>I</kbd> *or* <kbd>Alt</kbd> + <kbd>Ctrl</kbd> + <kbd>I</kbd>
5759

5860
## Options
5961
| Option | Description |
@@ -62,11 +64,12 @@ This extension provides several commands in the Command Palette (<kbd>F1</kbd> o
6264
| `arduino.commandPath` | Path to an executable (or script) relative to `arduino.path`. The default value is `arduino_debug.exe` for windows,`Contents/MacOS/Arduino` for Mac and `arduino` for Linux, You also can use a custom launch script to run Arduino by modifying this setting. (Requires a restart after change) Example: `run-arduino.bat` for Windows, `Contents/MacOS/run-arduino.sh` for Mac and `bin/run-arduino.sh` for Linux. |
6365
| `arduino.additionalUrls` | Additional Boards Manager URLs for 3rd party packages. You can have multiple URLs in one string with a comma(`,`) as separator, or have a string array. The default value is empty. |
6466
| `arduino.logLevel` | CLI output log level. Could be info or verbose. The default value is `"info"`. |
65-
| `arduino.allowPDEFiletype` | Allow the VSCode Arduino extension to open .pde files from pre-1.0.0 versions of Ardiuno. Note that this will break Processing code. Default value is `false`. |
67+
| `arduino.allowPDEFiletype` | Allow the VSCode Arduino extension to open .pde files from pre-1.0.0 versions of Ardiuno. Note that this will break Processing code. Default value is `false`. |
6668
| `arduino.enableUSBDetection` | Enable/disable USB detection from the VSCode Arduino extension. The default value is `true`. When your device is plugged in to your computer, it will pop up a message "`Detected board ****, Would you like to switch to this board type`". After clicking the `Yes` button, it will automatically detect which serial port (COM) is connected a USB device. If your device does not support this feature, please provide us with the PID/VID of your device; the code format is defined in `misc/usbmapping.json`.To learn more about how to list the vid/pid, use the following tools: https://github.com/EmergingTechnologyAdvisors/node-serialport `npm install -g serialport` `serialport-list -f jsonline`|
6769
| `arduino.disableTestingOpen` | Enable/disable automatic sending of a test message to the serial port for checking the open status. The default value is `false` (a test message will be sent). |
6870
| `arduino.skipHeaderProvider` | Enable/disable the extension providing completion items for headers. This functionality is included in newer versions of the C++ extension. The default value is `false`.|
6971
| `arduino.defaultBaudRate` | Default baud rate for the serial port monitor. The default value is 115200. Supported values are 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 74880, 115200, 230400 and 250000 |
72+
| `arduino.disableIntelliSenseAutoGen` | When `true` vscode-arduino will not auto-generate an IntelliSense configuration (i.e. `.vscode/c_cpp_properties.json`) by analyzing Arduino's compiler output. |
7073

7174
The following Visual Studio Code settings are available for the Arduino extension. These can be set in global user preferences <kbd>Ctrl</kbd> + <kbd>,</kbd> or workspace settings (`.vscode/settings.json`). The latter overrides the former.
7275

@@ -75,7 +78,7 @@ The following Visual Studio Code settings are available for the Arduino extensio
7578
"arduino.path": "C:/Program Files (x86)/Arduino",
7679
"arduino.commandPath": "arduino_debug.exe",
7780
"arduino.logLevel": "info",
78-
"arduino.allowPDEFiletype": false,
81+
"arduino.allowPDEFiletype": false,
7982
"arduino.enableUSBDetection": true,
8083
"arduino.disableTestingOpen": false,
8184
"arduino.skipHeaderProvider": false,
@@ -98,15 +101,78 @@ The following settings are as per sketch settings of the Arduino extension. You
98101
"board": "adafruit:samd:adafruit_feather_m0",
99102
"output": "../build",
100103
"debugger": "jlink",
101-
"prebuild": "bash prebuild.sh"
104+
"prebuild": "./prebuild.sh",
105+
"postbuild": "./postbuild.sh",
106+
"intelliSenseGen": "global"
102107
}
103108
```
104109
- `sketch` - The main sketch file name of Arduino.
105110
- `port` - Name of the serial port connected to the device. Can be set by the `Arduino: Select Serial Port` command. For Mac users could be "/dev/cu.wchusbserial1420".
106111
- `board` - Currently selected Arduino board alias. Can be set by the `Arduino: Change Board Type` command. Also, you can find the board list there.
107112
- `output` - Arduino build output path. If not set, Arduino will create a new temporary output folder each time, which means it cannot reuse the intermediate result of the previous build leading to long verify/upload time, so it is recommended to set the field. Arduino requires that the output path should not be the workspace itself or in a subfolder of the workspace, otherwise, it may not work correctly. By default, this option is not set. It's worth noting that the contents of this file could be deleted during the build process, so pick (or create) a directory that will not store files you want to keep.
108113
- `debugger` - The short name of the debugger that will be used when the board itself does not have a debugger and there is more than one debugger available. You can find the list of debuggers [here](https://github.com/Microsoft/vscode-arduino/blob/master/misc/debuggerUsbMapping.json). By default, this option is not set.
109-
- `prebuild` - External command before building the sketch file. You should only set one `prebuild` command. `command1 && command2` does not work. If you need to run multiple commands before the build, then create a script.
114+
- `prebuild` - External command which will be invoked before any sketch build (verify, upload, ...). For details see the [Pre- and Post-Build Commands](#Pre--and-Post-Build-Commands) section.
115+
- `postbuild` - External command to be run after the sketch has been built successfully. See the afore mentioned section for more details.
116+
- `intelliSenseGen` - Override the global setting for auto-generation of the IntelliSense configuration (i.e. `.vscode/c_cpp_properties.json`). Three options are available:
117+
- `"global"`: Use the global settings (default)
118+
- `"disable"`: Disable the auto-generation even if globally enabled
119+
- `"enable"`: Enable the auto-generation even if globally disabled
120+
- `buildPreferences` - Set Arduino preferences which then are used during any build (verify, upload, ...). This allows for extra defines, compiler options or includes. The preference key-value pairs must be set as follows:
121+
```json
122+
"buildPreferences": [
123+
["build.extra_flags", "-DMY_DEFINE=666 -DANOTHER_DEFINE=3.14 -Wall"],
124+
["compiler.cpp.extra_flags", "-DYET_ANOTER=\"hello\""]
125+
]
126+
}
127+
```
128+
129+
## Pre- and Post-Build Commands
130+
On Windows the commands run within a `cmd`-, on Linux and OSX within a `bash`-instance. Therefore your command can be anything what you can run within those shells. Instead of running a command you can invoke a script. This makes writing more complex pre-/post-build mechanisms much easier and opens up the possibility to run python or other scripting languages.
131+
The commands run within the workspace root directory and vscode-arduino sets the following environment variables:
132+
**`VSCA_BUILD_MODE`** The current build mode, one of `Verifying`, `Uploading`, `Uploading (programmer)` or `Analyzing`. This allows you to run your script on certain build modes only.
133+
**`VSCA_SKETCH`** The sketch file relative to your workspace root directory.
134+
**`VSCA_BOARD`** Your board and configuration, e.g. `arduino:avr:nano:cpu=atmega328`.
135+
**`VSCA_WORKSPACE_DIR`** The absolute path of your workspace root directory.
136+
**`VSCA_LOG_LEVEL`** The current log level. This allows you to control the verbosity of your scripts.
137+
**`VSCA_SERIAL`** The serial port used for uploading. Not set if you haven't set one in your `arduino.json`.
138+
**`VSCA_BUILD_DIR`** The build directory. Not set if you haven't set one in your `arduino.json`.
139+
140+
For example under Windows the following `arduino.json` setup
141+
```json
142+
{
143+
"board": "arduino:avr:nano",
144+
"sketch": "test.ino",
145+
"configuration": "cpu=atmega328",
146+
"prebuild": "IF \"%VSCA_BUILD_MODE%\"==\"Verifying\" (echo VSCA_BUILD_MODE=%VSCA_BUILD_MODE% && echo VSCA_BOARD=%VSCA_BOARD%)"
147+
}
148+
```
149+
will produce
150+
```
151+
[Starting] Verifying sketch 'test.ino'
152+
Running pre-build command: "IF "%VSCA_BUILD_MODE%"=="Verifying" (echo VSCA_BUILD_MODE=%VSCA_BUILD_MODE% && echo VSCA_BOARD=%VSCA_BOARD%)"
153+
VSCA_BUILD_MODE=Verifying
154+
VSCA_BOARD=arduino:avr:nano:cpu=atmega328
155+
Loading configuration...
156+
<...>
157+
```
158+
when verifying.
159+
160+
## IntelliSense
161+
vscode-arduino auto-configures IntelliSense by default. vscode-arduino analyzes Arduino's compiler output by running a separate build and generates the corresponding configuration file at `.vscode/c_cpp_properties.json`. vscode-arduino tries as hard as possible to keep things up to date, e.g. it runs the analysis when switching the board or the sketch.
162+
163+
It doesn't makes sense though to run the analysis repeatedly. Therefore if the workspace reports problems ("squiggles") - for instance after adding new includes from a new library - run the analysis manually:
164+
165+
Manual rebuild: **Arduino: Rebuild IntelliSense Configuration**,
166+
Keybindings: <kbd>Alt</kbd> + <kbd>Cmd</kbd> + <kbd>I</kbd> *or* <kbd>Alt</kbd> + <kbd>Ctrl</kbd> + <kbd>I</kbd>
167+
168+
When the analysis is invoked manually it ignores any global and project specific disable.
169+
170+
### IntelliSense Configurations
171+
vscode-arduino's analysis stores the result as a dedicated IntelliSense-configuration named `Arduino`. You have to select it from the far right of the status bar when you're in one of your source files as shown here:
172+
173+
![74001156-cfce8280-496a-11ea-9b9d-7d30c83765c1](https://user-images.githubusercontent.com/21954933/74351237-2696ea80-4db7-11ea-9f7a-1bfc652ad5f5.png)
174+
175+
This system allows you to setup and use own IntelliSense configurations in parallel to the automatically generated configurations provided through vscode-arduino. Just add your configuration to `c_cpp_properties.json` and name it differently from the default configuration (`Arduino`), e.g. `My awesome configuration` and select it from the status bar or via the command palette command **C/C++: Select a Configuration...**
110176

111177
## Debugging Arduino Code <sup>preview</sup>
112178
Before you start to debug your Arduino code, please read [this document](https://code.visualstudio.com/docs/editor/debugging) to learn about the basic mechanisms of debugging in Visual Studio Code. Also see [debugging for C++ in VSCode](https://code.visualstudio.com/docs/languages/cpp#_debugging) for further reference.

ThirdPartyNotices.txt

+28-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Visual Studio Code Extension for Arduino incorporates third party material from
2525
18. vscode-extension-telemetry (https://github.com/Microsoft/vscode-extension-telemetry)
2626
19. winreg (https://github.com/fresc81/node-winreg)
2727
20. Winston (https://github.com/winstonjs/winston)
28-
28+
21. cocopa (https://github.com/elektronikworkshop/cocopa)
2929

3030
%% body-parser NOTICES, INFORMATION, AND LICENSE BEGIN HERE
3131
=========================================
@@ -532,4 +532,31 @@ THE SOFTWARE.
532532
=========================================
533533
END OF Winston NOTICES, INFORMATION, AND LICENSE
534534

535+
%% cocopa NOTICES, INFORMATION, AND LICENSE BEGIN HERE
536+
=========================================
537+
Copyright (C) 2020 Uli Franke - Elektronik Workshop
538+
539+
All rights reserved.
540+
541+
The MIT License (MIT)
542+
543+
Permission is hereby granted, free of charge, to any person obtaining a copy
544+
of this software and associated documentation files (the "Software"), to deal
545+
in the Software without restriction, including without limitation the rights
546+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
547+
copies of the Software, and to permit persons to whom the Software is
548+
furnished to do so, subject to the following conditions:
549+
550+
The above copyright notice and this permission notice shall be included in
551+
all copies or substantial portions of the Software.
552+
553+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
554+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
555+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
556+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
557+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
558+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
559+
THE SOFTWARE.
560+
=========================================
561+
END OF cocopa NOTICES, INFORMATION, AND LICENSE
535562

misc/arduinoValidator.json

+33-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,38 @@
3232
"description": "Arduino Debugger Settings",
3333
"type": "string",
3434
"minLength": 1
35+
},
36+
"intelliSenseGen": {
37+
"description": "Disable/enable the automatic generation of the IntelliSense configuration file (c_cpp_properties.json) for this project (overrides the global setting). When set to \"global\" the global extension settings will be used.",
38+
"type": "string",
39+
"default": "global",
40+
"enum": [
41+
"global",
42+
"disable",
43+
"enable"
44+
]
45+
},
46+
"prebuild": {
47+
"description": "Command to be run before every build",
48+
"type": "string",
49+
"minLength": 1
50+
},
51+
"postbuild": {
52+
"description": "Command to be run after every build",
53+
"type": "string",
54+
"minLength": 1
55+
},
56+
"buildPreferences": {
57+
"description": "Arduino preferences which are passed to the Arduino back-end during build",
58+
"type": "array",
59+
"items": {
60+
"type":"array",
61+
"minItems": 2,
62+
"maxItems": 2,
63+
"items": {
64+
"type": "string"
65+
}
66+
}
3567
}
3668
}
37-
}
69+
}

0 commit comments

Comments
 (0)