@@ -246,6 +246,12 @@ func (s *Sketch) GetDefaultPortAddressAndProtocol() (string, string) {
246
246
return s .Project .DefaultPort , s .Project .DefaultProtocol
247
247
}
248
248
249
+ // GetDefaultProgrammer return the default Programmer for the sketch (from the sketch.yaml project file),
250
+ // ore the empty string if not set.
251
+ func (s * Sketch ) GetDefaultProgrammer () string {
252
+ return s .Project .DefaultProgrammer
253
+ }
254
+
249
255
// SetDefaultFQBN sets the default FQBN for the sketch and saves it in the sketch.yaml project file.
250
256
func (s * Sketch ) SetDefaultFQBN (fqbn string ) error {
251
257
s .Project .DefaultFqbn = fqbn
@@ -263,6 +269,12 @@ func (s *Sketch) SetDefaultPort(address, protocol string) error {
263
269
return updateOrAddYamlRootEntry (s .GetProjectPath (), "default_protocol" , protocol )
264
270
}
265
271
272
+ // SetDefaultFQBN sets the default programmer for the sketch and saves it in the sketch.yaml project file.
273
+ func (s * Sketch ) SetDefaultProgrammer (programmer string ) error {
274
+ s .Project .DefaultProgrammer = programmer
275
+ return updateOrAddYamlRootEntry (s .GetProjectPath (), "default_programmer" , programmer )
276
+ }
277
+
266
278
// InvalidSketchFolderNameError is returned when the sketch directory doesn't match the sketch name
267
279
type InvalidSketchFolderNameError struct {
268
280
SketchFolder * paths.Path
@@ -290,15 +302,16 @@ func (s *Sketch) Hash() string {
290
302
func (s * Sketch ) ToRpc () * rpc.Sketch {
291
303
defaultPort , defaultProtocol := s .GetDefaultPortAddressAndProtocol ()
292
304
res := & rpc.Sketch {
293
- MainFile : s .MainFile .String (),
294
- LocationPath : s .FullPath .String (),
295
- OtherSketchFiles : s .OtherSketchFiles .AsStrings (),
296
- AdditionalFiles : s .AdditionalFiles .AsStrings (),
297
- RootFolderFiles : s .RootFolderFiles .AsStrings (),
298
- DefaultFqbn : s .GetDefaultFQBN (),
299
- DefaultPort : defaultPort ,
300
- DefaultProtocol : defaultProtocol ,
301
- Profiles : f .Map (s .Project .Profiles , (* Profile ).ToRpc ),
305
+ MainFile : s .MainFile .String (),
306
+ LocationPath : s .FullPath .String (),
307
+ OtherSketchFiles : s .OtherSketchFiles .AsStrings (),
308
+ AdditionalFiles : s .AdditionalFiles .AsStrings (),
309
+ RootFolderFiles : s .RootFolderFiles .AsStrings (),
310
+ DefaultFqbn : s .GetDefaultFQBN (),
311
+ DefaultPort : defaultPort ,
312
+ DefaultProtocol : defaultProtocol ,
313
+ DefaultProgrammer : s .GetDefaultProgrammer (),
314
+ Profiles : f .Map (s .Project .Profiles , (* Profile ).ToRpc ),
302
315
}
303
316
if defaultProfile , err := s .GetProfile (s .Project .DefaultProfile ); err == nil {
304
317
res .DefaultProfile = defaultProfile .ToRpc ()
0 commit comments