mirror of
https://github.com/cccb/servicepoint.git
synced 2025-01-18 18:10:14 +01:00
update language bindings and examples
This commit is contained in:
parent
862804de3b
commit
95928ee85c
|
@ -9,7 +9,7 @@ int main(void) {
|
||||||
sp2_PixelGrid *pixels = sp2_pixel_grid_new(sp2_PIXEL_WIDTH, sp2_PIXEL_HEIGHT);
|
sp2_PixelGrid *pixels = sp2_pixel_grid_new(sp2_PIXEL_WIDTH, sp2_PIXEL_HEIGHT);
|
||||||
sp2_pixel_grid_fill(pixels, true);
|
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);
|
sp2_Packet *packet = sp2_packet_from_command(command);
|
||||||
if (!sp2_connection_send(connection, packet))
|
if (!sp2_connection_send(connection, packet))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using ServicePoint2;
|
using ServicePoint2;
|
||||||
|
using CompressionCode = ServicePoint2.BindGen.CompressionCode;
|
||||||
|
|
||||||
using var connection = Connection.Open("127.0.0.1:2342");
|
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++)
|
for (var y = 0; y < pixels.Height; y++)
|
||||||
pixels[(y + offset) % Constants.PixelWidth, y] = true;
|
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);
|
Thread.Sleep(14);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ impl Connection {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
|
/// use servicepoint2::CompressionCode;
|
||||||
/// let connection = servicepoint2::Connection::open("172.23.42.29:2342")
|
/// let connection = servicepoint2::Connection::open("172.23.42.29:2342")
|
||||||
/// .expect("connection failed");
|
/// .expect("connection failed");
|
||||||
///
|
///
|
||||||
|
@ -50,7 +51,7 @@ impl Connection {
|
||||||
/// pixels.fill(true);
|
/// pixels.fill(true);
|
||||||
///
|
///
|
||||||
/// // send pixels to display
|
/// // 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");
|
/// .expect("send failed");
|
||||||
/// ```
|
/// ```
|
||||||
pub fn send(
|
pub fn send(
|
||||||
|
|
Loading…
Reference in a new issue