Successful acro and level mode now! Relying on MPU9250 as base sensor. I'm working continuously on tuning and features :) NEWEST VERSION ON: https://github.com/MaEtUgR/FlyBed (CODE 100% compatible/copyable)
PC/PC.cpp@0:37f0c1e8fa66, 2015-09-08 (annotated)
- Committer:
- maetugr
- Date:
- Tue Sep 08 13:38:10 2015 +0000
- Revision:
- 0:37f0c1e8fa66
MPU9250 on the new Board works fine over SPI; RC is broken and works with FlyBed2 :(
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
maetugr | 0:37f0c1e8fa66 | 1 | #include "PC.h" |
maetugr | 0:37f0c1e8fa66 | 2 | #include "mbed.h" |
maetugr | 0:37f0c1e8fa66 | 3 | |
maetugr | 0:37f0c1e8fa66 | 4 | PC::PC(PinName tx, PinName rx, int baudrate) : Serial(tx, rx) |
maetugr | 0:37f0c1e8fa66 | 5 | { |
maetugr | 0:37f0c1e8fa66 | 6 | baud(baudrate); |
maetugr | 0:37f0c1e8fa66 | 7 | cls(); |
maetugr | 0:37f0c1e8fa66 | 8 | |
maetugr | 0:37f0c1e8fa66 | 9 | command[0] = '\0'; |
maetugr | 0:37f0c1e8fa66 | 10 | command_char_count = 0; |
maetugr | 0:37f0c1e8fa66 | 11 | } |
maetugr | 0:37f0c1e8fa66 | 12 | |
maetugr | 0:37f0c1e8fa66 | 13 | |
maetugr | 0:37f0c1e8fa66 | 14 | void PC::cls() |
maetugr | 0:37f0c1e8fa66 | 15 | { |
maetugr | 0:37f0c1e8fa66 | 16 | printf("\x1B[2J"); |
maetugr | 0:37f0c1e8fa66 | 17 | } |
maetugr | 0:37f0c1e8fa66 | 18 | |
maetugr | 0:37f0c1e8fa66 | 19 | |
maetugr | 0:37f0c1e8fa66 | 20 | void PC::locate(int Spalte, int Zeile) |
maetugr | 0:37f0c1e8fa66 | 21 | { |
maetugr | 0:37f0c1e8fa66 | 22 | printf("\x1B[%d;%dH", Zeile + 1, Spalte + 1); |
maetugr | 0:37f0c1e8fa66 | 23 | } |
maetugr | 0:37f0c1e8fa66 | 24 | |
maetugr | 0:37f0c1e8fa66 | 25 | void PC::readcommand(void (*executer)(char*)) |
maetugr | 0:37f0c1e8fa66 | 26 | { |
maetugr | 0:37f0c1e8fa66 | 27 | char input = getc(); // get the character from serial bus |
maetugr | 0:37f0c1e8fa66 | 28 | if(input == '\r') { // if return was pressed, the command must be executed |
maetugr | 0:37f0c1e8fa66 | 29 | command[command_char_count] = '\0'; |
maetugr | 0:37f0c1e8fa66 | 30 | executer(&command[0]); |
maetugr | 0:37f0c1e8fa66 | 31 | |
maetugr | 0:37f0c1e8fa66 | 32 | command_char_count = 0; // reset command |
maetugr | 0:37f0c1e8fa66 | 33 | command[command_char_count] = '\0'; |
maetugr | 0:37f0c1e8fa66 | 34 | } else if (command_char_count < COMMAND_MAX_LENGHT) { |
maetugr | 0:37f0c1e8fa66 | 35 | command[command_char_count] = input; |
maetugr | 0:37f0c1e8fa66 | 36 | command_char_count++; |
maetugr | 0:37f0c1e8fa66 | 37 | } |
maetugr | 0:37f0c1e8fa66 | 38 | } |