ForceSensor
Example
// Initialize the ForceSensor
var force_sensor = new serviceSPIKE.ForceSensor("E")
Methods
-
inner is_pressed() → {boolean}
-
Tests whether the button on the sensor is pressed.
Returns:
boolean -true if force sensor is pressed, false otherwise
Example
if (force_sensor.is_pressed() === true) { console.log("force sensor is pressed"); }
-
inner get_force_newton() → {number}
-
Retrieves the measured force, in newtons.
Returns:
number -Force in newtons [0 to 10]
Example
var newtons = force_sensor.get_force_newtons();
-
inner get_force_percentage() → {number}
-
Retrieves the measured force as a percentage of the maximum force.
Returns:
number -percentage [0 to 100] var percentage = force_sensor.get_force_percentage();
-
inner wait_until_pressed(callback)
-
Executes callback when Force Sensor is pressed The function is executed in updateHubPortsInfo()'s Force Sensor part
Parameters:
Name Type Description callback
function Example
force_sensor.wait_until_pressed( function () { console.log("force sensor is pressed!"); })
-
inner wait_until_released(callback)
-
Executes callback when Force Sensor is released The function is executed in updateHubPortsInfo()'s Force Sensor part
Parameters:
Name Type Description callback
function Example
force_sensor.wait_until_released ( function () { console.log("force sensor is released!"); })