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

Auto connect if only one port available #163

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
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
15 changes: 14 additions & 1 deletion ui/arduino/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ button.small .icon {
}

#panel #drag-handle {
width: 100%;
flex-grow: 2;
height: 100%;
cursor: grab;
}
Expand All @@ -293,6 +293,19 @@ button.small .icon {
background: #008184;
}

.panel-bar #connection-status {
display: flex;
align-items: center;
gap: 10px;
color: white;
}

.panel-bar #connection-status img {
width: 1.25em;
height: 1.25em;
filter: invert(1);
}

.panel-bar .term-operations {
transition: opacity 0.15s;
display: flex;
Expand Down
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 () => {
sebromero marked this conversation as resolved.
Show resolved Hide resolved
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
4 changes: 4 additions & 0 deletions ui/arduino/views/components/repl-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ function ReplPanel(state, emit) {
return html`
<div id="panel" style="height: ${state.panelHeight}px">
<div class="panel-bar">
<div id="connection-status" style="visibility:${state.isConnected ? 'visible' : 'hidden'};">
<img src="media/connect.svg" />
<div>${state.isConnected ? 'Connected to ' + state.connectedPort : ''}</div>
</div>
<div id="drag-handle"
onmousedown=${() => emit('start-resizing-panel')}
onmouseup=${() => emit('stop-resizing-panel')}
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