From ef152954c7182f8d69ac0caf8a46862b5e105a64 Mon Sep 17 00:00:00 2001 From: David Carley Date: Sun, 11 Sep 2022 02:40:36 +0000 Subject: [PATCH 01/27] Changed the time/timezone dialog to for the virtual keyboard --- scripts/install.sh | 8 +- .../components/TextFieldWithOptions.svelte | 2 +- .../src/dialogs/ChangeHostnameDialog.svelte | 5 +- .../src/dialogs/ManualHomeAxisDialog.svelte | 5 +- .../src/dialogs/SetAxisPositionDialog.svelte | 5 +- .../src/dialogs/SetTimeDialog.svelte | 124 +++++++++++------- .../src/dialogs/WifiConnectionDialog.svelte | 5 +- .../src/lib/CustomActions.ts | 22 ++-- 8 files changed, 103 insertions(+), 73 deletions(-) diff --git a/scripts/install.sh b/scripts/install.sh index d9eaa1e..11be9f6 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -27,7 +27,13 @@ if $UPDATE_AVR; then ./installer/scripts/avr109-flash.py src/avr/bbctrl-avr-firmware.hex fi -# Update config.txt +# Set a default time-zone, if one has not been set +timedatectl | grep 'Time zone: Etc/UTC' >/dev/null +if [ $? -eq 0 ]; then + timedatectl set-timezone America/Los_Angeles +fi + +# Update /boot/config.txt ./installer/scripts/edit-boot-config \ disable_overscan=1 \ framebuffer_width=1280 \ diff --git a/src/svelte-components/src/components/TextFieldWithOptions.svelte b/src/svelte-components/src/components/TextFieldWithOptions.svelte index 9a54ad5..2c2d8a0 100644 --- a/src/svelte-components/src/components/TextFieldWithOptions.svelte +++ b/src/svelte-components/src/components/TextFieldWithOptions.svelte @@ -46,7 +46,7 @@ bind:value on:focusin={() => showMenu(true)} on:focusout={() => showMenu(false)} - use={[[virtualKeyboardChange, (newValue) => (value = newValue)]]} + use={[virtualKeyboardChange((v) => (value = v))]} {...$$restProps} >
diff --git a/src/svelte-components/src/dialogs/ChangeHostnameDialog.svelte b/src/svelte-components/src/dialogs/ChangeHostnameDialog.svelte index 5912525..717abf6 100644 --- a/src/svelte-components/src/dialogs/ChangeHostnameDialog.svelte +++ b/src/svelte-components/src/dialogs/ChangeHostnameDialog.svelte @@ -78,10 +78,7 @@ (hostname = newValue)], - ]} + use={[InitialFocus, virtualKeyboardChange((v) => (hostname = v))]} label="New Hostname" spellcheck="false" variant="filled" diff --git a/src/svelte-components/src/dialogs/ManualHomeAxisDialog.svelte b/src/svelte-components/src/dialogs/ManualHomeAxisDialog.svelte index 30fabc9..2cabd2f 100644 --- a/src/svelte-components/src/dialogs/ManualHomeAxisDialog.svelte +++ b/src/svelte-components/src/dialogs/ManualHomeAxisDialog.svelte @@ -37,10 +37,7 @@ label="Absolute" type="number" bind:value - use={[ - InitialFocus, - [virtualKeyboardChange, (newValue) => (value = newValue)], - ]} + use={[InitialFocus, virtualKeyboardChange((v) => (value = v))]} variant="filled" style="width: 100%;" /> diff --git a/src/svelte-components/src/dialogs/SetAxisPositionDialog.svelte b/src/svelte-components/src/dialogs/SetAxisPositionDialog.svelte index 76f3cef..d1e76e9 100644 --- a/src/svelte-components/src/dialogs/SetAxisPositionDialog.svelte +++ b/src/svelte-components/src/dialogs/SetAxisPositionDialog.svelte @@ -49,10 +49,7 @@ label="Position" type="number" bind:value - use={[ - InitialFocus, - [virtualKeyboardChange, (newValue) => (value = newValue)], - ]} + use={[InitialFocus, virtualKeyboardChange((v) => (value = v))]} spellcheck="false" variant="filled" style="width: 100%;" diff --git a/src/svelte-components/src/dialogs/SetTimeDialog.svelte b/src/svelte-components/src/dialogs/SetTimeDialog.svelte index 1ab5578..ae963b5 100644 --- a/src/svelte-components/src/dialogs/SetTimeDialog.svelte +++ b/src/svelte-components/src/dialogs/SetTimeDialog.svelte @@ -7,6 +7,7 @@ } from "@smui/dialog"; import Button, { Label } from "@smui/button"; import TextField from "@smui/textfield"; + import Select, { Option } from "@smui/select"; import CircularProgress from "@smui/circular-progress"; import VirtualList from "svelte-tiny-virtual-list"; import * as api from "$lib/api"; @@ -20,7 +21,12 @@ }; export let open = false; - let value = ""; + let year = ""; + let month = ""; + let day = ""; + let hour = ""; + let minute = ""; + let am = true; let wasOpen = false; let loading = true; let timezones: Timezone[] = []; @@ -43,7 +49,14 @@ parseTimezones(result.timezones); parseTimeinfo(result.timeinfo); - value = getDateTimeValueString(); + + const date = new Date(); + year = date.getFullYear().toString(); + month = (date.getMonth() + 1).toString(); + day = date.getDate().toString(); + hour = date.getHours().toString(); + minute = date.getMinutes().toString(); + am = date.getHours() >= 12; loading = false; } @@ -61,7 +74,7 @@ break; case "NTP synchronized": - networkTimeSynchronized = value === "yes"; + networkTimeSynchronized = false; break; } } @@ -98,28 +111,15 @@ }); } - function getDateTimeValueString() { - const date = new Date(); - - const year = date.getFullYear().toString().padStart(2, "0"); - const month = (date.getMonth() + 1).toString().padStart(2, "0"); - const day = date.getDate().toString().padStart(2, "0"); - const hour = date.getHours().toString().padStart(2, "0"); - const minute = date.getMinutes().toString().padStart(2, "0"); - - return `${year}-${month}-${day}T${hour}:${minute}:00`; - } - async function onConfirm() { - const date = new Date(value); - const year = date.getFullYear().toString().padStart(2, "0"); - const month = (date.getMonth() + 1).toString().padStart(2, "0"); - const day = date.getDate().toString().padStart(2, "0"); - const hour = date.getHours().toString().padStart(2, "0"); - const minute = date.getMinutes().toString().padStart(2, "0"); + const YY = year.toString().padStart(2, "0"); + const MM = month.toString().padStart(2, "0"); + const DD = day.toString().padStart(2, "0"); + const hh = hour.toString().padStart(2, "0"); + const mm = minute.toString().padStart(2, "0"); await api.PUT("time", { - datetime: `${year}-${month}-${day} ${hour}:${minute}:00`, + datetime: `${YY}-${MM}-${DD} ${hh}:${mm}:00`, timezone: timezones[selectedTimezoneIndex].value, }); } @@ -131,7 +131,7 @@ aria-labelledby="set-time-dialog-title" aria-describedby="set-time-dialog-content" > - Adjust Clock & Timezone + Change Time & Timezone {#if loading} @@ -149,40 +149,70 @@

{:else}

- Because this controller is not connected to the internet, - you can manually set the time. + Any time the controller is turned off, the time will need to + be reset. If you connect the controller to the internet, the + time will be managed automatically.

-

- Note: any time the controller is turned off, the time will - need to be reset. If you connect the controller to the - internet, the time will be managed automatically. -

- - (value = newValue), - ], + virtualKeyboardChange((v) => (year = v)), ]} - label="Time" - type="datetime-local" + label="Year" + type="number" variant="filled" - style="width: 100%;" + style="width: 70px;" /> + (month = v))]} + label="Month" + type="number" + variant="filled" + style="width: 70px;" + /> + (day = v))]} + label="Day" + type="number" + variant="filled" + style="width: 70px;" + /> + + + + (hour = v))]} + label="Hour" + type="number" + variant="filled" + style="width: 70px;" + /> + (minute = v))]} + label="Minute" + type="number" + variant="filled" + style="width: 70px;" + /> + + {/if} -

