Skip to content

Commit

Permalink
On mac no override of carrier or duty cycle needed
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Young <[email protected]>
  • Loading branch information
seanyoung committed May 20, 2024
1 parent 54cb040 commit 89a626d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cir/src/bin/cir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,12 @@ struct TransmitIrp {
pronto: bool,

/// Set carrier in Hz, 0 for unmodulated
#[arg(long = "carrier", short = 'c', value_parser = value_parser!(i64).range(1..1_000_000), hide = true, help_heading = "DEVICE")]
#[cfg(target_os = "linux")]
#[arg(long = "carrier", short = 'c', value_parser = value_parser!(i64).range(1..1_000_000), help_heading = "DEVICE")]
carrier: Option<i64>,

/// Override duty cycle % (1 to 99)
#[cfg(target_os = "linux")]
#[arg(long = "duty-cycle", short = 'u', value_parser = value_parser!(u8).range(1..99), help_heading = "DEVICE")]
duty_cycle: Option<u8>,

Expand Down Expand Up @@ -377,10 +379,12 @@ struct TransmitRawIR {
rawir: Vec<String>,

/// Set carrier in Hz, 0 for unmodulated
#[arg(long = "carrier", short = 'c', value_parser = value_parser!(i64).range(1..1_000_000), hide = true, help_heading = "DEVICE")]
#[cfg(target_os = "linux")]
#[arg(long = "carrier", short = 'c', value_parser = value_parser!(i64).range(1..1_000_000), help_heading = "DEVICE")]
carrier: Option<i64>,

/// Set send duty cycle % (1 to 99)
#[cfg(target_os = "linux")]
#[arg(long = "duty-cycle", short = 'u', value_parser = value_parser!(u8).range(1..99), help_heading = "DEVICE")]
duty_cycle: Option<u8>,

Expand Down Expand Up @@ -444,10 +448,12 @@ enum Transmitables {
#[derive(Args, Debug)]
struct TransmitKeymap {
/// Override carrier in Hz, 0 for unmodulated
#[cfg(target_os = "linux")]
#[arg(long = "carrier", short = 'c', value_parser = value_parser!(i64).range(0..1_000_000), help_heading = "DEVICE")]
carrier: Option<i64>,

/// Override duty cycle % (1 to 99)
#[cfg(target_os = "linux")]
#[arg(long = "duty-cycle", short = 'u', value_parser = value_parser!(u8).range(1..99), help_heading = "DEVICE")]
duty_cycle: Option<u8>,

Expand Down
9 changes: 9 additions & 0 deletions cir/src/bin/commands/transmit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ fn encode_args(transmit: &crate::Transmit) -> Message {
}
};

#[allow(unused_mut)]
let mut m = if tx_irp.pronto {
match irp.encode_pronto(vars) {
Ok(p) => {
Expand All @@ -177,10 +178,12 @@ fn encode_args(transmit: &crate::Transmit) -> Message {
}
};

#[cfg(target_os = "linux")]
if tx_irp.carrier.is_some() {
m.carrier = tx_irp.carrier;
}

#[cfg(target_os = "linux")]
if tx_irp.duty_cycle.is_some() {
m.duty_cycle = tx_irp.duty_cycle;
}
Expand Down Expand Up @@ -223,11 +226,14 @@ fn encode_keymap(args: &crate::TransmitKeymap) -> Message {
let m = cir::keymap::encode(&remotes, args.remote.as_deref(), &codes, args.repeats);

match m {
#[allow(unused_mut)]
Ok(mut m) => {
#[cfg(target_os = "linux")]
if args.carrier.is_some() {
m.carrier = args.carrier;
}

#[cfg(target_os = "linux")]
if args.duty_cycle.is_some() {
m.duty_cycle = args.duty_cycle;
}
Expand Down Expand Up @@ -260,11 +266,14 @@ fn encode_lircd_conf(lircd: &crate::TransmitKeymap) -> Message {
let m = lircd_conf::encode(&remotes, lircd.remote.as_deref(), &codes, lircd.repeats);

match m {
#[allow(unused_mut)]
Ok(mut m) => {
#[cfg(target_os = "linux")]
if lircd.carrier.is_some() {
m.carrier = lircd.carrier;
}

#[cfg(target_os = "linux")]
if lircd.duty_cycle.is_some() {
m.duty_cycle = lircd.duty_cycle;
}
Expand Down

0 comments on commit 89a626d

Please sign in to comment.