servicepoint-binding-c/src/commands/bitvec_command.rs
2025-06-26 17:29:03 +02:00

47 lines
1.4 KiB
Rust

use crate::{
commands::wrap_command,
macros::{wrap_fields, wrap_functions},
mem::heap_move_nonnull,
};
use servicepoint::{
BinaryOperation, BitVecCommand, CompressionCode, DisplayBitVec, Offset,
};
use std::ptr::NonNull;
wrap_command!(BitVec);
wrap_fields!(BitVecCommand;
prop bitvec: DisplayBitVec { get mut; set move; };
prop offset: Offset { get; set; };
prop operation: BinaryOperation { get; set; };
prop compression: CompressionCode { get; set; };
);
wrap_functions!(associate BitVecCommand;
/// 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.
fn new(
bitvec: move NonNull<DisplayBitVec>,
offset: val usize,
operation: val BinaryOperation,
compression: val CompressionCode,
) -> NonNull<BitVecCommand> {
heap_move_nonnull(BitVecCommand {
bitvec,
offset,
operation,
compression,
})
};
);