- To display your local time correctly, the controller must know - what timezone it is in. -

- -
- +
(password = newValue), - ], + virtualKeyboardChange((v) => (password = v)), ]} label="Password" spellcheck="false" diff --git a/src/svelte-components/src/lib/CustomActions.ts b/src/svelte-components/src/lib/CustomActions.ts index a3a405e..6b8fa0d 100644 --- a/src/svelte-components/src/lib/CustomActions.ts +++ b/src/svelte-components/src/lib/CustomActions.ts @@ -1,9 +1,15 @@ -export function virtualKeyboardChange(node: HTMLElement, cb: (value: any) => void) { - const input = node.querySelector("input"); - if (!input) { - console.error("Could not find the textfield's :", node); - throw new Error("Could not find the textfield's "); - } +import type { HTMLActionEntry } from "@smui/common/internal"; - input.addEventListener("keyup", () => cb(input.value)); -} +export function virtualKeyboardChange(cb: (v: any) => void): HTMLActionEntry { + const func = (node: HTMLElement, cb: (value: any) => void) => { + const input = node.querySelector("input"); + if (!input) { + console.error("Could not find the textfield's :", node); + throw new Error("Could not find the textfield's "); + } + + input.addEventListener("keyup", () => cb(input.value)); + }; + + return [ func, cb ]; +} \ No newline at end of file From 32cdf2adbda0e5150bd5a4620613ab6d56835086 Mon Sep 17 00:00:00 2001 From: David Carley Date: Sun, 11 Sep 2022 02:40:49 +0000 Subject: [PATCH 02/27] Bumped the version to 1.1.1 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7585cb7..04afd6b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bbctrl", - "version": "1.1.0", + "version": "1.1.1b2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "bbctrl", - "version": "1.1.0", + "version": "1.1.1b2", "hasInstallScript": true, "license": "GPL-3.0+", "devDependencies": { diff --git a/package.json b/package.json index 92c287a..40ef319 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bbctrl", - "version": "1.1.0", + "version": "1.1.1b2", "homepage": "https://onefinitycnc.com/", "repository": "https://github.com/OneFinityCNC/onefinity", "license": "GPL-3.0+", From cd9975541a00c1e04b71462c1ec550d3fd7c636e Mon Sep 17 00:00:00 2001 From: David Carley Date: Sun, 11 Sep 2022 02:41:25 +0000 Subject: [PATCH 03/27] Tweaks to the release scripts --- scripts/create-sdcard-image.js | 2 +- scripts/prep-controller-for-imaging.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/create-sdcard-image.js b/scripts/create-sdcard-image.js index 88fdc10..c5deb3f 100755 --- a/scripts/create-sdcard-image.js +++ b/scripts/create-sdcard-image.js @@ -38,5 +38,5 @@ async function main() { runCommand(`dd if=${device} of=${IMAGE_FILENAME} status=progress`, { stdio: "inherit" }); - runCommand(`chown ${uid} 1f.img`); + runCommand(`chown ${uid} ${IMAGE_FILENAME}`); } diff --git a/scripts/prep-controller-for-imaging.js b/scripts/prep-controller-for-imaging.js index 3616c52..0bdd682 100755 --- a/scripts/prep-controller-for-imaging.js +++ b/scripts/prep-controller-for-imaging.js @@ -4,6 +4,7 @@ const inquirer = require("inquirer"); const { runCommand, logErrorAndExit, initSignalHandlers, assertInstalled, info } = require("./util"); const PACKAGES_TO_PURGE = [ + "aptitude", "dphys-swapfile", "gdb", "geoip-database", @@ -47,6 +48,7 @@ async function main() { }); ssh("apt-get update"); + ssh("apt-get install usbutils"); ssh(`apt-get purge -y ${PACKAGES_TO_PURGE.join(" ")}`); ssh("apt-get autoremove -y"); ssh("touch /root/.prep-controller-completed"); From 1cda3cbbefa28cd9c2f8c14b1f726a945a41d4a2 Mon Sep 17 00:00:00 2001 From: David Carley Date: Sun, 11 Sep 2022 02:52:48 +0000 Subject: [PATCH 04/27] Fixed: when changing an input value on settings/motors/tool/io, the Save button wasn't always enabled. --- .../components/ConfigTemplatedInput.svelte | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/svelte-components/src/components/ConfigTemplatedInput.svelte b/src/svelte-components/src/components/ConfigTemplatedInput.svelte index 1d5fa4a..ed31d07 100644 --- a/src/svelte-components/src/components/ConfigTemplatedInput.svelte +++ b/src/svelte-components/src/components/ConfigTemplatedInput.svelte @@ -69,6 +69,11 @@ return value; } + function onKeyup(event) { + value = event.target.value; + onChange(); + } + function onChange() { Config.update((config) => { let target = config; @@ -108,6 +113,7 @@ step={template.step || "any"} bind:value on:input={onChange} + on:keyup={onKeyup} /> {:else if template.type === "int"} {:else if template.type === "string"} - + {:else if template.type == "text"} -