Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Commit 746eea8

Browse files
authored
Save the selected programmer in Arduino.json (#714)
1 parent c090b8d commit 746eea8

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/arduino/programmerManager.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as vscode from "vscode";
22
import * as constants from "../common/constants";
3+
import { DeviceContext } from "../deviceContext";
34
import { ArduinoApp } from "./arduino";
45
import { IArduinoSettings } from "./arduinoSettings";
5-
import { ArduinoSettings } from "./arduinoSettings";
66

77
export enum ProgrammerList {
88
"AVR ISP",
@@ -54,6 +54,8 @@ export class ProgrammerManager {
5454
this._currentprogrammer = ProgrammerList[chosen];
5555
this.getProgrammer(this._currentprogrammer);
5656
this._programmerStatusBar.text = chosen;
57+
const dc = DeviceContext.getInstance();
58+
dc.programmer = chosen;
5759
}
5860

5961
public getProgrammer(newProgrammer: ProgrammerList) {

src/deviceContext.ts

+21
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ export interface IDeviceContext {
4545

4646
debugger_: string;
4747

48+
/**
49+
* Current selected programmer.
50+
* @property {string}
51+
*/
52+
programmer: string;
53+
4854
/**
4955
* Arduino custom board configuration
5056
* @property {string}
@@ -88,6 +94,8 @@ export class DeviceContext implements IDeviceContext, vscode.Disposable {
8894

8995
private _prebuild: string;
9096

97+
private _programmer: string;
98+
9199
/**
92100
* @constructor
93101
*/
@@ -145,6 +153,7 @@ export class DeviceContext implements IDeviceContext, vscode.Disposable {
145153
this._debugger = deviceConfigJson["debugger"];
146154
this._onDidChange.fire();
147155
this._prebuild = deviceConfigJson.prebuild;
156+
this._programmer = deviceConfigJson.programmer;
148157
} else {
149158
Logger.notifyUserError("arduinoFileError", new Error(constants.messages.ARDUINO_FILE_ERROR));
150159
}
@@ -157,6 +166,7 @@ export class DeviceContext implements IDeviceContext, vscode.Disposable {
157166
this._debugger = null;
158167
this._onDidChange.fire();
159168
this._prebuild = null;
169+
this._programmer = null;
160170
}
161171
return this;
162172
}, (reason) => {
@@ -174,6 +184,7 @@ export class DeviceContext implements IDeviceContext, vscode.Disposable {
174184
this._debugger = null;
175185
this._onDidChange.fire();
176186
this._prebuild = null;
187+
this._programmer = null;
177188

178189
return this;
179190
});
@@ -207,6 +218,7 @@ export class DeviceContext implements IDeviceContext, vscode.Disposable {
207218
deviceConfigJson.output = this.output;
208219
deviceConfigJson["debugger"] = this.debugger_;
209220
deviceConfigJson.configuration = this.configuration;
221+
deviceConfigJson.programmer = this.programmer;
210222

211223
util.mkdirRecursivelySync(path.dirname(deviceConfigFile));
212224
fs.writeFileSync(deviceConfigFile, JSON.stringify(deviceConfigJson, (key, value) => {
@@ -279,6 +291,15 @@ export class DeviceContext implements IDeviceContext, vscode.Disposable {
279291
this.saveContext();
280292
}
281293

294+
public get programmer() {
295+
return this._programmer;
296+
}
297+
298+
public set programmer(value: string) {
299+
this._programmer = value;
300+
this.saveContext();
301+
}
302+
282303
public async initialize() {
283304
if (ArduinoWorkspace.rootPath && util.fileExistsSync(path.join(ArduinoWorkspace.rootPath, ARDUINO_CONFIG_FILE))) {
284305
vscode.window.showInformationMessage("Arduino.json is already generated.");

0 commit comments

Comments
 (0)