Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of GA-Berkay_Alex by
PC/PC.cpp
- Committer:
- bberabi
- Date:
- 2018-02-28
- Revision:
- 4:120ff05a7c27
- Parent:
- 3:8bee1711d186
File content as of revision 4:120ff05a7c27:
#include "PC.h" #include "mbed.h" PC::PC(PinName tx, PinName rx, int baudrate) : Serial(tx, rx) { baud(baudrate); cls(); command[0] = '\0'; command_char_count = 0; } void PC::cls() { printf("\x1B[2J"); } void PC::locate(int Spalte, int Zeile) { printf("\x1B[%d;%dH", Zeile + 1, Spalte + 1); } //This fufnction enable reading strings from matlab. void PC::readcommand(void (*executer)(char*)) { char input = getc(); //get character from the serial bus if(input == '\r') { // \r is our end of command character when this shows up, command will be executed ! this->command[command_char_count] = '\0'; executer(&command[0]); this->command_char_count = 0; // reset command this->command[command_char_count] = '\0'; // break; } else if (command_char_count < COMMAND_MAX_LENGHT) { //wait for other characters // printf("Debug Point 4"); this->command[command_char_count] = input; this->command_char_count++; } //} /* while (1) { if (readable()) { scanf( "%s" , command ); break; } } executer(&command[0]); command_char_count = 0; // reset command */ }