An fully working IMU-Filter and Sensor drivers for the 10DOF-Board over I2C. All in one simple class. Include, calibrate sensors, call read, get angles. (3D Visualisation code for Python also included) Sensors: L3G4200D, ADXL345, HMC5883, BMP085
PC/PC.cpp@4:f62337b907e5, 2013-08-29 (annotated)
- Committer:
- maetugr
- Date:
- Thu Aug 29 13:52:30 2013 +0000
- Revision:
- 4:f62337b907e5
- Parent:
- 0:3e7450f1a938
The Altitude Sensor is now implemented, it's really 10DOF now ;); TODO: Autocalibration
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
maetugr | 0:3e7450f1a938 | 1 | #include "PC.h" |
maetugr | 0:3e7450f1a938 | 2 | #include "mbed.h" |
maetugr | 0:3e7450f1a938 | 3 | |
maetugr | 0:3e7450f1a938 | 4 | PC::PC(PinName tx, PinName rx, int baudrate) : Serial(tx, rx) |
maetugr | 0:3e7450f1a938 | 5 | { |
maetugr | 0:3e7450f1a938 | 6 | baud(baudrate); |
maetugr | 0:3e7450f1a938 | 7 | cls(); |
maetugr | 0:3e7450f1a938 | 8 | |
maetugr | 0:3e7450f1a938 | 9 | command[0] = '\0'; |
maetugr | 0:3e7450f1a938 | 10 | command_char_count = 0; |
maetugr | 0:3e7450f1a938 | 11 | } |
maetugr | 0:3e7450f1a938 | 12 | |
maetugr | 0:3e7450f1a938 | 13 | |
maetugr | 0:3e7450f1a938 | 14 | void PC::cls() |
maetugr | 0:3e7450f1a938 | 15 | { |
maetugr | 0:3e7450f1a938 | 16 | printf("\x1B[2J"); |
maetugr | 0:3e7450f1a938 | 17 | } |
maetugr | 0:3e7450f1a938 | 18 | |
maetugr | 0:3e7450f1a938 | 19 | |
maetugr | 0:3e7450f1a938 | 20 | void PC::locate(int Spalte, int Zeile) |
maetugr | 0:3e7450f1a938 | 21 | { |
maetugr | 0:3e7450f1a938 | 22 | printf("\x1B[%d;%dH", Zeile + 1, Spalte + 1); |
maetugr | 0:3e7450f1a938 | 23 | } |
maetugr | 0:3e7450f1a938 | 24 | |
maetugr | 0:3e7450f1a938 | 25 | void PC::readcommand(void (*executer)(char*)) |
maetugr | 0:3e7450f1a938 | 26 | { |
maetugr | 0:3e7450f1a938 | 27 | char input = getc(); // get the character from serial bus |
maetugr | 0:3e7450f1a938 | 28 | if(input == '\r') { // if return was pressed, the command must be executed |
maetugr | 0:3e7450f1a938 | 29 | command[command_char_count] = '\0'; |
maetugr | 0:3e7450f1a938 | 30 | executer(&command[0]); |
maetugr | 0:3e7450f1a938 | 31 | |
maetugr | 0:3e7450f1a938 | 32 | command_char_count = 0; // reset command |
maetugr | 0:3e7450f1a938 | 33 | command[command_char_count] = '\0'; |
maetugr | 0:3e7450f1a938 | 34 | } else if (command_char_count < COMMAND_MAX_LENGHT) { |
maetugr | 0:3e7450f1a938 | 35 | command[command_char_count] = input; |
maetugr | 0:3e7450f1a938 | 36 | command_char_count++; |
maetugr | 0:3e7450f1a938 | 37 | } |
maetugr | 0:3e7450f1a938 | 38 | } |