Skip to content

Commit a81697f

Browse files
committed
Add new blink n times command and use it
1 parent 357946c commit a81697f

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

dbus-monitor/src/dbus_monitor.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ use clap::{Parser, Subcommand};
2222
fn handle_message(msg: &Message) {
2323
println!("Got message from DBus: {:?}", msg);
2424

25-
run_inputmodule_command(vec!["led-matrix", "--pattern", "all-on", "--blinking"]);
26-
// Can't seem to get to this second command
25+
run_inputmodule_command(vec!["led-matrix", "--pattern", "all-on", "--blink-n-times", "3"]);
2726
run_inputmodule_command(vec!["led-matrix", "--brightness", "0"]);
2827

2928
println!("Message handled");

inputmodule-control/src/inputmodule.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ pub fn serial_commands(args: &ClapCli) {
190190
if let Some(pattern) = ledmatrix_args.pattern {
191191
pattern_cmd(serialdev, pattern);
192192
}
193+
if let Some(blink_n_times_arg) = ledmatrix_args.blink_n_times {
194+
blink_n_cmd(&serialdevs, blink_n_times_arg);
195+
}
193196
if ledmatrix_args.all_brightnesses {
194197
all_brightnesses_cmd(serialdev);
195198
}
@@ -556,6 +559,16 @@ fn blinking_cmd(serialdevs: &Vec<String>) {
556559
}
557560
}
558561

562+
fn blink_n_cmd(serialdevs: &Vec<String>, blink_n_times: u8) {
563+
let duration = Duration::from_millis(500);
564+
for _ in 0..blink_n_times {
565+
simple_cmd_multiple(serialdevs, Command::Brightness, &[0]);
566+
thread::sleep(duration);
567+
simple_cmd_multiple(serialdevs, Command::Brightness, &[200]);
568+
thread::sleep(duration);
569+
}
570+
}
571+
559572
fn breathing_cmd(serialdevs: &Vec<String>) {
560573
loop {
561574
// Go quickly from 250 to 50

inputmodule-control/src/ledmatrix.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ pub struct LedMatrixSubcommand {
7070
#[arg(long)]
7171
pub blinking: bool,
7272

73+
/// Blink the current pattern once a second, n times
74+
#[arg(long)]
75+
pub blink_n_times: Option<u8>,
76+
7377
/// Breathing brightness of the current pattern
7478
#[arg(long)]
7579
pub breathing: bool,

0 commit comments

Comments
 (0)