45 lines
1.3 KiB
Rust
45 lines
1.3 KiB
Rust
use crate::{
|
|
macros::{wrap_clone, wrap_free},
|
|
mem::{heap_move_nonnull, heap_remove},
|
|
};
|
|
use servicepoint::{Brightness, GlobalBrightnessCommand, Packet};
|
|
use std::ptr::NonNull;
|
|
|
|
/// Set the brightness of all tiles to the same value.
|
|
///
|
|
/// Returns: a new [GlobalBrightnessCommand] instance.
|
|
#[no_mangle]
|
|
pub unsafe extern "C" fn sp_cmd_brightness_global_new(
|
|
brightness: Brightness,
|
|
) -> NonNull<GlobalBrightnessCommand> {
|
|
heap_move_nonnull(GlobalBrightnessCommand::from(brightness))
|
|
}
|
|
|
|
#[no_mangle]
|
|
pub unsafe extern "C" fn sp_cmd_brightness_global_into_packet(
|
|
command: NonNull<GlobalBrightnessCommand>,
|
|
) -> NonNull<Packet> {
|
|
heap_move_nonnull(unsafe { heap_remove(command) }.into())
|
|
}
|
|
|
|
wrap_clone!(sp_cmd_brightness_global::GlobalBrightnessCommand);
|
|
wrap_free!(sp_cmd_brightness_global::GlobalBrightnessCommand);
|
|
|
|
/// Moves the provided bitmap to be contained in the command.
|
|
#[no_mangle]
|
|
pub unsafe extern "C" fn sp_cmd_brightness_global_set(
|
|
mut command: NonNull<GlobalBrightnessCommand>,
|
|
brightness: Brightness,
|
|
) {
|
|
unsafe {
|
|
command.as_mut().brightness = brightness;
|
|
}
|
|
}
|
|
|
|
#[no_mangle]
|
|
pub unsafe extern "C" fn sp_cmd_brightness_global_get(
|
|
mut command: NonNull<GlobalBrightnessCommand>,
|
|
) -> Brightness {
|
|
unsafe { command.as_mut().brightness }
|
|
}
|