My fully self designed first stable working Quadrocopter Software.

Dependencies:   mbed

Dependents:   fluy343

/media/uploads/maetugr/dsc09031.jpg

Committer:
maetugr
Date:
Mon Aug 31 20:20:50 2015 +0000
Revision:
10:14390c90c3f5
Parent:
0:12950aa67f2a
before changing to MPU9250

Who changed what in which revision?

UserRevisionLine numberNew contents of line
maetugr 0:12950aa67f2a 1 #include "PC.h"
maetugr 0:12950aa67f2a 2 #include "mbed.h"
maetugr 0:12950aa67f2a 3
maetugr 0:12950aa67f2a 4 PC::PC(PinName tx, PinName rx, int baudrate) : Serial(tx, rx)
maetugr 0:12950aa67f2a 5 {
maetugr 0:12950aa67f2a 6 baud(baudrate);
maetugr 0:12950aa67f2a 7 cls();
maetugr 0:12950aa67f2a 8
maetugr 0:12950aa67f2a 9 command[0] = '\0';
maetugr 0:12950aa67f2a 10 command_char_count = 0;
maetugr 0:12950aa67f2a 11 }
maetugr 0:12950aa67f2a 12
maetugr 0:12950aa67f2a 13
maetugr 0:12950aa67f2a 14 void PC::cls()
maetugr 0:12950aa67f2a 15 {
maetugr 0:12950aa67f2a 16 printf("\x1B[2J");
maetugr 0:12950aa67f2a 17 }
maetugr 0:12950aa67f2a 18
maetugr 0:12950aa67f2a 19
maetugr 0:12950aa67f2a 20 void PC::locate(int Spalte, int Zeile)
maetugr 0:12950aa67f2a 21 {
maetugr 0:12950aa67f2a 22 printf("\x1B[%d;%dH", Zeile + 1, Spalte + 1);
maetugr 0:12950aa67f2a 23 }
maetugr 0:12950aa67f2a 24
maetugr 0:12950aa67f2a 25 void PC::readcommand(void (*executer)(char*))
maetugr 0:12950aa67f2a 26 {
maetugr 0:12950aa67f2a 27 char input = getc(); // get the character from serial bus
maetugr 0:12950aa67f2a 28 if(input == '\r') { // if return was pressed, the command must be executed
maetugr 0:12950aa67f2a 29 command[command_char_count] = '\0';
maetugr 0:12950aa67f2a 30 executer(&command[0]);
maetugr 0:12950aa67f2a 31
maetugr 0:12950aa67f2a 32 command_char_count = 0; // reset command
maetugr 0:12950aa67f2a 33 command[command_char_count] = '\0';
maetugr 0:12950aa67f2a 34 } else if (command_char_count < COMMAND_MAX_LENGHT) {
maetugr 0:12950aa67f2a 35 command[command_char_count] = input;
maetugr 0:12950aa67f2a 36 command_char_count++;
maetugr 0:12950aa67f2a 37 }
maetugr 0:12950aa67f2a 38 }