AGH UST MBED part 2
Dependencies: LCD_DISCO_F429ZI mbed BSP_DISCO_F429ZI
main.cpp@5:3c19c3ae6286, 2020-05-22 (annotated)
- Committer:
- matis755
- Date:
- Fri May 22 07:21:44 2020 +0000
- Revision:
- 5:3c19c3ae6286
- Parent:
- 4:e48aee3e8d09
Add GUI,; Get ready to deploy
Who changed what in which revision?
User | Revision | Line number | New 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 | int main() { |
matis755 | 4:e48aee3e8d09 | 7 | Decoder MyDecoder; |
matis755 | 4:e48aee3e8d09 | 8 | Uart MyUart; |
matis755 | 4:e48aee3e8d09 | 9 | Stepper MyStepper; |
matis755 | 4:e48aee3e8d09 | 10 | |
matis755 | 2:8788d711db7e | 11 | char cTablica[BUFFER_SIZE]; |
matis755 | 4:e48aee3e8d09 | 12 | char cCorrectResponse[] = "ok\n"; |
matis755 | 4:e48aee3e8d09 | 13 | char cUnknownKeyword[] = "unknowncommand\n"; |
matis755 | 4:e48aee3e8d09 | 14 | char cIdentifier[] = "id anyidentyfier\n"; |
matis755 | 2:8788d711db7e | 15 | |
matis755 | 2:8788d711db7e | 16 | while(1){ |
matis755 | 4:e48aee3e8d09 | 17 | if(!MyUart.gets(cTablica, BUFFER_SIZE)){ |
matis755 | 4:e48aee3e8d09 | 18 | MyDecoder.DecodeMsg(cTablica); |
matis755 | 4:e48aee3e8d09 | 19 | if ((MyDecoder.eGetTokenType(0) == KEYWORD) & (MyDecoder.GetTokenCnt() != 0)){ |
matis755 | 4:e48aee3e8d09 | 20 | switch (MyDecoder.eGetKeyword(0)){ |
matis755 | 4:e48aee3e8d09 | 21 | case (ID): |
matis755 | 4:e48aee3e8d09 | 22 | MyUart.puts(cIdentifier, BUFFER_SIZE); |
matis755 | 4:e48aee3e8d09 | 23 | break; |
matis755 | 3:6fc7976cc5bf | 24 | case (CLB): |
matis755 | 4:e48aee3e8d09 | 25 | MyStepper.Callib(); |
matis755 | 4:e48aee3e8d09 | 26 | MyUart.puts(cCorrectResponse, BUFFER_SIZE); |
matis755 | 3:6fc7976cc5bf | 27 | break; |
matis755 | 3:6fc7976cc5bf | 28 | case (GT): |
matis755 | 5:3c19c3ae6286 | 29 | MyStepper.Goto(MyDecoder.uiGetNumber(1)); |
matis755 | 4:e48aee3e8d09 | 30 | MyUart.puts(cCorrectResponse, BUFFER_SIZE); |
matis755 | 4:e48aee3e8d09 | 31 | break; |
matis755 | 4:e48aee3e8d09 | 32 | case (ST): |
matis755 | 5:3c19c3ae6286 | 33 | MyStepper.Step(MyDecoder.uiGetNumber(1)); |
matis755 | 4:e48aee3e8d09 | 34 | MyUart.puts(cCorrectResponse, BUFFER_SIZE); |
matis755 | 3:6fc7976cc5bf | 35 | break; |
matis755 | 3:6fc7976cc5bf | 36 | default: |
matis755 | 3:6fc7976cc5bf | 37 | break; |
matis755 | 3:6fc7976cc5bf | 38 | } |
matis755 | 2:8788d711db7e | 39 | } |
matis755 | 4:e48aee3e8d09 | 40 | else { |
matis755 | 4:e48aee3e8d09 | 41 | MyUart.puts(cUnknownKeyword, BUFFER_SIZE); |
matis755 | 4:e48aee3e8d09 | 42 | } |
matis755 | 0:e65dff476cf0 | 43 | } |
matis755 | 0:e65dff476cf0 | 44 | } |
matis755 | 0:e65dff476cf0 | 45 | } |