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

Save the selected programmer in Arduino.json #714

Merged
merged 1 commit into from
Nov 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/arduino/programmerManager.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as vscode from "vscode";
import * as constants from "../common/constants";
import { DeviceContext } from "../deviceContext";
import { ArduinoApp } from "./arduino";
import { IArduinoSettings } from "./arduinoSettings";
import { ArduinoSettings } from "./arduinoSettings";

export enum ProgrammerList {
"AVR ISP",
Expand Down Expand Up @@ -54,6 +54,8 @@ export class ProgrammerManager {
this._currentprogrammer = ProgrammerList[chosen];
this.getProgrammer(this._currentprogrammer);
this._programmerStatusBar.text = chosen;
const dc = DeviceContext.getInstance();
dc.programmer = chosen;
}

public getProgrammer(newProgrammer: ProgrammerList) {
Expand Down
21 changes: 21 additions & 0 deletions src/deviceContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ export interface IDeviceContext {

debugger_: string;

/**
* Current selected programmer.
* @property {string}
*/
programmer: string;

/**
* Arduino custom board configuration
* @property {string}
Expand Down Expand Up @@ -88,6 +94,8 @@ export class DeviceContext implements IDeviceContext, vscode.Disposable {

private _prebuild: string;

private _programmer: string;

/**
* @constructor
*/
Expand Down Expand Up @@ -145,6 +153,7 @@ export class DeviceContext implements IDeviceContext, vscode.Disposable {
this._debugger = deviceConfigJson["debugger"];
this._onDidChange.fire();
this._prebuild = deviceConfigJson.prebuild;
this._programmer = deviceConfigJson.programmer;
} else {
Logger.notifyUserError("arduinoFileError", new Error(constants.messages.ARDUINO_FILE_ERROR));
}
Expand All @@ -157,6 +166,7 @@ export class DeviceContext implements IDeviceContext, vscode.Disposable {
this._debugger = null;
this._onDidChange.fire();
this._prebuild = null;
this._programmer = null;
}
return this;
}, (reason) => {
Expand All @@ -174,6 +184,7 @@ export class DeviceContext implements IDeviceContext, vscode.Disposable {
this._debugger = null;
this._onDidChange.fire();
this._prebuild = null;
this._programmer = null;

return this;
});
Expand Down Expand Up @@ -207,6 +218,7 @@ export class DeviceContext implements IDeviceContext, vscode.Disposable {
deviceConfigJson.output = this.output;
deviceConfigJson["debugger"] = this.debugger_;
deviceConfigJson.configuration = this.configuration;
deviceConfigJson.programmer = this.programmer;

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

public get programmer() {
return this._programmer;
}

public set programmer(value: string) {
this._programmer = value;
this.saveContext();
}

public async initialize() {
if (ArduinoWorkspace.rootPath && util.fileExistsSync(path.join(ArduinoWorkspace.rootPath, ARDUINO_CONFIG_FILE))) {
vscode.window.showInformationMessage("Arduino.json is already generated.");
Expand Down