a bunch of docs
This commit is contained in:
parent
626a887480
commit
36f3d84dc8
|
@ -35,8 +35,8 @@ include = []
|
||||||
exclude = ["BitVec"]
|
exclude = ["BitVec"]
|
||||||
|
|
||||||
[export.rename]
|
[export.rename]
|
||||||
"SpByteSlice" = "ByteSlice"
|
"SPCommand" = "Command"
|
||||||
"SpCommand" = "Command"
|
"DisplayBitVec" = "BitVec"
|
||||||
|
|
||||||
[enum]
|
[enum]
|
||||||
rename_variants = "QualifiedScreamingSnakeCase"
|
rename_variants = "QualifiedScreamingSnakeCase"
|
||||||
|
|
|
@ -346,7 +346,7 @@ typedef struct Cp437GridCommand Cp437GridCommand;
|
||||||
/**
|
/**
|
||||||
* This is a type only used by cbindgen to have a type for pointers.
|
* This is a type only used by cbindgen to have a type for pointers.
|
||||||
*/
|
*/
|
||||||
typedef struct DisplayBitVec DisplayBitVec;
|
typedef struct BitVec BitVec;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <div class="warning">Untested</div>
|
* <div class="warning">Untested</div>
|
||||||
|
@ -569,7 +569,7 @@ typedef struct {
|
||||||
* The pointer to the command struct
|
* The pointer to the command struct
|
||||||
*/
|
*/
|
||||||
CommandUnion data;
|
CommandUnion data;
|
||||||
} SPCommand;
|
} Command;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A raw header.
|
* A raw header.
|
||||||
|
@ -637,7 +637,7 @@ void sp_bitmap_free(Bitmap */*notnull*/ bitmap);
|
||||||
*
|
*
|
||||||
* Returns NULL in case of error.
|
* Returns NULL in case of error.
|
||||||
*/
|
*/
|
||||||
Bitmap *sp_bitmap_from_bitvec(size_t width, DisplayBitVec */*notnull*/ bitvec);
|
Bitmap *sp_bitmap_from_bitvec(size_t width, BitVec */*notnull*/ bitvec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the current value at the specified position in the [Bitmap].
|
* Gets the current value at the specified position in the [Bitmap].
|
||||||
|
@ -665,7 +665,7 @@ size_t sp_bitmap_height(Bitmap */*notnull*/ bitmap);
|
||||||
/**
|
/**
|
||||||
* Consumes the Bitmap and returns the contained BitVec
|
* Consumes the Bitmap and returns the contained BitVec
|
||||||
*/
|
*/
|
||||||
DisplayBitVec */*notnull*/ sp_bitmap_into_bitvec(Bitmap */*notnull*/ bitmap);
|
BitVec */*notnull*/ sp_bitmap_into_bitvec(Bitmap */*notnull*/ bitmap);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a [BitmapCommand] and immediately turns that into a [Packet].
|
* Creates a [BitmapCommand] and immediately turns that into a [Packet].
|
||||||
|
@ -771,7 +771,7 @@ size_t sp_bitmap_width(Bitmap */*notnull*/ bitmap);
|
||||||
/**
|
/**
|
||||||
* Clones a [DisplayBitVec].
|
* Clones a [DisplayBitVec].
|
||||||
*/
|
*/
|
||||||
DisplayBitVec */*notnull*/ sp_bitvec_clone(DisplayBitVec */*notnull*/ bit_vec);
|
BitVec */*notnull*/ sp_bitvec_clone(BitVec */*notnull*/ bit_vec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value of all bits in the [DisplayBitVec].
|
* Sets the value of all bits in the [DisplayBitVec].
|
||||||
|
@ -781,12 +781,12 @@ DisplayBitVec */*notnull*/ sp_bitvec_clone(DisplayBitVec */*notnull*/ bit_vec);
|
||||||
* - `bit_vec`: instance to write to
|
* - `bit_vec`: instance to write to
|
||||||
* - `value`: the value to set all bits to
|
* - `value`: the value to set all bits to
|
||||||
*/
|
*/
|
||||||
void sp_bitvec_fill(DisplayBitVec */*notnull*/ bit_vec, bool value);
|
void sp_bitvec_fill(BitVec */*notnull*/ bit_vec, bool value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deallocates a [DisplayBitVec].
|
* Deallocates a [DisplayBitVec].
|
||||||
*/
|
*/
|
||||||
void sp_bitvec_free(DisplayBitVec */*notnull*/ bit_vec);
|
void sp_bitvec_free(BitVec */*notnull*/ bit_vec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of a bit from the [DisplayBitVec].
|
* Gets the value of a bit from the [DisplayBitVec].
|
||||||
|
@ -802,7 +802,7 @@ void sp_bitvec_free(DisplayBitVec */*notnull*/ bit_vec);
|
||||||
*
|
*
|
||||||
* - when accessing `index` out of bounds
|
* - when accessing `index` out of bounds
|
||||||
*/
|
*/
|
||||||
bool sp_bitvec_get(DisplayBitVec */*notnull*/ bit_vec, size_t index);
|
bool sp_bitvec_get(BitVec */*notnull*/ bit_vec, size_t index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a [BitVecCommand] and immediately turns that into a [Packet].
|
* Creates a [BitVecCommand] and immediately turns that into a [Packet].
|
||||||
|
@ -811,7 +811,7 @@ bool sp_bitvec_get(DisplayBitVec */*notnull*/ bit_vec, size_t index);
|
||||||
*
|
*
|
||||||
* Returns NULL in case of an error.
|
* Returns NULL in case of an error.
|
||||||
*/
|
*/
|
||||||
Packet *sp_bitvec_into_packet(DisplayBitVec */*notnull*/ bitvec,
|
Packet *sp_bitvec_into_packet(BitVec */*notnull*/ bitvec,
|
||||||
size_t offset,
|
size_t offset,
|
||||||
BinaryOperation operation,
|
BinaryOperation operation,
|
||||||
CompressionCode compression);
|
CompressionCode compression);
|
||||||
|
@ -823,7 +823,7 @@ Packet *sp_bitvec_into_packet(DisplayBitVec */*notnull*/ bitvec,
|
||||||
*
|
*
|
||||||
* - `bit_vec`: instance to write to
|
* - `bit_vec`: instance to write to
|
||||||
*/
|
*/
|
||||||
bool sp_bitvec_is_empty(DisplayBitVec */*notnull*/ bit_vec);
|
bool sp_bitvec_is_empty(BitVec */*notnull*/ bit_vec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the length of the [DisplayBitVec] in bits.
|
* Gets the length of the [DisplayBitVec] in bits.
|
||||||
|
@ -832,14 +832,14 @@ bool sp_bitvec_is_empty(DisplayBitVec */*notnull*/ bit_vec);
|
||||||
*
|
*
|
||||||
* - `bit_vec`: instance to write to
|
* - `bit_vec`: instance to write to
|
||||||
*/
|
*/
|
||||||
size_t sp_bitvec_len(DisplayBitVec */*notnull*/ bit_vec);
|
size_t sp_bitvec_len(BitVec */*notnull*/ bit_vec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interpret the data as a series of bits and load then into a new [DisplayBitVec] instance.
|
* Interpret the data as a series of bits and load then into a new [DisplayBitVec] instance.
|
||||||
*
|
*
|
||||||
* returns: [DisplayBitVec] instance containing data.
|
* returns: [DisplayBitVec] instance containing data.
|
||||||
*/
|
*/
|
||||||
DisplayBitVec */*notnull*/ sp_bitvec_load(ByteSlice data);
|
BitVec */*notnull*/ sp_bitvec_load(ByteSlice data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new [DisplayBitVec] instance.
|
* Creates a new [DisplayBitVec] instance.
|
||||||
|
@ -854,7 +854,7 @@ DisplayBitVec */*notnull*/ sp_bitvec_load(ByteSlice data);
|
||||||
*
|
*
|
||||||
* - when `size` is not divisible by 8.
|
* - when `size` is not divisible by 8.
|
||||||
*/
|
*/
|
||||||
DisplayBitVec */*notnull*/ sp_bitvec_new(size_t size);
|
BitVec */*notnull*/ sp_bitvec_new(size_t size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value of a bit in the [DisplayBitVec].
|
* Sets the value of a bit in the [DisplayBitVec].
|
||||||
|
@ -869,9 +869,7 @@ DisplayBitVec */*notnull*/ sp_bitvec_new(size_t size);
|
||||||
*
|
*
|
||||||
* - when accessing `index` out of bounds
|
* - when accessing `index` out of bounds
|
||||||
*/
|
*/
|
||||||
void sp_bitvec_set(DisplayBitVec */*notnull*/ bit_vec,
|
void sp_bitvec_set(BitVec */*notnull*/ bit_vec, size_t index, bool value);
|
||||||
size_t index,
|
|
||||||
bool value);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an unsafe reference to the data of the [DisplayBitVec] instance.
|
* Gets an unsafe reference to the data of the [DisplayBitVec] instance.
|
||||||
|
@ -882,7 +880,7 @@ void sp_bitvec_set(DisplayBitVec */*notnull*/ bit_vec,
|
||||||
*
|
*
|
||||||
* - `bit_vec`: instance to write to
|
* - `bit_vec`: instance to write to
|
||||||
*/
|
*/
|
||||||
ByteSlice sp_bitvec_unsafe_data_ref(DisplayBitVec */*notnull*/ bit_vec);
|
ByteSlice sp_bitvec_unsafe_data_ref(BitVec */*notnull*/ bit_vec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clones a [BrightnessGrid].
|
* Clones a [BrightnessGrid].
|
||||||
|
@ -1126,6 +1124,11 @@ void sp_char_grid_set(CharGrid */*notnull*/ char_grid,
|
||||||
*/
|
*/
|
||||||
size_t sp_char_grid_width(CharGrid */*notnull*/ char_grid);
|
size_t sp_char_grid_width(CharGrid */*notnull*/ char_grid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clones an [BitmapCommand] instance.
|
||||||
|
*
|
||||||
|
* returns: a new [BitmapCommand] instance.
|
||||||
|
*/
|
||||||
BitmapCommand */*notnull*/ sp_cmd_bitmap_clone(BitmapCommand */*notnull*/ command);
|
BitmapCommand */*notnull*/ sp_cmd_bitmap_clone(BitmapCommand */*notnull*/ command);
|
||||||
|
|
||||||
void sp_cmd_bitmap_free(BitmapCommand */*notnull*/ command);
|
void sp_cmd_bitmap_free(BitmapCommand */*notnull*/ command);
|
||||||
|
@ -1181,11 +1184,19 @@ void sp_cmd_bitmap_set_origin(BitmapCommand */*notnull*/ command,
|
||||||
size_t origin_x,
|
size_t origin_x,
|
||||||
size_t origin_y);
|
size_t origin_y);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clones an [BitVecCommand] instance.
|
||||||
|
*
|
||||||
|
* returns: a new [BitVecCommand] instance.
|
||||||
|
*/
|
||||||
BitVecCommand */*notnull*/ sp_cmd_bitvec_clone(BitVecCommand */*notnull*/ command);
|
BitVecCommand */*notnull*/ sp_cmd_bitvec_clone(BitVecCommand */*notnull*/ command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deallocates a [BitVecCommand].
|
||||||
|
*/
|
||||||
void sp_cmd_bitvec_free(BitVecCommand */*notnull*/ command);
|
void sp_cmd_bitvec_free(BitVecCommand */*notnull*/ command);
|
||||||
|
|
||||||
DisplayBitVec *sp_cmd_bitvec_get(BitVecCommand */*notnull*/ command);
|
BitVec *sp_cmd_bitvec_get(BitVecCommand */*notnull*/ command);
|
||||||
|
|
||||||
CompressionCode sp_cmd_bitvec_get_compression(BitVecCommand */*notnull*/ command);
|
CompressionCode sp_cmd_bitvec_get_compression(BitVecCommand */*notnull*/ command);
|
||||||
|
|
||||||
|
@ -1209,7 +1220,7 @@ Packet *sp_cmd_bitvec_into_packet(BitVecCommand */*notnull*/ command);
|
||||||
*
|
*
|
||||||
* The contained [`DisplayBitVec`] is always uncompressed.
|
* The contained [`DisplayBitVec`] is always uncompressed.
|
||||||
*/
|
*/
|
||||||
BitVecCommand */*notnull*/ sp_cmd_bitvec_new(DisplayBitVec */*notnull*/ bitvec,
|
BitVecCommand */*notnull*/ sp_cmd_bitvec_new(BitVec */*notnull*/ bitvec,
|
||||||
size_t offset,
|
size_t offset,
|
||||||
BinaryOperation operation,
|
BinaryOperation operation,
|
||||||
CompressionCode compression);
|
CompressionCode compression);
|
||||||
|
@ -1218,7 +1229,7 @@ BitVecCommand */*notnull*/ sp_cmd_bitvec_new(DisplayBitVec */*notnull*/ bitvec,
|
||||||
* Moves the provided bitmap to be contained in the command.
|
* Moves the provided bitmap to be contained in the command.
|
||||||
*/
|
*/
|
||||||
void sp_cmd_bitvec_set(BitVecCommand */*notnull*/ command,
|
void sp_cmd_bitvec_set(BitVecCommand */*notnull*/ command,
|
||||||
DisplayBitVec */*notnull*/ bitvec);
|
BitVec */*notnull*/ bitvec);
|
||||||
|
|
||||||
void sp_cmd_bitvec_set_compression(BitVecCommand */*notnull*/ command,
|
void sp_cmd_bitvec_set_compression(BitVecCommand */*notnull*/ command,
|
||||||
CompressionCode compression);
|
CompressionCode compression);
|
||||||
|
@ -1229,14 +1240,24 @@ void sp_cmd_bitvec_set_offset(BitVecCommand */*notnull*/ command,
|
||||||
void sp_cmd_bitvec_set_operation(BitVecCommand */*notnull*/ command,
|
void sp_cmd_bitvec_set_operation(BitVecCommand */*notnull*/ command,
|
||||||
BinaryOperation operation);
|
BinaryOperation operation);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clones an [GlobalBrightnessCommand] instance.
|
||||||
|
*
|
||||||
|
* returns: a new [GlobalBrightnessCommand] instance.
|
||||||
|
*/
|
||||||
GlobalBrightnessCommand */*notnull*/ sp_cmd_brightness_global_clone(GlobalBrightnessCommand */*notnull*/ command);
|
GlobalBrightnessCommand */*notnull*/ sp_cmd_brightness_global_clone(GlobalBrightnessCommand */*notnull*/ command);
|
||||||
|
|
||||||
void sp_cmd_brightness_global_free(BitmapCommand */*notnull*/ command);
|
void sp_cmd_brightness_global_free(BitmapCommand */*notnull*/ command);
|
||||||
|
|
||||||
Brightness *sp_cmd_brightness_global_get(GlobalBrightnessCommand */*notnull*/ command);
|
Brightness *sp_cmd_brightness_global_get(GlobalBrightnessCommand */*notnull*/ command);
|
||||||
|
|
||||||
Packet *sp_cmd_brightness_global_into_packet(GlobalBrightnessCommand */*notnull*/ command);
|
Packet */*notnull*/ sp_cmd_brightness_global_into_packet(GlobalBrightnessCommand */*notnull*/ command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the brightness of all tiles to the same value.
|
||||||
|
*
|
||||||
|
* Returns: a new [GlobalBrightnessCommand] instance.
|
||||||
|
*/
|
||||||
GlobalBrightnessCommand */*notnull*/ sp_cmd_brightness_global_new(Brightness brightness);
|
GlobalBrightnessCommand */*notnull*/ sp_cmd_brightness_global_new(Brightness brightness);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1245,10 +1266,22 @@ GlobalBrightnessCommand */*notnull*/ sp_cmd_brightness_global_new(Brightness bri
|
||||||
void sp_cmd_brightness_global_set(GlobalBrightnessCommand */*notnull*/ command,
|
void sp_cmd_brightness_global_set(GlobalBrightnessCommand */*notnull*/ command,
|
||||||
Brightness brightness);
|
Brightness brightness);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clones an [BrightnessGridCommand] instance.
|
||||||
|
*
|
||||||
|
* returns: a new [BrightnessGridCommand] instance.
|
||||||
|
*/
|
||||||
BrightnessGridCommand */*notnull*/ sp_cmd_brightness_grid_clone(BrightnessGridCommand */*notnull*/ command);
|
BrightnessGridCommand */*notnull*/ sp_cmd_brightness_grid_clone(BrightnessGridCommand */*notnull*/ command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deallocates a [BitmapCommand].
|
||||||
|
*/
|
||||||
void sp_cmd_brightness_grid_free(BitmapCommand */*notnull*/ command);
|
void sp_cmd_brightness_grid_free(BitmapCommand */*notnull*/ command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moves the provided [BrightnessGrid] into a new [BrightnessGridCommand],
|
||||||
|
* leaving other fields as their default values.
|
||||||
|
*/
|
||||||
BrightnessGridCommand */*notnull*/ sp_cmd_brightness_grid_from_grid(BrightnessGrid */*notnull*/ grid);
|
BrightnessGridCommand */*notnull*/ sp_cmd_brightness_grid_from_grid(BrightnessGrid */*notnull*/ grid);
|
||||||
|
|
||||||
BrightnessGrid *sp_cmd_brightness_grid_get(BrightnessGridCommand */*notnull*/ command);
|
BrightnessGrid *sp_cmd_brightness_grid_get(BrightnessGridCommand */*notnull*/ command);
|
||||||
|
@ -1259,6 +1292,13 @@ void sp_cmd_brightness_grid_get_origin(BrightnessGridCommand */*notnull*/ comman
|
||||||
|
|
||||||
Packet *sp_cmd_brightness_grid_into_packet(BrightnessGridCommand */*notnull*/ command);
|
Packet *sp_cmd_brightness_grid_into_packet(BrightnessGridCommand */*notnull*/ command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the brightness of individual tiles in a rectangular area of the display.
|
||||||
|
*
|
||||||
|
* The passed [BrightnessGrid] gets consumed.
|
||||||
|
*
|
||||||
|
* Returns: a new [BrightnessGridCommand] instance.
|
||||||
|
*/
|
||||||
BrightnessGridCommand */*notnull*/ sp_cmd_brightness_grid_new(BrightnessGrid */*notnull*/ grid,
|
BrightnessGridCommand */*notnull*/ sp_cmd_brightness_grid_new(BrightnessGrid */*notnull*/ grid,
|
||||||
size_t origin_x,
|
size_t origin_x,
|
||||||
size_t origin_y);
|
size_t origin_y);
|
||||||
|
@ -1273,10 +1313,22 @@ void sp_cmd_brightness_grid_set_origin(BrightnessGridCommand */*notnull*/ comman
|
||||||
size_t origin_x,
|
size_t origin_x,
|
||||||
size_t origin_y);
|
size_t origin_y);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clones an [CharGridCommand] instance.
|
||||||
|
*
|
||||||
|
* returns: a new [CharGridCommand] instance.
|
||||||
|
*/
|
||||||
CharGridCommand */*notnull*/ sp_cmd_char_grid_clone(CharGridCommand */*notnull*/ command);
|
CharGridCommand */*notnull*/ sp_cmd_char_grid_clone(CharGridCommand */*notnull*/ command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deallocates a [BitmapCommand].
|
||||||
|
*/
|
||||||
void sp_cmd_char_grid_free(BitmapCommand */*notnull*/ command);
|
void sp_cmd_char_grid_free(BitmapCommand */*notnull*/ command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moves the provided [CharGrid] into a new [CharGridCommand],
|
||||||
|
* leaving other fields as their default values.
|
||||||
|
*/
|
||||||
CharGridCommand */*notnull*/ sp_cmd_char_grid_from_grid(CharGrid */*notnull*/ grid);
|
CharGridCommand */*notnull*/ sp_cmd_char_grid_from_grid(CharGrid */*notnull*/ grid);
|
||||||
|
|
||||||
CharGrid *sp_cmd_char_grid_get(CharGridCommand */*notnull*/ command);
|
CharGrid *sp_cmd_char_grid_get(CharGridCommand */*notnull*/ command);
|
||||||
|
@ -1287,6 +1339,13 @@ void sp_cmd_char_grid_get_origin(CharGridCommand */*notnull*/ command,
|
||||||
|
|
||||||
Packet *sp_cmd_char_grid_into_packet(CharGridCommand */*notnull*/ command);
|
Packet *sp_cmd_char_grid_into_packet(CharGridCommand */*notnull*/ command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show UTF-8 encoded text on the screen.
|
||||||
|
*
|
||||||
|
* The passed [CharGrid] gets consumed.
|
||||||
|
*
|
||||||
|
* Returns: a new [CharGridCommand] instance.
|
||||||
|
*/
|
||||||
CharGridCommand */*notnull*/ sp_cmd_char_grid_new(CharGrid */*notnull*/ grid,
|
CharGridCommand */*notnull*/ sp_cmd_char_grid_new(CharGrid */*notnull*/ grid,
|
||||||
size_t origin_x,
|
size_t origin_x,
|
||||||
size_t origin_y);
|
size_t origin_y);
|
||||||
|
@ -1301,6 +1360,9 @@ void sp_cmd_char_grid_set_origin(CharGridCommand */*notnull*/ command,
|
||||||
size_t origin_x,
|
size_t origin_x,
|
||||||
size_t origin_y);
|
size_t origin_y);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deallocates a [ClearCommand].
|
||||||
|
*/
|
||||||
void sp_cmd_clear_free(ClearCommand */*notnull*/ command);
|
void sp_cmd_clear_free(ClearCommand */*notnull*/ command);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1309,21 +1371,35 @@ void sp_cmd_clear_free(ClearCommand */*notnull*/ command);
|
||||||
* Does not affect brightness.
|
* Does not affect brightness.
|
||||||
*
|
*
|
||||||
* Returns: a new [ClearCommand] instance.
|
* Returns: a new [ClearCommand] instance.
|
||||||
*
|
|
||||||
* # Examples
|
|
||||||
*
|
|
||||||
* ```C
|
|
||||||
* sp_udp_send_command(connection, sp_cmd_clear());
|
|
||||||
* ```
|
|
||||||
*/
|
*/
|
||||||
ClearCommand */*notnull*/ sp_cmd_clear_new(void);
|
ClearCommand */*notnull*/ sp_cmd_clear_new(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clones an [Cp437GridCommand] instance.
|
||||||
|
*
|
||||||
|
* returns: a new [Cp437GridCommand] instance.
|
||||||
|
*/
|
||||||
Cp437GridCommand */*notnull*/ sp_cmd_cp437_grid_clone(Cp437GridCommand */*notnull*/ command);
|
Cp437GridCommand */*notnull*/ sp_cmd_cp437_grid_clone(Cp437GridCommand */*notnull*/ command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deallocates a [Cp437GridCommand].
|
||||||
|
*/
|
||||||
void sp_cmd_cp437_grid_free(BitmapCommand */*notnull*/ command);
|
void sp_cmd_cp437_grid_free(BitmapCommand */*notnull*/ command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moves the provided [Cp437Grid] into a new [Cp437GridCommand],
|
||||||
|
* leaving other fields as their default values.
|
||||||
|
*/
|
||||||
Cp437GridCommand */*notnull*/ sp_cmd_cp437_grid_from_grid(Cp437Grid */*notnull*/ grid);
|
Cp437GridCommand */*notnull*/ sp_cmd_cp437_grid_from_grid(Cp437Grid */*notnull*/ grid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show text on the screen.
|
||||||
|
*
|
||||||
|
* The text is sent in the form of a 2D grid of [CP-437] encoded characters.
|
||||||
|
* For sending UTF-8 encoded characters, see [servicepoint::CharGridCommand].
|
||||||
|
*
|
||||||
|
* [CP-437]: https://en.wikipedia.org/wiki/Code_page_437
|
||||||
|
*/
|
||||||
Cp437Grid *sp_cmd_cp437_grid_get(Cp437GridCommand */*notnull*/ command);
|
Cp437Grid *sp_cmd_cp437_grid_get(Cp437GridCommand */*notnull*/ command);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1337,6 +1413,13 @@ void sp_cmd_cp437_grid_get_origin(Cp437GridCommand */*notnull*/ command,
|
||||||
|
|
||||||
Packet *sp_cmd_cp437_grid_into_packet(Cp437GridCommand */*notnull*/ command);
|
Packet *sp_cmd_cp437_grid_into_packet(Cp437GridCommand */*notnull*/ command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show text on the screen.
|
||||||
|
*
|
||||||
|
* The text is sent in the form of a 2D grid of [CP-437] encoded characters.
|
||||||
|
*
|
||||||
|
* The origin is relative to the top-left of the display.
|
||||||
|
*/
|
||||||
Cp437GridCommand */*notnull*/ sp_cmd_cp437_grid_new(Cp437Grid */*notnull*/ grid,
|
Cp437GridCommand */*notnull*/ sp_cmd_cp437_grid_new(Cp437Grid */*notnull*/ grid,
|
||||||
size_t origin_x,
|
size_t origin_x,
|
||||||
size_t origin_y);
|
size_t origin_y);
|
||||||
|
@ -1358,6 +1441,9 @@ void sp_cmd_cp437_grid_set_origin(Cp437GridCommand */*notnull*/ command,
|
||||||
size_t origin_x,
|
size_t origin_x,
|
||||||
size_t origin_y);
|
size_t origin_y);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deallocates a [FadeOutCommand].
|
||||||
|
*/
|
||||||
void sp_cmd_fade_out_free(ClearCommand */*notnull*/ command);
|
void sp_cmd_fade_out_free(ClearCommand */*notnull*/ command);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1368,41 +1454,44 @@ void sp_cmd_fade_out_free(ClearCommand */*notnull*/ command);
|
||||||
FadeOutCommand */*notnull*/ sp_cmd_fade_out_new(void);
|
FadeOutCommand */*notnull*/ sp_cmd_fade_out_new(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clones a [SPCommand] instance.
|
* Clones an [SPCommand] instance.
|
||||||
*
|
*
|
||||||
* returns: new [SPCommand] instance.
|
* returns: a new [SPCommand] instance.
|
||||||
*/
|
*/
|
||||||
SPCommand sp_cmd_generic_clone(SPCommand command);
|
Command sp_cmd_generic_clone(Command command);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deallocates a [SPCommand].
|
* Deallocates an [SPCommand].
|
||||||
*
|
*
|
||||||
* # Examples
|
* # Examples
|
||||||
*
|
*
|
||||||
* ```C
|
* ```C
|
||||||
* TypedCommand c = sp_command_clear();
|
* SPCommand c = sp_cmd_clear_into_generic(sp_cmd_clear_new());
|
||||||
* sp_command_free(c);
|
* sp_command_free(c);
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
void sp_cmd_generic_free(SPCommand command);
|
void sp_cmd_generic_free(Command command);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns a [TypedCommand] into a [Packet].
|
* Tries to turn a [SPCommand] into a [Packet].
|
||||||
* The [TypedCommand] gets consumed.
|
* The [SPCommand] gets consumed.
|
||||||
*
|
*
|
||||||
* Returns NULL in case of an error.
|
* Returns tag [CommandTag::Invalid] in case of an error.
|
||||||
*/
|
*/
|
||||||
Packet *sp_cmd_generic_into_packet(SPCommand command);
|
Packet *sp_cmd_generic_into_packet(Command command);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to turn a [Packet] into a [TypedCommand].
|
* Tries to turn a [Packet] into a [SPCommand].
|
||||||
*
|
*
|
||||||
* The packet is deallocated in the process.
|
* The packet is dropped in the process.
|
||||||
*
|
*
|
||||||
* Returns: pointer to new [TypedCommand] instance or NULL if parsing failed.
|
* Returns: pointer to new [SPCommand] instance or NULL if parsing failed.
|
||||||
*/
|
*/
|
||||||
SPCommand *sp_cmd_generic_try_from_packet(Packet */*notnull*/ packet);
|
Command *sp_cmd_generic_try_from_packet(Packet */*notnull*/ packet);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deallocates a [HardResetCommand].
|
||||||
|
*/
|
||||||
void sp_cmd_hard_reset_free(ClearCommand */*notnull*/ command);
|
void sp_cmd_hard_reset_free(ClearCommand */*notnull*/ command);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1520,6 +1609,8 @@ size_t sp_cp437_grid_width(Cp437Grid */*notnull*/ cp437_grid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clones a [Packet].
|
* Clones a [Packet].
|
||||||
|
*
|
||||||
|
* returns: a new [Packet] instance.
|
||||||
*/
|
*/
|
||||||
Packet */*notnull*/ sp_packet_clone(Packet */*notnull*/ packet);
|
Packet */*notnull*/ sp_packet_clone(Packet */*notnull*/ packet);
|
||||||
|
|
||||||
|
@ -1633,7 +1724,7 @@ UdpSocket *sp_udp_open_ipv4(uint8_t ip1,
|
||||||
* sp_udp_send_command(connection, sp_command_brightness(5));
|
* sp_udp_send_command(connection, sp_command_brightness(5));
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
bool sp_udp_send_command(UdpSocket */*notnull*/ connection, SPCommand command);
|
bool sp_udp_send_command(UdpSocket */*notnull*/ connection, Command command);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a [Header] to the display using the [UdpSocket].
|
* Sends a [Header] to the display using the [UdpSocket].
|
||||||
|
|
|
@ -41,6 +41,9 @@ pub unsafe extern "C" fn sp_cmd_bitmap_into_packet(
|
||||||
heap_move_ok(unsafe { heap_remove(command) }.try_into())
|
heap_move_ok(unsafe { heap_remove(command) }.try_into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Clones an [BitmapCommand] instance.
|
||||||
|
///
|
||||||
|
/// returns: a new [BitmapCommand] instance.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_cmd_bitmap_clone(
|
pub unsafe extern "C" fn sp_cmd_bitmap_clone(
|
||||||
command: NonNull<BitmapCommand>,
|
command: NonNull<BitmapCommand>,
|
||||||
|
|
|
@ -41,6 +41,9 @@ pub unsafe extern "C" fn sp_cmd_bitvec_into_packet(
|
||||||
heap_move_ok(unsafe { heap_remove(command) }.try_into())
|
heap_move_ok(unsafe { heap_remove(command) }.try_into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Clones an [BitVecCommand] instance.
|
||||||
|
///
|
||||||
|
/// returns: a new [BitVecCommand] instance.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_cmd_bitvec_clone(
|
pub unsafe extern "C" fn sp_cmd_bitvec_clone(
|
||||||
command: NonNull<BitVecCommand>,
|
command: NonNull<BitVecCommand>,
|
||||||
|
@ -48,6 +51,7 @@ pub unsafe extern "C" fn sp_cmd_bitvec_clone(
|
||||||
unsafe { heap_clone(command) }
|
unsafe { heap_clone(command) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Deallocates a [BitVecCommand].
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_cmd_bitvec_free(command: NonNull<BitVecCommand>) {
|
pub unsafe extern "C" fn sp_cmd_bitvec_free(command: NonNull<BitVecCommand>) {
|
||||||
unsafe { heap_drop(command) }
|
unsafe { heap_drop(command) }
|
||||||
|
|
|
@ -6,6 +6,11 @@ use servicepoint::{
|
||||||
};
|
};
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
|
/// Set the brightness of individual tiles in a rectangular area of the display.
|
||||||
|
///
|
||||||
|
/// The passed [BrightnessGrid] gets consumed.
|
||||||
|
///
|
||||||
|
/// Returns: a new [BrightnessGridCommand] instance.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_cmd_brightness_grid_new(
|
pub unsafe extern "C" fn sp_cmd_brightness_grid_new(
|
||||||
grid: NonNull<BrightnessGrid>,
|
grid: NonNull<BrightnessGrid>,
|
||||||
|
@ -18,6 +23,8 @@ pub unsafe extern "C" fn sp_cmd_brightness_grid_new(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Moves the provided [BrightnessGrid] into a new [BrightnessGridCommand],
|
||||||
|
/// leaving other fields as their default values.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_cmd_brightness_grid_from_grid(
|
pub unsafe extern "C" fn sp_cmd_brightness_grid_from_grid(
|
||||||
grid: NonNull<BrightnessGrid>,
|
grid: NonNull<BrightnessGrid>,
|
||||||
|
@ -32,6 +39,9 @@ pub unsafe extern "C" fn sp_cmd_brightness_grid_into_packet(
|
||||||
heap_move_ok(unsafe { heap_remove(command) }.try_into())
|
heap_move_ok(unsafe { heap_remove(command) }.try_into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Clones an [BrightnessGridCommand] instance.
|
||||||
|
///
|
||||||
|
/// returns: a new [BrightnessGridCommand] instance.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_cmd_brightness_grid_clone(
|
pub unsafe extern "C" fn sp_cmd_brightness_grid_clone(
|
||||||
command: NonNull<BrightnessGridCommand>,
|
command: NonNull<BrightnessGridCommand>,
|
||||||
|
@ -39,6 +49,7 @@ pub unsafe extern "C" fn sp_cmd_brightness_grid_clone(
|
||||||
unsafe { heap_clone(command) }
|
unsafe { heap_clone(command) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Deallocates a [BitmapCommand].
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_cmd_brightness_grid_free(
|
pub unsafe extern "C" fn sp_cmd_brightness_grid_free(
|
||||||
command: NonNull<BitmapCommand>,
|
command: NonNull<BitmapCommand>,
|
||||||
|
|
|
@ -7,17 +7,12 @@ use std::ptr::NonNull;
|
||||||
/// Does not affect brightness.
|
/// Does not affect brightness.
|
||||||
///
|
///
|
||||||
/// Returns: a new [ClearCommand] instance.
|
/// Returns: a new [ClearCommand] instance.
|
||||||
///
|
|
||||||
/// # Examples
|
|
||||||
///
|
|
||||||
/// ```C
|
|
||||||
/// sp_udp_send_command(connection, sp_cmd_clear());
|
|
||||||
/// ```
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_cmd_clear_new() -> NonNull<ClearCommand> {
|
pub unsafe extern "C" fn sp_cmd_clear_new() -> NonNull<ClearCommand> {
|
||||||
heap_move_nonnull(ClearCommand)
|
heap_move_nonnull(ClearCommand)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Deallocates a [ClearCommand].
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_cmd_clear_free(command: NonNull<ClearCommand>) {
|
pub unsafe extern "C" fn sp_cmd_clear_free(command: NonNull<ClearCommand>) {
|
||||||
unsafe { heap_drop(command) }
|
unsafe { heap_drop(command) }
|
||||||
|
@ -33,6 +28,7 @@ pub unsafe extern "C" fn sp_cmd_hard_reset_new() -> NonNull<HardResetCommand> {
|
||||||
heap_move_nonnull(HardResetCommand)
|
heap_move_nonnull(HardResetCommand)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Deallocates a [HardResetCommand].
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_cmd_hard_reset_free(
|
pub unsafe extern "C" fn sp_cmd_hard_reset_free(
|
||||||
command: NonNull<ClearCommand>,
|
command: NonNull<ClearCommand>,
|
||||||
|
@ -48,6 +44,7 @@ pub unsafe extern "C" fn sp_cmd_fade_out_new() -> NonNull<FadeOutCommand> {
|
||||||
heap_move_nonnull(FadeOutCommand)
|
heap_move_nonnull(FadeOutCommand)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Deallocates a [FadeOutCommand].
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_cmd_fade_out_free(command: NonNull<ClearCommand>) {
|
pub unsafe extern "C" fn sp_cmd_fade_out_free(command: NonNull<ClearCommand>) {
|
||||||
unsafe { heap_drop(command) }
|
unsafe { heap_drop(command) }
|
||||||
|
|
|
@ -4,6 +4,11 @@ use crate::mem::{
|
||||||
use servicepoint::{BitmapCommand, CharGrid, CharGridCommand, Origin, Packet};
|
use servicepoint::{BitmapCommand, CharGrid, CharGridCommand, Origin, Packet};
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
|
/// Show UTF-8 encoded text on the screen.
|
||||||
|
///
|
||||||
|
/// The passed [CharGrid] gets consumed.
|
||||||
|
///
|
||||||
|
/// Returns: a new [CharGridCommand] instance.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_cmd_char_grid_new(
|
pub unsafe extern "C" fn sp_cmd_char_grid_new(
|
||||||
grid: NonNull<CharGrid>,
|
grid: NonNull<CharGrid>,
|
||||||
|
@ -16,6 +21,8 @@ pub unsafe extern "C" fn sp_cmd_char_grid_new(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Moves the provided [CharGrid] into a new [CharGridCommand],
|
||||||
|
/// leaving other fields as their default values.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_cmd_char_grid_from_grid(
|
pub unsafe extern "C" fn sp_cmd_char_grid_from_grid(
|
||||||
grid: NonNull<CharGrid>,
|
grid: NonNull<CharGrid>,
|
||||||
|
@ -30,6 +37,9 @@ pub unsafe extern "C" fn sp_cmd_char_grid_into_packet(
|
||||||
heap_move_ok(unsafe { heap_remove(command) }.try_into())
|
heap_move_ok(unsafe { heap_remove(command) }.try_into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Clones an [CharGridCommand] instance.
|
||||||
|
///
|
||||||
|
/// returns: a new [CharGridCommand] instance.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_cmd_char_grid_clone(
|
pub unsafe extern "C" fn sp_cmd_char_grid_clone(
|
||||||
command: NonNull<CharGridCommand>,
|
command: NonNull<CharGridCommand>,
|
||||||
|
@ -37,6 +47,7 @@ pub unsafe extern "C" fn sp_cmd_char_grid_clone(
|
||||||
unsafe { heap_clone(command) }
|
unsafe { heap_clone(command) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Deallocates a [BitmapCommand].
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_cmd_char_grid_free(
|
pub unsafe extern "C" fn sp_cmd_char_grid_free(
|
||||||
command: NonNull<BitmapCommand>,
|
command: NonNull<BitmapCommand>,
|
||||||
|
|
|
@ -6,6 +6,11 @@ use servicepoint::{
|
||||||
};
|
};
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
|
/// Show text on the screen.
|
||||||
|
///
|
||||||
|
/// The text is sent in the form of a 2D grid of [CP-437] encoded characters.
|
||||||
|
///
|
||||||
|
/// The origin is relative to the top-left of the display.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_cmd_cp437_grid_new(
|
pub unsafe extern "C" fn sp_cmd_cp437_grid_new(
|
||||||
grid: NonNull<Cp437Grid>,
|
grid: NonNull<Cp437Grid>,
|
||||||
|
@ -18,6 +23,8 @@ pub unsafe extern "C" fn sp_cmd_cp437_grid_new(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Moves the provided [Cp437Grid] into a new [Cp437GridCommand],
|
||||||
|
/// leaving other fields as their default values.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_cmd_cp437_grid_from_grid(
|
pub unsafe extern "C" fn sp_cmd_cp437_grid_from_grid(
|
||||||
grid: NonNull<Cp437Grid>,
|
grid: NonNull<Cp437Grid>,
|
||||||
|
@ -32,6 +39,9 @@ pub unsafe extern "C" fn sp_cmd_cp437_grid_into_packet(
|
||||||
heap_move_ok(unsafe { heap_remove(command) }.try_into())
|
heap_move_ok(unsafe { heap_remove(command) }.try_into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Clones an [Cp437GridCommand] instance.
|
||||||
|
///
|
||||||
|
/// returns: a new [Cp437GridCommand] instance.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_cmd_cp437_grid_clone(
|
pub unsafe extern "C" fn sp_cmd_cp437_grid_clone(
|
||||||
command: NonNull<Cp437GridCommand>,
|
command: NonNull<Cp437GridCommand>,
|
||||||
|
@ -39,6 +49,7 @@ pub unsafe extern "C" fn sp_cmd_cp437_grid_clone(
|
||||||
unsafe { heap_clone(command) }
|
unsafe { heap_clone(command) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Deallocates a [Cp437GridCommand].
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_cmd_cp437_grid_free(
|
pub unsafe extern "C" fn sp_cmd_cp437_grid_free(
|
||||||
command: NonNull<BitmapCommand>,
|
command: NonNull<BitmapCommand>,
|
||||||
|
@ -59,6 +70,12 @@ pub unsafe extern "C" fn sp_cmd_cp437_grid_set(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Show text on the screen.
|
||||||
|
///
|
||||||
|
/// The text is sent in the form of a 2D grid of [CP-437] encoded characters.
|
||||||
|
/// For sending UTF-8 encoded characters, see [servicepoint::CharGridCommand].
|
||||||
|
///
|
||||||
|
/// [CP-437]: https://en.wikipedia.org/wiki/Code_page_437
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_cmd_cp437_grid_get(
|
pub unsafe extern "C" fn sp_cmd_cp437_grid_get(
|
||||||
mut command: NonNull<Cp437GridCommand>,
|
mut command: NonNull<Cp437GridCommand>,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::mem::{
|
use crate::mem::{
|
||||||
heap_clone, heap_drop, heap_move_nonnull, heap_move_ok, heap_remove,
|
heap_clone, heap_drop, heap_move, heap_move_nonnull, heap_move_ok,
|
||||||
|
heap_remove,
|
||||||
};
|
};
|
||||||
use servicepoint::{
|
use servicepoint::{
|
||||||
BitVecCommand, BitmapCommand, BrightnessGridCommand, CharGridCommand,
|
BitVecCommand, BitmapCommand, BrightnessGridCommand, CharGridCommand,
|
||||||
|
@ -229,7 +230,7 @@ pub unsafe extern "C" fn sp_cmd_generic_clone(command: SPCommand) -> SPCommand {
|
||||||
pub unsafe extern "C" fn sp_cmd_generic_free(command: SPCommand) {
|
pub unsafe extern "C" fn sp_cmd_generic_free(command: SPCommand) {
|
||||||
unsafe {
|
unsafe {
|
||||||
match command.tag {
|
match command.tag {
|
||||||
CommandTag::Invalid => return,
|
CommandTag::Invalid => (),
|
||||||
CommandTag::Bitmap => heap_drop(command.data.bitmap),
|
CommandTag::Bitmap => heap_drop(command.data.bitmap),
|
||||||
CommandTag::BitVec => heap_drop(command.data.bitvec),
|
CommandTag::BitVec => heap_drop(command.data.bitvec),
|
||||||
CommandTag::BrightnessGrid => {
|
CommandTag::BrightnessGrid => {
|
||||||
|
@ -273,20 +274,20 @@ pub unsafe extern "C" fn sp_cmd_generic_into_packet(
|
||||||
CommandTag::Cp437Grid => heap_move_ok(unsafe {
|
CommandTag::Cp437Grid => heap_move_ok(unsafe {
|
||||||
heap_remove(command.data.cp437_grid).try_into()
|
heap_remove(command.data.cp437_grid).try_into()
|
||||||
}),
|
}),
|
||||||
CommandTag::GlobalBrightness => heap_move_ok(unsafe {
|
CommandTag::GlobalBrightness => heap_move(unsafe {
|
||||||
heap_remove(command.data.global_brightness).try_into()
|
heap_remove(command.data.global_brightness).into()
|
||||||
}),
|
}),
|
||||||
CommandTag::Clear => {
|
CommandTag::Clear => {
|
||||||
heap_move_ok(unsafe { heap_remove(command.data.clear).try_into() })
|
heap_move(unsafe { heap_remove(command.data.clear).into() })
|
||||||
|
}
|
||||||
|
CommandTag::HardReset => {
|
||||||
|
heap_move(unsafe { heap_remove(command.data.hard_reset).into() })
|
||||||
|
}
|
||||||
|
CommandTag::FadeOut => {
|
||||||
|
heap_move(unsafe { heap_remove(command.data.fade_out).into() })
|
||||||
|
}
|
||||||
|
CommandTag::BitmapLegacy => {
|
||||||
|
heap_move(unsafe { heap_remove(command.data.bitmap_legacy).into() })
|
||||||
}
|
}
|
||||||
CommandTag::HardReset => heap_move_ok(unsafe {
|
|
||||||
heap_remove(command.data.hard_reset).try_into()
|
|
||||||
}),
|
|
||||||
CommandTag::FadeOut => heap_move_ok(unsafe {
|
|
||||||
heap_remove(command.data.fade_out).try_into()
|
|
||||||
}),
|
|
||||||
CommandTag::BitmapLegacy => heap_move_ok(unsafe {
|
|
||||||
heap_remove(command.data.bitmap_legacy).try_into()
|
|
||||||
}),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
use crate::mem::{
|
use crate::mem::{heap_clone, heap_drop, heap_move_nonnull, heap_remove};
|
||||||
heap_clone, heap_drop, heap_move_nonnull, heap_move_ok, heap_remove,
|
|
||||||
};
|
|
||||||
use servicepoint::{
|
use servicepoint::{
|
||||||
BitmapCommand, Brightness, GlobalBrightnessCommand, Packet,
|
BitmapCommand, Brightness, GlobalBrightnessCommand, Packet,
|
||||||
};
|
};
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
|
/// Set the brightness of all tiles to the same value.
|
||||||
|
///
|
||||||
|
/// Returns: a new [GlobalBrightnessCommand] instance.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_cmd_brightness_global_new(
|
pub unsafe extern "C" fn sp_cmd_brightness_global_new(
|
||||||
brightness: Brightness,
|
brightness: Brightness,
|
||||||
|
@ -16,10 +17,13 @@ pub unsafe extern "C" fn sp_cmd_brightness_global_new(
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_cmd_brightness_global_into_packet(
|
pub unsafe extern "C" fn sp_cmd_brightness_global_into_packet(
|
||||||
command: NonNull<GlobalBrightnessCommand>,
|
command: NonNull<GlobalBrightnessCommand>,
|
||||||
) -> *mut Packet {
|
) -> NonNull<Packet> {
|
||||||
heap_move_ok(unsafe { heap_remove(command) }.try_into())
|
heap_move_nonnull(unsafe { heap_remove(command) }.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Clones an [GlobalBrightnessCommand] instance.
|
||||||
|
///
|
||||||
|
/// returns: a new [GlobalBrightnessCommand] instance.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_cmd_brightness_global_clone(
|
pub unsafe extern "C" fn sp_cmd_brightness_global_clone(
|
||||||
command: NonNull<GlobalBrightnessCommand>,
|
command: NonNull<GlobalBrightnessCommand>,
|
||||||
|
|
|
@ -25,10 +25,14 @@
|
||||||
//! }
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
|
/// Functions related to commands.
|
||||||
pub mod commands;
|
pub mod commands;
|
||||||
|
/// Functions related to [servicepoint::Bitmap], [servicepoint::CharGrid] and friends.
|
||||||
pub mod containers;
|
pub mod containers;
|
||||||
pub mod mem;
|
pub(crate) mod mem;
|
||||||
|
/// Functions related to [Packet].
|
||||||
pub mod packet;
|
pub mod packet;
|
||||||
|
/// Functions related to [UdpSocket].
|
||||||
pub mod udp;
|
pub mod udp;
|
||||||
|
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
|
@ -79,6 +79,8 @@ pub unsafe extern "C" fn sp_packet_serialize_to(
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Clones a [Packet].
|
/// Clones a [Packet].
|
||||||
|
///
|
||||||
|
/// returns: a new [Packet] instance.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sp_packet_clone(
|
pub unsafe extern "C" fn sp_packet_clone(
|
||||||
packet: NonNull<Packet>,
|
packet: NonNull<Packet>,
|
||||||
|
|
Loading…
Reference in a new issue