59 lines
1.2 KiB
C++
Executable File
59 lines
1.2 KiB
C++
Executable File
#include <QCoreApplication>
|
|
#include <QDebug>
|
|
#include <termios.h>
|
|
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
|
|
|
|
// evaluate keyboard hits
|
|
// return 0 - no keyboard hit detected
|
|
// return 1 - keyboard hit detected
|
|
int kbhit() {
|
|
struct termios oldt, newt;
|
|
int ch;
|
|
int oldf;
|
|
|
|
tcgetattr(STDIN_FILENO, &oldt);
|
|
newt = oldt;
|
|
newt.c_lflag &= ~(ICANON | ECHO);
|
|
tcsetattr(STDIN_FILENO, TCSANOW, &newt);
|
|
oldf = fcntl(STDIN_FILENO, F_GETFL, 0);
|
|
fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK);
|
|
|
|
ch = getchar();
|
|
|
|
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
|
|
fcntl(STDIN_FILENO, F_SETFL, oldf);
|
|
|
|
if (ch != EOF) {
|
|
ungetc(ch, stdin);
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
#include "Controller.hpp"
|
|
|
|
|
|
// entry point for controller app
|
|
// no arguments used (yet)
|
|
// program stops on any keyboard hit
|
|
int main(int argc, char *argv[])
|
|
{
|
|
QCoreApplication a(argc, argv);
|
|
|
|
Controller bbr; // create controller instance
|
|
|
|
// loop endlessly until keybord hit
|
|
qDebug() << "Press any key to stop ...";
|
|
while(!kbhit())
|
|
{
|
|
qDebug() << "Perform bbr setp";
|
|
bbr.step();
|
|
usleep(200000); // 200ms delay
|
|
}
|
|
return 0;
|
|
|
|
// todo uj 30.03.26 - uncomment if needed
|
|
// return QCoreApplication::exec();
|
|
}
|