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

Calibration information #350

Open
wants to merge 3 commits into
base: beta
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions app/[locale]/calibrate/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export default function Page() {
PatternScaleReducer,
"1",
);
const [calibrationInformation, setCalibrationInformation] = useState("");

const timeoutRef = useRef<NodeJS.Timeout | null>(null);

Expand Down Expand Up @@ -411,6 +412,9 @@ export default function Page() {
}

function handlePointerMove(e: React.PointerEvent) {
setCalibrationInformation(
`calibration grid corners: (1x: ${points[0].x} 1y: ${points[0].y}) (2x: ${points[1].x} 2y: ${points[1].y}) (3x: ${points[2].x} 3y: ${points[2].y}) (4x: ${points[3].x} 4y: ${points[3].y}) window.innerWidth: ${window.innerWidth} window.innerHeight: ${window.innerHeight} window.screenTop: ${window.screenTop} window.screenLeft: ${window.screenLeft} window.devicePixelRatio: ${window.devicePixelRatio} fullScreen.active: ${fullScreenHandle.active} clientScreenTop: ${e.screenY - e.clientY} clientScreenLeft: ${e.screenX - e.clientX}`,
);
// Chromebook triggers move after menu hides #268
if (e.movementX === 0 && e.movementY === 0) {
return;
Expand Down Expand Up @@ -683,6 +687,7 @@ export default function Page() {
mailOpen={mailOpen}
setMailOpen={setMailOpen}
patternScale={patternScale}
setPoints={() => dispatch({ type: "set", points })}
/>
{isCalibrating && menuStates.nav && <TroubleshootingButton />}
<MailModal open={mailOpen} setOpen={setMailOpen} />
Expand Down Expand Up @@ -716,6 +721,9 @@ export default function Page() {
className="absolute left-1/2 top-1/2"
/>
) : null}
<p className="absolute z-[150] left-1/2 -translate-x-1/2 top-1/2 -translate-y-1/2 bg-black text-white">
{calibrationInformation}
</p>
</Transformable>
</FullScreen>
</div>
Expand Down
3 changes: 3 additions & 0 deletions app/_components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export default function Header({
mailOpen,
setMailOpen,
patternScale,
setPoints,
}: {
isCalibrating: boolean;
setIsCalibrating: Dispatch<SetStateAction<boolean>>;
Expand Down Expand Up @@ -140,6 +141,7 @@ export default function Header({
mailOpen: boolean;
setMailOpen: Dispatch<SetStateAction<boolean>>;
patternScale: string;
setPoints: () => void;
}) {
const [calibrationAlert, setCalibrationAlert] = useState("");
const mailRead = useRef(true);
Expand All @@ -166,6 +168,7 @@ export default function Header({
e: React.PointerEvent<HTMLButtonElement>,
) {
if (isCalibrating) {
setPoints();
const expectedContext = localStorage.getItem("calibrationContext");
if (expectedContext) {
const expected = JSON.parse(expectedContext);
Expand Down