Skip to content

Commit

Permalink
Add comments explaining the MAVLink buttons mapping logic
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaellehmkuhl committed Sep 13, 2023
1 parent 81f0fc3 commit afc68f1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/views/ConfigurationJoystickView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,10 @@ const updateMapping = (index: number, newValue: ProtocolInput, inputType: InputT
}
let mavlinkButton: undefined | number = undefined
if (oldInputMapping[index].protocol === JoystickProtocol.MAVLink) {
// If the selected Cockpit button is already mapped to be used with MAVLink functions, re-use it
mavlinkButton = oldInputMapping[index].value as number
} else {
// If not, we should look for a MAVLink button that is not being used already and use it
const usedMavlinkButtons = oldInputMapping
.filter((i) => i.protocol === JoystickProtocol.MAVLink)
.map((i) => i.value)
Expand All @@ -393,6 +395,7 @@ const updateMapping = (index: number, newValue: ProtocolInput, inputType: InputT
}
}
if (mavlinkButton === undefined) {
// If the variable is still undefined, it means we could not find an available MAVLink button, thus we cannot proceed mapping
const errorMessage = `None of the 16 MAVLink Manual Control buttons are available.
Please assign "No function" to one already used.`
console.error(errorMessage)
Expand Down

0 comments on commit afc68f1

Please sign in to comment.