(serialdev: &str, arg: Option<u8>)
| 471 | } |
| 472 | |
| 473 | fn brightness_cmd(serialdev: &str, arg: Option<u8>) { |
| 474 | let mut port = serialport::new(serialdev, 115_200) |
| 475 | .timeout(SERIAL_TIMEOUT) |
| 476 | .open() |
| 477 | .expect("Failed to open port"); |
| 478 | |
| 479 | if let Some(brightness) = arg { |
| 480 | simple_cmd_port(&mut port, Command::Brightness, &[brightness]); |
| 481 | } else { |
| 482 | simple_cmd_port(&mut port, Command::Brightness, &[]); |
| 483 | |
| 484 | let mut response: Vec<u8> = vec![0; 32]; |
| 485 | port.read_exact(response.as_mut_slice()) |
| 486 | .expect("Found no data!"); |
| 487 | |
| 488 | let brightness: u8 = response[0]; |
| 489 | println!("Current brightness: {brightness}"); |
| 490 | } |
| 491 | } |
| 492 | |
| 493 | fn animate_cmd(serialdev: &str, arg: Option<bool>) { |
| 494 | let mut port = serialport::new(serialdev, 115_200) |
no test coverage detected