Skip to content

Commit

Permalink
limit brightness error added
Browse files Browse the repository at this point in the history
  • Loading branch information
Roco-scientist committed Sep 1, 2021
1 parent 592ff80 commit 1bdb4ea
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,20 @@ pub fn arguments() -> Result<(String, String, u8, String, String), Box<dyn std::

// either set clock_brightness to input or defaul to 7
let clock_brightness = args.value_of("clock_brightness").unwrap().parse::<u8>()?;
// exit if the brightness is too high for TM1637
if clock_brightness > 7 && clock_type == "TM1637".to_string() {
panic!(
"Clock brightness limit of 7 for TM1637. Value input is {}",
clock_brightness
);
};
// exit if the brightness is too high for HT16K33
if clock_brightness > 9 && clock_type == "HT16K33".to_string() {
panic!(
"Clock brightness limit of 9 for HT16K33. Value input is {}",
clock_brightness
);
};
return Ok((
dir_code,
station,
Expand Down

0 comments on commit 1bdb4ea

Please sign in to comment.