AGH UST MBED part 2
Dependencies: LCD_DISCO_F429ZI mbed BSP_DISCO_F429ZI
main.cpp
- Committer:
- matis755
- Date:
- 2020-05-21
- Revision:
- 4:e48aee3e8d09
- Parent:
- 3:6fc7976cc5bf
- Child:
- 5:3c19c3ae6286
File content as of revision 4:e48aee3e8d09:
#include "mbed.h" #include "decoder.h" #include "uart.h" #include "stepper.h" DigitalOut led_green(LED1); DigitalOut led_red(LED2); int main() { Decoder MyDecoder; Uart MyUart; Stepper MyStepper; char cTablica[BUFFER_SIZE]; char cCorrectResponse[] = "ok\n"; char cUnknownKeyword[] = "unknowncommand\n"; char cIdentifier[] = "id anyidentyfier\n"; while(1){ if(!MyUart.gets(cTablica, BUFFER_SIZE)){ MyDecoder.DecodeMsg(cTablica); if ((MyDecoder.eGetTokenType(0) == KEYWORD) & (MyDecoder.GetTokenCnt() != 0)){ switch (MyDecoder.eGetKeyword(0)){ case (ID): MyUart.puts(cIdentifier, BUFFER_SIZE); break; case (CLB): led_green = !led_green; MyStepper.Callib(); MyUart.puts(cCorrectResponse, BUFFER_SIZE); break; case (GT): led_red = !led_red; MyStepper.Goto(4); MyUart.puts(cCorrectResponse, BUFFER_SIZE); break; case (ST): MyStepper.Step(5); MyUart.puts(cCorrectResponse, BUFFER_SIZE); break; default: break; } } else { MyUart.puts(cUnknownKeyword, BUFFER_SIZE); } } } }