- Notifications
You must be signed in to change notification settings - Fork 440
/
Copy pathburn-bootloader.ts
92 lines (87 loc) · 2.5 KB
/
burn-bootloader.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import{nls}from'@theia/core/lib/common';
import{injectable}from'@theia/core/shared/inversify';
import{CoreService}from'../../common/protocol';
import{ArduinoMenus}from'../menu/arduino-menus';
import{
Command,
CommandRegistry,
CoreServiceContribution,
MenuModelRegistry,
}from'./contribution';
@injectable()
exportclassBurnBootloaderextendsCoreServiceContribution{
overrideregisterCommands(registry: CommandRegistry): void{
registry.registerCommand(BurnBootloader.Commands.BURN_BOOTLOADER,{
execute: ()=>this.burnBootloader(),
});
}
overrideregisterMenus(registry: MenuModelRegistry): void{
registry.registerMenuAction(ArduinoMenus.TOOLS__BOARD_SETTINGS_GROUP,{
commandId: BurnBootloader.Commands.BURN_BOOTLOADER.id,
label: nls.localize(
'arduino/bootloader/burnBootloader',
'Burn Bootloader'
),
order: 'z99',
});
}
privateasyncburnBootloader(): Promise<void>{
this.clearVisibleNotification();
constoptions=awaitthis.options();
try{
awaitthis.doWithProgress({
progressText: nls.localize(
'arduino/bootloader/burningBootloader',
'Burning bootloader...'
),
task: (progressId,coreService,token)=>
coreService.burnBootloader(
{
...options,
progressId,
},
token
),
cancelable: true,
});
this.messageService.info(
nls.localize(
'arduino/bootloader/doneBurningBootloader',
'Done burning bootloader.'
),
{
timeout: 3000,
}
);
}catch(e){
this.handleError(e);
}
}
privateasyncoptions(): Promise<CoreService.Options.Bootloader>{
const{ boardsConfig }=this.boardsServiceProvider;
constport=boardsConfig.selectedPort;
const[fqbn,{selectedProgrammer: programmer},verify,verbose]=
awaitPromise.all([
this.boardsDataStore.appendConfigToFqbn(
boardsConfig.selectedBoard?.fqbn
),
this.boardsDataStore.getData(boardsConfig.selectedBoard?.fqbn),
this.preferences.get('arduino.upload.verify'),
this.preferences.get('arduino.upload.verbose'),
]);
return{
fqbn,
programmer,
port,
verify,
verbose,
};
}
}
exportnamespaceBurnBootloader{
exportnamespaceCommands{
exportconstBURN_BOOTLOADER: Command={
id: 'arduino-burn-bootloader',
};
}
}