Skip to content

Commit

Permalink
Added --disable-fade-in option to set the 3 previously "unused" bits …
Browse files Browse the repository at this point in the history
…in byte FE and FF.

Setting those bits to 1 makes all examples from README.md working on my MSI B350 Tomahawk board.
  • Loading branch information
Bernhard Trummer committed Sep 30, 2018
1 parent 03adc32 commit 0a04c04
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ fn run<'a>(f: &mut fs::File, base_port: u16, matches: ArgMatches<'a>) -> Result<
let step_duration = matches.value_of("STEPDURATION").expect("bug: STEPDURATION argument")
.parse::<u16>()?;
let invs = matches.values_of("INVHALF").map(|i| i.collect()).unwrap_or(Vec::new());
let disable_fade_in = matches.values_of("DISABLE_FADE_IN").map(|i| i.collect()).unwrap_or(Vec::new());

// Check if indeed a NCT6795D
if !ignore {
Expand Down Expand Up @@ -146,9 +147,12 @@ fn run<'a>(f: &mut fs::File, base_port: u16, matches: ArgMatches<'a>) -> Result<
write_byte_to_cell(f, base_port, 0xfe, step_duration as u8)?;
let ff_val = (step_duration >> 8) as u8 & 1 |
0b10 | // if 0 disable lights on rgb header only, not on board
if invs.contains(&"b") { 0b10000 } else { 0 } |
if invs.contains(&"g") { 0b01000 } else { 0 } |
if invs.contains(&"r") { 0b00100 } else { 0 };
if invs.contains(&"b") { 0b00010000 } else { 0 } |
if invs.contains(&"g") { 0b00001000 } else { 0 } |
if invs.contains(&"r") { 0b00000100 } else { 0 } |
if disable_fade_in.contains(&"b") { 0b10000000 } else { 0 } |
if disable_fade_in.contains(&"g") { 0b01000000 } else { 0 } |
if disable_fade_in.contains(&"r") { 0b00100000 } else { 0 };
write_byte_to_cell(f, base_port, 0xff, ff_val)?;

write_colour(f, base_port, REDCELL, red)?;
Expand Down Expand Up @@ -234,6 +238,9 @@ fn main() {
.help("duration between blinks (from 0 to 6, 0 is always on, 6 is slowest)"))
.arg(Arg::with_name("DISABLE").long("disable").short("x")
.help("disable the RGB subsystem altogether"))
.arg(Arg::with_name("DISABLE_FADE_IN").long("disable-fade-in").multiple(true)
.takes_value(true).possible_values(&["r","g","b"])
.help("disable fade-in effect for specified channel(s)"))
.arg(Arg::with_name("IGNORECHECK").long("ignore-check")
.help("ignore the result of sI/O identification check"))
.arg(Arg::with_name("BASEPORT").long("base-port").default_value("4e")
Expand Down

0 comments on commit 0a04c04

Please sign in to comment.