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)

Dependencies:   mbed

Committer:
maetugr
Date:
Thu Nov 19 18:47:27 2015 +0000
Revision:
8:609a2ad4c30e
Parent:
0:37f0c1e8fa66
made I2C-Sensors working in parallel, added rolling buffer for PID derivative, played with the PID and frequency parameters in main

Who changed what in which revision?

UserRevisionLine numberNew 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 }