beetlebug▾
/

ztcl::devicedevice

Gives the vibration, the haptics, the battery, and the network state of a phone.

ztcl::device SUBCOMMAND ?ARG ...?

Description

The device services of a phone: a vibration, a haptic feedback, the battery, and the network state, and watches of the battery and the network. The command is not a package: it exists when the embedder turns on the capability device, 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 Android and iOS. A host with no service for a subcommand, as the ztcl program on a desktop, gives the error ZTCL DEVICE UNAVAILABLE.

The examples of this page run with --allow device and no host, so each one is an error.

Subcommands

SubcommandDescription
ztcl::device batteryGives the level and the state of the battery.
ztcl::device networkGives the state of the network.
ztcl::device vibrateVibrates the device.
ztcl::device hapticGives a haptic feedback.
ztcl::device watchRuns a script at each change of the battery or the network.
ztcl::device cancelStops a watch.

Returns

The result of the subcommand.

Examples

% catch {ztcl::device battery} msg opts; list $msg [dict get $opts -errorcode]
{the battery is not available on this platform} {ZTCL DEVICE UNAVAILABLE}

Errors

% ztcl::device
wrong # args: should be "ztcl::device subcommand ?arg ...?"
-errorcode TCL WRONGARGS

% ztcl::device bogus
unknown or ambiguous subcommand "bogus": must be battery, cancel, haptic, network, vibrate, or watch
-errorcode TCL LOOKUP SUBCOMMAND

Facts

Capability
device. 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::device.

See also