~ruther/map-led-strip

ref: ea65b1edebc47b88e36ebbec9e67f8449b39950f map-led-strip/src/commands/reset_command.rs -rw-r--r-- 649 bytes
ea65b1ed — František Boháček fix: replace - with _ in map 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use crate::commands::command_handler::{CommandData, CommandHandleError, SpecificCommandHandler};
use crate::commands::command_handler::CommandHandleError::WrongArguments;

pub struct ResetCommand {}

impl ResetCommand {
    pub fn new() -> Self {
        Self {}
    }
}

impl SpecificCommandHandler for ResetCommand {
    fn handle(&self, command: &mut CommandData) -> Result<(), CommandHandleError> {
        for led in command.map.get_map_mut() {
            led.r = 0;
            led.g = 0;
            led.b = 0;
        }
        Ok(())
    }

    fn help(&self) -> &'static str {
        "- Resets the board, all leds set to 0, 0, 0"
    }
}