Skip to content

Commit d1ece64

Browse files
committed
Added cores.Board method to get config options
1 parent 9add6ce commit d1ece64

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

arduino/cores/board.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,29 @@ func (b *Board) String() string {
6060
return b.FQBN()
6161
}
6262

63+
// GetConfigOptions returns an OrderedMap of configuration options for this board.
64+
// The returned map will have key and value as option id and option name, respectively.
65+
func (b *Board) GetConfigOptions() *properties.Map {
66+
res := properties.NewMap()
67+
menu := b.Properties.SubTree("menu")
68+
for _, option := range menu.FirstLevelKeys() {
69+
res.Set(option, b.PlatformRelease.Menus.Get(option))
70+
}
71+
return res
72+
}
73+
74+
// GetConfigOptionValues returns an OrderedMap of possible values for a specific configuratio options
75+
// for this board. The returned map will have key and value as option value and option value name,
76+
// respectively.
77+
func (b *Board) GetConfigOptionValues(option string) *properties.Map {
78+
res := properties.NewMap()
79+
menu := b.Properties.SubTree("menu").SubTree(option)
80+
for _, value := range menu.FirstLevelKeys() {
81+
res.Set(value, menu.Get(value))
82+
}
83+
return res
84+
}
85+
6386
// GetBuildProperties returns the build properties and the build
6487
// platform for the Board with the configuration passed as parameter.
6588
func (b *Board) GetBuildProperties(userConfigs *properties.Map) (*properties.Map, error) {

0 commit comments

Comments
 (0)