Angular library for connecting to USB scales
Check out the live demo
Add the npm
package to your app
npm i ng-scales
Add the providers in the app.config.ts
providers: [
...
provideNgScales()
...
]
The easiest way to integrate is the provided button directive which handles connecting and disconnecting from the scale. Add this into your template
<button libNgScalesConnectionButton></button>
Import the component
@Component({
...
imports: [NgScalesConnectionButtonDirective]
...
})
Vendor | Vendor ID | Product | Product Id | Name | Verified |
---|---|---|---|---|---|
DYMO | 2338 | M25 | 32771 | DYMO M25 25 Lb Digital Postal Scale | ✅ |
You can add a new scale by providing additional mappers. The mapper function coverts the array buffer into a usable data object
provideNgScales({mappers: [
{
vendorId: 2338,
productId: 32771,
mapper: (arrayBuffer: ArrayBuffer): HardwareScaleReportEvent => {
const d = new Uint8Array(arrayBuffer);
let weight = (d[3] + 256 * d[4])/10;
if (d[0] === 5) {
weight *= -1;
}
return {
units: d[1] === 2 ? 'grams' : 'ounces',
weight
};
}
}
]})