Skip to content

Commit

Permalink
#127 with new layout
Browse files Browse the repository at this point in the history
Signed-off-by: nicolaskolbenschlag <[email protected]>
  • Loading branch information
nicolaskolbenschlag committed Jan 11, 2023
1 parent 28ef9b4 commit 9f3619f
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 5 deletions.
4 changes: 4 additions & 0 deletions Apps/frontend/src/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,8 @@ nav {
&--close {
background-image: url("./assets/mui_close.svg");
}

&--drop-down {
background-image: url("./assets/mui_drop-down.svg");
}
}
1 change: 1 addition & 0 deletions Apps/frontend/src/assets/mui_drop-down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions Apps/frontend/src/components/GNDButton.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<script>
import { createEventDispatcher } from "svelte";
const dispatch = createEventDispatcher();
const handleClick = async (/** @type {boolean} */ down) => {
dispatch("set-gnd", { down: down });
};
</script>

<button
class="icon-button mui-icon--drop-down"
on:mousedown={async () => {
handleClick(true);
}}
on:mouseup={async () => {
handleClick(false);
}}
data-cy="gnd-button"
/>
1 change: 1 addition & 0 deletions Apps/frontend/src/stores.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ export const thicknessAdjustment = writable(
);

export const expandedPanelOpen = writable(false);
export const isGND = writable(false);
8 changes: 7 additions & 1 deletion Apps/frontend/src/views/GeneralButtons.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<script>
import { osciEnabled } from "../stores";
import { osciEnabled, isGND } from "../stores";
import OnOffButton from "../components/OnOffButton.svelte";
import ResetButton from "../components/ResetButton.svelte";
import GNDButton from "../components/GNDButton.svelte";
let onOffButton;
export let indicatorElement;
Expand All @@ -25,3 +26,8 @@
waveElement.resetPlot();
}}
/>
<GNDButton
on:set-gnd={(e) => {
$isGND = e.detail.down;
}}
/>
14 changes: 10 additions & 4 deletions Apps/frontend/src/views/Oscilloscope.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Waves from "../components/Waves.svelte";
import CoordinateSystem from "./CoordinateSystem.svelte";
import { MIN_CONTROL_PANEL_BOTTOM_HEIGHT, NUM_CHANNELS } from "../const";
import { osciEnabled } from "../stores";
import { osciEnabled, isGND } from "../stores";
import { logSocketCloseCode } from "../helper";
$: innerWidth = 0;
Expand All @@ -22,6 +22,8 @@
let socket;
let gndSample = null;
// ----- Svelte lifecycle hooks -----
onMount(() => {
socket = createSocket();
Expand Down Expand Up @@ -51,6 +53,12 @@
const socketOnMessage = (messageEvent) => {
if (!$osciEnabled) return;
let samples = new Float64Array(messageEvent.data);
if ($isGND) {
if (gndSample == null) {
gndSample = new Array(samples.length).fill(0.0);
}
samples = gndSample;
}
for (let index = 0; index < samples.length; index += NUM_CHANNELS) {
waveElement.updateBuffer(samples, index, index + NUM_CHANNELS);
if (index % 1000 == 0) indicatorElement.update(samples, index);
Expand Down Expand Up @@ -84,9 +92,7 @@
<Waves bind:this={waveElement} {scalesY} />
</div>
</div>
<div class="control-panel--right">
Overall Buttons
</div>
<div class="control-panel--right">Overall Buttons</div>
<div
class="control-panel--bottom"
bind:clientHeight={controlPanelBottomHeight}
Expand Down

0 comments on commit 9f3619f

Please sign in to comment.