https://github.com/baggerfast/massak.plugin
C# nuget package for usb massa-k adapter
https://github.com/baggerfast/massak.plugin
Last synced: 9 months ago
JSON representation
C# nuget package for usb massa-k adapter
- Host: GitHub
- URL: https://github.com/baggerfast/massak.plugin
- Owner: BaggerFast
- License: mit
- Created: 2024-05-27T10:15:29.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-06-06T11:07:22.000Z (over 1 year ago)
- Last Synced: 2025-03-31T19:21:14.686Z (10 months ago)
- Language: C#
- Homepage: https://baggerfast.github.io/MassaK.Plugin/
- Size: 499 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Usage
## Setup MassaK
This code creates MassaK Instance without connecting.
It is recommended to subscribe to [OnStatusChanged](Docs/docs/guide/events.md) and [OnWeightChanged](Docs/docs/guide/events.md) before using method `Connect()`
```csharp{4}
using MassaK.Plugin
using MassaK.Plugin.Imp;
IMassaK MassaK = new MassaUsb("COM6");
MassaK.OnStatusChanged += ReceiveStatus;
MassaK.OnWeightChanged += ReceiveWeight;
```
## Connect
This method is safely for use, no exceptions only event `StatusChanged`.
```csharp
MassaK.Connect();
```
## Get weight
This method requests weight data from the scales. The argument specifies the interval in milliseconds between requests.
A smaller value means faster polling, with a minimum of 100 milliseconds (use cautiously).
Use [OnWeightChanged](Docs/docs/guide/events.md) event
```csharp
MassaK.StartWeightPolling(100);
```
## Calibrate
Ensure there is no weight placed on the scales before connecting them via USB.
If any issues arise, reconnect the scales via USB.
```csharp
MassaK.Сalibrate();
```
## Disconnect
```csharp
MassaK.Disconnect();
```
After calling Disconnect, you can reconnect the object again that's why you need to call `Dispose()` for full destroy.
Or call only `Dispose()` without `Disconnect()`
```csharp
MassaK.Dispose();
```