From 4962ce9009c4789f7909a62fe9d061c85cc8e3be Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 12 May 2022 20:26:12 +0200 Subject: [PATCH] Adding switch command. --- src/commands.c | 22 ++++++++++++++++++++-- src/include/commands.h | 2 ++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/commands.c b/src/commands.c index 7dd2253..3fae5a5 100644 --- a/src/commands.c +++ b/src/commands.c @@ -10,10 +10,15 @@ cmd_t command = { .index = 0 }; +void cmd_mirror_char(char c) +{ + printf("%c", c); +} + void cmd_collect_char(char c) { - command.buf[command.index] = c; - printf("%c", command.buf[command.index]); + command.buf[command.index] = c; + cmd_mirror_char(c); command.index++; @@ -42,6 +47,9 @@ void cmd_handle(cmd_t *command) if (0 == strcmp(tok1, "set")) cmd_handle_set(tok2, tok3); + + if (0 == strcmp(tok1, "switch")) + cmd_handle_switch(); } void cmd_handle_set(char *op1, char *op2) @@ -83,4 +91,14 @@ void cmd_handle_set(char *op1, char *op2) break; } } +} + +void cmd_handle_switch(void) +{ + int state = 0; + + PORTC ^= (1<