use ddc::Ddc; use ddc_i2c::{I2cDeviceDdc, I2cDeviceEnumerator}; use ::ddcmqtt::StdError; fn main() -> StdError<()> { let args_: Vec<_> = std::env::args().skip(1).collect(); let args: Vec<&str> = args_.iter().map(|s| &**s).collect(); match args.as_slice() { ["brightness", arg] => ddc_all(0x10, arg.parse::()?), ["input", arg] => ddc_all(0x60, arg.parse::()?), _ => Err("Bad usage".into()), }?; Ok(()) } fn ddc_all(feat: u8, val: u16) -> StdError<()> { let mut m1 = ddc_i2c::from_i2c_device("/dev/i2c-20")?; let mut m2 = ddc_i2c::from_i2c_device("/dev/i2c-21")?; m1.set_vcp_feature(feat, val)?; m2.set_vcp_feature(feat, val)?; Ok(()) }