device-capabilities

Device Capabilities Library
https://github.com/adireddy/device-capabilities

To install, run:

haxelib install device-capabilities 0.0.4 

See using Haxelib in Haxelib documentation for more information.

README.md

device-capabilities logo

Library to detect and use capabilities like Battery, DeviceMotion, Vibration, etc.

experimental

Build Status npm version

Installation

npm install device-capabilities.js

For haxe users:

haxelib install device-capabilities

API Documentation

Usage

<script src="dist/device-capabilities.min.js"></script>
var batterySupport = new BatterySupport(onReady);
var vibration = new Vibration();
var motion = new Motion();

function onReady() {
	console.log(batterySupport.isSupported);
	console.log("Charging: " + batterySupport.battery.charging);
	console.log("Charging Time: " + batterySupport.battery.chargingTime);
	console.log("Level: " + batterySupport.battery.level);
	console.log("Discharging Time: " + batterySupport.battery.dischargingTime);
}

motion.shake(onShake);
function onShake() {
	console.log("shake detected");
}

if (vibration.isSupported) {
    vibration.start(10000); // Vibrates for 10 seconds
    vibration.startPattern([200, 100, 300, 200, 50, 50, 50, 50, 1000]); // On and off vibration pattern
    vibration.stop(); // Stops vibration
}

Demo

Licensing Information

MIT license

This content is released under the MIT License.

Icon by Icons8

Contributor Code of Conduct

Code of Conduct is adapted from Contributor Covenant, version 1.3.0

Contributors
adireddy
Version
0.0.4
Published
2 years ago
License
MIT

All libraries are free

Every month, more than thousand developers use haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on Github!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on Github