add hard reset

This commit is contained in:
Vinzenz Schroeter 2025-05-04 14:35:59 +02:00
parent 57181b508f
commit 3b30d061fa
2 changed files with 13 additions and 6 deletions

View file

@ -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(

View file

@ -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),