a

Dependencies:   LCD_DISCO_F429ZI mbed BSP_DISCO_F429ZI

Committer:
matis755
Date:
Thu May 21 11:03:32 2020 +0000
Revision:
4:e48aee3e8d09
Parent:
3:6fc7976cc5bf
Child:
5:3c19c3ae6286
Ready without GUI;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
matis755 0:e65dff476cf0 1 #include "mbed.h"
matis755 4:e48aee3e8d09 2 #include "decoder.h"
matis755 4:e48aee3e8d09 3 #include "uart.h"
matis755 4:e48aee3e8d09 4 #include "stepper.h"
matis755 0:e65dff476cf0 5
matis755 2:8788d711db7e 6
matis755 0:e65dff476cf0 7 DigitalOut led_green(LED1);
matis755 0:e65dff476cf0 8 DigitalOut led_red(LED2);
matis755 0:e65dff476cf0 9
matis755 2:8788d711db7e 10
matis755 2:8788d711db7e 11 int main() {
matis755 4:e48aee3e8d09 12 Decoder MyDecoder;
matis755 4:e48aee3e8d09 13 Uart MyUart;
matis755 4:e48aee3e8d09 14 Stepper MyStepper;
matis755 4:e48aee3e8d09 15
matis755 2:8788d711db7e 16 char cTablica[BUFFER_SIZE];
matis755 4:e48aee3e8d09 17 char cCorrectResponse[] = "ok\n";
matis755 4:e48aee3e8d09 18 char cUnknownKeyword[] = "unknowncommand\n";
matis755 4:e48aee3e8d09 19 char cIdentifier[] = "id anyidentyfier\n";
matis755 2:8788d711db7e 20
matis755 2:8788d711db7e 21 while(1){
matis755 4:e48aee3e8d09 22 if(!MyUart.gets(cTablica, BUFFER_SIZE)){
matis755 4:e48aee3e8d09 23 MyDecoder.DecodeMsg(cTablica);
matis755 4:e48aee3e8d09 24 if ((MyDecoder.eGetTokenType(0) == KEYWORD) & (MyDecoder.GetTokenCnt() != 0)){
matis755 4:e48aee3e8d09 25 switch (MyDecoder.eGetKeyword(0)){
matis755 4:e48aee3e8d09 26 case (ID):
matis755 4:e48aee3e8d09 27 MyUart.puts(cIdentifier, BUFFER_SIZE);
matis755 4:e48aee3e8d09 28 break;
matis755 3:6fc7976cc5bf 29 case (CLB):
matis755 3:6fc7976cc5bf 30 led_green = !led_green;
matis755 4:e48aee3e8d09 31 MyStepper.Callib();
matis755 4:e48aee3e8d09 32 MyUart.puts(cCorrectResponse, BUFFER_SIZE);
matis755 3:6fc7976cc5bf 33 break;
matis755 3:6fc7976cc5bf 34 case (GT):
matis755 3:6fc7976cc5bf 35 led_red = !led_red;
matis755 4:e48aee3e8d09 36 MyStepper.Goto(4);
matis755 4:e48aee3e8d09 37 MyUart.puts(cCorrectResponse, BUFFER_SIZE);
matis755 4:e48aee3e8d09 38 break;
matis755 4:e48aee3e8d09 39 case (ST):
matis755 4:e48aee3e8d09 40 MyStepper.Step(5);
matis755 4:e48aee3e8d09 41 MyUart.puts(cCorrectResponse, BUFFER_SIZE);
matis755 3:6fc7976cc5bf 42 break;
matis755 3:6fc7976cc5bf 43 default:
matis755 3:6fc7976cc5bf 44 break;
matis755 3:6fc7976cc5bf 45 }
matis755 2:8788d711db7e 46 }
matis755 4:e48aee3e8d09 47 else {
matis755 4:e48aee3e8d09 48 MyUart.puts(cUnknownKeyword, BUFFER_SIZE);
matis755 4:e48aee3e8d09 49 }
matis755 0:e65dff476cf0 50 }
matis755 0:e65dff476cf0 51 }
matis755 0:e65dff476cf0 52 }