Crate servicepoint_binding_c

Source
Expand description

C API wrapper for the servicepoint crate.

§Examples

Make sure to check out this GitHub repo as well!

#include <stdio.h>
#include "servicepoint.h"

int main(void) {
    UdpConnection *connection = sp_udp_open("172.23.42.29:2342");
    if (connection == NULL)
        return 1;

    Bitmap *pixels = sp_bitmap_new(SP_PIXEL_WIDTH, SP_PIXEL_HEIGHT);
    sp_bitmap_fill(pixels, true);

    TypedCommand *command = sp_command_bitmap_linear_win(0, 0, pixels, Uncompressed);
    while (sp_udp_send_command(connection, sp_command_clone(command)));

    sp_command_free(command);
    sp_udp_free(connection);
    return 0;
}

Structs§

ByteSlice
Represents a span of memory (&mut [u8] ) as a struct.
SPBitVec
A vector of bits
UdpSocket
This is a type only used by cbindgen to have a type for pointers.

Enums§

CommandCode
The u16 command codes used for the [Command]s.

Constants§

SP_FRAME_PACING_MS
Actual hardware limit is around 28-29ms/frame. Rounded up for less dropped packets.

Functions§

sp_bitmap_clone
Clones a Bitmap.
sp_bitmap_fill
Sets the state of all pixels in the Bitmap.
sp_bitmap_free
Deallocates a Bitmap.
sp_bitmap_from_bitvec
Tries to convert the BitVec to a Bitmap.
sp_bitmap_get
Gets the current value at the specified position in the Bitmap.
sp_bitmap_height
Gets the height in pixels of the Bitmap instance.
sp_bitmap_into_bitvec
Consumes the Bitmap and returns the contained BitVec
sp_bitmap_into_packet
Creates a BitmapCommand and immediately turns that into a Packet.
sp_bitmap_load
Loads a Bitmap with the specified dimensions from the provided data.
sp_bitmap_new
Creates a new Bitmap with the specified dimensions.
sp_bitmap_new_max_sized
Creates a new Bitmap with a size matching the screen.
sp_bitmap_set
Sets the value of the specified position in the Bitmap.
sp_bitmap_unsafe_data_ref
Gets an unsafe reference to the data of the Bitmap instance.
sp_bitmap_width
Gets the width in pixels of the Bitmap instance.
sp_bitvec_clone
Clones a SPBitVec.
sp_bitvec_fill
Sets the value of all bits in the SPBitVec.
sp_bitvec_free
Deallocates a SPBitVec.
sp_bitvec_get
Gets the value of a bit from the SPBitVec.
sp_bitvec_into_packet
Creates a BitVecCommand and immediately turns that into a Packet.
sp_bitvec_is_empty
Returns true if length is 0.
sp_bitvec_len
Gets the length of the SPBitVec in bits.
sp_bitvec_load
Interpret the data as a series of bits and load then into a new SPBitVec instance.
sp_bitvec_new
Creates a new SPBitVec instance.
sp_bitvec_set
Sets the value of a bit in the SPBitVec.
sp_bitvec_unsafe_data_ref
Gets an unsafe reference to the data of the SPBitVec instance.
sp_brightness_grid_clone
Clones a BrightnessGrid.
sp_brightness_grid_fill
Sets the value of all cells in the BrightnessGrid.
sp_brightness_grid_free
Deallocates a BrightnessGrid.
sp_brightness_grid_get
Gets the current value at the specified position.
sp_brightness_grid_height
Gets the height of the BrightnessGrid instance.
sp_brightness_grid_into_packet
Creates a BrightnessGridCommand and immediately turns that into a Packet.
sp_brightness_grid_load
Loads a BrightnessGrid with the specified dimensions from the provided data.
sp_brightness_grid_new
Creates a new BrightnessGrid with the specified dimensions.
sp_brightness_grid_set
Sets the value of the specified position in the BrightnessGrid.
sp_brightness_grid_unsafe_data_ref
Gets an unsafe reference to the data of the BrightnessGrid instance.
sp_brightness_grid_width
Gets the width of the BrightnessGrid instance.
sp_char_grid_clone
Clones a CharGrid.
sp_char_grid_fill
Sets the value of all cells in the CharGrid.
sp_char_grid_free
Deallocates a CharGrid.
sp_char_grid_get
Returns the current value at the specified position.
sp_char_grid_height
Gets the height of the CharGrid instance.
sp_char_grid_into_packet
Creates a CharGridCommand and immediately turns that into a Packet.
sp_char_grid_load
Loads a CharGrid with the specified dimensions from the provided data.
sp_char_grid_new
Creates a new CharGrid with the specified dimensions.
sp_char_grid_set
Sets the value of the specified position in the CharGrid.
sp_char_grid_width
Gets the width of the CharGrid instance.
sp_command_bitmap
Sets a window of pixels to the specified values.
sp_command_bitvec
Set pixel data starting at the pixel offset on screen.
sp_command_brightness_grid
Set the brightness of individual tiles in a rectangular area of the display.
sp_command_char_grid
Show UTF-8 encoded text on the screen.
sp_command_clear
Set all pixels to the off state.
sp_command_clone
Clones a TypedCommand instance.
sp_command_cp437_grid
Show codepage 437 encoded text on the screen.
sp_command_fade_out
A yet-to-be-tested command.
sp_command_free
Deallocates a TypedCommand.
sp_command_global_brightness
Set the brightness of all tiles to the same value.
sp_command_hard_reset
Kills the udp daemon on the display, which usually results in a restart.
sp_command_try_from_packet
Tries to turn a Packet into a TypedCommand.
sp_cp437_grid_clone
Clones a Cp437Grid.
sp_cp437_grid_fill
Sets the value of all cells in the Cp437Grid.
sp_cp437_grid_free
Deallocates a Cp437Grid.
sp_cp437_grid_get
Gets the current value at the specified position.
sp_cp437_grid_height
Gets the height of the Cp437Grid instance.
sp_cp437_grid_into_packet
Creates a Cp437GridCommand and immediately turns that into a Packet.
sp_cp437_grid_load
Loads a Cp437Grid with the specified dimensions from the provided data.
sp_cp437_grid_new
Creates a new Cp437Grid with the specified dimensions.
sp_cp437_grid_set
Sets the value of the specified position in the Cp437Grid.
sp_cp437_grid_unsafe_data_ref
Gets an unsafe reference to the data of the Cp437Grid instance.
sp_cp437_grid_width
Gets the width of the Cp437Grid instance.
sp_packet_clone
Clones a Packet.
sp_packet_free
Deallocates a Packet.
sp_packet_from_command
Turns a TypedCommand into a Packet. The TypedCommand gets consumed.
sp_packet_from_parts
Creates a raw Packet from parts.
sp_packet_get_header
Returns a pointer to the header field of the provided packet.
sp_packet_get_payload
Returns a pointer to the current payload of the provided packet.
sp_packet_serialize_to
Serialize the packet into the provided buffer.
sp_packet_set_payload
Sets the payload of the provided packet to the provided data.
sp_packet_try_load
Tries to load a Packet from the passed array with the specified length.
sp_u16_to_command_code
Converts u16 into CommandCode.
sp_udp_free
Closes and deallocates a [UdpConnection].
sp_udp_open
Creates a new instance of [UdpConnection].
sp_udp_open_ipv4
Creates a new instance of [UdpConnection].
sp_udp_send_command
Sends a TypedCommand to the display using the [UdpConnection].
sp_udp_send_header
Sends a Header to the display using the [UdpConnection].
sp_udp_send_packet
Sends a Packet to the display using the [UdpConnection].