From 5abdc630c83813caadb91d1a2abe2c96accebeea Mon Sep 17 00:00:00 2001 From: Carsten Keller Date: Sun, 9 Jun 2024 17:58:18 +0200 Subject: [PATCH] =?UTF-8?q?ist=20Kommandoi=20umgebaut=20sodass=20neben=20k?= =?UTF-8?q?onttinuierlicher=20Ausgabe=20auch=20der=20Intervall=20angegeben?= =?UTF-8?q?=20werden=20kann.=20Au=C3=9Ferdem=20kann=20man=20auch=20alles?= =?UTF-8?q?=20in=20neue=20Zeilen=20drucken.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/ElektronischeLast.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/Source/ElektronischeLast.cpp b/Source/ElektronischeLast.cpp index cf5eab5..844d742 100644 --- a/Source/ElektronischeLast.cpp +++ b/Source/ElektronischeLast.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -167,20 +168,29 @@ uint16_t set_solltrom(CLI_OutFunction pfvOutFunction, char *acCommands[], uint16 uint16_t ist_werte(CLI_OutFunction pfvOutFunction, char *acCommands[], uint16_t u16ArgCount) { static uint32_t last_call = 0U; - uint16_t recall = 0U; + bool recall = false; int32_t recall_time = 999; bool newline = false; if(u16ArgCount >= 1U) { - recall = (acCommands[0][0] == '-' && acCommands[0][1] == 'r' && acCommands[0][2] == '\0'); - } - if(u16ArgCount >= 2U) - { - recall_time = strtol(acCommands[1], NULL, 10); - newline = true; + for(uint32_t a = 0UL; a < u16ArgCount; a++) + { + if(strcmp(acCommands[a], "-r") == 0) + { + recall = 1U; + } + else if(strcmp(acCommands[a], "-p") == 0) + { + newline = true; + } + else if(strcmp(acCommands[a], "-t") == 0) + { + recall_time = strtol(acCommands[a + 1U], NULL, 10); + } + } } - if(((recall == 1U) && ((int32_t)(systick - last_call) > recall_time)) || recall == 0U) + if((recall && ((int32_t)(systick - last_call) > recall_time)) || !recall) { char buffer[64]; if(newline)