Skip to content

Commit

Permalink
Add rover page + control pad
Browse files Browse the repository at this point in the history
  • Loading branch information
MRoehricht committed Oct 11, 2023
1 parent f8f9227 commit 125347e
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 1 deletion.
9 changes: 8 additions & 1 deletion SEVEN.MissionControl.Dashboard/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
Explore,
LogoGithub,
SettingsAdjust,
Label
Label,
DroneVideo
} from 'carbon-icons-svelte';
import { onMount } from 'svelte';
import '@carbon/styles/css/styles.css';
Expand Down Expand Up @@ -173,6 +174,12 @@
href="/devices/explore"
isSelected={path?.endsWith('/devices/explore')}
/>
<SideNavLink
icon={DroneVideo}
text="Rover"
href="/rovers"
isSelected={path?.endsWith('/rovers')}
/>
</SideNavItems>
{/if}
</SideNav>
Expand Down
104 changes: 104 additions & 0 deletions SEVEN.MissionControl.Dashboard/src/routes/rovers/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<script lang="ts">
import { onMount, onDestroy } from 'svelte';
import CaretDown from 'carbon-icons-svelte/lib/CaretDown.svelte';
import CaretLeft from 'carbon-icons-svelte/lib/CaretLeft.svelte';
import CaretRight from 'carbon-icons-svelte/lib/CaretRight.svelte';
import CaretUp from 'carbon-icons-svelte/lib/CaretUp.svelte';
import StopOutline from 'carbon-icons-svelte/lib/StopOutline.svelte';
import { Button, Grid, Row, Column, Slider } from 'carbon-components-svelte';
import DashboardToolbar from '$lib/components/DashboardToolbar.svelte';
let speed: number = 0;
let socket: WebSocket;
onMount(() => {
socket = new WebSocket('ws://192.168.178.4:8745');
socket.addEventListener('open', () => {
console.log('Opened');
});
});
onDestroy(() => {
socket?.close();
});
</script>

<DashboardToolbar
title="Rover"
crumbs={[
{ label: 'Home', path: '/' },
{ label: 'Rover', path: '/rovers' }
]}
/>

<Grid narrow>
<Row>
<Column sm={1} md={1} lg={1} />
<Column sm={1} md={1} lg={1}
><Button
tooltipPosition="top"
tooltipAlignment="end"
iconDescription="Vorwärts"
size="lg"
icon={CaretUp}
on:click={() => socket?.send('1;0;' + speed + ';0;0')}
/></Column
>
<Column sm={1} md={1} lg={1} />
</Row>
<Row>
<Column sm={1} md={1} lg={1}
><Button
tooltipPosition="top"
tooltipAlignment="end"
iconDescription="Links"
size="lg"
icon={CaretLeft}
on:click={() => socket?.send('0;1;0;0;' + speed + '')}
/></Column
>
<Column sm={1} md={1} lg={1}>
<Button
tooltipPosition="top"
tooltipAlignment="start"
iconDescription="Stopp"
size="lg"
icon={StopOutline}
on:click={() => socket?.send('0;0;0;0;0')}
/></Column
>
<Column sm={1} md={1} lg={1}
><Button
tooltipPosition="top"
tooltipAlignment="end"
iconDescription="Rechts"
size="lg"
icon={CaretRight}
on:click={() => socket?.send('0;2;0;' + speed + ';0')}
/></Column
>
</Row>
<Row>
<Column sm={1} md={1} lg={1} />
<Column sm={1} md={1} lg={1}
><Button
tooltipPosition="bottom"
tooltipAlignment="end"
iconDescription="Rückwärts"
size="lg"
icon={CaretDown}
on:click={() => socket?.send('2;0;' + speed + ';0;0')}
/></Column
>
<Column sm={1} md={1} lg={1} />
</Row>
</Grid>

<Slider
light
labelText="Geschwíndigkeit"
min={55000}
max={65520}
bind:value={speed}
step={1000}
hideTextInput
/>

0 comments on commit 125347e

Please sign in to comment.