Acceleration

Gets the values from the accelerometer directly.

obniz.motion.start(temperature, accel, recognition)

Starts the motion module.
You can specify the sensitivity as an argument to determine the threshold for data transmission based on value changes. The sensitivity can be set between 0.0 and 1.0. If set to 1.0, even the slightest change in value will trigger a data transmission.

Regardless of the specified value, the data will be sent at least once immediately after the module starts.

The acceleration sensitivity is specified in the second argument.

// Javascript Example
  obniz.motion.onAccelerationUpdate = ((r, t, p) => {
    console.log(`R: ${r}\nTheta: ${t}\nPhi: ${p}`);
  });
  // Starting with 0.97 sensitivity for acceleration
  obniz.motion.start(0, 0.97, 0);

obniz.motion.onAccelerationUpdate

This callback is triggered whenever an update to the acceleration data is received.

The acceleration data is transmitted as 3D spherical coordinates (r, theta, phi) rather than Cartesian coordinates (x, y, z).

// Javascript Example
  obniz.motion.onAccelerationUpdate = ((r, t, p) => {
    console.log(`R: ${r}\nTheta: ${t}\nPhi: ${p}`);
  });
  obniz.motion.start(0, 0.97, 0);

obniz.motion.getAccelerationWait()

This method performs a single measurement and retrieves the values immediately, rather than continuous monitoring.

// Javascript Example
  const acc = await obniz.motion.getAccelerationWait();
  console.log(`Acc.R: ${acc.r}\nAcc.Theta: ${acc.t}\nAcc.Phi: ${acc.p}`);