From ed34001962781ddea626e229a808ec92dfb1e13b Mon Sep 17 00:00:00 2001 From: JovannMC Date: Tue, 8 Oct 2024 17:05:52 +0000 Subject: [PATCH] Add drift compensation warning (#1160) --- gui/public/i18n/en/translation.ftl | 9 +++ .../settings/DriftCompensationModal.tsx | 72 +++++++++++++++++++ .../settings/pages/GeneralSettings.tsx | 20 ++++++ 3 files changed, 101 insertions(+) create mode 100644 gui/src/components/settings/DriftCompensationModal.tsx diff --git a/gui/public/i18n/en/translation.ftl b/gui/public/i18n/en/translation.ftl index 783ab650a4..fb58896b99 100644 --- a/gui/public/i18n/en/translation.ftl +++ b/gui/public/i18n/en/translation.ftl @@ -321,7 +321,16 @@ settings-general-tracker_mechanics-drift_compensation = Drift compensation settings-general-tracker_mechanics-drift_compensation-description = Compensates IMU yaw drift by applying an inverse rotation. Change amount of compensation and up to how many resets are taken into account. + This should only be used if you need to reset very often! settings-general-tracker_mechanics-drift_compensation-enabled-label = Drift compensation +settings-general-tracker_mechanics-drift_compensation_warning = + Warning: Only use drift compensation if you need to reset + very often (every ~5-10 minutes). + + Some IMUs prone to frequent resets include: + Joy-Cons, owoTrack, and MPUs (without recent firmware). +settings-general-tracker_mechanics-drift_compensation_warning-cancel = Cancel +settings-general-tracker_mechanics-drift_compensation_warning-done = I understand settings-general-tracker_mechanics-drift_compensation-amount-label = Compensation amount settings-general-tracker_mechanics-drift_compensation-max_resets-label = Use up to x last resets settings-general-tracker_mechanics-save_mounting_reset = Save automatic mounting reset calibration diff --git a/gui/src/components/settings/DriftCompensationModal.tsx b/gui/src/components/settings/DriftCompensationModal.tsx new file mode 100644 index 0000000000..1ca4511f61 --- /dev/null +++ b/gui/src/components/settings/DriftCompensationModal.tsx @@ -0,0 +1,72 @@ +import { Button } from '@/components/commons/Button'; +import { WarningBox } from '@/components/commons/TipBox'; +import { Localized, useLocalization } from '@fluent/react'; +import { BaseModal } from '@/components/commons/BaseModal'; +import ReactModal from 'react-modal'; + +export function DriftCompensationModal({ + isOpen = true, + onClose, + accept, + ...props +}: { + /** + * Is the parent/sibling component opened? + */ + isOpen: boolean; + /** + * Function to trigger when the warning hasn't been accepted + */ + onClose: () => void; + /** + * Function when you press `I understand` + */ + accept: () => void; +} & ReactModal.Props) { + const { l10n } = useLocalization(); + + return ( + +
+
+ }} + > + + Warning: Drift compensation should only be used if you find + you need to reset very often (~5-10 minutes). +
+ Some IMUs prone to frequent resets include: Joy-Cons, owoTrack, + and MPUs (without recent firmware). +
+
+ +
+ + +
+
+
+
+ ); +} diff --git a/gui/src/components/settings/pages/GeneralSettings.tsx b/gui/src/components/settings/pages/GeneralSettings.tsx index f6d0c1c0ef..62a9cee538 100644 --- a/gui/src/components/settings/pages/GeneralSettings.tsx +++ b/gui/src/components/settings/pages/GeneralSettings.tsx @@ -31,6 +31,7 @@ import { SettingsPagePaneLayout, } from '@/components/settings/SettingsPageLayout'; import { HandsWarningModal } from '@/components/settings/HandsWarningModal'; +import { DriftCompensationModal } from '@/components/settings/DriftCompensationModal'; interface SettingsForm { trackers: { @@ -435,6 +436,8 @@ export function GeneralSettings() { // } // }, [state]); + const [showDriftCompWarning, setShowDriftCompWarning] = useState(false); + return ( { + if (getValues('driftCompensation.enabled')) { + return; + } + + setShowDriftCompWarning(true); + }} /> + { + setShowDriftCompWarning(false); + }} + onClose={() => { + setShowDriftCompWarning(false); + setValue('driftCompensation.enabled', false); + }} + isOpen={showDriftCompWarning} + >