rog-aura: reorganise per-key effects

This commit is contained in:
Luke D. Jones
2022-08-25 18:25:04 +12:00
parent 503aa20257
commit a8a99ac1d1
6 changed files with 177 additions and 129 deletions

View File

@@ -1,52 +1,56 @@
//! Using a combination of key-colour array plus a key layout to generate outputs.
use rog_aura::{keys::Key, Colour, PerKey, Sequences, Speed};
use rog_aura::{keys::Key, layouts::KeyLayout, ActionData, Colour, Sequences, Speed};
use rog_dbus::RogDbusClientBlocking;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let layout = KeyLayout::gx502_layout();
let (client, _) = RogDbusClientBlocking::new().unwrap();
let mut seq = Sequences::new();
let mut key = PerKey::new_breathe(Key::W, Colour(255, 127, 0), Colour(127, 0, 255), Speed::Med);
let mut key =
ActionData::new_breathe(Key::W, Colour(255, 127, 0), Colour(127, 0, 255), Speed::Med);
seq.push(key.clone());
key.key = Key::A;
key.set_key(Key::A);
seq.push(key.clone());
key.key = Key::S;
key.set_key(Key::S);
seq.push(key.clone());
key.key = Key::D;
key.set_key(Key::D);
seq.push(key.clone());
let mut key = PerKey::new_breathe(
let mut key = ActionData::new_breathe(
Key::Q,
Colour(127, 127, 127),
Colour(127, 255, 255),
Speed::Low,
);
seq.push(key.clone());
key.key = Key::E;
key.set_key(Key::E);
seq.push(key.clone());
let mut key = PerKey::new_breathe(
let mut key = ActionData::new_breathe(
Key::N1,
Colour(166, 127, 166),
Colour(127, 155, 20),
Speed::High,
);
key.key = Key::Tilde;
key.set_key(Key::Tilde);
seq.push(key.clone());
key.key = Key::N2;
key.set_key(Key::N2);
seq.push(key.clone());
key.key = Key::N3;
key.set_key(Key::N3);
seq.push(key.clone());
key.key = Key::N4;
key.set_key(Key::N4);
seq.push(key.clone());
loop {
seq.next_state();
seq.next_state(&layout);
let packets = seq.create_packets();
println!("{:#0x?}", &packets[0]);
client.proxies().led().per_key_raw(packets)?;
std::thread::sleep(std::time::Duration::from_millis(100));
std::thread::sleep(std::time::Duration::from_millis(300));
}
}