add first specific commands
This commit is contained in:
parent
84adf166a9
commit
373725c648
7 changed files with 360 additions and 66 deletions
|
@ -179,6 +179,22 @@ enum CompressionCode
|
|||
typedef uint16_t CompressionCode;
|
||||
#endif // __cplusplus
|
||||
|
||||
/**
|
||||
* 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 [`BinaryOperation`] will be applied on the display comparing old and sent bit.
|
||||
*
|
||||
* `new_bit = old_bit op sent_bit`
|
||||
*
|
||||
* For example, [`BinaryOperation::Or`] can be used to turn on some pixels without affecting other pixels.
|
||||
*
|
||||
* The contained [`DisplayBitVec`] is always uncompressed.
|
||||
*/
|
||||
typedef struct BitVecCommand BitVecCommand;
|
||||
|
||||
/**
|
||||
* A fixed-size 2D grid of booleans.
|
||||
*
|
||||
|
@ -196,6 +212,38 @@ typedef uint16_t CompressionCode;
|
|||
*/
|
||||
typedef struct Bitmap Bitmap;
|
||||
|
||||
/**
|
||||
* Overwrites a rectangular region of pixels.
|
||||
*
|
||||
* Origin coordinates must be divisible by 8.
|
||||
*
|
||||
* # Examples
|
||||
*
|
||||
* ```rust
|
||||
* # use servicepoint::*;
|
||||
* # let connection = FakeConnection;
|
||||
* #
|
||||
* let mut bitmap = Bitmap::max_sized();
|
||||
* // draw something to the pixels here
|
||||
* # bitmap.set(2, 5, true);
|
||||
*
|
||||
* // create command to send pixels
|
||||
* let command = BitmapCommand {
|
||||
* bitmap,
|
||||
* origin: Origin::ZERO,
|
||||
* compression: CompressionCode::Uncompressed
|
||||
* };
|
||||
*
|
||||
* connection.send_command(command).expect("send failed");
|
||||
* ```
|
||||
*/
|
||||
typedef struct BitmapCommand BitmapCommand;
|
||||
|
||||
/**
|
||||
* This is a type only used by cbindgen to have a type for pointers.
|
||||
*/
|
||||
typedef struct DisplayBitVec DisplayBitVec;
|
||||
|
||||
/**
|
||||
* The raw packet.
|
||||
*
|
||||
|
@ -348,6 +396,11 @@ typedef uint8_t Brightness;
|
|||
*/
|
||||
typedef ValueGrid_char CharGrid;
|
||||
|
||||
/**
|
||||
* Type alias for documenting the meaning of the u16 in enum values
|
||||
*/
|
||||
typedef size_t Offset;
|
||||
|
||||
/**
|
||||
* A grid containing codepage 437 characters.
|
||||
*
|
||||
|
@ -908,17 +961,64 @@ void sp_char_grid_set(CharGrid */*notnull*/ char_grid,
|
|||
*/
|
||||
size_t sp_char_grid_width(CharGrid */*notnull*/ char_grid);
|
||||
|
||||
BitmapCommand */*notnull*/ sp_cmd_bitmap_from_bitmap(Bitmap */*notnull*/ bitmap);
|
||||
|
||||
/**
|
||||
* Returns a pointer to the provided `BitmapCommand`.
|
||||
*
|
||||
* # Safety
|
||||
*
|
||||
* - The returned bitmap inherits the lifetime of the command in which it is contained.
|
||||
* - The returned pointer may not be used in a function that consumes the instance, e.g. to create a command.
|
||||
*/
|
||||
Bitmap */*notnull*/ sp_cmd_bitmap_get(BitmapCommand */*notnull*/ command);
|
||||
|
||||
CompressionCode sp_cmd_bitmap_get_compression(BitmapCommand */*notnull*/ command);
|
||||
|
||||
void sp_cmd_bitmap_get_origin(BitmapCommand */*notnull*/ command,
|
||||
size_t */*notnull*/ origin_x,
|
||||
size_t */*notnull*/ origin_y);
|
||||
|
||||
Packet *sp_cmd_bitmap_into_packet(BitmapCommand */*notnull*/ command);
|
||||
|
||||
TypedCommand */*notnull*/ sp_cmd_bitmap_into_typed(BitmapCommand */*notnull*/ command);
|
||||
|
||||
/**
|
||||
* Sets a window of pixels to the specified values.
|
||||
*
|
||||
* The passed [Bitmap] gets consumed.
|
||||
*
|
||||
* Returns: a new [servicepoint::BitmapCommand] instance.
|
||||
* Returns: a new [BitmapCommand] instance.
|
||||
*/
|
||||
TypedCommand *sp_command_bitmap(size_t x,
|
||||
size_t y,
|
||||
Bitmap */*notnull*/ bitmap,
|
||||
CompressionCode compression);
|
||||
BitmapCommand */*notnull*/ sp_cmd_bitmap_new(Bitmap */*notnull*/ bitmap,
|
||||
size_t origin_x,
|
||||
size_t origin_y,
|
||||
CompressionCode compression);
|
||||
|
||||
/**
|
||||
* Moves the provided bitmap to be contained in the command.
|
||||
*/
|
||||
void sp_cmd_bitmap_set(BitmapCommand */*notnull*/ command,
|
||||
Bitmap */*notnull*/ bitmap);
|
||||
|
||||
void sp_cmd_bitmap_set_compression(BitmapCommand */*notnull*/ command,
|
||||
CompressionCode compression);
|
||||
|
||||
void sp_cmd_bitmap_set_origin(BitmapCommand */*notnull*/ command,
|
||||
size_t origin_x,
|
||||
size_t origin_y);
|
||||
|
||||
DisplayBitVec *sp_cmd_bitvec_get(BitVecCommand */*notnull*/ command);
|
||||
|
||||
CompressionCode sp_cmd_bitvec_get_compression(BitVecCommand */*notnull*/ command);
|
||||
|
||||
Offset sp_cmd_bitvec_get_offset(BitVecCommand */*notnull*/ command);
|
||||
|
||||
BinaryOperation sp_cmd_bitvec_get_operation(BitVecCommand */*notnull*/ command);
|
||||
|
||||
Packet *sp_cmd_bitvec_into_packet(BitVecCommand */*notnull*/ command);
|
||||
|
||||
TypedCommand */*notnull*/ sp_cmd_bitvec_into_typed(BitVecCommand */*notnull*/ command);
|
||||
|
||||
/**
|
||||
* Set pixel data starting at the pixel offset on screen.
|
||||
|
@ -932,12 +1032,27 @@ TypedCommand *sp_command_bitmap(size_t x,
|
|||
*
|
||||
* For example, [`BinaryOperation::Or`] can be used to turn on some pixels without affecting other pixels.
|
||||
*
|
||||
* The contained [`BitVecU8Msb0`] is always uncompressed.
|
||||
* The contained [`DisplayBitVec`] is always uncompressed.
|
||||
*/
|
||||
TypedCommand *sp_command_bitvec(size_t offset,
|
||||
SPBitVec */*notnull*/ bit_vec,
|
||||
CompressionCode compression,
|
||||
BinaryOperation operation);
|
||||
BitVecCommand */*notnull*/ sp_cmd_bitvec_new(DisplayBitVec */*notnull*/ bitvec,
|
||||
size_t offset,
|
||||
BinaryOperation operation,
|
||||
CompressionCode compression);
|
||||
|
||||
/**
|
||||
* Moves the provided bitmap to be contained in the command.
|
||||
*/
|
||||
void sp_cmd_bitvec_set(BitVecCommand */*notnull*/ command,
|
||||
DisplayBitVec */*notnull*/ bitvec);
|
||||
|
||||
void sp_cmd_bitvec_set_compression(BitVecCommand */*notnull*/ command,
|
||||
CompressionCode compression);
|
||||
|
||||
void sp_cmd_bitvec_set_offset(BitVecCommand */*notnull*/ command,
|
||||
Offset offset);
|
||||
|
||||
void sp_cmd_bitvec_set_operation(BitVecCommand */*notnull*/ command,
|
||||
BinaryOperation operation);
|
||||
|
||||
/**
|
||||
* Set the brightness of individual tiles in a rectangular area of the display.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue