Skip to content

Commit ad768aa

Browse files
authored
Merge branch 'master' into programmers_improvement
2 parents 394e1aa + 1da5ced commit ad768aa

File tree

8 files changed

+142
-10
lines changed

8 files changed

+142
-10
lines changed

.github/stale.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Number of days of inactivity before an issue becomes stale
2+
daysUntilStale: 30
3+
# Number of days of inactivity before a stale issue is closed
4+
daysUntilClose: 5
5+
# Issues with these labels will never be considered stale
6+
exemptLabels:
7+
- "help wanted"
8+
- bug
9+
# Label to use when marking an issue as stale
10+
staleLabel: stale
11+
# Comment to post when marking an issue as stale. Set to `false` to disable
12+
markComment: >
13+
This issue has been automatically marked as stale and closed because it
14+
has not had recent activity. Please feel free to open a new issue if you
15+
would like further discussion. Thank you for your contributions.
16+
# Comment to post when closing a stale issue. Set to `false` to disable
17+
closeComment: false
18+
# Set to true to ignore issues in a milestone (defaults to false)
19+
exemptMilestones: true
20+
# Set to true to ignore issues with an assignee (defaults to false)
21+
exemptAssignees: true
22+
# Limit to only `issues` or `pulls`
23+
only: issues

.vscodeignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ tsconfig.json
1010
tslint.json
1111
.travis.yml
1212
gulpfile.js
13-
*.vsix
13+
*.vsix
14+
.github/**

CHANGELOG.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## Version 0.2.26
5+
-Release date: May 30, 2019
6+
7+
### Added
8+
- Add .pde support
9+
10+
### Changed
11+
- The value of 'Include Path' will be updated automatically when board package is updated
12+
13+
### Fixed
14+
- Fix the issue of "ST-Link upload - Please specify the upload serial port" [#595](https://github.com/microsoft/vscode-arduino/issues/595)
15+
16+
Special thanks to [Riz-waan](https://github.com/Riz-waan), [LuisAbrantes](https://github.com/LuisAbrantes), [Christopher Schmitz](https://github.com/chris-schmitz), [Christian](https://github.com/ChriD) and [LMtx](https://github.com/LMtx), thanks for your contributions and feedbacks.
17+
418
## Version 0.2.25
519
-Release date: January 10, 2019
620

721
### Added
822
- Add upload and verify button in action bar [#737](https://github.com/Microsoft/vscode-arduino/pull/737)
923
- Add serial port support for Electron 3.0 [#729](https://github.com/Microsoft/vscode-arduino/pull/729), [#730](https://github.com/Microsoft/vscode-arduino/pull/730), [#731](https://github.com/Microsoft/vscode-arduino/pull/731)
1024

11-
Special thanks to [Michael Omiccioli](https://github.com/momiccioli) and [MarNwk](https://github.com/MarNwk),thank you for your feedbacks.
25+
Special thanks to [Michael Omiccioli](https://github.com/momiccioli) and [MarNwk](https://github.com/MarNwk), thank you for your feedbacks.
1226

1327
## Version 0.2.24
1428
-Release date: December 11, 2018

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ ext install vscode-arduino
3232
You can also install directly from the Marketplace within Visual Studio Code, searching for `Arduino`.
3333

3434
## Get Started
35-
You can find code samples and tutorials each time that you connect a supported device. Alternatively you can visit our [IoT Developer Blog Space](https://aka.ms/iotdevblog) or [Get Started Tutorials](https://docs.microsoft.com/azure/iot-hub/iot-hub-arduino-iot-devkit-az3166-get-started).
35+
You can find code samples and tutorials each time that you connect a supported device. Alternatively you can visit our [IoT Developer Blog Space](https://devblogs.microsoft.com/iotdev/) or [Get Started Tutorials](https://docs.microsoft.com/azure/iot-hub/iot-hub-arduino-iot-devkit-az3166-get-started).
3636

3737
## Commands
3838
This extension provides several commands in the Command Palette (<kbd>F1</kbd> or <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd>) for working with `*.ino` files:
@@ -102,7 +102,7 @@ The following settings are as per sketch settings of the Arduino extension. You
102102
- `sketch` - The main sketch file name of Arduino.
103103
- `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".
104104
- `board` - Currently selected Arduino board alias. Can be set by the `Arduino: Change Board Type` command. Also, you can find the board list there.
105-
- `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.
105+
- `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.
106106
- `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.
107107
- `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.
108108

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-arduino",
33
"displayName": "Arduino",
44
"description": "Arduino for Visual Studio Code",
5-
"version": "0.2.25",
5+
"version": "0.2.26",
66
"publisher": "vsciot-vscode",
77
"aiKey": "83dd2c27-6594-41d3-85a9-bdb22070eb42",
88
"preview": true,
@@ -505,7 +505,8 @@
505505
{
506506
"id": "cpp",
507507
"extensions": [
508-
".ino"
508+
".ino",
509+
".pde"
509510
]
510511
}
511512
],

src/arduino/arduino.ts

+69-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ export class ArduinoApp {
108108
if (!dc.sketch || !util.fileExistsSync(path.join(ArduinoWorkspace.rootPath, dc.sketch))) {
109109
await this.getMainSketch(dc);
110110
}
111-
if (!dc.port) {
111+
112+
if ((!dc.configuration || !/upload_method=[^=,]*st[^,]*link/i.test(dc.configuration)) && !dc.port) {
112113
const choice = await vscode.window.showInformationMessage(
113114
"Serial port is not specified. Do you want to select a serial port for uploading?",
114115
"Yes", "No");
@@ -140,7 +141,11 @@ export class ArduinoApp {
140141
}
141142

142143
const appPath = path.join(ArduinoWorkspace.rootPath, dc.sketch);
143-
const args = ["--upload", "--board", boardDescriptor, "--port", dc.port, appPath];
144+
const args = ["--upload", "--board", boardDescriptor];
145+
if (dc.port) {
146+
args.push("--port", dc.port);
147+
}
148+
args.push(appPath);
144149
if (VscodeSettings.getInstance().logLevel === "verbose") {
145150
args.push("--verbose");
146151
}
@@ -304,6 +309,68 @@ export class ArduinoApp {
304309

305310
}
306311

312+
public tryToUpdateIncludePaths() {
313+
const configFilePath = path.join(ArduinoWorkspace.rootPath, constants.CPP_CONFIG_FILE);
314+
if (!fs.existsSync(configFilePath)) {
315+
return;
316+
}
317+
const cppConfigFile = fs.readFileSync(configFilePath, "utf8");
318+
const cppConfig = JSON.parse(cppConfigFile) as {configurations: Array<{includePath: string[], forcedInclude: string[]}>};
319+
const libPaths = this.getDefaultPackageLibPaths();
320+
const defaultForcedInclude = this.getDefaultForcedIncludeFiles();
321+
const configuration = cppConfig.configurations[0];
322+
323+
let cppConfigFileUpdated = false;
324+
// cpp exntension changes \\ to \\\\ in paths in JSON string, revert them first
325+
configuration.includePath = configuration.includePath.map((path) => path.replace(/\\\\/g, "\\"));
326+
configuration.forcedInclude = configuration.forcedInclude.map((path) => path.replace(/\\\\/g, "\\"));
327+
328+
for (const libPath of libPaths) {
329+
if (configuration.includePath.indexOf(libPath) === -1) {
330+
cppConfigFileUpdated = true;
331+
configuration.includePath.push(libPath);
332+
}
333+
}
334+
for (const forcedIncludePath of defaultForcedInclude) {
335+
if (configuration.forcedInclude.indexOf(forcedIncludePath) === -1) {
336+
cppConfigFileUpdated = true;
337+
configuration.forcedInclude.push(forcedIncludePath);
338+
}
339+
}
340+
341+
// remove all unexisting paths
342+
// concern mistake removal, comment temporary
343+
// for (let pathIndex = 0; pathIndex < configuration.includePath.length; pathIndex++) {
344+
// let libPath = configuration.includePath[pathIndex];
345+
// if (libPath.indexOf("${workspaceFolder}") !== -1) {
346+
// continue;
347+
// }
348+
// if (/\*$/.test(libPath)) {
349+
// libPath = libPath.match(/^[^\*]*/)[0];
350+
// }
351+
// if (!fs.existsSync(libPath)) {
352+
// cppConfigFileUpdated = true;
353+
// configuration.includePath.splice(pathIndex, 1);
354+
// pathIndex--;
355+
// }
356+
// }
357+
// for (let pathIndex = 0; pathIndex < configuration.forcedInclude.length; pathIndex++) {
358+
// const forcedIncludePath = configuration.forcedInclude[pathIndex];
359+
// if (forcedIncludePath.indexOf("${workspaceFolder}") !== -1) {
360+
// continue;
361+
// }
362+
// if (!fs.existsSync(forcedIncludePath)) {
363+
// cppConfigFileUpdated = true;
364+
// configuration.forcedInclude.splice(pathIndex, 1);
365+
// pathIndex--;
366+
// }
367+
// }
368+
369+
if (cppConfigFileUpdated) {
370+
fs.writeFileSync(configFilePath, JSON.stringify(cppConfig, null, 4));
371+
}
372+
}
373+
307374
// Add selected library path to the intellisense search path.
308375
public addLibPath(libraryPath: string) {
309376
let libPaths;

src/extension.ts

+27-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

4+
import * as fs from "fs";
45
import * as path from "path";
56
import * as Uuid from "uuid/v4";
67
import * as vscode from "vscode";
@@ -286,7 +287,7 @@ export async function activate(context: vscode.ExtensionContext) {
286287
registerNonArduinoCommand("arduino.changeBaudRate", () => serialMonitor.changeBaudRate());
287288
registerNonArduinoCommand("arduino.changeEnding", () => serialMonitor.changeEnding());
288289
registerNonArduinoCommand("arduino.sendMessageToSerialPort", () => serialMonitor.sendMessageToSerialPort());
289-
registerNonArduinoCommand("arduino.closeSerialMonitor", (port) => serialMonitor.closeSerialMonitor(port));
290+
registerNonArduinoCommand("arduino.closeSerialMonitor", (port, showWarning = true) => serialMonitor.closeSerialMonitor(port, showWarning));
290291

291292
const completionProvider = new CompletionProvider();
292293
context.subscriptions.push(vscode.languages.registerCompletionItemProvider(ARDUINO_MODE, completionProvider, "<", '"', "."));
@@ -307,6 +308,7 @@ export async function activate(context: vscode.ExtensionContext) {
307308
SerialMonitor.getInstance().initialize();
308309
}
309310
ArduinoContext.boardManager.updateStatusBar(true);
311+
ArduinoContext.arduinoApp.tryToUpdateIncludePaths();
310312
vscode.commands.executeCommand("setContext", "vscode-arduino:showExampleExplorer", true);
311313
})();
312314
}
@@ -326,6 +328,30 @@ export async function activate(context: vscode.ExtensionContext) {
326328
vscode.commands.executeCommand("setContext", "vscode-arduino:showExampleExplorer", true);
327329
}
328330
});
331+
332+
vscode.workspace.onDidOpenTextDocument(async (document) => {
333+
if (/\.pde$/.test(document.uri.fsPath)) {
334+
const newFsName = document.uri.fsPath.replace(/\.pde$/, ".ino");
335+
await vscode.commands.executeCommand("workbench.action.closeActiveEditor");
336+
fs.renameSync(document.uri.fsPath, newFsName);
337+
await vscode.commands.executeCommand("vscode.open", vscode.Uri.file(newFsName));
338+
}
339+
});
340+
341+
vscode.window.onDidChangeActiveTextEditor(async (editor) => {
342+
if (!editor) {
343+
return;
344+
}
345+
346+
const document = editor.document;
347+
if (/\.pde$/.test(document.uri.fsPath)) {
348+
const newFsName = document.uri.fsPath.replace(/\.pde$/, ".ino");
349+
await vscode.commands.executeCommand("workbench.action.closeActiveEditor");
350+
fs.renameSync(document.uri.fsPath, newFsName);
351+
await vscode.commands.executeCommand("vscode.open", vscode.Uri.file(newFsName));
352+
}
353+
});
354+
329355
Logger.traceUserData("end-activate-extension", { correlationId: activeGuid });
330356
}
331357

0 commit comments

Comments
 (0)