Fix anime exampels

This commit is contained in:
Luke D. Jones
2022-07-10 15:05:46 +12:00
parent ff76c356c5
commit f3f6fadfe2
8 changed files with 28 additions and 15 deletions

View File

@@ -1,6 +1,6 @@
use std::{env, error::Error, path::Path, process::exit};
use rog_anime::{AnimeDataBuffer, AnimeDiagonal};
use rog_anime::{usb::get_anime_type, AnimeDiagonal};
use rog_dbus::RogDbusClientBlocking;
fn main() -> Result<(), Box<dyn Error>> {
@@ -16,10 +16,12 @@ fn main() -> Result<(), Box<dyn Error>> {
let matrix =
AnimeDiagonal::from_png(Path::new(&args[1]), None, args[2].parse::<f32>().unwrap())?;
let anime_type = get_anime_type()?;
client
.proxies()
.anime()
.write(<AnimeDataBuffer>::from(&matrix))
.write(matrix.into_data_buffer(anime_type))
.unwrap();
Ok(())

View File

@@ -1,6 +1,6 @@
use std::{thread::sleep, time::Duration};
use rog_anime::{AnimeDataBuffer, AnimeDiagonal};
use rog_anime::{usb::get_anime_type, AnimeDiagonal};
use rog_dbus::RogDbusClientBlocking;
// In usable data:
@@ -25,8 +25,12 @@ fn main() {
}
}
let m = <AnimeDataBuffer>::from(&matrix);
client.proxies().anime().write(m).unwrap();
let anime_type = get_anime_type().unwrap();
client
.proxies()
.anime()
.write(matrix.into_data_buffer(anime_type))
.unwrap();
sleep(Duration::from_millis(300));
}
}

View File

@@ -1,6 +1,6 @@
use std::{env, path::Path, thread::sleep};
use rog_anime::{ActionData, ActionLoader, Sequences};
use rog_anime::{usb::get_anime_type, ActionData, ActionLoader, Sequences};
use rog_dbus::RogDbusClientBlocking;
fn main() {
@@ -14,7 +14,8 @@ fn main() {
let path = Path::new(&args[1]);
let brightness = args[2].parse::<f32>().unwrap();
let mut seq = Sequences::new();
let anime_type = get_anime_type().unwrap();
let mut seq = Sequences::new(anime_type);
seq.insert(
0,
&ActionLoader::AsusAnimation {

View File

@@ -1,4 +1,4 @@
use rog_anime::{AnimeDataBuffer, AnimeGrid};
use rog_anime::{usb::get_anime_type, AnimeDataBuffer, AnimeGrid};
use rog_dbus::RogDbusClientBlocking;
// In usable data:
@@ -8,7 +8,8 @@ use rog_dbus::RogDbusClientBlocking;
fn main() {
let (client, _) = RogDbusClientBlocking::new().unwrap();
let mut matrix = AnimeGrid::new(None);
let anime_type = get_anime_type().unwrap();
let mut matrix = AnimeGrid::new(anime_type);
let tmp = matrix.get_mut();
let mut i = 0;

View File

@@ -1,4 +1,4 @@
use rog_anime::AnimeDataBuffer;
use rog_anime::{usb::get_anime_type, AnimeDataBuffer};
use rog_dbus::RogDbusClientBlocking;
// In usable data:
@@ -6,7 +6,8 @@ use rog_dbus::RogDbusClientBlocking;
fn main() {
let (client, _) = RogDbusClientBlocking::new().unwrap();
let mut matrix = AnimeDataBuffer::new();
let anime_type = get_anime_type().unwrap();
let mut matrix = AnimeDataBuffer::new(anime_type);
matrix.data_mut()[1] = 100; // start = 1
for n in matrix.data_mut()[2..32].iter_mut() {
*n = 250;

View File

@@ -1,6 +1,7 @@
use std::{env, error::Error, path::Path, process::exit};
use rog_anime::{
usb::get_anime_type,
AnimeDataBuffer, {AnimeImage, Vec2},
};
use rog_dbus::RogDbusClientBlocking;
@@ -15,6 +16,7 @@ fn main() -> Result<(), Box<dyn Error>> {
exit(-1);
}
let anime_type = get_anime_type()?;
let matrix = AnimeImage::from_png(
Path::new(&args[1]),
args[2].parse::<f32>().unwrap(),
@@ -24,6 +26,7 @@ fn main() -> Result<(), Box<dyn Error>> {
args[5].parse::<f32>().unwrap(),
),
args[6].parse::<f32>().unwrap(),
anime_type,
)?;
client

View File

@@ -3,6 +3,7 @@ use std::{
};
use rog_anime::{
usb::get_anime_type,
AnimeDataBuffer, {AnimeImage, Vec2},
};
use rog_dbus::RogDbusClientBlocking;
@@ -17,6 +18,7 @@ fn main() -> Result<(), Box<dyn Error>> {
exit(-1);
}
let anime_type = get_anime_type()?;
let mut matrix = AnimeImage::from_png(
Path::new(&args[1]),
args[2].parse::<f32>().unwrap(),
@@ -26,6 +28,7 @@ fn main() -> Result<(), Box<dyn Error>> {
args[5].parse::<f32>().unwrap(),
),
args[6].parse::<f32>().unwrap(),
anime_type,
)?;
loop {

View File

@@ -1,5 +1,5 @@
use rog_aura::{GX502Layout, Key, KeyColourArray, KeyLayout};
use rog_dbus::RogDbusClient;
use rog_dbus::RogDbusClientBlocking;
use std::collections::LinkedList;
#[derive(Debug, Clone)]
@@ -52,7 +52,7 @@ impl Ball {
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let (dbus, _) = RogDbusClient::new()?;
let (dbus, _) = RogDbusClientBlocking::new()?;
let mut colours = KeyColourArray::new();
@@ -60,8 +60,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut balls = [Ball::new(2, 1, 12), Ball::new(4, 6, 12)];
dbus.proxies().led().init_effect()?;
let rows = layout.get_rows();
loop {
for (n, ball) in balls.iter_mut().enumerate() {