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

@kduma-autoid/capacitor-usb-scale

v2.0.0

Published

Capacitor adapter for cheap USB scales like Dymo M10

Downloads

19

Readme

@kduma-autoid/capacitor-usb-scale

Capacitor adapter for cheap USB scales like Dymo M10

Install

npm install @kduma-autoid/capacitor-usb-scale
npx cap sync

API

enumerateDevices()

enumerateDevices() => Promise<EnumerateDevicesResponse>

Get a list of all connected compatible USB scale devices

Returns: Promise<EnumerateDevicesResponse>


requestPermission(...)

requestPermission(options?: RequestPermissionOptions | undefined) => Promise<void>

Request permission to access the USB scale device

Throws an error if permission is denied

| Param | Type | | ------------- | ----------------------------------------------------------------------------- | | options | RequestPermissionOptions |


hasPermission(...)

hasPermission(options?: HasPermissionOptions | undefined) => Promise<HasPermissionResponse>

Check if app has permission to access the USB scale device

| Param | Type | | ------------- | --------------------------------------------------------------------- | | options | HasPermissionOptions |

Returns: Promise<HasPermissionResponse>


open(...)

open(options?: OpenOptions | undefined) => Promise<void>

Open the USB scale device for data reading

Throws an error if the device is not connected or permission is denied

| Param | Type | | ------------- | --------------------------------------------------- | | options | OpenOptions |


close()

close() => Promise<void>

Close the USB scale device


addListener('onRead', ...)

addListener(eventName: 'onRead', listenerFunc: (event: OnReadEvent) => void) => Promise<PluginListenerHandle>

Event emitted when the scale sends data

| Param | Type | | ------------------ | ----------------------------------------------------------------------- | | eventName | 'onRead' | | listenerFunc | (event: OnReadEvent) => void |

Returns: Promise<PluginListenerHandle>


addListener('onScaleConnected', ...)

addListener(eventName: 'onScaleConnected', listenerFunc: (event: OnScaleConnectedEvent) => void) => Promise<PluginListenerHandle>

Event emitted when a compatible USB scale device is connected.

| Param | Type | | ------------------ | ------------------------------------------------------------------------------------------- | | eventName | 'onScaleConnected' | | listenerFunc | (event: OnScaleConnectedEvent) => void |

Returns: Promise<PluginListenerHandle>


addListener('onScaleDisconnected', ...)

addListener(eventName: 'onScaleDisconnected', listenerFunc: (event: OnScaleDisconnectedEvent) => void) => Promise<PluginListenerHandle>

Event emitted when a compatible USB scale device is disconnected.

| Param | Type | | ------------------ | ------------------------------------------------------------------------------------------------- | | eventName | 'onScaleDisconnected' | | listenerFunc | (event: OnScaleDisconnectedEvent) => void |

Returns: Promise<PluginListenerHandle>


removeAllListeners()

removeAllListeners() => Promise<void>

Removes all listeners


Interfaces

EnumerateDevicesResponse

| Prop | Type | | ------------- | ------------------------ | | devices | USBDevice[] |

USBDevice

| Prop | Type | | ------------- | ---------------------------------------------------- | | id | string | | vid | number | | pid | number | | serial | string | | product | { manufacturer: string; name: string; } |

RequestPermissionOptions

| Prop | Type | Description | | --------------- | ------------------- | -------------------------------------------------------------------------------------- | | device_id | string | The device to request permission for. If not specified, the first device will be used. |

HasPermissionResponse

| Prop | Type | Description | | ---------------- | -------------------- | ------------------------------------------------------------- | | permission | boolean | Whether the app has permission to access the USB scale device |

HasPermissionOptions

| Prop | Type | Description | | --------------- | ------------------- | ------------------------------------------------------------------------------------ | | device_id | string | The device to check permission for. If not specified, the first device will be used. |

OpenOptions

| Prop | Type | Description | | --------------- | ------------------- | -------------------------------------------------------------------- | | device_id | string | The device to open. If not specified, the first device will be used. |

PluginListenerHandle

| Prop | Type | | ------------ | ----------------------------------------- | | remove | () => Promise<void> |

OnReadEvent

| Prop | Type | | ------------ | --------------------------------------------------- | | data | number[] | | weight | number | | status | ScaleStatus |

OnScaleConnectedEvent

| Prop | Type | | ------------ | ----------------------------------------------- | | device | USBDevice |

OnScaleDisconnectedEvent

| Prop | Type | | ------------ | ----------------------------------------------- | | device | USBDevice |

Enums

ScaleStatus

| Members | Value | | --------------------- | ------------------------------- | | Fault | "fault" | | Zero | "zero" | | InMotion | "in-motion" | | Stable | "stable" | | UnderZero | "under-zero" | | OverWeight | "over-weight" | | NeedCalibration | "need-calibration" | | NeedZeroing | "need-zeroing" | | Unknown | "unknown" |

Events

usb_scale_read

addEventListener(type: "usb_scale_read", listener: (ev: ScaleRead) => any, useCapture?: boolean): void;

Emitted when the scale sends data, and there is no callback set by setIncomingWeightDataCallback.

usb_scale_connected

addEventListener(type: "usb_scale_connected", listener: (ev: { device: USBDevice }) => any, useCapture?: boolean): void;

Emitted when a compatible USB scale device is connected.

usb_scale_disconnected

addEventListener(type: "usb_scale_disconnected", listener: (ev: { device: USBDevice }) => any, useCapture?: boolean): void;

Emitted when a compatible USB scale device is disconnected.