@@ -101,10 +101,13 @@ export class ArduinoApp {
101
101
102
102
/**
103
103
* Upload code to selected board
104
+ * @param {BuildMode } buildMode Build mode.
105
+ * * BuildMode.Upload: Compile and upload
106
+ * * BuildMode.UploadProgrammer: Compile and upload using the user
107
+ * selectable programmer
104
108
* @param {bool } [compile=true] - Indicates whether to compile the code when using the CLI to upload
105
- * @param {bool } [useProgrammer=false] - Indicate whether a specific programmer should be used
106
109
*/
107
- public async upload ( buildMode : BuildMode , compile : boolean = true , useProgrammer : boolean = false ) {
110
+ public async upload ( buildMode : BuildMode , compile : boolean = true ) {
108
111
const dc = DeviceContext . getInstance ( ) ;
109
112
const args : string [ ] = [ ] ;
110
113
let restoreSerialMonitor : boolean = false ;
@@ -134,11 +137,6 @@ export class ArduinoApp {
134
137
}
135
138
}
136
139
137
- const selectProgrammer = useProgrammer ? this . getProgrammerString ( ) : null ;
138
- if ( useProgrammer && ! selectProgrammer ) {
139
- return ;
140
- }
141
-
142
140
if ( buildMode === BuildMode . Upload ) {
143
141
if ( ( ! dc . configuration || ! / u p l o a d _ m e t h o d = [ ^ = , ] * s t [ ^ , ] * l i n k / i. test ( dc . configuration ) ) && ! dc . port ) {
144
142
await selectSerial ( ) ;
@@ -162,17 +160,43 @@ export class ArduinoApp {
162
160
args . push ( "-b" , boardDescriptor ) ;
163
161
}
164
162
165
- if ( useProgrammer ) {
166
- if ( this . useArduinoCli ( ) ) {
167
- args . push ( "--programmer" , selectProgrammer )
163
+ if ( dc . port ) {
164
+ args . push ( "--port" , dc . port ) ;
165
+ }
166
+ } else if ( buildMode === BuildMode . UploadProgrammer ) {
167
+ const programmer = this . getProgrammerString ( ) ;
168
+ if ( ! programmer ) {
169
+ return ;
170
+ }
171
+ if ( ! dc . port ) {
172
+ await selectSerial ( ) ;
173
+ return ;
174
+ }
175
+
176
+ if ( ! compile && ! this . useArduinoCli ( ) ) {
177
+ arduinoChannel . error ( "This command is only available when using the Arduino CLI" ) ;
178
+ return ;
179
+ }
180
+
181
+ if ( ! this . useArduinoCli ( ) ) {
182
+ args . push ( "--upload" ) ;
183
+ } else {
184
+ // TODO: add the --clean argument to the cli args when v 0.14 is released (this will clean up the build folder after uploading)
185
+ if ( compile ) {
186
+ args . push ( "compile" , "--upload" ) ;
168
187
} else {
169
- args . push ( "--useprogrammer" , "--pref" , "programmer=arduino:" + selectProgrammer )
188
+ args . push ( "upload" ) ;
170
189
}
190
+ args . push ( "-b" , boardDescriptor ) ;
171
191
}
172
192
173
- if ( dc . port ) {
174
- args . push ( "--port" , dc . port ) ;
193
+ if ( this . useArduinoCli ( ) ) {
194
+ args . push ( "--programmer" , programmer )
195
+ } else {
196
+ args . push ( "--useprogrammer" , "--pref" , "programmer=arduino:" + programmer )
175
197
}
198
+
199
+ args . push ( "--port" , dc . port ) ;
176
200
}
177
201
178
202
const verbose = VscodeSettings . getInstance ( ) . logLevel === "verbose" ;
0 commit comments