
mbed2 pre-final
Dependencies: LCD_DISCO_F429ZI mbed BSP_DISCO_F429ZI
main.cpp
- Committer:
- domino5740
- Date:
- 2020-06-15
- Revision:
- 5:7ca9ea4cde3a
- Parent:
- 4:a8494b656292
File content as of revision 5:7ca9ea4cde3a:
#include "mbed.h" #include "token_decoder.h" #include "servo.h" #include "uart.h" //#include "string.h" DigitalIn UserButton(USER_BUTTON); unsigned char ucTokenNr = 0; struct Token asToken[MAX_TOKEN_NR]; struct Keyword asKeywordList[MAX_KEYWORD_NR] = { {ID, "id"}, {CALIB, "calib"}, {GOTO, "goto"}, {STEP, "step"} }; Uart MyUart; TokenDecoder MyTokenDecoder; Servo MyServo; Serial pc(SERIAL_TX, SERIAL_RX); int main() { char cRecCharTab[MAX_KEYWORD_STRING_LTH]; while(1) { MyUart.gets(cRecCharTab, MAX_KEYWORD_STRING_LTH); MyTokenDecoder.DecodeMsg(cRecCharTab); if((ucTokenNr > 0) && (asToken[0].eType == KEYWORD)) { switch(asToken[0].uValue.eKeyword) { case ID: MyUart.puts("id anyidentifier", 20); break; case CALIB: MyServo.Callib(); MyUart.puts("ok", 5); break; case GOTO: MyServo.GoTo(asToken[1].uValue.uiNumber); MyUart.puts("ok", 5); break; case STEP: MyServo.GoTo(MyServo.uiCurrentPosition + asToken[1].uValue.uiNumber); MyUart.puts("ok", 5); break; } } else { MyUart.puts("unknowncommand", 15); } pc.putc('\n'); } }