add hard reset
This commit is contained in:
parent
57181b508f
commit
3b30d061fa
|
@ -29,7 +29,10 @@ pub struct Cli {
|
|||
#[derive(clap::Parser, std::fmt::Debug)]
|
||||
pub enum Mode {
|
||||
#[command(visible_alias = "r", about = "Reset both pixels and brightness")]
|
||||
ResetEverything,
|
||||
Reset {
|
||||
#[arg(short, long, help = "hard reset screen")]
|
||||
force: bool,
|
||||
},
|
||||
#[command(visible_alias = "p")]
|
||||
Pixels {
|
||||
#[clap(subcommand)]
|
||||
|
@ -114,7 +117,7 @@ pub enum BrightnessCommand {
|
|||
#[clap(about = "Commands for sending text to the screen")]
|
||||
pub enum TextCommand {
|
||||
#[command(
|
||||
about = "Pipe text to the display, example: `journalctl | servicepoint-cli stream stdin`"
|
||||
about = "Pipe text to the display, example: `journalctl | servicepoint-cli text stdin`"
|
||||
)]
|
||||
Stdin {
|
||||
#[arg(
|
||||
|
|
12
src/main.rs
12
src/main.rs
|
@ -7,7 +7,7 @@ use crate::{
|
|||
};
|
||||
use clap::Parser;
|
||||
use log::debug;
|
||||
use servicepoint::{Brightness, UdpSocketExt};
|
||||
use servicepoint::{Brightness, HardResetCommand, UdpSocketExt};
|
||||
|
||||
mod brightness;
|
||||
mod cli;
|
||||
|
@ -32,9 +32,13 @@ fn main() {
|
|||
|
||||
pub fn execute_mode(mode: Mode, connection: UdpSocket) {
|
||||
match mode {
|
||||
Mode::ResetEverything => {
|
||||
brightness_set(&connection, Brightness::MAX);
|
||||
pixels_off(&connection);
|
||||
Mode::Reset{force} => {
|
||||
if force {
|
||||
connection.send_command(HardResetCommand).unwrap()
|
||||
} else {
|
||||
brightness_set(&connection, Brightness::MAX);
|
||||
pixels_off(&connection);
|
||||
}
|
||||
}
|
||||
Mode::Pixels { pixel_command } => pixels(&connection, pixel_command),
|
||||
Mode::Brightness { brightness_command } => brightness(&connection, brightness_command),
|
||||
|
|
Loading…
Reference in a new issue