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

Fix generic indicator size #606

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
11 changes: 0 additions & 11 deletions src/assets/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ export const widgetProfiles: Profile[] = [
options: {
displayName: 'Pilot Gain',
variableName: 'PilotGain',
fractionalDigits: 1,
iconName: 'mdi-account-hard-hat',
variableUnit: '%',
variableMultiplier: 100,
Expand All @@ -107,7 +106,6 @@ export const widgetProfiles: Profile[] = [
options: {
displayName: 'Lights (1)',
variableName: 'Lights1',
fractionalDigits: 1,
iconName: 'mdi-flashlight',
variableUnit: '%',
variableMultiplier: 100,
Expand All @@ -120,7 +118,6 @@ export const widgetProfiles: Profile[] = [
options: {
displayName: 'Cam Tilt',
variableName: 'CamTilt',
fractionalDigits: 1,
iconName: 'mdi-camera-retake',
variableUnit: '%',
variableMultiplier: 100,
Expand All @@ -144,7 +141,6 @@ export const widgetProfiles: Profile[] = [
options: {
displayName: 'Water Temp',
variableName: 'SCALED_PRESSURE2.temperature',
fractionalDigits: 1,
iconName: 'mdi-thermometer',
variableUnit: '°C',
variableMultiplier: '.01',
Expand Down Expand Up @@ -267,7 +263,6 @@ export const widgetProfiles: Profile[] = [
options: {
displayName: 'Pilot Gain',
variableName: 'PilotGain',
fractionalDigits: 1,
iconName: 'mdi-account-hard-hat',
variableUnit: '%',
variableMultiplier: 100,
Expand All @@ -280,7 +275,6 @@ export const widgetProfiles: Profile[] = [
options: {
displayName: 'Lights (1)',
variableName: 'Lights1',
fractionalDigits: 1,
iconName: 'mdi-flashlight',
variableUnit: '%',
variableMultiplier: 100,
Expand All @@ -293,7 +287,6 @@ export const widgetProfiles: Profile[] = [
options: {
displayName: 'Cam Tilt',
variableName: 'CamTilt',
fractionalDigits: 1,
iconName: 'mdi-camera-retake',
variableUnit: '%',
variableMultiplier: 100,
Expand Down Expand Up @@ -438,7 +431,6 @@ export const widgetProfiles: Profile[] = [
options: {
displayName: 'Pilot Gain',
variableName: 'PilotGain',
fractionalDigits: 1,
iconName: 'mdi-account-hard-hat',
variableUnit: '%',
variableMultiplier: 100,
Expand All @@ -451,7 +443,6 @@ export const widgetProfiles: Profile[] = [
options: {
displayName: 'Lights (1)',
variableName: 'Lights1',
fractionalDigits: 1,
iconName: 'mdi-flashlight',
variableUnit: '%',
variableMultiplier: 100,
Expand All @@ -464,7 +455,6 @@ export const widgetProfiles: Profile[] = [
options: {
displayName: 'Cam Tilt',
variableName: 'CamTilt',
fractionalDigits: 1,
iconName: 'mdi-camera-retake',
variableUnit: '%',
variableMultiplier: 100,
Expand All @@ -488,7 +478,6 @@ export const widgetProfiles: Profile[] = [
options: {
displayName: 'Water Temp',
variableName: 'SCALED_PRESSURE2.temperature',
fractionalDigits: 1,
iconName: 'mdi-thermometer',
variableUnit: '°C',
variableMultiplier: '.01',
Expand Down
24 changes: 11 additions & 13 deletions src/components/mini-widgets/VeryGenericIndicator.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="flex items-center justify-center h-12 py-1 text-white transition-all w-fit">
<div class="flex items-center justify-center h-12 py-1 text-white transition-all w-[7rem]">
<span class="relative w-[2rem] mdi icon-symbol" :class="[miniWidget.options.iconName]"></span>
<div class="flex flex-col items-start justify-center mx-1 select-none w-fit min-w-[3rem]">
<div class="flex flex-col items-start justify-center ml-1 select-none w-[4.75rem]">
<div>
<span class="font-mono text-xl font-semibold leading-6 w-fit">{{ parsedState }}</span>
<span class="text-xl font-semibold leading-6 w-fit">
Expand Down Expand Up @@ -40,10 +40,6 @@
<Dropdown v-model="miniWidget.options.variableName" :options="Object.keys(store.genericVariables)" />
</div>
</div>
<div class="flex items-center justify-between w-full my-1">
<span class="mr-1 text-slate-100">Fractional digits</span>
<input v-model="miniWidget.options.fractionalDigits" class="w-48 px-2 py-1 rounded-md bg-slate-200" />
</div>
<div class="flex items-center justify-between w-full my-1">
<span class="mr-1 text-slate-100">Unit</span>
<input v-model="miniWidget.options.variableUnit" class="w-48 px-2 py-1 rounded-md bg-slate-200" />
Expand Down Expand Up @@ -140,7 +136,6 @@ onBeforeMount(() => {
Object.assign(miniWidget.value.options, {
displayName: '',
variableName: '',
fractionalDigits: 1,
iconName: 'mdi-help-box',
variableUnit: '%',
variableMultiplier: 1,
Expand All @@ -155,14 +150,17 @@ onBeforeMount(() => {
const store = useMainVehicleStore()

const currentState = ref<unknown>(0)

const finalValue = computed(() => Number(miniWidget.value.options.variableMultiplier) * Number(currentState.value))
const parsedState = computed(() => {
if (currentState.value !== undefined) {
return round(
Number(miniWidget.value.options.variableMultiplier) * Number(currentState.value),
miniWidget.value.options.fractionalDigits as number
).toFixed(miniWidget.value.options.fractionalDigits as number)
if (currentState.value === undefined) {
return '--'
}
return '--'
const value = finalValue.value
if (value < 1) return value.toFixed(2)
if (value >= 1 && value < 100) return value.toFixed(1)
if (value >= 10000) return `${(value / 10000).toFixed(0)}k`
return value.toFixed(0)
})

const updateVariableState = (): void => {
Expand Down
12 changes: 0 additions & 12 deletions src/types/genericIndicator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ export interface VeryGenericIndicatorPreset {
* Symbols representing the unit system of the variable
*/
variableUnit: string
/**
* Number of digits to be displayed after the decimal separator (usually dot)
*/
fractionalDigits: number
/**
* Value that multiplies the original value to bring it to a representative unit system
*/
Expand All @@ -34,63 +30,55 @@ export const veryGenericIndicatorPresets: VeryGenericIndicatorPreset[] = [
variableName: 'CamTilt',
iconName: 'mdi-camera-retake',
variableUnit: '%',
fractionalDigits: 0,
variableMultiplier: 100,
},
{
displayName: 'Cam Pan',
variableName: 'CamPan',
iconName: 'mdi-camera-retake',
variableUnit: '%',
fractionalDigits: 0,
variableMultiplier: 100,
},
{
displayName: 'Tether Turns',
variableName: 'TetherTrn',
iconName: 'mdi-horizontal-rotate-clockwise',
variableUnit: 'x',
fractionalDigits: 0,
variableMultiplier: 100,
},
{
displayName: 'Lights (1)',
variableName: 'Lights1',
iconName: 'mdi-flashlight',
variableUnit: '%',
fractionalDigits: 0,
variableMultiplier: 100,
},
{
displayName: 'Lights (2)',
variableName: 'Lights2',
iconName: 'mdi-flashlight',
variableUnit: '%',
fractionalDigits: 0,
variableMultiplier: 100,
},
{
displayName: 'Pilot Gain',
variableName: 'PilotGain',
iconName: 'mdi-account-hard-hat',
variableUnit: '%',
fractionalDigits: 0,
variableMultiplier: 100,
},
{
displayName: 'Input Hold',
variableName: 'InputHold',
iconName: 'mdi-gesture-tap-hold',
variableUnit: '',
fractionalDigits: 0,
variableMultiplier: 1,
},
{
displayName: 'Roll Pitch',
variableName: 'RollPitch',
iconName: 'mdi-controller',
variableUnit: '',
fractionalDigits: 0,
variableMultiplier: 1,
},
]