servicepoint-binding-csharp/README.md

88 lines
2.9 KiB
Markdown
Raw Permalink Normal View History

# ServicePoint
2024-11-23 17:38:50 +01:00
2024-05-12 01:49:38 +02:00
In [CCCB](https://berlin.ccc.de/), there is a big pixel matrix hanging on the wall. It is called "Service Point
Display" or "Airport Display".
2024-05-12 00:03:10 +02:00
2025-02-16 15:05:24 +01:00
This crate contains C# bindings for the [servicepoint](https://git.berlin.ccc.de/servicepoint/servicepoint) library based on [servicepoint-binding-uniffi](https://git.berlin.ccc.de/servicepoint/servicepoint-binding-uniffi).
2025-02-16 15:05:24 +01:00
F# is not tested. If there are usability or functionality problems, please open an issue.
## Note on stability
This library is still in early development.
You can absolutely use it, and it works, but expect minor breaking changes with every version bump.
## Notes on differences to rust library
- Performance will not be as good as the rust version:
- most objects are reference counted.
- objects with mutating methods will also have a MRSW lock
- You will not get rust backtraces in release builds of the native code
- Panic messages will work (PanicException)
## Installation
Including this repository as a submodule and building from source is the recommended way of using the library.
```bash
2025-02-16 15:05:24 +01:00
git submodule add https://git.berlin.ccc.de/servicepoint/servicepoint-binding-csharp.git
git commit -m "add servicepoint-binding-csharp submodule"
```
2025-02-16 15:05:24 +01:00
After that, add a reference to the ServicePoint project in your `.csproj` and, if applicable, your `.sln`.
```xml
<ItemGroup>
<ProjectReference Include="servicepoint-binding-csharp/ServicePoint/ServicePoint.csproj"/>
</ItemGroup>
```
2025-02-16 15:05:24 +01:00
That's it!
You do not have to compile or copy the rust crate manually, as building `ServicePoint.csproj` also builds it.
Currently, the project file is hard-coded for Linux and will need tweaks for other platforms (e.g. `.dylib` instead of `.so`).
2025-02-16 15:05:24 +01:00
Feel free to open an issue or a PR with whatever you OS expects.
2025-02-16 15:05:24 +01:00
## Example
2024-05-13 18:59:31 +02:00
```csharp
using System.Threading;
using ServicePoint;
2024-05-13 18:59:31 +02:00
var connection = new Connection("127.0.0.1:2342");
connection.Send(Command.Clear());
2024-05-13 18:59:31 +02:00
connection.Send(Command.Brightness(5));
2024-05-13 18:59:31 +02:00
var pixels = Bitmap.NewMaxSized();
for (ulong offset = 0; offset < ulong.MaxValue; offset++)
{
pixels.Fill(false);
2025-02-08 14:49:04 +01:00
for (ulong y = 0; y < pixels.Height(); y++)
pixels.Set((y + offset) % pixels.Width(), y, true);
2025-02-15 12:10:45 +01:00
connection.Send(Command.BitmapLinearWin(0, 0, pixels));
Thread.Sleep(14);
}
```
2024-05-13 18:59:31 +02:00
A full example including project files is available as part of this crate.
2024-05-12 00:03:10 +02:00
2025-02-16 15:05:24 +01:00
## Why is there no NuGet-Package?
2024-09-07 12:59:02 +02:00
NuGet packages are not a good way to distribute native
binaries ([relevant issue](https://github.com/dotnet/sdk/issues/33845)).
Because of that, there is no NuGet package you can use directly.
2025-02-16 15:05:24 +01:00
## Development
Run `./generate-binding.sh` to regenerate the base library.
The generated source file is checked in.
The CI enforces that generated bindings do not change.
2025-02-16 18:24:05 +01:00
## Everything else
Look at the main project [README](https://git.berlin.ccc.de/servicepoint/servicepoint/src/branch/main/README.md) for
further information.