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

add a way to skip rest calibration tutorial #1186

Merged
merged 5 commits into from
Oct 9, 2024
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
1 change: 1 addition & 0 deletions gui/public/i18n/en/translation.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,7 @@ onboarding-calibration_tutorial-status-waiting = Waiting for you
onboarding-calibration_tutorial-status-calibrating = Calibrating
onboarding-calibration_tutorial-status-success = Nice!
onboarding-calibration_tutorial-status-error = The tracker was moved
onboarding-calibration_tutorial-skip = Skip tutorial

## Tracker assignment tutorial
onboarding-assignment_tutorial = How to prepare a Slime Tracker before putting it on
Expand Down
10 changes: 10 additions & 0 deletions gui/src/components/onboarding/pages/CalibrationTutorial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { useTrackers } from '@/hooks/tracker';
import { useRestCalibrationTrackers } from '@/hooks/imu-logic';
import { averageVector, Vector3FromVec3fT } from '@/maths/vector3';
import { Vector3 } from 'three';
import { useTimeout } from '@/hooks/timeout';

export enum CalibrationStatus {
SUCCESS,
Expand All @@ -29,10 +30,12 @@ export function CalibrationTutorialPage() {
const [calibrationStatus, setCalibrationStatus] = useState(
CalibrationStatus.WAITING
);
const [skipButton, setSkipButton] = useState(false);
const { timer, isCounting, startCountdown, abortCountdown } = useCountdown({
duration: IMU_CALIBRATION_TIME,
onCountdownEnd: () => setCalibrationStatus(CalibrationStatus.SUCCESS),
});
useTimeout(() => setSkipButton(true), 10000);
const { useConnectedIMUTrackers } = useTrackers();
const connectedIMUTrackers = useConnectedIMUTrackers();
const restCalibrationTrackers =
Expand Down Expand Up @@ -192,6 +195,13 @@ export function CalibrationTutorialPage() {
{l10n.getString('onboarding-continue')}
</Button>
</div>
<Button
variant="secondary"
to="/onboarding/assign-tutorial"
className={classNames('xs:ml-auto', !skipButton && 'hidden')}
>
{l10n.getString('onboarding-calibration_tutorial-skip')}
</Button>
</div>
</div>
<div className="mobile:hidden flex self-center w-[32rem] mobile:absolute">
Expand Down
12 changes: 11 additions & 1 deletion gui/src/hooks/imu-logic.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import { useMemo } from 'react';
import { FlatDeviceTracker } from './app';

const IGNORED_BOARDS = new Set(['Sony Mocopi', 'Haritora']);

export function useIsRestCalibrationTrackers(
connectedTrackers: FlatDeviceTracker[]
): boolean {
const imuExists = useMemo(
() => connectedTrackers.some((tracker) => tracker.tracker.info?.isImu),
() =>
connectedTrackers.some(
(tracker) =>
tracker.tracker.info?.isImu &&
!(
tracker.device?.hardwareInfo?.boardType &&
IGNORED_BOARDS.has(tracker.device?.hardwareInfo?.boardType as string)
ButterscotchV marked this conversation as resolved.
Show resolved Hide resolved
)
),
[connectedTrackers]
);

Expand Down