rog-aura: tested effects on TUF, works

This commit is contained in:
Luke D. Jones
2022-08-27 22:30:57 +12:00
parent 1a132d847f
commit 64322044ac
7 changed files with 73 additions and 60 deletions

View File

@@ -139,7 +139,7 @@ I'm unsure of how many laptops this works on, so please try it.
`led_type: PerZone` works on most zoned laptops but I've no idea if it works on unzoned. Please try it if you can.
Does not work for TUF laptops.
For TUF use `"Zone": "None"` (and yes this does mean an audio EQ can be done now).
`~/.config/rog/rog-user.cfg` contains a setting `"active_aura": "<FILENAME>"` where `<FILENAME>` is the name of the Aura config to use, located in the same directory and without the file postfix, e.g, `"active_anime": "aura-default"`
@@ -184,7 +184,7 @@ An Aura config itself is a file with contents:
"led_type": {
"Key": "N9"
},
"colour": [
"start_colour": [
0,
0,
255
@@ -197,7 +197,7 @@ An Aura config itself is a file with contents:
}
```
If your laptop supports multizone, `"led_type"` can also be `"PerZone": <one of the following>`
If your laptop supports multizone, `"led_type"` can also be `"Zone": <one of the following>`
- `"None"`
- `"KeyboardLeft"`
- `"KeyboardCenterLeft"`

View File

@@ -1,6 +1,6 @@
//! Using a combination of key-colour array plus a key layout to generate outputs.
use rog_aura::{keys::Key, layouts::KeyLayout, Colour, LedType, Sequences, Speed, Effect, Breathe};
use rog_aura::{keys::Key, layouts::KeyLayout, Breathe, Colour, Effect, LedType, Sequences, Speed};
use rog_dbus::RogDbusClientBlocking;
fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -9,8 +9,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let (client, _) = RogDbusClientBlocking::new().unwrap();
let mut seq = Sequences::new();
let mut key = Effect::Breathe(
Breathe::new(LedType::Key(Key::W),
let mut key = Effect::Breathe(Breathe::new(
LedType::Key(Key::W),
Colour(255, 127, 0),
Colour(127, 0, 255),
Speed::Med,
@@ -24,8 +24,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
key.set_led_type(LedType::Key(Key::D));
seq.push(key.clone());
let mut key = Effect::Breathe(
Breathe::new(
let mut key = Effect::Breathe(Breathe::new(
LedType::Key(Key::Q),
Colour(127, 127, 127),
Colour(127, 255, 255),
@@ -35,8 +34,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
key.set_led_type(LedType::Key(Key::E));
seq.push(key.clone());
let mut key = Effect::Breathe(
Breathe::new(
let mut key = Effect::Breathe(Breathe::new(
LedType::Key(Key::N1),
Colour(166, 127, 166),
Colour(127, 155, 20),

View File

@@ -1,6 +1,6 @@
//! Using a combination of key-colour array plus a key layout to generate outputs.
use rog_aura::{layouts::KeyLayout, Colour, LedType, PerZone, Sequences, Speed, Effect, Breathe};
use rog_aura::{layouts::KeyLayout, Breathe, Colour, Effect, LedType, PerZone, Sequences, Speed};
use rog_dbus::RogDbusClientBlocking;
fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -10,8 +10,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut seq = Sequences::new();
let zone = Effect::Breathe(
Breathe::new(
let zone = Effect::Breathe(Breathe::new(
LedType::Zone(PerZone::KeyboardLeft),
Colour(166, 127, 166),
Colour(127, 155, 20),
@@ -19,8 +18,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
));
seq.push(zone);
let zone = Effect::Breathe(
Breathe::new(
let zone = Effect::Breathe(Breathe::new(
LedType::Zone(PerZone::KeyboardCenterLeft),
Colour(16, 127, 255),
Colour(127, 15, 20),
@@ -28,8 +26,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
));
seq.push(zone);
let zone = Effect::Breathe(
Breathe::new(
let zone = Effect::Breathe(Breathe::new(
LedType::Zone(PerZone::LightbarRightCorner),
Colour(0, 255, 255),
Colour(255, 0, 255),

View File

@@ -67,45 +67,45 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
}
}
if supported.keyboard_led.per_key_led_mode {
if let Some(cfg) = config.active_aura {
let mut aura_config = UserAuraConfig::load(cfg)?;
// if supported.keyboard_led.per_key_led_mode {
if let Some(cfg) = config.active_aura {
let mut aura_config = UserAuraConfig::load(cfg)?;
// Find and load a matching layout for laptop
let mut file = OpenOptions::new()
.read(true)
.open(PathBuf::from(BOARD_NAME))
.map_err(|e| {
println!("{BOARD_NAME}, {e}");
e
})?;
let mut board_name = String::new();
file.read_to_string(&mut board_name)?;
// Find and load a matching layout for laptop
let mut file = OpenOptions::new()
.read(true)
.open(PathBuf::from(BOARD_NAME))
.map_err(|e| {
println!("{BOARD_NAME}, {e}");
e
})?;
let mut board_name = String::new();
file.read_to_string(&mut board_name)?;
let layout = KeyLayout::find_layout(board_name.as_str(), PathBuf::from(DATA_DIR))
.map_err(|e| {
println!("{BOARD_NAME}, {e}");
})
.unwrap_or(KeyLayout::ga401_layout());
let layout = KeyLayout::find_layout(board_name.as_str(), PathBuf::from(DATA_DIR))
.map_err(|e| {
println!("{BOARD_NAME}, {e}");
})
.unwrap_or(KeyLayout::ga401_layout());
executor
.spawn(async move {
// Create server
let (client, _) = RogDbusClientBlocking::new().unwrap();
// let connection = Connection::session().await.unwrap();
// connection.request_name(DBUS_NAME).await.unwrap();
executor
.spawn(async move {
// Create server
let (client, _) = RogDbusClientBlocking::new().unwrap();
// let connection = Connection::session().await.unwrap();
// connection.request_name(DBUS_NAME).await.unwrap();
loop {
aura_config.aura.next_state(&layout);
let packets = aura_config.aura.create_packets();
loop {
aura_config.aura.next_state(&layout);
let packets = aura_config.aura.create_packets();
client.proxies().led().per_key_raw(packets).unwrap();
std::thread::sleep(std::time::Duration::from_millis(60));
}
})
.detach();
}
client.proxies().led().per_key_raw(packets).unwrap();
std::thread::sleep(std::time::Duration::from_millis(60));
}
})
.detach();
}
// }
loop {
smol::block_on(executor.tick());

View File

@@ -5,7 +5,7 @@ use std::{
};
use rog_anime::{ActionLoader, AnimTime, AnimeType, Fade, Sequences, Vec2};
use rog_aura::{keys::Key, Breathe, Colour, Effect, LedType, Speed, Static, Flicker};
use rog_aura::{keys::Key, Breathe, Colour, Effect, Flicker, LedType, Speed, Static};
use serde::de::DeserializeOwned;
use serde_derive::{Deserialize, Serialize};
@@ -224,7 +224,12 @@ impl Default for UserAuraConfig {
key.set_led_type(LedType::Key(Key::Esc));
seq.push(key);
let key = Effect::Flicker(Flicker::new(LedType::Key(Key::N9), Colour(0, 0, 255), 80, 40));
let key = Effect::Flicker(Flicker::new(
LedType::Key(Key::N9),
Colour(0, 0, 255),
80,
40,
));
seq.push(key.clone());
Self {

View File

@@ -321,6 +321,13 @@ impl CtrlKbdLed {
for row in effect.iter() {
hid_raw.write_bytes(row)?;
}
} else if let LEDNode::KbdLed(tuf) = &self.led_node {
for row in effect.iter() {
let r = row[9];
let g = row[10];
let b = row[11];
tuf.set_kbd_rgb_mode(&[0, 0, r, g, b, 0])?;
}
}
self.flip_effect_write = !self.flip_effect_write;
}

View File

@@ -178,12 +178,13 @@ impl EffectState for Breathe {
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Flicker {
led_type: LedType,
/// The starting colour
colour: Colour,
start_colour: Colour,
max_percentage: u8,
min_percentage: u8,
#[serde(skip)]
count: u8,
#[serde(skip)]
colour: Colour,
}
impl Flicker {
@@ -194,6 +195,7 @@ impl Flicker {
count: 4,
max_percentage,
min_percentage,
start_colour: colour,
}
}
}
@@ -204,9 +206,13 @@ impl EffectState for Flicker {
max_percentage,
min_percentage,
colour,
start_colour,
..
} = self;
if self.count == 0 {
self.count = 4;
}
self.count -= 1;
if self.count != 0 {
return;
@@ -214,15 +220,15 @@ impl EffectState for Flicker {
// TODO: make a "percentage" method on Colour.
let max_light = Colour(
(colour.0 as f32 / 100.0 * *max_percentage as f32) as u8,
(colour.1 as f32 / 100.0 * *max_percentage as f32) as u8,
(colour.2 as f32 / 100.0 * *max_percentage as f32) as u8,
(start_colour.0 as f32 / 100.0 * *max_percentage as f32) as u8,
(start_colour.1 as f32 / 100.0 * *max_percentage as f32) as u8,
(start_colour.2 as f32 / 100.0 * *max_percentage as f32) as u8,
);
// min light is a percentage of the set colour
let min_light = Colour(
(colour.0 as f32 / 100.0 * *min_percentage as f32) as u8,
(colour.1 as f32 / 100.0 * *min_percentage as f32) as u8,
(colour.2 as f32 / 100.0 * *min_percentage as f32) as u8,
(start_colour.0 as f32 / 100.0 * *min_percentage as f32) as u8,
(start_colour.1 as f32 / 100.0 * *min_percentage as f32) as u8,
(start_colour.2 as f32 / 100.0 * *min_percentage as f32) as u8,
);
// Convert the 255 to percentage