rename/merge functions to match rust side more
This commit is contained in:
parent
bbe4000468
commit
63dfecdbf5
7 changed files with 165 additions and 280 deletions
|
@ -66,6 +66,35 @@
|
|||
*/
|
||||
#define TILE_WIDTH 56
|
||||
|
||||
/**
|
||||
* Binary operations for use with the [`BitVecCommand`] command.
|
||||
*/
|
||||
enum BinaryOperation
|
||||
#ifdef __cplusplus
|
||||
: uint8_t
|
||||
#endif // __cplusplus
|
||||
{
|
||||
/**
|
||||
* r := a
|
||||
*/
|
||||
BINARY_OPERATION_OVERWRITE,
|
||||
/**
|
||||
* r := a && b
|
||||
*/
|
||||
BINARY_OPERATION_AND,
|
||||
/**
|
||||
* r := a || b
|
||||
*/
|
||||
BINARY_OPERATION_OR,
|
||||
/**
|
||||
* r := (a || b) && (a != b)
|
||||
*/
|
||||
BINARY_OPERATION_XOR,
|
||||
};
|
||||
#ifndef __cplusplus
|
||||
typedef uint8_t BinaryOperation;
|
||||
#endif // __cplusplus
|
||||
|
||||
/**
|
||||
* Specifies the kind of compression to use. Availability depends on features.
|
||||
*
|
||||
|
@ -428,7 +457,7 @@ Bitmap *sp_bitmap_new(size_t width, size_t height);
|
|||
*
|
||||
* returns: [Bitmap] initialized to all pixels off.
|
||||
*/
|
||||
Bitmap */*notnull*/ sp_bitmap_new_screen_sized(void);
|
||||
Bitmap */*notnull*/ sp_bitmap_new_max_sized(void);
|
||||
|
||||
/**
|
||||
* Sets the value of the specified position in the [Bitmap].
|
||||
|
@ -791,81 +820,36 @@ void sp_char_grid_set(CharGrid */*notnull*/ char_grid,
|
|||
*/
|
||||
size_t sp_char_grid_width(CharGrid */*notnull*/ char_grid);
|
||||
|
||||
/**
|
||||
* Sets a window of pixels to the specified values.
|
||||
*
|
||||
* The passed [Bitmap] gets consumed.
|
||||
*
|
||||
* Returns: a new [servicepoint::BitmapCommand] instance.
|
||||
*/
|
||||
TypedCommand *sp_command_bitmap(size_t x,
|
||||
size_t y,
|
||||
Bitmap */*notnull*/ bitmap,
|
||||
CompressionCode compression);
|
||||
|
||||
/**
|
||||
* Set pixel data starting at the pixel offset on screen.
|
||||
*
|
||||
* The screen will continuously overwrite more pixel data without regarding the offset, meaning
|
||||
* once the starting row is full, overwriting will continue on column 0.
|
||||
*
|
||||
* The contained [SPBitVec] is always uncompressed.
|
||||
* The [`BinaryOperation`] will be applied on the display comparing old and sent bit.
|
||||
*
|
||||
* The passed [SPBitVec] gets consumed.
|
||||
* `new_bit = old_bit op sent_bit`
|
||||
*
|
||||
* Returns: a new [servicepoint::Command::BitmapLinear] instance.
|
||||
* For example, [`BinaryOperation::Or`] can be used to turn on some pixels without affecting other pixels.
|
||||
*
|
||||
* The contained [`BitVecU8Msb0`] is always uncompressed.
|
||||
*/
|
||||
TypedCommand *sp_command_bitmap_linear(size_t offset,
|
||||
SPBitVec */*notnull*/ bit_vec,
|
||||
CompressionCode compression);
|
||||
|
||||
/**
|
||||
* Set pixel data according to an and-mask starting at the offset.
|
||||
*
|
||||
* The screen will continuously overwrite more pixel data without regarding the offset, meaning
|
||||
* once the starting row is full, overwriting will continue on column 0.
|
||||
*
|
||||
* The contained [SPBitVec] is always uncompressed.
|
||||
*
|
||||
* The passed [SPBitVec] gets consumed.
|
||||
*
|
||||
* Returns: a new [servicepoint::Command::BitmapLinearAnd] instance.
|
||||
*/
|
||||
TypedCommand *sp_command_bitmap_linear_and(size_t offset,
|
||||
SPBitVec */*notnull*/ bit_vec,
|
||||
CompressionCode compression);
|
||||
|
||||
/**
|
||||
* Set pixel data according to an or-mask starting at the offset.
|
||||
*
|
||||
* The screen will continuously overwrite more pixel data without regarding the offset, meaning
|
||||
* once the starting row is full, overwriting will continue on column 0.
|
||||
*
|
||||
* The contained [SPBitVec] is always uncompressed.
|
||||
*
|
||||
* The passed [SPBitVec] gets consumed.
|
||||
*
|
||||
* Returns: a new [servicepoint::Command::BitmapLinearOr] instance.
|
||||
*/
|
||||
TypedCommand *sp_command_bitmap_linear_or(size_t offset,
|
||||
SPBitVec */*notnull*/ bit_vec,
|
||||
CompressionCode compression);
|
||||
|
||||
/**
|
||||
* Sets a window of pixels to the specified values.
|
||||
*
|
||||
* The passed [Bitmap] gets consumed.
|
||||
*
|
||||
* Returns: a new [servicepoint::Command::BitmapLinearWin] instance.
|
||||
*/
|
||||
TypedCommand *sp_command_bitmap_linear_win(size_t x,
|
||||
size_t y,
|
||||
Bitmap */*notnull*/ bitmap,
|
||||
CompressionCode compression);
|
||||
|
||||
/**
|
||||
* Set pixel data according to a xor-mask starting at the offset.
|
||||
*
|
||||
* The screen will continuously overwrite more pixel data without regarding the offset, meaning
|
||||
* once the starting row is full, overwriting will continue on column 0.
|
||||
*
|
||||
* The contained [SPBitVec] is always uncompressed.
|
||||
*
|
||||
* The passed [SPBitVec] gets consumed.
|
||||
*
|
||||
* Returns: a new [servicepoint::Command::BitmapLinearXor] instance.
|
||||
*/
|
||||
TypedCommand *sp_command_bitmap_linear_xor(size_t offset,
|
||||
SPBitVec */*notnull*/ bit_vec,
|
||||
CompressionCode compression);
|
||||
TypedCommand *sp_command_bitvec(size_t offset,
|
||||
SPBitVec */*notnull*/ bit_vec,
|
||||
CompressionCode compression,
|
||||
BinaryOperation operation);
|
||||
|
||||
/**
|
||||
* Set the brightness of all tiles to the same value.
|
||||
|
@ -885,6 +869,17 @@ TypedCommand */*notnull*/ sp_command_char_brightness(size_t x,
|
|||
size_t y,
|
||||
BrightnessGrid */*notnull*/ grid);
|
||||
|
||||
/**
|
||||
* Show UTF-8 encoded text on the screen.
|
||||
*
|
||||
* The passed [CharGrid] gets consumed.
|
||||
*
|
||||
* Returns: a new [servicepoint::CharGridCommand] instance.
|
||||
*/
|
||||
TypedCommand */*notnull*/ sp_command_char_grid(size_t x,
|
||||
size_t y,
|
||||
CharGrid */*notnull*/ grid);
|
||||
|
||||
/**
|
||||
* Set all pixels to the off state.
|
||||
*
|
||||
|
@ -912,9 +907,9 @@ TypedCommand */*notnull*/ sp_command_clone(TypedCommand */*notnull*/ command);
|
|||
*
|
||||
* The passed [Cp437Grid] gets consumed.
|
||||
*
|
||||
* Returns: a new [servicepoint::Command::Cp437Data] instance.
|
||||
* Returns: a new [servicepoint::Cp437GridCommand] instance.
|
||||
*/
|
||||
TypedCommand */*notnull*/ sp_command_cp437_data(size_t x,
|
||||
TypedCommand */*notnull*/ sp_command_cp437_grid(size_t x,
|
||||
size_t y,
|
||||
Cp437Grid */*notnull*/ grid);
|
||||
|
||||
|
@ -955,83 +950,6 @@ TypedCommand */*notnull*/ sp_command_hard_reset(void);
|
|||
*/
|
||||
TypedCommand *sp_command_try_from_packet(Packet */*notnull*/ packet);
|
||||
|
||||
/**
|
||||
* Show UTF-8 encoded text on the screen.
|
||||
*
|
||||
* The passed [CharGrid] gets consumed.
|
||||
*
|
||||
* Returns: a new [servicepoint::Command::Utf8Data] instance.
|
||||
*/
|
||||
TypedCommand */*notnull*/ sp_command_utf8_data(size_t x,
|
||||
size_t y,
|
||||
CharGrid */*notnull*/ grid);
|
||||
|
||||
/**
|
||||
* Closes and deallocates a [UdpConnection].
|
||||
*/
|
||||
void sp_connection_free(UdpConnection */*notnull*/ connection);
|
||||
|
||||
/**
|
||||
* Creates a new instance of [UdpConnection].
|
||||
*
|
||||
* returns: NULL if connection fails, or connected instance
|
||||
*
|
||||
* # Examples
|
||||
*
|
||||
* ```C
|
||||
* UdpConnection connection = sp_connection_open("172.23.42.29:2342");
|
||||
* if (connection != NULL)
|
||||
* sp_connection_send_command(connection, sp_command_clear());
|
||||
* ```
|
||||
*/
|
||||
UdpConnection *sp_connection_open(char */*notnull*/ host);
|
||||
|
||||
/**
|
||||
* Creates a new instance of [UdpConnection].
|
||||
*
|
||||
* returns: NULL if connection fails, or connected instance
|
||||
*
|
||||
* # Examples
|
||||
*
|
||||
* ```C
|
||||
* UdpConnection connection = sp_connection_open_ipv4(172, 23, 42, 29, 2342);
|
||||
* if (connection != NULL)
|
||||
* sp_connection_send_command(connection, sp_command_clear());
|
||||
* ```
|
||||
*/
|
||||
UdpConnection *sp_connection_open_ipv4(uint8_t ip1,
|
||||
uint8_t ip2,
|
||||
uint8_t ip3,
|
||||
uint8_t ip4,
|
||||
uint16_t port);
|
||||
|
||||
/**
|
||||
* Sends a [TypedCommand] to the display using the [UdpConnection].
|
||||
*
|
||||
* The passed `command` gets consumed.
|
||||
*
|
||||
* returns: true in case of success
|
||||
*
|
||||
* # Examples
|
||||
*
|
||||
* ```C
|
||||
* sp_connection_send_command(connection, sp_command_clear());
|
||||
* sp_connection_send_command(connection, sp_command_brightness(5));
|
||||
* ```
|
||||
*/
|
||||
bool sp_connection_send_command(UdpConnection */*notnull*/ connection,
|
||||
TypedCommand */*notnull*/ command);
|
||||
|
||||
/**
|
||||
* Sends a [Packet] to the display using the [UdpConnection].
|
||||
*
|
||||
* The passed `packet` gets consumed.
|
||||
*
|
||||
* returns: true in case of success
|
||||
*/
|
||||
bool sp_connection_send_packet(UdpConnection */*notnull*/ connection,
|
||||
Packet */*notnull*/ packet);
|
||||
|
||||
/**
|
||||
* Clones a [Cp437Grid].
|
||||
*/
|
||||
|
@ -1188,6 +1106,72 @@ void sp_packet_set_payload(Packet */*notnull*/ packet, ByteSlice data);
|
|||
*/
|
||||
Packet *sp_packet_try_load(ByteSlice data);
|
||||
|
||||
/**
|
||||
* Closes and deallocates a [UdpConnection].
|
||||
*/
|
||||
void sp_udp_free(UdpConnection */*notnull*/ connection);
|
||||
|
||||
/**
|
||||
* Creates a new instance of [UdpConnection].
|
||||
*
|
||||
* returns: NULL if connection fails, or connected instance
|
||||
*
|
||||
* # Examples
|
||||
*
|
||||
* ```C
|
||||
* UdpConnection connection = sp_connection_open("172.23.42.29:2342");
|
||||
* if (connection != NULL)
|
||||
* sp_connection_send_command(connection, sp_command_clear());
|
||||
* ```
|
||||
*/
|
||||
UdpConnection *sp_udp_open(char */*notnull*/ host);
|
||||
|
||||
/**
|
||||
* Creates a new instance of [UdpConnection].
|
||||
*
|
||||
* returns: NULL if connection fails, or connected instance
|
||||
*
|
||||
* # Examples
|
||||
*
|
||||
* ```C
|
||||
* UdpConnection connection = sp_connection_open_ipv4(172, 23, 42, 29, 2342);
|
||||
* if (connection != NULL)
|
||||
* sp_connection_send_command(connection, sp_command_clear());
|
||||
* ```
|
||||
*/
|
||||
UdpConnection *sp_udp_open_ipv4(uint8_t ip1,
|
||||
uint8_t ip2,
|
||||
uint8_t ip3,
|
||||
uint8_t ip4,
|
||||
uint16_t port);
|
||||
|
||||
/**
|
||||
* Sends a [TypedCommand] to the display using the [UdpConnection].
|
||||
*
|
||||
* The passed `command` gets consumed.
|
||||
*
|
||||
* returns: true in case of success
|
||||
*
|
||||
* # Examples
|
||||
*
|
||||
* ```C
|
||||
* sp_connection_send_command(connection, sp_command_clear());
|
||||
* sp_connection_send_command(connection, sp_command_brightness(5));
|
||||
* ```
|
||||
*/
|
||||
bool sp_udp_send_command(UdpConnection */*notnull*/ connection,
|
||||
TypedCommand */*notnull*/ command);
|
||||
|
||||
/**
|
||||
* Sends a [Packet] to the display using the [UdpConnection].
|
||||
*
|
||||
* The passed `packet` gets consumed.
|
||||
*
|
||||
* returns: true in case of success
|
||||
*/
|
||||
bool sp_udp_send_packet(UdpConnection */*notnull*/ connection,
|
||||
Packet */*notnull*/ packet);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue