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 { heap_move_nonnull(GlobalBrightnessCommand::from(brightness)) } #[no_mangle] pub unsafe extern "C" fn sp_cmd_brightness_global_into_packet( command: NonNull, ) -> NonNull { 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, brightness: Brightness, ) { unsafe { command.as_mut().brightness = brightness; } } #[no_mangle] pub unsafe extern "C" fn sp_cmd_brightness_global_get( mut command: NonNull, ) -> Brightness { unsafe { command.as_mut().brightness } }