Skip to content

Commit

Permalink
Auto connect if only one port available
Browse files Browse the repository at this point in the history
  • Loading branch information
sebromero committed Dec 17, 2024
1 parent 8d7586a commit 65e53cc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions ui/arduino/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,20 @@ async function store(state, emitter) {
emitter.emit('render')
})

emitter.on('connect', async () => {
try {
state.availablePorts = await getAvailablePorts()
} catch(e) {
console.error('Could not get available ports. ', e)
}

if(state.availablePorts.length == 1) {
emitter.emit('select-port', state.availablePorts[0])
} else {
emitter.emit('open-connection-dialog')
}
})

// CODE EXECUTION
emitter.on('run', async (onlySelected = false) => {
log('run')
Expand Down
2 changes: 1 addition & 1 deletion ui/arduino/views/components/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function Toolbar(state, emit) {
${Button({
icon: state.isConnected ? 'connect.svg' : 'disconnect.svg',
tooltip: state.isConnected ? `Disconnect (${metaKeyString}+Shift+D)` : `Connect (${metaKeyString}+Shift+C)`,
onClick: () => state.isConnected ? emit('disconnect') : emit('open-connection-dialog'),
onClick: () => state.isConnected ? emit('disconnect') : emit('connect'),
active: state.isConnected
})}
Expand Down

0 comments on commit 65e53cc

Please sign in to comment.