From 95928ee85c9aab5312f1952f72cb547c0dc58d68 Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Thu, 16 May 2024 23:12:03 +0200 Subject: [PATCH] update language bindings and examples --- examples/lang_c/main.c | 2 +- examples/lang_cs/Program.cs | 3 ++- servicepoint2-binding-cs/src/Command.cs | 4 ++-- servicepoint2/src/connection.rs | 5 +++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/examples/lang_c/main.c b/examples/lang_c/main.c index e736c72..cf4fcff 100644 --- a/examples/lang_c/main.c +++ b/examples/lang_c/main.c @@ -9,7 +9,7 @@ int main(void) { sp2_PixelGrid *pixels = sp2_pixel_grid_new(sp2_PIXEL_WIDTH, sp2_PIXEL_HEIGHT); sp2_pixel_grid_fill(pixels, true); - sp2_Command *command = sp2_command_bitmap_linear_win(0, 0, pixels); + sp2_Command *command = sp2_command_bitmap_linear_win(0, 0, pixels, Uncompressed); sp2_Packet *packet = sp2_packet_from_command(command); if (!sp2_connection_send(connection, packet)) return 1; diff --git a/examples/lang_cs/Program.cs b/examples/lang_cs/Program.cs index 51869ac..718cee3 100644 --- a/examples/lang_cs/Program.cs +++ b/examples/lang_cs/Program.cs @@ -1,4 +1,5 @@ using ServicePoint2; +using CompressionCode = ServicePoint2.BindGen.CompressionCode; using var connection = Connection.Open("127.0.0.1:2342"); @@ -14,6 +15,6 @@ for (var offset = 0; offset < int.MaxValue; offset++) for (var y = 0; y < pixels.Height; y++) pixels[(y + offset) % Constants.PixelWidth, y] = true; - connection.Send(Command.BitmapLinearWin(0, 0, pixels.Clone()).IntoPacket()); + connection.Send(Command.BitmapLinearWin(0, 0, pixels.Clone(), CompressionCode.Lzma).IntoPacket()); Thread.Sleep(14); } diff --git a/servicepoint2-binding-cs/src/Command.cs b/servicepoint2-binding-cs/src/Command.cs index 1cb4e99..50e5824 100644 --- a/servicepoint2-binding-cs/src/Command.cs +++ b/servicepoint2-binding-cs/src/Command.cs @@ -105,11 +105,11 @@ public sealed class Command : Sp2NativeInstance } } - public static Command BitmapLinearWin(int x, int y, PixelGrid pixelGrid) + public static Command BitmapLinearWin(int x, int y, PixelGrid pixelGrid, CompressionCode compression) { unsafe { - return new Command(NativeMethods.sp2_command_bitmap_linear_win((ushort)x, (ushort)y, pixelGrid.Into())); + return new Command(NativeMethods.sp2_command_bitmap_linear_win((ushort)x, (ushort)y, pixelGrid.Into(), compression)); } } diff --git a/servicepoint2/src/connection.rs b/servicepoint2/src/connection.rs index bd503cd..8deb0b5 100644 --- a/servicepoint2/src/connection.rs +++ b/servicepoint2/src/connection.rs @@ -38,7 +38,8 @@ impl Connection { /// # Examples /// /// ```rust - /// let connection = servicepoint2::Connection::open("172.23.42.29:2342") + /// use servicepoint2::CompressionCode; + /// let connection = servicepoint2::Connection::open("172.23.42.29:2342") /// .expect("connection failed"); /// /// // turn off all pixels @@ -50,7 +51,7 @@ impl Connection { /// pixels.fill(true); /// /// // send pixels to display - /// connection.send(servicepoint2::Command::BitmapLinearWin(servicepoint2::Origin::top_left(), pixels).into()) + /// connection.send(servicepoint2::Command::BitmapLinearWin(servicepoint2::Origin::top_left(), pixels, CompressionCode::Lzma).into()) /// .expect("send failed"); /// ``` pub fn send(