Tobi's ubw test branch
Dependencies: mavlink_bridge mbed
Fork of AIT_UWB_Range by
PC/PC.cpp@67:bd0f0580af5a, 2016-01-05 (annotated)
- Committer:
- naegelit
- Date:
- Tue Jan 05 17:06:19 2016 +0000
- Revision:
- 67:bd0f0580af5a
- Parent:
- 0:f50e671ffff7
working with 4 odroids (hacky version)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
manumaet | 0:f50e671ffff7 | 1 | #include "PC.h" |
manumaet | 0:f50e671ffff7 | 2 | #include "mbed.h" |
manumaet | 0:f50e671ffff7 | 3 | |
manumaet | 0:f50e671ffff7 | 4 | PC::PC(PinName tx, PinName rx, int baudrate) : Serial(tx, rx) |
manumaet | 0:f50e671ffff7 | 5 | { |
manumaet | 0:f50e671ffff7 | 6 | baud(baudrate); |
manumaet | 0:f50e671ffff7 | 7 | cls(); |
manumaet | 0:f50e671ffff7 | 8 | |
manumaet | 0:f50e671ffff7 | 9 | command[0] = '\0'; |
manumaet | 0:f50e671ffff7 | 10 | command_char_count = 0; |
manumaet | 0:f50e671ffff7 | 11 | } |
manumaet | 0:f50e671ffff7 | 12 | |
manumaet | 0:f50e671ffff7 | 13 | |
manumaet | 0:f50e671ffff7 | 14 | void PC::cls() |
manumaet | 0:f50e671ffff7 | 15 | { |
manumaet | 0:f50e671ffff7 | 16 | printf("\x1B[2J"); |
manumaet | 0:f50e671ffff7 | 17 | } |
manumaet | 0:f50e671ffff7 | 18 | |
manumaet | 0:f50e671ffff7 | 19 | |
manumaet | 0:f50e671ffff7 | 20 | void PC::locate(int Spalte, int Zeile) |
manumaet | 0:f50e671ffff7 | 21 | { |
manumaet | 0:f50e671ffff7 | 22 | printf("\x1B[%d;%dH", Zeile + 1, Spalte + 1); |
manumaet | 0:f50e671ffff7 | 23 | } |
manumaet | 0:f50e671ffff7 | 24 | |
manumaet | 0:f50e671ffff7 | 25 | void PC::readcommand(void (*executer)(char*)) |
manumaet | 0:f50e671ffff7 | 26 | { |
manumaet | 0:f50e671ffff7 | 27 | char input = getc(); // get the character from serial bus |
manumaet | 0:f50e671ffff7 | 28 | if(input == '\r') { // if return was pressed, the command must be executed |
manumaet | 0:f50e671ffff7 | 29 | command[command_char_count] = '\0'; |
manumaet | 0:f50e671ffff7 | 30 | executer(&command[0]); |
manumaet | 0:f50e671ffff7 | 31 | |
manumaet | 0:f50e671ffff7 | 32 | command_char_count = 0; // reset command |
manumaet | 0:f50e671ffff7 | 33 | command[command_char_count] = '\0'; |
manumaet | 0:f50e671ffff7 | 34 | } else if (command_char_count < COMMAND_MAX_LENGHT) { |
manumaet | 0:f50e671ffff7 | 35 | command[command_char_count] = input; |
manumaet | 0:f50e671ffff7 | 36 | command_char_count++; |
manumaet | 0:f50e671ffff7 | 37 | } |
manumaet | 0:f50e671ffff7 | 38 | } |