From 4fd54179cb610352ddd5b07ea9742994cc65aee8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Boh=C3=A1=C4=8Dek?= Date: Wed, 21 Jun 2023 12:13:00 +0200 Subject: [PATCH] feat: add hello world command --- src/commands/hello_world_command.rs | 32 +++++++++++++++++++++++++++++ src/main.rs | 3 +++ 2 files changed, 35 insertions(+) create mode 100644 src/commands/hello_world_command.rs diff --git a/src/commands/hello_world_command.rs b/src/commands/hello_world_command.rs new file mode 100644 index 0000000000000000000000000000000000000000..1842a49d51233a4a5a69f7f2741917a17ee0817c --- /dev/null +++ b/src/commands/hello_world_command.rs @@ -0,0 +1,32 @@ +use embedded_hal::serial::{Read, Write}; +use esp_println::{print, println}; +use crate::command_handler::{CommandData, CommandHandleError, SpecificCommandHandler}; +use crate::map::Map; + +pub struct HelloWorldCommand { + +} + +impl HelloWorldCommand { + pub fn new() -> Self { + Self {} + } +} + +impl SpecificCommandHandler for HelloWorldCommand +{ + fn handle(&self, command: &mut CommandData) -> Result<(), CommandHandleError> + { + print!("Hello world!"); + for c in &command.command.full[command.command.parsed_arguments[0].data.len()..] { + print!("{}", c); + } + println!("\r"); + + Ok(()) + } + + fn help(&self) -> &'static str { + " - prints Hello world! " + } +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 1949c9a237bbba95facdb06b0b580dad8ad92140..8a7f7669d15df9b8052d331f26b103e13485714d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -91,8 +91,11 @@ fn main() -> ! { let mut rgb_data: [RGB8; 72] = [RGB8 { r: 0, g: 0, b: 0 }; 72]; let mut map = map::Map::new(&map::INDEX_MAP, &mut rgb_data); + + let world_command = HelloWorldCommand::new(); let mut handler = CommandHandler::new( [ + ("HELLO_WORLD", &world_command), ], ['\0'; COMMAND_BUFFER], );