~ruther/map-led-strip

ref: ca6d33bf252720b350b50b4dabba7a4a23bdf09f map-led-strip/src/commands/reset_command.rs -rw-r--r-- 649 bytes
ca6d33bf — František Boháček feat: add all command 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"
    }
}
Do not follow this link