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

show current direction on manual mounting #1108

Merged
Merged
Changes from 3 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
20 changes: 18 additions & 2 deletions gui/src/components/onboarding/pages/mounting/ManualMounting.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { useEffect, useMemo, useState } from 'react';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { AssignTrackerRequestT, BodyPart, RpcMessage } from 'solarxr-protocol';
import { FlatDeviceTracker } from '@/hooks/app';
import { useOnboarding } from '@/hooks/onboarding';
import { useTrackers } from '@/hooks/tracker';
import { useWebsocketAPI } from '@/hooks/websocket-api';
import { MountingOrientationDegreesToQuatT } from '@/maths/quaternion';
import {
MountingOrientationDegreesToQuatT,
QuaternionFromQuatT,
} from '@/maths/quaternion';
import { Button } from '@/components/commons/Button';
import { TipBox } from '@/components/commons/TipBox';
import { Typography } from '@/components/commons/Typography';
Expand Down Expand Up @@ -66,10 +69,23 @@ export function ManualMountingPage() {
setSelectRole(BodyPart.NONE);
};

const getCurrRotation = useCallback(
(role: BodyPart) => {
const trackers = trackerPartGrouped[role] || [];
if (!trackers.length || role === BodyPart.NONE) return undefined;
const mountingOrientation = trackers[0].tracker.info?.mountingOrientation;
ZycaR marked this conversation as resolved.
Show resolved Hide resolved
return mountingOrientation
? QuaternionFromQuatT(mountingOrientation)
: undefined;
},
[trackerPartGrouped]
);

return (
<>
<MountingSelectionMenu
bodyPart={selectedRole}
currRotation={getCurrRotation(selectedRole)}
isOpen={selectedRole !== BodyPart.NONE}
onClose={() => setSelectRole(BodyPart.NONE)}
onDirectionSelected={onDirectionSelected}
Expand Down