Gyroscope (Gryoscope)
源码类名为 Gryoscope — 导入时保持该拼写。
- Methods: start(callback), stop()
- Import Gryoscope, not Gyroscope
TSXGryoscope — React
1import { useEffect, useState } from "react";
2import { Gryoscope } from "@quan-erp/shared-frontend-core";
3
4export function GyroDebug() {
5 const [rate, setRate] = useState({ alpha: 0, beta: 0, gamma: 0 });
6
7 useEffect(() => {
8 const gyro = Gryoscope.instance;
9 gyro.start((data) => {
10 setRate({
11 alpha: data.alpha ?? 0,
12 beta: data.beta ?? 0,
13 gamma: data.gamma ?? 0,
14 });
15 });
16 return () => gyro.stop();
17 }, []);
18
19 return <pre>{JSON.stringify(rate)}</pre>;
20}