setShakeThreshold

Static setShakeThreshold 

Source
pub static setShakeThreshold: SetShakeThresholdInternalType
Expand description

The setShakeThreshold() function is used to set the movement threshold for the deviceShaken() function. The default threshold is set to 30.

Examples

// Run this example on a mobile device
// You will need to shake the device more firmly
// the closer the box's fill gets to white in order to change the value.

let value = 0;
let threshold = 30;
function setup() {
  setShakeThreshold(threshold);
}
function draw() {
  fill(value);
  rect(25, 25, 50, 50);
}
function deviceMoved() {
  value = value + 5;
  threshold = threshold + 5;
  if (value > 255) {
    value = 0;
    threshold = 30;
  }
  setShakeThreshold(threshold);
}

Parameters

value The threshold value