Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion asusctl/examples/anime-diag-png.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn main() -> Result<(), Box<dyn Error>> {

let anime_type = get_anime_type();

proxy.write(matrix.into_data_buffer(anime_type)?).unwrap();
proxy.write(&matrix.into_data_buffer(anime_type)?).unwrap();

Ok(())
}
13 changes: 10 additions & 3 deletions asusctl/examples/anime-diag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,16 @@ fn main() {
}

let anime_type = get_anime_type();
proxy
.write(matrix.into_data_buffer(anime_type).unwrap())
.unwrap();
match matrix.into_data_buffer(anime_type) {
Ok(buf) => {
if let Err(e) = proxy.write(&buf) {
eprintln!("Failed to write matrix frame to D-Bus: {e}");
}
}
Err(e) => {
eprintln!("Failed to convert matrix into data buffer: {e}");
}
}
sleep(Duration::from_millis(300));
}
}
2 changes: 1 addition & 1 deletion asusctl/examples/anime-gif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn main() {
for action in seq.iter() {
if let ActionData::Animation(frames) = action {
for frame in frames.frames() {
proxy.write(frame.frame().clone()).unwrap();
proxy.write(frame.frame()).unwrap();
sleep(frame.delay());
}
}
Expand Down
2 changes: 1 addition & 1 deletion asusctl/examples/anime-grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ fn main() {

let matrix = <AnimeDataBuffer>::try_from(matrix).unwrap();

proxy.write(matrix).unwrap();
proxy.write(&matrix).unwrap();
}
10 changes: 6 additions & 4 deletions asusctl/examples/anime-led-scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,16 @@ fn write_single_led(
if index < data.len() {
data[index] = brightness;
}
if let Err(e) = proxy.write(buffer) {
if let Err(e) = proxy.write(&buffer) {
eprintln!("Error writing to device: {}", e);
}
}

fn clear_display(proxy: &AnimeProxyBlocking, anime_type: AnimeType) {
let buffer = AnimeDataBuffer::new(anime_type);
let _ = proxy.write(buffer);
if let Err(e) = proxy.write(&buffer) {
eprintln!("Error writing to device: {}", e);
}
}

fn fill_display(proxy: &AnimeProxyBlocking, anime_type: AnimeType, brightness: u8) {
Expand All @@ -106,7 +108,7 @@ fn fill_display(proxy: &AnimeProxyBlocking, anime_type: AnimeType, brightness: u
for byte in data.iter_mut() {
*byte = brightness;
}
if let Err(e) = proxy.write(buffer) {
if let Err(e) = proxy.write(&buffer) {
eprintln!("Error writing to device: {}", e);
}
}
Expand All @@ -124,7 +126,7 @@ fn fill_range(
for i in start..=end.min(data.len().saturating_sub(1)) {
data[i] = brightness;
}
if let Err(e) = proxy.write(buffer) {
if let Err(e) = proxy.write(&buffer) {
eprintln!("Error writing to device: {}", e);
}
}
Expand Down
2 changes: 1 addition & 1 deletion asusctl/examples/anime-outline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,5 @@ fn main() {
matrix.data_mut()[1244] = 100; // end
println!("{:?}", matrix);

proxy.write(matrix).unwrap();
proxy.write(&matrix).unwrap();
}
2 changes: 1 addition & 1 deletion asusctl/examples/anime-png.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn main() -> Result<(), Box<dyn Error>> {
anime_type,
)?;

proxy.write(<AnimeDataBuffer>::try_from(&matrix)?).unwrap();
proxy.write(&<AnimeDataBuffer>::try_from(&matrix)?).unwrap();

Ok(())
}
2 changes: 1 addition & 1 deletion asusctl/examples/anime-spinning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn main() -> Result<(), Box<dyn Error>> {
}
matrix.update();

proxy.write(<AnimeDataBuffer>::try_from(&matrix)?).unwrap();
proxy.write(&<AnimeDataBuffer>::try_from(&matrix)?).unwrap();
sleep(Duration::from_micros(500));
}
}
10 changes: 5 additions & 5 deletions asusctl/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
if cmd.clear {
let data = vec![255u8; anime_type.data_length()];
let tmp = AnimeDataBuffer::from_vec(anime_type, data)?;
proxy.write(tmp)?;
proxy.write(&tmp)?;
}

if let Some(action) = cmd.command.as_ref() {
Expand All @@ -393,7 +393,7 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
anime_type,
)?;

proxy.write(<AnimeDataBuffer>::try_from(&matrix)?)?;
proxy.write(&<AnimeDataBuffer>::try_from(&matrix)?)?;
}
AnimeActions::PixelImage(image) => {
if image.path.is_empty() {
Expand All @@ -407,7 +407,7 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
let matrix =
AnimeDiagonal::from_png(Path::new(&image.path), image.bright, anime_type)?;

proxy.write(matrix.into_data_buffer(anime_type)?)?;
proxy.write(&matrix.into_data_buffer(anime_type)?)?;
}
AnimeActions::Gif(gif) => {
if gif.path.is_empty() {
Expand All @@ -431,7 +431,7 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
let mut loops = gif.loops as i32;
loop {
for frame in matrix.frames() {
proxy.write(frame.frame().clone())?;
proxy.write(frame.frame())?;
sleep(frame.delay());
}
if loops >= 0 {
Expand Down Expand Up @@ -461,7 +461,7 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
let mut loops = gif.loops as i32;
loop {
for frame in matrix.frames() {
proxy.write(frame.frame().clone())?;
proxy.write(frame.frame())?;
sleep(frame.delay());
}
if loops >= 0 {
Expand Down
4 changes: 2 additions & 2 deletions asusd-user/src/ctrl_anime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ impl CtrlAnimeInner<'static> {
return Ok(true); // Do safe exit
}
self.client
.write(output)
.write(&output)
.map_err(|e| AnimeError::Dbus(format!("{}", e)))
.map(|_| false)
});
}
ActionData::Image(image) => {
self.client.write(image.as_ref().clone()).ok();
self.client.write(image.as_ref()).ok();
}
ActionData::Pause(duration) => {
let start = Instant::now();
Expand Down
Loading