Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(boards): Support board revisions #2157

Merged
merged 9 commits into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions docs/src/templates/setup.ps1.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,19 @@ if ($keyboard_type -eq "shield") {
{{/boards}}
}

$boards_revisions = [ordered]@{
{{#boards}}
{{id}} = @({{#revisions}}
"{{.}}"{{/revisions}});
{{/boards}}
}

$boards_default_revision=[ordered]@{
{{#boards}}
{{id}} = "{{{default_revision}}}";
{{/boards}}
}

Write-Host "$title"
Write-Host ""
Write-Host "MCU Board Selection:"
Expand All @@ -145,6 +158,22 @@ if ($keyboard_type -eq "shield") {
$shields = $keyboard_siblings
$board = $($($boards.keys)[$choice])
$boards = ( $board )

if ($($($boards_revisions.values)[$choice]).count -gt 0) {
$valid_revisions = $($($boards_revisions.values)[$choice])
$revision_choices = @() + $valid_revisions

for ($i = 0; $i -lt $valid_revisions.count; $i += 1) {
if ($valid_revisions[$i] -eq $($($boards_default_revision.values)[$choice])) {
$revision_choices[$i] += " (default)"
}
}

$revision_choice = Get-Choice-From-Options -Options $revision_choices -Prompt $prompt
$board = $board + "@" + $valid_revisions[$revision_choice]
$boards = ( $board )
}

} else {
$boards = ( $keyboard_siblings )
$shields = @( )
Expand Down
35 changes: 35 additions & 0 deletions docs/src/templates/setup.sh.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ if [ "$keyboard_shield" == "y" ]; then
board_ids=({{#boards}}"{{id}}" {{/boards}})
boards_usb_only=({{#boards}}"{{#usb_only}}y{{/usb_only}}{{^usb_only}}n{{/usb_only}}" {{/boards}})

boards_revisions=({{#boards}}"{{#revisions}}{{.}} {{/revisions}}" {{/boards}})
boards_default_revision=({{#boards}}"{{{default_revision}}}" {{/boards}})

echo ""
echo "MCU Board Selection:"
PS3="$prompt "
Expand Down Expand Up @@ -151,6 +154,38 @@ if [ "$keyboard_shield" == "y" ]; then

esac
done

if [ -n "${boards_revisions[$board_index]}" ]; then
read -a _valid_revisions <<< "${boards_revisions[$board_index]}"

_rev_choices=("${_valid_revisions[@]}")
for (( _i=0; _i<${#_valid_revisions}; _i++ )); do
if [ "${boards_default_revision[board_index]}" = "${_valid_revisions[_i]}" ]; then
_rev_choices[_i]+=" (default)"
fi
done

echo ""
echo "MCU Board Revision:"
select opt in "${_rev_choices[@]}" "Quit"; do
case "$REPLY" in
''|*[!0-9]*) echo "Invalid option. Try another one."; continue;;

$(( ${#_valid_revisions[@]}+1 )) ) echo "Goodbye!"; exit 1;;
*)
if [ $REPLY -gt $(( ${#_valid_revisions[@]}+1 )) ] || [ $REPLY -lt 0 ]; then
echo "Invalid option. Try another one."
continue
fi

_rev_index=$(( $REPLY-1 ))
board="${board_ids[$board_index]}@${_valid_revisions[_rev_index]}"
boards=( "${board}" )
break
;;
esac
done
fi
else
board=${keyboard}
boards=$keyboard_siblings
Expand Down
15 changes: 14 additions & 1 deletion schema/hardware-metadata.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
"$defs": {
"id": {
"type": "string",
"pattern": "^[a-z0-9_]+$"
"pattern": "^[a-z0-9_]+(@([A-Z]|[0-9]+|([0-9]+(\\.[0-9]+){1,2})))?$"
},
"revision": {
"type": "string",
"pattern": "[A-Z]|[0-9]+|([0-9]+(\\.[0-9]+){1,2})"
},
"keyboard_siblings": {
"type": "array",
Expand Down Expand Up @@ -202,6 +206,15 @@
},
"exposes": {
"$ref": "#/$defs/interconnects"
},
"revisions": {
"type": "array",
"items": {
"$ref": "#/$defs/revision"
}
},
"default_revision": {
"$ref": "#/$defs/revision"
}
}
},
Expand Down
Loading