more commands

This commit is contained in:
Vinzenz Schroeter 2025-05-06 21:12:37 +02:00
parent 2165629bef
commit 4f0eca3ea0
9 changed files with 489 additions and 78 deletions

View file

@ -239,6 +239,54 @@ typedef struct Bitmap Bitmap;
*/
typedef struct BitmapCommand BitmapCommand;
/**
* Set the brightness of individual tiles in a rectangular area of the display.
*/
typedef struct BrightnessGridCommand BrightnessGridCommand;
/**
* Show text on the screen.
*
* The text is sent in the form of a 2D grid of UTF-8 encoded characters (the default encoding in rust).
*
* # Examples
*
* ```rust
* # use servicepoint::*;
* # let connection = FakeConnection;
* let grid = CharGrid::from("Hello,\nWorld!");
* connection.send_command(CharGridCommand { origin: Origin::ZERO, grid }).expect("send failed");
* ```
*/
typedef struct CharGridCommand CharGridCommand;
/**
* Show text on the screen.
*
* The text is sent in the form of a 2D grid of [CP-437] encoded characters.
*
* <div class="warning">You probably want to use [Command::Utf8Data] instead</div>
*
* # Examples
*
* ```rust
* # use servicepoint::*;
* # let connection = FakeConnection;
* let grid = CharGrid::from("Hello,\nWorld!");
* let grid = Cp437Grid::from(&grid);
* connection.send_command(Cp437GridCommand{ origin: Origin::ZERO, grid }).expect("send failed");
* ```
*
* ```rust
* # use servicepoint::*;
* # let connection = FakeConnection;
* let grid = Cp437Grid::load_ascii("Hello\nWorld", 5, false).unwrap();
* connection.send_command(Cp437GridCommand{ origin: Origin::new(2, 2), grid }).unwrap();
* ```
* [CP-437]: https://en.wikipedia.org/wiki/Code_page_437
*/
typedef struct Cp437GridCommand Cp437GridCommand;
/**
* This is a type only used by cbindgen to have a type for pointers.
*/
@ -961,6 +1009,10 @@ void sp_char_grid_set(CharGrid */*notnull*/ char_grid,
*/
size_t sp_char_grid_width(CharGrid */*notnull*/ char_grid);
BitmapCommand */*notnull*/ sp_cmd_bitmap_clone(BitmapCommand */*notnull*/ command);
void sp_cmd_bitmap_free(BitmapCommand */*notnull*/ command);
BitmapCommand */*notnull*/ sp_cmd_bitmap_from_bitmap(Bitmap */*notnull*/ bitmap);
/**
@ -1008,6 +1060,10 @@ void sp_cmd_bitmap_set_origin(BitmapCommand */*notnull*/ command,
size_t origin_x,
size_t origin_y);
BitVecCommand */*notnull*/ sp_cmd_bitvec_clone(BitVecCommand */*notnull*/ command);
void sp_cmd_bitvec_free(BitVecCommand */*notnull*/ command);
DisplayBitVec *sp_cmd_bitvec_get(BitVecCommand */*notnull*/ command);
CompressionCode sp_cmd_bitvec_get_compression(BitVecCommand */*notnull*/ command);
@ -1054,6 +1110,96 @@ void sp_cmd_bitvec_set_offset(BitVecCommand */*notnull*/ command,
void sp_cmd_bitvec_set_operation(BitVecCommand */*notnull*/ command,
BinaryOperation operation);
BrightnessGridCommand */*notnull*/ sp_cmd_brightness_grid_clone(BrightnessGridCommand */*notnull*/ command);
void sp_cmd_brightness_grid_free(BitmapCommand */*notnull*/ command);
BrightnessGridCommand */*notnull*/ sp_cmd_brightness_grid_from_grid(BrightnessGrid */*notnull*/ grid);
BrightnessGrid *sp_cmd_brightness_grid_get(BrightnessGridCommand */*notnull*/ command);
void sp_cmd_brightness_grid_get_origin(BrightnessGridCommand */*notnull*/ command,
size_t */*notnull*/ origin_x,
size_t */*notnull*/ origin_y);
Packet *sp_cmd_brightness_grid_into_packet(BrightnessGridCommand */*notnull*/ command);
TypedCommand */*notnull*/ sp_cmd_brightness_grid_into_typed(BrightnessGridCommand */*notnull*/ command);
BrightnessGridCommand */*notnull*/ sp_cmd_brightness_grid_new(BrightnessGrid */*notnull*/ grid,
size_t origin_x,
size_t origin_y);
/**
* Moves the provided bitmap to be contained in the command.
*/
void sp_cmd_brightness_grid_set(BrightnessGridCommand */*notnull*/ command,
BrightnessGrid */*notnull*/ grid);
void sp_cmd_brightness_grid_set_origin(BrightnessGridCommand */*notnull*/ command,
size_t origin_x,
size_t origin_y);
CharGridCommand */*notnull*/ sp_cmd_char_grid_clone(CharGridCommand */*notnull*/ command);
void sp_cmd_char_grid_free(BitmapCommand */*notnull*/ command);
CharGridCommand */*notnull*/ sp_cmd_char_grid_from_grid(CharGrid */*notnull*/ grid);
CharGrid *sp_cmd_char_grid_get(CharGridCommand */*notnull*/ command);
void sp_cmd_char_grid_get_origin(CharGridCommand */*notnull*/ command,
size_t */*notnull*/ origin_x,
size_t */*notnull*/ origin_y);
Packet *sp_cmd_char_grid_into_packet(CharGridCommand */*notnull*/ command);
TypedCommand */*notnull*/ sp_cmd_char_grid_into_typed(CharGridCommand */*notnull*/ command);
CharGridCommand */*notnull*/ sp_cmd_char_grid_new(CharGrid */*notnull*/ grid,
size_t origin_x,
size_t origin_y);
/**
* Moves the provided bitmap to be contained in the command.
*/
void sp_cmd_char_grid_set(CharGridCommand */*notnull*/ command,
CharGrid */*notnull*/ grid);
void sp_cmd_char_grid_set_origin(CharGridCommand */*notnull*/ command,
size_t origin_x,
size_t origin_y);
Cp437GridCommand */*notnull*/ sp_cmd_cp437_grid_clone(Cp437GridCommand */*notnull*/ command);
void sp_cmd_cp437_grid_free(BitmapCommand */*notnull*/ command);
Cp437GridCommand */*notnull*/ sp_cmd_cp437_grid_from_grid(Cp437Grid */*notnull*/ grid);
Cp437Grid *sp_cmd_cp437_grid_get(Cp437GridCommand */*notnull*/ command);
void sp_cmd_cp437_grid_get_origin(Cp437GridCommand */*notnull*/ command,
size_t */*notnull*/ origin_x,
size_t */*notnull*/ origin_y);
Packet *sp_cmd_cp437_grid_into_packet(Cp437GridCommand */*notnull*/ command);
TypedCommand */*notnull*/ sp_cmd_cp437_grid_into_typed(Cp437GridCommand */*notnull*/ command);
Cp437GridCommand */*notnull*/ sp_cmd_cp437_grid_new(Cp437Grid */*notnull*/ grid,
size_t origin_x,
size_t origin_y);
/**
* Moves the provided bitmap to be contained in the command.
*/
void sp_cmd_cp437_grid_set(Cp437GridCommand */*notnull*/ command,
Cp437Grid */*notnull*/ grid);
void sp_cmd_cp437_grid_set_origin(Cp437GridCommand */*notnull*/ command,
size_t origin_x,
size_t origin_y);
/**
* Set the brightness of individual tiles in a rectangular area of the display.
*