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

Analog channel setup fixes and custom RTD spec support #1888

Merged
Merged
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
12 changes: 6 additions & 6 deletions firmware.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[FIRMWARE]
firmware_version=e8cdb3b0
firmware_date=2024-07-08
firmware_sha=e8cdb3b07d717f5178320702ad814c8b1d51af63
proto_version=a58d8532
proto_date=2024-07-07
proto_sha=a58d8532c9337310966401f24afc2a64ec15701d
firmware_version=799fb9f0
firmware_date=2025-02-05
firmware_sha=799fb9f00bf57867f4ce2460e0ee62ad701f0484
proto_version=fb8c001b
proto_date=2025-02-05
proto_sha=fb8c001b1849efd4d8435829f0f85580f5e3a724
system_version=3.2.0
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"dependencies": {
"@quasar/extras": "^1.16.11",
"axios": "^1.6.8",
"brewblox-proto": "https://github.com/brewblox/brewblox-proto#commit=a58d8532c9337310966401f24afc2a64ec15701d",
"brewblox-proto": "https://github.com/brewblox/brewblox-proto#commit=fb8c001b1849efd4d8435829f0f85580f5e3a724",
"buffer": "^6.0.3",
"cm6-theme-basic-dark": "^0.2.0",
"codemirror": "^6.0.1",
Expand Down
2 changes: 2 additions & 0 deletions src/auto-import.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ declare module '@vue/runtime-core' {
QuantityDialog: typeof import('src/components/form/QuantityDialog.vue').default;
NumberField: typeof import('src/components/form/NumberField.vue').default;
NumberDialog: typeof import('src/components/form/NumberDialog.vue').default;
ScientificNumberField: typeof import('src/components/form/ScientificNumberField.vue').default;
ScientificNumberDialog: typeof import('src/components/form/ScientificNumberDialog.vue').default;
MarkdownView: typeof import('src/components/form/MarkdownView.vue').default;
MarkdownDialog: typeof import('src/components/form/MarkdownDialog.vue').default;
LoginDialog: typeof import('src/components/form/LoginDialog.vue').default;
Expand Down
3 changes: 3 additions & 0 deletions src/components/form/QuantityDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ interface Props extends UseDialogProps {
modelValue: Quantity;
decimals?: number;
label?: string;
clearable?: boolean;
}

const props = withDefaults(defineProps<Props>(), {
...useDialog.defaultProps,
decimals: 2,
label: 'Value',
clearable: false,
});

defineEmits<UseDialogEmits>();
Expand Down Expand Up @@ -59,6 +61,7 @@ function showKeyboard(): void {
v-model.number="local"
:label="label"
:suffix="notation"
:clearable="clearable"
input-class="text-big"
inputmode="numeric"
pattern="[0-9\.]*"
Expand Down
3 changes: 3 additions & 0 deletions src/components/form/QuantityField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ interface Props extends UseFieldProps {
tagClass?: VueClassProp;
decimals?: number;
unitTag?: string;
clearable?: boolean;
}

const props = withDefaults(defineProps<Props>(), {
Expand All @@ -23,6 +24,7 @@ const props = withDefaults(defineProps<Props>(), {
tagClass: '',
decimals: 2,
unitTag: 'small',
clearable: false,
});

const emit = defineEmits<{
Expand Down Expand Up @@ -59,6 +61,7 @@ function openDialog(): void {
message: props.message,
html: props.html,
label: props.label,
clearable: props.clearable,
},
}).onOk(change);
}
Expand Down
129 changes: 129 additions & 0 deletions src/components/form/ScientificNumberDialog.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<script setup lang="ts">
import { computed, ref } from 'vue';
import { useDialog, UseDialogEmits, UseDialogProps } from '@/composables';
import { createDialog } from '@/utils/dialog';
import { makeRuleValidator } from '@/utils/rules';

interface Props extends UseDialogProps {
modelValue: number | null;
fractionDigits?: number;
label?: string;
rules?: InputRule[];
clearable?: boolean;
autogrow?: boolean;
fontSize?: string;
suffix?: string;
placeholder?: string;
}

const props = withDefaults(defineProps<Props>(), {
...useDialog.defaultProps,
fractionDigits: 4,
label: '',
rules: () => [],
clearable: true,
autogrow: false,
fontSize: '170%',
suffix: '',
placeholder: undefined,
});

defineEmits<UseDialogEmits>();

const { dialogRef, dialogOpts, onDialogHide, onDialogCancel, onDialogOK } =
useDialog.setup<number | null>();

const local = ref<string | number>(
props.modelValue != null
? Number(props.modelValue).toExponential(props.fractionDigits)
: '',
);

function parse(v: Maybe<string | number>): number | null {
if (v == null) {
return null;
}
if (v === '') {
return null;
}
return Number(v);
}

const parsed = computed<number | null>(() => parse(local.value));
const parsedDisplay = computed<string>(() => {
const value = parse(local.value);
return value !== null
? Number(value).toExponential(props.fractionDigits)
: '<not set>';
});
const validator = computed<(val: any) => boolean>(() =>
makeRuleValidator(props.rules),
);

const isValid = computed<boolean>(() => validator.value(parsed.value));

function save(): void {
if (isValid.value) {
onDialogOK(parsed.value);
}
}

function showKeyboard(): void {
createDialog({
component: 'KeyboardDialog',
componentProps: {
modelValue: local.value,
type: 'number',
rules: props.rules,
},
}).onOk((v) => (local.value = v));
}
</script>

<template>
<q-dialog
ref="dialogRef"
v-bind="dialogOpts"
@hide="onDialogHide"
@keyup.enter="save"
>
<DialogCard v-bind="{ title, message, html }">
<q-input
v-model.number="local"
v-bind="{
clearable,
label,
autogrow,
suffix,
placeholder,
rules,
}"
:input-style="{ fontSize }"
:hint="`${parsedDisplay}`"
type="number"
step="any"
inputmode="numeric"
autofocus
>
<template #append>
<KeyboardButton @click="showKeyboard" />
</template>
</q-input>
<template #actions>
<q-btn
flat
label="Cancel"
color="primary"
@click="onDialogCancel"
/>
<q-btn
:disable="!isValid"
flat
label="OK"
color="primary"
@click="save"
/>
</template>
</DialogCard>
</q-dialog>
</template>
81 changes: 81 additions & 0 deletions src/components/form/ScientificNumberField.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<script setup lang="ts">
import { computed } from 'vue';
import { useField, UseFieldProps } from '@/composables';
import { createDialog } from '@/utils/dialog';

export interface Props extends UseFieldProps {
modelValue: number | null;
fractionDigits?: number;
clearable?: boolean;
autogrow?: boolean;
suffix?: string;
dialogSuffix?: string;
placeholder?: string;
}

const props = withDefaults(defineProps<Props>(), {
...useField.defaultProps,
fractionDigits: 4,
clearable: true,
autogrow: false,
suffix: '',
placeholder: undefined,
});

const emit = defineEmits<{
'update:modelValue': [payload: number];
}>();

const { activeSlots } = useField.setup();

const displayValue = computed<string>(() => {
if (props.modelValue === null) {
return '';
}
return Number.parseFloat(String(props.modelValue)).toExponential(
props.fractionDigits,
);
});

function openDialog(): void {
if (props.readonly) {
return;
}

createDialog({
component: 'ScientificNumberDialog',
componentProps: {
modelValue: props.modelValue,
title: props.title,
message: props.message,
html: props.html,
fractionDigits: props.fractionDigits,
label: props.label,
rules: props.rules,
clearable: props.clearable,
autogrow: props.autogrow,
suffix: props.dialogSuffix || props.suffix,
placeholder: props.placeholder,
...props.dialogProps,
},
}).onOk((v) => emit('update:modelValue', v));
}
</script>

<template>
<LabeledField
v-bind="{ ...$attrs, ...$props }"
@click="openDialog"
>
<slot name="value">
{{ displayValue }}
</slot>

<template
v-for="slot in activeSlots"
#[slot]
>
<slot :name="slot" />
</template>
</LabeledField>
</template>
Loading