-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/proper-mdns-support
- Loading branch information
Showing
42 changed files
with
928 additions
and
416 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<script lang="ts"> | ||
import { DeviceStateStore } from '$lib/stores'; | ||
import { UsedPinsStore } from '$lib/stores/UsedPinsStore'; | ||
import { WebSocketClient } from '$lib/WebSocketClient'; | ||
export let name: string; | ||
export let currentPin: number | null; | ||
export let serializer: (gpio: number) => Uint8Array; | ||
let pendingPin: number | null = null; | ||
let statusText: string = 'Loading...'; | ||
$: canSet = pendingPin !== null && pendingPin !== currentPin && pendingPin >= 0 && pendingPin <= 255 && $DeviceStateStore.gpioValidOutputs.includes(pendingPin) && !$UsedPinsStore.has(pendingPin); | ||
$: if (currentPin !== null) { | ||
UsedPinsStore.markPinUsed(currentPin, name); | ||
statusText = currentPin >= 0 ? 'Currently ' + currentPin : 'Invalid pin'; | ||
} else { | ||
statusText = 'Loading...'; | ||
} | ||
$: if (pendingPin !== null) { | ||
if (pendingPin < 0) { | ||
pendingPin = null; | ||
} else if (pendingPin > 255) { | ||
pendingPin = 255; | ||
} | ||
} | ||
function setGpioPin() { | ||
if (!canSet) return; | ||
const data = serializer(pendingPin!); | ||
WebSocketClient.Instance.Send(data); | ||
} | ||
</script> | ||
|
||
<div class="flex flex-col space-y-2"> | ||
<div class="flex flex-row space-x-2 items-center"> | ||
<h3 class="h3">{name}</h3> | ||
<span class="text-sm text-gray-500">{statusText}</span> | ||
</div> | ||
<div class="flex space-x-2"> | ||
<input class="input variant-form-material" type="number" placeholder="GPIO Pin" bind:value={pendingPin} /> | ||
<button class="btn variant-filled" on:click={setGpioPin} disabled={!canSet}>Set</button> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { writable } from "svelte/store"; | ||
|
||
const { subscribe, update } = writable<Map<number, string>>(new Map<number, string>()); | ||
|
||
export const UsedPinsStore = { | ||
subscribe, | ||
markPinUsed(pin: number, name: string) { | ||
update((store) => { | ||
// Remove any existing entries with the same pin or name | ||
for (const [key, value] of store) { | ||
if (key === pin || value === name) { | ||
store.delete(key); | ||
} | ||
} | ||
|
||
store.set(pin, name); | ||
|
||
return store; | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
dae41bb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cpp-Linter Report⚠️
Some files did not pass the configured checks!
clang-format reports: 3 file(s) not formatted
Have any feedback or feature suggestions? Share it here.