ztcl::motionsensors
Gives the readings of the motion sensors of a phone.
ztcl::motion SUBCOMMAND ?ARG ...?
Description
The accelerometer, the gyroscope, the rotation, and the heading of a phone. The command is not a package: it exists when the embedder turns on the capability sensors, and a child interp has it only when its parent has it.
The services come from Interp.device_host of the embedder, which ztk fills on iOS and Android. A host with no service for a sensor, as the ztcl program on a desktop, gives the error ZTCL MOTION UNAVAILABLE.
The examples of this page run with --allow sensors and no host.
Subcommands
| Subcommand | Description |
|---|---|
ztcl::motion has | Tells whether the device has a sensor. |
ztcl::motion watch | Runs a script at each reading of a sensor. |
ztcl::motion cancel | Stops a watch. |
Returns
The result of the subcommand.
Examples
% ztcl::motion has accelerometer
0
Errors
% ztcl::motion
wrong # args: should be "ztcl::motion subcommand ?arg ...?"
-errorcode TCL WRONGARGS
% ztcl::motion bogus
unknown or ambiguous subcommand "bogus": must be cancel, has, or watch
-errorcode TCL LOOKUP SUBCOMMAND
Facts
- Capability
sensors. A new interpreter does not have it until the host turns it on.- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztcl 1.0.0-beta.6
The full page: ztcl::motion.