npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-plugin-flic2

v0.0.2

Published

Cordova Flic2 Plugin

Downloads

8

Readme

cordova-plugin-flic2

This plugin provides the ability to interact with Flic2 buttons.

Although in the global scope, it is not available until after the deviceready event.

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
    console.log(flic2);
}

Installation

cordova plugin add cordova-plugin-flic2

Supported Platforms

  • Android

How to use

First initialize the plugin

flic2.init()

Scan for new buttons

flic2.startScan(success, error)

Parameters

  • success: A callback to be called for each step of the scan. Takes an object argument. The properties on the object are statusCode and button. The button will only be set on success. See Constants for all status codes.
  • error: A callback for errors. Will always be an integer. See Constants for all failures;

Stop scan for buttons

flic2.stopScan()

Get buttons

flic2.getButtons(success, error)

Parameters

  • success: A callback called when successful. It takes a list of buttons as argument.
  • error: A callback for errors.

Buttons

getButtons and startScan returns buttons. Each buttons has some properties and methods.

Properties

  • name: Name
  • bdAddr: Bluetooth address
  • connectionState: Connection state
  • firmwareVersion: Firmware version
  • getLastKnownBatteryLevel: Last known battery level
  • pressCount: Press count
  • readyTimestamp: Timestamp when the button was ready
  • serialNumber: Serial number
  • uuid: Unique button id

Methods

  • connect: Connects the button
  • disconnectOrAbortPendingConnection: Disconnects the button
  • setName: Set the name of the button
  • setAutoDisconnectTime: Set auto disconnect time
  • onButtonSingleOrDoubleClickOrHold: Add event listener for single, double, click or hold events
  • onAllQueuedButtonEventsProcessed: Add event listener for when all button events are processed
  • onBatteryLevelUpdated: Add event listener for battery level updated
  • onButtonClickOrHold: Add event listener for click or hold events
  • onButtonSingleOrDoubleClick: Add event listener for single or double click events
  • onButtonUpOrDown:' Add event listener for button up or button down events
  • onConnect: Add event listener for connect events
  • onDisconnect: Add event listener for disconnect events
  • onFailure: Add event listener for failure events
  • onReady: Add event listener for ready events
  • onFirmwareVersionUpdated: Add event listener for firmware version updates events
  • onNameUpdated: Add event listener for name update events
  • onUnpaired: Add event listener for unpaired events

Every event listener can be removed by calling the un instead of on method, example unButtonClickOrHold

Constants

The following constants are reported as part of the callback for startScan:

  • flic2.SCAN_RESULT.ALREADY_PAIRED = 0;
  • flic2.SCAN_RESULT.DISCOVERED = 1;
  • flic2.SCAN_RESULT.CONNECTED = 2;
  • flic2.SCAN_RESULT.COMPLETE = 3;
  • flic2.SCAN_RESULT.FAILED_ALREADY_RUNNING = 1;
  • flic2.SCAN_RESULT.FAILED_BLUETOOTH_OFF = 2;
  • flic2.SCAN_RESULT.FAILED_SCAN_ERROR = 3;
  • flic2.SCAN_RESULT.FAILED_NO_NEW_BUTTONS_FOUND = 4;
  • flic2.SCAN_RESULT.FAILED_BUTTON_ALREADY_CONNECTED_TO_OTHER_DEVICE = 5;
  • flic2.SCAN_RESULT.FAILED_CONNECT_TIMED_OUT = 6;
  • flic2.SCAN_RESULT.FAILED_VERIFY_TIMED_OUT = 7;