update language bindings and examples

This commit is contained in:
Vinzenz Schroeter 2024-05-16 23:12:03 +02:00
parent 862804de3b
commit 95928ee85c
4 changed files with 8 additions and 6 deletions

View file

@ -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;

View file

@ -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);
}

View file

@ -105,11 +105,11 @@ public sealed class Command : Sp2NativeInstance<BindGen.Command>
}
}
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));
}
}

View file

@ -38,6 +38,7 @@ impl Connection {
/// # Examples
///
/// ```rust
/// use servicepoint2::CompressionCode;
/// let connection = servicepoint2::Connection::open("172.23.42.29:2342")
/// .expect("connection failed");
///
@ -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(