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)]
|
#[derive(clap::Parser, std::fmt::Debug)]
|
||||||
pub enum Mode {
|
pub enum Mode {
|
||||||
#[command(visible_alias = "r", about = "Reset both pixels and brightness")]
|
#[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")]
|
#[command(visible_alias = "p")]
|
||||||
Pixels {
|
Pixels {
|
||||||
#[clap(subcommand)]
|
#[clap(subcommand)]
|
||||||
|
@ -114,7 +117,7 @@ pub enum BrightnessCommand {
|
||||||
#[clap(about = "Commands for sending text to the screen")]
|
#[clap(about = "Commands for sending text to the screen")]
|
||||||
pub enum TextCommand {
|
pub enum TextCommand {
|
||||||
#[command(
|
#[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 {
|
Stdin {
|
||||||
#[arg(
|
#[arg(
|
||||||
|
|
12
src/main.rs
12
src/main.rs
|
@ -7,7 +7,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use servicepoint::{Brightness, UdpSocketExt};
|
use servicepoint::{Brightness, HardResetCommand, UdpSocketExt};
|
||||||
|
|
||||||
mod brightness;
|
mod brightness;
|
||||||
mod cli;
|
mod cli;
|
||||||
|
@ -32,9 +32,13 @@ fn main() {
|
||||||
|
|
||||||
pub fn execute_mode(mode: Mode, connection: UdpSocket) {
|
pub fn execute_mode(mode: Mode, connection: UdpSocket) {
|
||||||
match mode {
|
match mode {
|
||||||
Mode::ResetEverything => {
|
Mode::Reset{force} => {
|
||||||
brightness_set(&connection, Brightness::MAX);
|
if force {
|
||||||
pixels_off(&connection);
|
connection.send_command(HardResetCommand).unwrap()
|
||||||
|
} else {
|
||||||
|
brightness_set(&connection, Brightness::MAX);
|
||||||
|
pixels_off(&connection);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Mode::Pixels { pixel_command } => pixels(&connection, pixel_command),
|
Mode::Pixels { pixel_command } => pixels(&connection, pixel_command),
|
||||||
Mode::Brightness { brightness_command } => brightness(&connection, brightness_command),
|
Mode::Brightness { brightness_command } => brightness(&connection, brightness_command),
|
||||||
|
|
Loading…
Reference in a new issue