mbed2 zad 5b

Dependencies:   LCD_DISCO_F429ZI mbed BSP_DISCO_F429ZI

Revision:
4:7855d3ab4c15
Parent:
0:d4dacd8a359b
diff -r e4d4cf43a2ca -r 7855d3ab4c15 main.cpp
--- a/main.cpp	Tue Jul 04 15:45:36 2017 +0000
+++ b/main.cpp	Mon Jun 08 21:49:36 2020 +0000
@@ -1,51 +1,54 @@
-#include "mbed.h"
-#include "LCD_DISCO_F429ZI.h"
+#include "Servo.h"
+#include "FunkcjeUART.h"
+#include "Tokeny.h"
+
+DigitalIn DetectorSignal(USER_BUTTON);
+Serial pc(USBTX, USBRX);
 
-LCD_DISCO_F429ZI lcd;
+unsigned char ucTokenNr;
+struct Token asToken[MAX_TOKEN_NR];
+struct Keyword asKeywordList[MAX_KEYWORD_NR] = 
+{
+    {ID, "id"},
+    {CAL, "callib"},
+    {GT, "goto"},
+    {ST, "step"}
+};
 
-DigitalOut led1(LED1);
+Servo MyServo;
 
 int main()
-{      
-    led1 = 1;
-  
-    BSP_LCD_SetFont(&Font20);
-    lcd.DisplayStringAt(0, LINE(1), (uint8_t *)"MBED EXAMPLE", CENTER_MODE);
-    wait(1);
-  
-    while(1)
-    {      
-      lcd.Clear(LCD_COLOR_BLUE);
-      lcd.SetBackColor(LCD_COLOR_BLUE);
-      lcd.SetTextColor(LCD_COLOR_WHITE);
-      wait(0.3);
-      lcd.DisplayStringAt(0, LINE(4), (uint8_t *)"DISCOVERY", CENTER_MODE);
-      lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"STM32F429ZI", CENTER_MODE);
-      wait(1);
-
-      lcd.Clear(LCD_COLOR_GREEN);
-      
-      lcd.SetTextColor(LCD_COLOR_BLUE);
-      lcd.FillRect(10, 20, 50, 50);
-      wait(0.1);
-      lcd.SetTextColor(LCD_COLOR_BROWN);
-      lcd.FillCircle(80, 80, 50);
-      wait(0.1);
-      lcd.SetTextColor(LCD_COLOR_YELLOW);
-      lcd.FillEllipse(150, 150, 50, 100);
-      wait(0.1);
-      lcd.SetTextColor(LCD_COLOR_RED);
-      lcd.FillCircle(200, 200, 40);
-      wait(1);
-
-      lcd.SetBackColor(LCD_COLOR_ORANGE);
-      lcd.SetTextColor(LCD_COLOR_CYAN);
-      BSP_LCD_SetFont(&Font24);
-      lcd.DisplayStringAt(0, LINE(7), (uint8_t *)"HAVE FUN !!!", CENTER_MODE);
-      wait(1);
-
-      led1 = !led1;
-      wait(0.5);
+{
+    char cString[MAX_KEYWORD_STRING_LTH];
+    while (true)
+    {
+        gets(cString, MAX_KEYWORD_STRING_LTH);
+        DecodeMsg(cString);
+        if((asToken[0].eType == KEYWORD) && (ucTokenNr > 0))
+        {
+            if((asToken[0].uValue.eKeyword == ID) && (ucTokenNr == 1))
+            {
+                puts("id anyidentifier", 16);
+            }
+            else if((asToken[0].uValue.eKeyword == CAL) && (ucTokenNr == 1))
+            {
+                puts("ok", 2);
+                MyServo.Callib();
+            }
+            else if((asToken[0].uValue.eKeyword == GT) && (asToken[1].eType == NUMBER))
+            {
+                puts("ok", 2);
+                MyServo.GoTo(asToken[1].uValue.uiNumber);
+            }
+            else if((asToken[0].uValue.eKeyword == ST) && (asToken[1].eType == NUMBER))
+            {
+                puts("ok", 2);
+                MyServo.GoTo(MyServo.uiCurrentPosition+asToken[1].uValue.uiNumber);             
+            }
+            else
+                puts("unknowncommand", 14);
+        }
+        else
+            puts("unknowncommand", 14);
     }
-}
-
+}
\ No newline at end of file