-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6137460
commit 4fdd202
Showing
9 changed files
with
2,070 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# ServicePoint | ||
|
||
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". | ||
|
||
This crate contains bindings for multiple programming languages, enabling non-rust-developers to use the library. | ||
|
||
Also take a look at the main project [README](https://github.com/cccb/servicepoint/blob/main/README.md) for more | ||
information. | ||
|
||
## 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) | ||
|
||
## Supported languages | ||
|
||
| Language | Support level | Notes | | ||
|-----------|----------------------------|-------------------------------------------------------------------------------------------------| | ||
| .NET (C#) | Full | see dedicated section | | ||
| Ruby | Working | example project included | | ||
| Python | Tested once (help wanted!) | Required project file not included. The shared library will be loaded from the script location. | | ||
| Go | never tested | | | ||
| Kotlin | never tested | | | ||
| Swift | never tested | | | ||
|
||
## Installation | ||
|
||
Including this repository as a submodule and building from source is the recommended way of using the library. | ||
|
||
```bash | ||
git submodule add https://github.com/cccb/servicepoint.git | ||
git commit -m "add servicepoint submodule" | ||
``` | ||
|
||
Run `generate-bindings.sh` to regenerate all bindings. This will also build `libservicepoint.so` (or equivalent on your platform). | ||
|
||
For languages not fully supported, there will be no project file for the library, just the naked source file(s). | ||
If you successfully use a language, please open an issue or PR to add the missing ones. | ||
|
||
## .NET (C#) | ||
|
||
This is the best supported language. | ||
|
||
F# is not tested. If there are usability or functionality problems, please open an issue. | ||
|
||
Currently, the project file is hard-coded for linux and may need tweaks for other platforms. | ||
|
||
### Example | ||
|
||
```csharp | ||
using System.Threading; | ||
using ServicePoint; | ||
|
||
var connection = new Connection("127.0.0.1:2342"); | ||
connection.Send(Command.Clear()); | ||
|
||
connection.Send(Command.Brightness(5)); | ||
|
||
var pixels = Bitmap.NewMaxSized(); | ||
for (ulong offset = 0; offset < ulong.MaxValue; offset++) | ||
{ | ||
pixels.Fill(false); | ||
|
||
for (ulong y = 0; y < pixels.Height(); y++) | ||
pixels.Set((y + offset) % pixels.Width(), y, true); | ||
|
||
connection.Send(Command.BitmapLinearWin(0, 0, pixels)); | ||
Thread.Sleep(14); | ||
} | ||
``` | ||
|
||
A full example including project files is available as part of this crate. | ||
|
||
### Why is there no NuGet-Package? | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
crates/servicepoint_binding_uniffi/libraries/ruby/example/Gemfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'servicepoint', path: '..' |
19 changes: 19 additions & 0 deletions
19
crates/servicepoint_binding_uniffi/libraries/ruby/example/Gemfile.lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
PATH | ||
remote: .. | ||
specs: | ||
servicepoint (0.0.0) | ||
ffi | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
ffi (1.17.0-x86_64-linux-gnu) | ||
|
||
PLATFORMS | ||
x86_64-linux | ||
|
||
DEPENDENCIES | ||
servicepoint! | ||
|
||
BUNDLED WITH | ||
2.3.27 |
25 changes: 25 additions & 0 deletions
25
crates/servicepoint_binding_uniffi/libraries/ruby/example/example.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require_relative "../lib/servicepoint_binding_uniffi" | ||
|
||
include ServicepointBindingUniffi | ||
|
||
connection = Connection.new("172.23.42.29:2342") | ||
|
||
pixels = Bitmap.new_max_sized | ||
x_offset = 0 | ||
loop do | ||
|
||
pixels.fill(false) | ||
|
||
(0..((pixels.height) -1)).each do |y| | ||
pixels.set((y + x_offset) % pixels.width, y, true); | ||
end | ||
|
||
command = Command.bitmap_linear_win(0, 0, pixels, CompressionCode::UNCOMPRESSED) | ||
|
||
connection.send(command) | ||
sleep 0.0005 | ||
|
||
x_offset += 1 | ||
end | ||
|
||
|
Oops, something went wrong.