@@ -246,6 +246,12 @@ func (s *Sketch) GetDefaultPortAddressAndProtocol() (string, string) {
246246 return s .Project .DefaultPort , s .Project .DefaultProtocol
247247}
248248
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+
249255// SetDefaultFQBN sets the default FQBN for the sketch and saves it in the sketch.yaml project file.
250256func (s * Sketch ) SetDefaultFQBN (fqbn string ) error {
251257 s .Project .DefaultFqbn = fqbn
@@ -263,6 +269,12 @@ func (s *Sketch) SetDefaultPort(address, protocol string) error {
263269 return updateOrAddYamlRootEntry (s .GetProjectPath (), "default_protocol" , protocol )
264270}
265271
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+
266278// InvalidSketchFolderNameError is returned when the sketch directory doesn't match the sketch name
267279type InvalidSketchFolderNameError struct {
268280 SketchFolder * paths.Path
@@ -290,15 +302,16 @@ func (s *Sketch) Hash() string {
290302func (s * Sketch ) ToRpc () * rpc.Sketch {
291303 defaultPort , defaultProtocol := s .GetDefaultPortAddressAndProtocol ()
292304 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 ),
302315 }
303316 if defaultProfile , err := s .GetProfile (s .Project .DefaultProfile ); err == nil {
304317 res .DefaultProfile = defaultProfile .ToRpc ()
0 commit comments